mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-16 16:06:44 +00:00
Compare commits
185 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0971f8ffa7 | |||
| 9739f94428 | |||
| 450f4eaec0 | |||
| b5186fa328 | |||
| 526dc8363d | |||
| 242d735d8c | |||
| 9fedd32e78 | |||
| a146003a6a | |||
| d17df74191 | |||
| d23403383f | |||
| 877b36f8a8 | |||
| 299820162b | |||
| 5d20a59d92 | |||
| c1ab3b5476 | |||
| 0076130483 | |||
| a5194b1999 | |||
| b53b1f083f | |||
| 994a36001f | |||
| 26b91e3f66 | |||
| f42aedd485 | |||
| a73818a615 | |||
| 7c22e9fe69 | |||
| c58e91b956 | |||
| a61059242c | |||
| cea9437e66 | |||
| 3f052ef1da | |||
| c137a4b06d | |||
| 6c46dafc59 | |||
| 1207417894 | |||
| 7c717c219c | |||
| a9fad53255 | |||
| 372cc021bd | |||
| 6820774266 | |||
| a0c189a349 | |||
| 1060ff16d8 | |||
| 1255f48645 | |||
| 7ef69208d4 | |||
| 5277cca4e1 | |||
| aaf77815ca | |||
| 3f488cc091 | |||
| bdbbdfe60e | |||
| d15c2be2d0 | |||
| 73994914eb | |||
| 63b0dae794 | |||
| 003e865ff7 | |||
| e3c03287b7 | |||
| 73493c3a23 | |||
| 562a3f6208 | |||
| 3c5f3d6c37 | |||
| a37d4214c0 | |||
| 636d6ce324 | |||
| eef8b362d2 | |||
| 4ae586ebaa | |||
| f6e673c2bb | |||
| 183a60159c | |||
| 1fdf4f371d | |||
| f50c374d04 | |||
| d59fc331f6 | |||
| b83f478294 | |||
| d5636f4a19 | |||
| 196bcf39cf | |||
| afec1c3a5b | |||
| 6025339b46 | |||
| 40c6cc59d3 | |||
| 514e568e04 | |||
| 2f34b0a5ed | |||
| 708c076885 | |||
| f0e0b918af | |||
| e45f5e1122 | |||
| 932015668b | |||
| 4011bc3fe6 | |||
| 1dcccdc434 | |||
| 3380ed9360 | |||
| ed9c14e63d | |||
| 4762793adc | |||
| 7df3946189 | |||
| d5fb75fe43 | |||
| c0b32a5584 | |||
| e2b1276d7b | |||
| f6aea13fae | |||
| 646b113c55 | |||
| 58074f499f | |||
| 1483ffd7ff | |||
| cdaef851a0 | |||
| 04068d7117 | |||
| 41e8ddea8c | |||
| cc49791997 | |||
| ba4a8050ba | |||
| 7c5067a59a | |||
| 69eb920173 | |||
| 07d761941a | |||
| ca52585759 | |||
| decc9d09f8 | |||
| 466a18447c | |||
| 27902ee107 | |||
| 8a8b806362 | |||
| 40bb181c78 | |||
| 8099847e29 | |||
| 6e8edd95ec | |||
| 5112c9598b | |||
| 749158c086 | |||
| b3d4024f21 | |||
| c283b66c1d | |||
| 3209843318 | |||
| d35e5cc0f7 | |||
| e5eeb592a2 | |||
| 3d38f4d17a | |||
| 2d91647e0b | |||
| cac0f30673 | |||
| c5ecba3389 | |||
| e0397dff47 | |||
| e08fb2e972 | |||
| c02ae82003 | |||
| e6fc301b0d | |||
| a385ed57fb | |||
| 09dafe4b1d | |||
| ba8505c983 | |||
| fba359d389 | |||
| c56763b68f | |||
| 03c2943545 | |||
| 98039b9048 | |||
| 5065d3b068 | |||
| 6828f7e262 | |||
| a685f3ffbd | |||
| e84156d2e9 | |||
| 0ce1c31e1c | |||
| f7e14bb60c | |||
| 7b907df816 | |||
| 7f5be2829c | |||
| fa5afae783 | |||
| b17507d0fa | |||
| 5ed43a3190 | |||
| d2a5144a23 | |||
| fb2031d7ca | |||
| 4a42571925 | |||
| 38413625c2 | |||
| 2d544b7a98 | |||
| b1e5e1840e | |||
| e6f9b4a125 | |||
| 5260b2b430 | |||
| 0213bc7aef | |||
| ca8b0899d0 | |||
| a1f5c0ab9b | |||
| b0e3f82d27 | |||
| 327ab4766b | |||
| 3aee8a49c1 | |||
| 57de0b7351 | |||
| 4df1e310a3 | |||
| 802a77238a | |||
| 85a7e18fae | |||
| 26b1fd3487 | |||
| ae7a363012 | |||
| 473362af45 | |||
| cde0d09f0a | |||
| 94f093826b | |||
| 84f231ea08 | |||
| 3d9bb14713 | |||
| 6c6cdcf763 | |||
| 00c8690e61 | |||
| a0d492cd2d | |||
| ba5ccc1021 | |||
| a4163017d5 | |||
| 7f4a5c48ec | |||
| 9f7588b245 | |||
| 63cbc0c55b | |||
| 28eb7a678c | |||
| a95c49915a | |||
| b7adc6add6 | |||
| 2aeebf280b | |||
| 8ac06979f0 | |||
| 2d4f90d5eb | |||
| d7a44a639d | |||
| 7bfa05f47d | |||
| c7bbb09195 | |||
| 41c9c15ae5 | |||
| 964831becf | |||
| e847b92cce | |||
| c2ecd86bb4 | |||
| 70d922fad6 | |||
| 854bee0519 | |||
| d54d991bdd | |||
| a4b600b97d | |||
| d6cfaa5050 | |||
| 00d1aec210 | |||
| f62e3391e1 |
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"ExpandedNodes": [
|
||||||
|
"",
|
||||||
|
"\\Moose Development",
|
||||||
|
"\\Moose Development\\Moose",
|
||||||
|
"\\Moose Development\\Moose\\Ops"
|
||||||
|
],
|
||||||
|
"SelectedNode": "\\Moose Development\\Moose\\Ops\\Airboss.lua",
|
||||||
|
"PreviewInSolutionExplorer": false
|
||||||
|
}
|
||||||
Binary file not shown.
+17
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"Lua.workspace.preloadFileSize": 1000,
|
||||||
|
"Lua.diagnostics.disable": [
|
||||||
|
"undefined-doc-name"
|
||||||
|
],
|
||||||
|
"Lua.diagnostics.globals": [
|
||||||
|
"BASE",
|
||||||
|
"lfs",
|
||||||
|
"__Moose",
|
||||||
|
"trigger",
|
||||||
|
"coord",
|
||||||
|
"missionCommands"
|
||||||
|
],
|
||||||
|
"Lua.completion.displayContext": 5,
|
||||||
|
"Lua.runtime.version": "Lua 5.1",
|
||||||
|
"Lua.completion.callSnippet": "Both"
|
||||||
|
}
|
||||||
@@ -40,8 +40,8 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.
|
-- Until a fuel or damage threshold 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.
|
-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
-- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets.
|
-- * **@{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.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.
|
-- * **@{#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
|
-- ## 3. Set the Range of Engagement
|
||||||
--
|
--
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -42,8 +42,8 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.
|
-- Until a fuel or damage threshold 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.
|
-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
-- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets.
|
-- * **@{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.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.
|
-- * **@{#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
|
-- ## 3. Set the Range of Engagement
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.
|
-- Until a fuel or damage threshold 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.
|
-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
-- * **RTB** ( Group ): Route the AI to the home base.
|
-- * **RTB** ( Group ): Route the AI to the home base.
|
||||||
-- * **Detect** ( Group ): The AI is detecting targets.
|
-- * **Detect** ( Group ): The AI is detecting targets.
|
||||||
-- * **Detected** ( Group ): The AI has detected new 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
|
-- ## 3. Set or Get the AI controllable
|
||||||
--
|
--
|
||||||
@@ -100,8 +100,8 @@
|
|||||||
-- ## 6. Manage the "out of fuel" in the AI_A2A_PATROL
|
-- ## 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.
|
-- 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.
|
-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel threshold is calculated.
|
||||||
-- When the fuel treshold is reached, the AI will continue for a given time its patrol task in orbit,
|
-- 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.
|
-- while a new AI is targetted to the AI_A2A_PATROL.
|
||||||
-- Once the time is finished, the old AI will return to the base.
|
-- 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.
|
-- 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
|
-- ## 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.
|
-- 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.
|
-- Use the method @{#AI_A2A_PATROL.ManageDamage}() to have this proces in place.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
|
|||||||
@@ -1000,6 +1000,8 @@ do -- AI_A2G_DISPATCHER
|
|||||||
-- self.Detection:InitDetectVisual( true )
|
-- self.Detection:InitDetectVisual( true )
|
||||||
-- self.Detection:SetRefreshTimeInterval( 30 )
|
-- self.Detection:SetRefreshTimeInterval( 30 )
|
||||||
|
|
||||||
|
self.SetSendPlayerMessages = false --flash messages to players
|
||||||
|
|
||||||
self:SetDefenseRadius()
|
self:SetDefenseRadius()
|
||||||
self:SetDefenseLimit( nil )
|
self:SetDefenseLimit( nil )
|
||||||
self:SetDefenseApproach( AI_A2G_DISPATCHER.DefenseApproach.Random )
|
self:SetDefenseApproach( AI_A2G_DISPATCHER.DefenseApproach.Random )
|
||||||
@@ -3243,17 +3245,17 @@ do -- AI_A2G_DISPATCHER
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the default fuel treshold when defenders will RTB or Refuel in the air.
|
--- Set the default fuel threshold 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.
|
-- 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 #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
|
-- @return #AI_A2G_DISPATCHER
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Now Setup the A2G dispatcher, and initialize it using the Detection object.
|
-- -- Now Setup the A2G dispatcher, and initialize it using the Detection object.
|
||||||
-- A2GDispatcher = AI_A2G_DISPATCHER:New( Detection )
|
-- 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.
|
-- A2GDispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||||
--
|
--
|
||||||
function AI_A2G_DISPATCHER:SetDefaultFuelThreshold( FuelThreshold )
|
function AI_A2G_DISPATCHER:SetDefaultFuelThreshold( FuelThreshold )
|
||||||
@@ -3264,18 +3266,18 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the fuel treshold for the squadron when defenders will RTB or Refuel in the air.
|
--- Set the fuel threshold 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.
|
-- 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 #AI_A2G_DISPATCHER self
|
||||||
-- @param #string SquadronName The name of the squadron.
|
-- @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
|
-- @return #AI_A2G_DISPATCHER
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Now Setup the A2G dispatcher, and initialize it using the Detection object.
|
-- -- Now Setup the A2G dispatcher, and initialize it using the Detection object.
|
||||||
-- A2GDispatcher = AI_A2G_DISPATCHER:New( Detection )
|
-- 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.
|
-- A2GDispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||||
--
|
--
|
||||||
function AI_A2G_DISPATCHER:SetSquadronFuelThreshold( SquadronName, FuelThreshold )
|
function AI_A2G_DISPATCHER:SetSquadronFuelThreshold( SquadronName, FuelThreshold )
|
||||||
@@ -3295,7 +3297,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
-- -- Now Setup the A2G dispatcher, and initialize it using the Detection object.
|
-- -- Now Setup the A2G dispatcher, and initialize it using the Detection object.
|
||||||
-- A2GDispatcher = AI_A2G_DISPATCHER:New( Detection )
|
-- 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.
|
-- A2GDispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||||
--
|
--
|
||||||
-- -- Now Setup the default tanker.
|
-- -- Now Setup the default tanker.
|
||||||
@@ -3318,7 +3320,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
-- -- Now Setup the A2G dispatcher, and initialize it using the Detection object.
|
-- -- Now Setup the A2G dispatcher, and initialize it using the Detection object.
|
||||||
-- A2GDispatcher = AI_A2G_DISPATCHER:New( Detection )
|
-- 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.
|
-- A2GDispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||||
--
|
--
|
||||||
-- -- Now Setup the squadron tanker.
|
-- -- Now Setup the squadron tanker.
|
||||||
@@ -3421,7 +3423,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_DISPATCHER:CountDefendersEngaged( AttackerDetection, AttackerCount )
|
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 DefendersEngaged = 0
|
||||||
local DefendersTotal = 0
|
local DefendersTotal = 0
|
||||||
|
|
||||||
@@ -3718,7 +3720,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
|
|
||||||
if Squadron then
|
if Squadron then
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", wheels up.", DefenderGroup )
|
if self.SetSendPlayerMessages then
|
||||||
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", wheels up.", DefenderGroup )
|
||||||
|
end
|
||||||
AI_A2G_Fsm:Patrol() -- Engage on the TargetSetUnit
|
AI_A2G_Fsm:Patrol() -- Engage on the TargetSetUnit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3730,7 +3734,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local DefenderName = DefenderGroup:GetCallsign()
|
local DefenderName = DefenderGroup:GetCallsign()
|
||||||
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
if Squadron then
|
if Squadron and self.SetSendPlayerMessages then
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", patrolling.", DefenderGroup )
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", patrolling.", DefenderGroup )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3749,8 +3753,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
if Squadron and AttackSetUnit:Count() > 0 then
|
if Squadron and AttackSetUnit:Count() > 0 then
|
||||||
local FirstUnit = AttackSetUnit:GetFirst()
|
local FirstUnit = AttackSetUnit:GetFirst()
|
||||||
local Coordinate = FirstUnit:GetCoordinate() -- Core.Point#COORDINATE
|
local Coordinate = FirstUnit:GetCoordinate() -- Core.Point#COORDINATE
|
||||||
|
if self.SetSendPlayerMessages then
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", moving on to ground target at " .. Coordinate:ToStringA2G( DefenderGroup ), DefenderGroup )
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", moving on to ground target at " .. Coordinate:ToStringA2G( DefenderGroup ), DefenderGroup )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3764,8 +3769,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local FirstUnit = AttackSetUnit:GetFirst()
|
local FirstUnit = AttackSetUnit:GetFirst()
|
||||||
if FirstUnit then
|
if FirstUnit then
|
||||||
local Coordinate = FirstUnit:GetCoordinate()
|
local Coordinate = FirstUnit:GetCoordinate()
|
||||||
|
if self.SetSendPlayerMessages then
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", engaging ground target at " .. Coordinate:ToStringA2G( DefenderGroup ), DefenderGroup )
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", engaging ground target at " .. Coordinate:ToStringA2G( DefenderGroup ), DefenderGroup )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3776,8 +3782,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local DefenderName = DefenderGroup:GetCallsign()
|
local DefenderName = DefenderGroup:GetCallsign()
|
||||||
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", returning to base.", DefenderGroup )
|
if self.SetSendPlayerMessages then
|
||||||
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", returning to base.", DefenderGroup )
|
||||||
|
end
|
||||||
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3789,7 +3796,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local DefenderName = DefenderGroup:GetCallsign()
|
local DefenderName = DefenderGroup:GetCallsign()
|
||||||
local Dispatcher = AI_A2G_Fsm:GetDispatcher() -- #AI_A2G_DISPATCHER
|
local Dispatcher = AI_A2G_Fsm:GetDispatcher() -- #AI_A2G_DISPATCHER
|
||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", lost control." )
|
if self.SetSendPlayerMessages then
|
||||||
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", lost control." )
|
||||||
|
end
|
||||||
if DefenderGroup:IsAboveRunway() then
|
if DefenderGroup:IsAboveRunway() then
|
||||||
Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup )
|
Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup )
|
||||||
DefenderGroup:Destroy()
|
DefenderGroup:Destroy()
|
||||||
@@ -3804,8 +3813,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local DefenderName = DefenderGroup:GetCallsign()
|
local DefenderName = DefenderGroup:GetCallsign()
|
||||||
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", landing at base.", DefenderGroup )
|
if self.SetSendPlayerMessages then
|
||||||
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", landing at base.", DefenderGroup )
|
||||||
|
end
|
||||||
if Action and Action == "Destroy" then
|
if Action and Action == "Destroy" then
|
||||||
Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup )
|
Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup )
|
||||||
DefenderGroup:Destroy()
|
DefenderGroup:Destroy()
|
||||||
@@ -3861,7 +3871,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
self:F( { DefenderTarget = DefenderTarget } )
|
self:F( { DefenderTarget = DefenderTarget } )
|
||||||
|
|
||||||
if DefenderTarget then
|
if DefenderTarget then
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", wheels up.", DefenderGroup )
|
if self.SetSendPlayerMessages then
|
||||||
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", wheels up.", DefenderGroup )
|
||||||
|
end
|
||||||
AI_A2G_Fsm:EngageRoute( DefenderTarget.Set ) -- Engage on the TargetSetUnit
|
AI_A2G_Fsm:EngageRoute( DefenderTarget.Set ) -- Engage on the TargetSetUnit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3876,8 +3888,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
if Squadron then
|
if Squadron then
|
||||||
local FirstUnit = AttackSetUnit:GetFirst()
|
local FirstUnit = AttackSetUnit:GetFirst()
|
||||||
local Coordinate = FirstUnit:GetCoordinate() -- Core.Point#COORDINATE
|
local Coordinate = FirstUnit:GetCoordinate() -- Core.Point#COORDINATE
|
||||||
|
if self.SetSendPlayerMessages then
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", on route to ground target at " .. Coordinate:ToStringA2G( DefenderGroup ), DefenderGroup )
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", on route to ground target at " .. Coordinate:ToStringA2G( DefenderGroup ), DefenderGroup )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self:GetParent(self).onafterEngageRoute( self, DefenderGroup, From, Event, To, AttackSetUnit )
|
self:GetParent(self).onafterEngageRoute( self, DefenderGroup, From, Event, To, AttackSetUnit )
|
||||||
end
|
end
|
||||||
@@ -3892,8 +3905,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local FirstUnit = AttackSetUnit:GetFirst()
|
local FirstUnit = AttackSetUnit:GetFirst()
|
||||||
if FirstUnit then
|
if FirstUnit then
|
||||||
local Coordinate = FirstUnit:GetCoordinate()
|
local Coordinate = FirstUnit:GetCoordinate()
|
||||||
|
if self.SetSendPlayerMessages then
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", engaging ground target at " .. Coordinate:ToStringA2G( DefenderGroup ), DefenderGroup )
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", engaging ground target at " .. Coordinate:ToStringA2G( DefenderGroup ), DefenderGroup )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3903,8 +3917,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local DefenderName = DefenderGroup:GetCallsign()
|
local DefenderName = DefenderGroup:GetCallsign()
|
||||||
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", returning to base.", DefenderGroup )
|
if self.SetSendPlayerMessages then
|
||||||
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", returning to base.", DefenderGroup )
|
||||||
|
end
|
||||||
self:GetParent(self).onafterRTB( self, DefenderGroup, From, Event, To )
|
self:GetParent(self).onafterRTB( self, DefenderGroup, From, Event, To )
|
||||||
|
|
||||||
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
||||||
@@ -3918,8 +3933,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local DefenderName = DefenderGroup:GetCallsign()
|
local DefenderName = DefenderGroup:GetCallsign()
|
||||||
local Dispatcher = AI_A2G_Fsm:GetDispatcher() -- #AI_A2G_DISPATCHER
|
local Dispatcher = AI_A2G_Fsm:GetDispatcher() -- #AI_A2G_DISPATCHER
|
||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
--Dispatcher:MessageToPlayers( Squadron, "Squadron " .. Squadron.Name .. ", " .. DefenderName .. " lost control." )
|
if self.SetSendPlayerMessages then
|
||||||
|
Dispatcher:MessageToPlayers( Squadron, "Squadron " .. Squadron.Name .. ", " .. DefenderName .. " lost control." )
|
||||||
|
end
|
||||||
if DefenderGroup:IsAboveRunway() then
|
if DefenderGroup:IsAboveRunway() then
|
||||||
Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup )
|
Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup )
|
||||||
DefenderGroup:Destroy()
|
DefenderGroup:Destroy()
|
||||||
@@ -3934,8 +3950,9 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local DefenderName = DefenderGroup:GetCallsign()
|
local DefenderName = DefenderGroup:GetCallsign()
|
||||||
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER
|
||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", landing at base.", DefenderGroup )
|
if self.SetSendPlayerMessages then
|
||||||
|
Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", landing at base.", DefenderGroup )
|
||||||
|
end
|
||||||
if Action and Action == "Destroy" then
|
if Action and Action == "Destroy" then
|
||||||
Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup )
|
Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup )
|
||||||
DefenderGroup:Destroy()
|
DefenderGroup:Destroy()
|
||||||
@@ -3975,7 +3992,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local EvaluateDistance = AttackCoordinate:Get2DDistance( DefenseCoordinate )
|
local EvaluateDistance = AttackCoordinate:Get2DDistance( DefenseCoordinate )
|
||||||
|
|
||||||
-- Now check if this coordinate is not in a danger zone, meaning, that the attack line is not crossing other coordinates.
|
-- Now check if this coordinate is not in a danger zone, meaning, that the attack line is not crossing other coordinates.
|
||||||
-- (y1 – y2)x + (x2 – x1)y + (x1y2 – x2y1) = 0
|
-- (y1 - y2)x + (x2 - x1)y + (x1y2 - x2y1) = 0
|
||||||
|
|
||||||
local c1 = DefenseCoordinate
|
local c1 = DefenseCoordinate
|
||||||
local c2 = AttackCoordinate
|
local c2 = AttackCoordinate
|
||||||
@@ -4036,7 +4053,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
for DefenderID, DefenderGroup in pairs( DefenderFriendlies or {} ) do
|
for DefenderID, DefenderGroup in pairs( DefenderFriendlies or {} ) do
|
||||||
|
|
||||||
-- Here we check if the defenders have a defense line to the attackers.
|
-- Here we check if the defenders have a defense line to the attackers.
|
||||||
-- If the attackers are behind enemy lines or too close to an other defense line; then don´t engage.
|
-- If the attackers are behind enemy lines or too close to an other defense line; then don't engage.
|
||||||
local DefenseCoordinate = DefenderGroup:GetCoordinate()
|
local DefenseCoordinate = DefenderGroup:GetCoordinate()
|
||||||
local HasDefenseLine = self:HasDefenseLine( DefenseCoordinate, DetectedItem )
|
local HasDefenseLine = self:HasDefenseLine( DefenseCoordinate, DetectedItem )
|
||||||
|
|
||||||
@@ -4341,7 +4358,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
|
|
||||||
-- Show tactical situation
|
-- Show tactical situation
|
||||||
local ThreatLevel = DetectedItem.Set:CalculateThreatLevelA2G()
|
local ThreatLevel = DetectedItem.Set:CalculateThreatLevelA2G()
|
||||||
Report:Add( string.format( " - %1s%s ( %04s ): ( #%02d - %-4s ) %s" , ( DetectedItem.IsDetected == true ) and "!" or " ", DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Type or " --- ", string.rep( "■", ThreatLevel ) ) )
|
Report:Add( string.format( " - %1s%s ( %04s ): ( #%02d - %-4s ) %s" , ( DetectedItem.IsDetected == true ) and "!" or " ", DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Type or " --- ", string.rep( "■", ThreatLevel ) ) )
|
||||||
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||||
local Defender = Defender -- Wrapper.Group#GROUP
|
local Defender = Defender -- Wrapper.Group#GROUP
|
||||||
if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then
|
if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then
|
||||||
@@ -4559,7 +4576,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
if self.TacticalDisplay then
|
if self.TacticalDisplay then
|
||||||
-- Show tactical situation
|
-- Show tactical situation
|
||||||
local ThreatLevel = DetectedItem.Set:CalculateThreatLevelA2G()
|
local ThreatLevel = DetectedItem.Set:CalculateThreatLevelA2G()
|
||||||
Report:Add( string.format( " - %1s%s ( %4s ): ( #%d - %4s ) %s" , ( DetectedItem.IsDetected == true ) and "!" or " ", DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Type or " --- ", string.rep( "■", ThreatLevel ) ) )
|
Report:Add( string.format( " - %1s%s ( %4s ): ( #%d - %4s ) %s" , ( DetectedItem.IsDetected == true ) and "!" or " ", DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Type or " --- ", string.rep( "■", ThreatLevel ) ) )
|
||||||
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||||
local Defender = Defender -- Wrapper.Group#GROUP
|
local Defender = Defender -- Wrapper.Group#GROUP
|
||||||
if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then
|
if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then
|
||||||
@@ -4729,5 +4746,34 @@ do
|
|||||||
self:Patrol( SquadronName, PatrolTaskType )
|
self:Patrol( SquadronName, PatrolTaskType )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set flashing player messages on or off
|
||||||
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
|
-- @param #boolean onoff Set messages on (true) or off (false)
|
||||||
|
function AI_A2G_DISPATCHER:SetSendMessages( onoff )
|
||||||
|
self.SetSendPlayerMessages = onoff
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add resources to a Squadron
|
||||||
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
|
-- @param #string Squadron The squadron name.
|
||||||
|
-- @param #number Amount Number of resources to add.
|
||||||
|
function AI_A2G_DISPATCHER:AddToSquadron(Squadron,Amount)
|
||||||
|
local Squadron = self:GetSquadron(Squadron)
|
||||||
|
if Squadron.ResourceCount then
|
||||||
|
Squadron.ResourceCount = Squadron.ResourceCount + Amount
|
||||||
|
end
|
||||||
|
self:T({Squadron = Squadron.Name,SquadronResourceCount = Squadron.ResourceCount})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove resources from a Squadron
|
||||||
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
|
-- @param #string Squadron The squadron name.
|
||||||
|
-- @param #number Amount Number of resources to remove.
|
||||||
|
function AI_A2G_DISPATCHER:RemoveFromSquadron(Squadron,Amount)
|
||||||
|
local Squadron = self:GetSquadron(Squadron)
|
||||||
|
if Squadron.ResourceCount then
|
||||||
|
Squadron.ResourceCount = Squadron.ResourceCount - Amount
|
||||||
|
end
|
||||||
|
self:T({Squadron = Squadron.Name,SquadronResourceCount = Squadron.ResourceCount})
|
||||||
|
end
|
||||||
@@ -42,8 +42,8 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.
|
-- Until a fuel or damage threshold 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.
|
-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -253,6 +253,9 @@ function AI_AIR:New( AIGroup )
|
|||||||
|
|
||||||
self.IdleCount = 0
|
self.IdleCount = 0
|
||||||
|
|
||||||
|
self.RTBSpeedMaxFactor = 0.6
|
||||||
|
self.RTBSpeedMinFactor = 0.5
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -370,11 +373,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.
|
--- 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.
|
-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel threshold 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.
|
-- 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.
|
-- Once the time is finished, the old AI will return to the base.
|
||||||
-- @param #AI_AIR self
|
-- @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.
|
-- @param #number OutOfFuelOrbitTime The amount of seconds the out of fuel AIControllable will orbit before returning to the base.
|
||||||
-- @return #AI_AIR self
|
-- @return #AI_AIR self
|
||||||
function AI_AIR:SetFuelThreshold( FuelThresholdPercentage, OutOfFuelOrbitTime )
|
function AI_AIR:SetFuelThreshold( FuelThresholdPercentage, OutOfFuelOrbitTime )
|
||||||
@@ -387,14 +390,14 @@ function AI_AIR:SetFuelThreshold( FuelThresholdPercentage, OutOfFuelOrbitTime )
|
|||||||
return self
|
return self
|
||||||
end
|
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.
|
-- 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).
|
-- the AI will return immediately to the home base (RTB).
|
||||||
-- Note that for groups, the average damage of the complete group will be calculated.
|
-- 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 #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
|
-- @return #AI_AIR self
|
||||||
function AI_AIR:SetDamageThreshold( PatrolDamageThreshold )
|
function AI_AIR:SetDamageThreshold( PatrolDamageThreshold )
|
||||||
|
|
||||||
@@ -476,7 +479,7 @@ function AI_AIR:onafterStatus()
|
|||||||
|
|
||||||
local Fuel = self.Controllable:GetFuelMin()
|
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.
|
-- then send for refuel in case of a tanker, otherwise RTB.
|
||||||
if Fuel < self.FuelThresholdPercentage then
|
if Fuel < self.FuelThresholdPercentage then
|
||||||
|
|
||||||
@@ -576,6 +579,19 @@ function AI_AIR.RTBHold( AIGroup, Fsm )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set the min and max factors on RTB speed. Use this, if your planes are heading back to base too fast. Default values are 0.5 and 0.6.
|
||||||
|
-- The RTB speed is calculated as the max speed of the unit multiplied by MinFactor (lower bracket) and multiplied by MaxFactor (upper bracket).
|
||||||
|
-- A random value in this bracket is then applied in the waypoint routing generation.
|
||||||
|
-- @param #AI_AIR self
|
||||||
|
-- @param #number MinFactor Lower bracket factor. Defaults to 0.5.
|
||||||
|
-- @param #number MaxFactor Upper bracket factor. Defaults to 0.6.
|
||||||
|
-- @return #AI_AIR self
|
||||||
|
function AI_AIR:SetRTBSpeedFactors(MinFactor,MaxFactor)
|
||||||
|
self.RTBSpeedMaxFactor = MaxFactor or 0.6
|
||||||
|
self.RTBSpeedMinFactor = MinFactor or 0.5
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
--- @param #AI_AIR self
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
@@ -590,6 +606,8 @@ function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
|||||||
self:ClearTargetDistance()
|
self:ClearTargetDistance()
|
||||||
--AIGroup:ClearTasks()
|
--AIGroup:ClearTasks()
|
||||||
|
|
||||||
|
AIGroup:OptionProhibitAfterburner(true)
|
||||||
|
|
||||||
local EngageRoute = {}
|
local EngageRoute = {}
|
||||||
|
|
||||||
--- Calculate the target route point.
|
--- Calculate the target route point.
|
||||||
@@ -597,12 +615,14 @@ function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
|||||||
local FromCoord = AIGroup:GetCoordinate()
|
local FromCoord = AIGroup:GetCoordinate()
|
||||||
local ToTargetCoord = self.HomeAirbase:GetCoordinate() -- coordinate is on land height(!)
|
local ToTargetCoord = self.HomeAirbase:GetCoordinate() -- coordinate is on land height(!)
|
||||||
local ToTargetVec3 = ToTargetCoord:GetVec3()
|
local ToTargetVec3 = ToTargetCoord:GetVec3()
|
||||||
ToTargetVec3.y = ToTargetCoord:GetLandHeight()+1000 -- let's set this 1000m/3000 feet above ground
|
ToTargetVec3.y = ToTargetCoord:GetLandHeight()+3000 -- let's set this 1000m/3000 feet above ground
|
||||||
local ToTargetCoord2 = COORDINATE:NewFromVec3( ToTargetVec3 )
|
local ToTargetCoord2 = COORDINATE:NewFromVec3( ToTargetVec3 )
|
||||||
|
|
||||||
if not self.RTBMinSpeed or not self.RTBMaxSpeed then
|
if not self.RTBMinSpeed or not self.RTBMaxSpeed then
|
||||||
local RTBSpeedMax = AIGroup:GetSpeedMax()
|
local RTBSpeedMax = AIGroup:GetSpeedMax()
|
||||||
self:SetRTBSpeed( RTBSpeedMax * 0.5, RTBSpeedMax * 0.6 )
|
local RTBSpeedMaxFactor = self.RTBSpeedMaxFactor or 0.6
|
||||||
|
local RTBSpeedMinFactor = self.RTBSpeedMinFactor or 0.5
|
||||||
|
self:SetRTBSpeed( RTBSpeedMax * RTBSpeedMinFactor, RTBSpeedMax * RTBSpeedMaxFactor)
|
||||||
end
|
end
|
||||||
|
|
||||||
local RTBSpeed = math.random( self.RTBMinSpeed, self.RTBMaxSpeed )
|
local RTBSpeed = math.random( self.RTBMinSpeed, self.RTBMaxSpeed )
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
-- * Setup (CAS) Controlled Air Support squadrons, to attack closeby enemy ground units near friendly installations.
|
-- * 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.
|
-- * Setup (BAI) Battleground Air Interdiction squadrons to attack remote enemy ground units and targets.
|
||||||
-- * Define and use a detection network controlled by recce.
|
-- * 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.
|
-- * Enable airbases for AIR defenses.
|
||||||
-- * Add different planes and helicopter templates to squadrons.
|
-- * 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.
|
-- * 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.
|
-- * Define different ranges to engage upon.
|
||||||
-- * Establish an automatic in air refuel process for planes using refuel tankers.
|
-- * Establish an automatic in air refuel process for planes using refuel tankers.
|
||||||
-- * Setup default settings for all squadrons and AIR defenses.
|
-- * 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.
|
-- 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?
|
-- ## 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.
|
-- 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**.
|
-- 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.
|
-- 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.
|
-- **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.
|
-- 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
|
-- 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.
|
-- 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.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.
|
-- * @{#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
|
-- 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.
|
-- 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.
|
-- 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.
|
-- 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 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.
|
-- - 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
|
-- ## 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.
|
-- 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**.
|
-- ## 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.
|
-- 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.
|
-- 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.
|
-- 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:SetSquadronCapInterval("Sochi", 2, 30, 600, 1 )
|
||||||
-- A2ADispatcher:SetSquadronGci( "Sochi", 900, 1200 )
|
-- 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:SetDefaultFuelThreshold( 0.9 )
|
||||||
-- A2ADispatcher:SetDefaultTanker( "Tanker" )
|
-- A2ADispatcher:SetDefaultTanker( "Tanker" )
|
||||||
--
|
--
|
||||||
@@ -883,9 +883,6 @@ do -- AI_AIR_DISPATCHER
|
|||||||
-- However, the squadron will still stay alive. Any airplane that is airborne will continue its operations until all airborne airplanes
|
-- 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.
|
-- of the squadron will be destroyed. This to keep consistency of air operations not to confuse the players.
|
||||||
--
|
--
|
||||||
--
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- @field #AI_AIR_DISPATCHER
|
-- @field #AI_AIR_DISPATCHER
|
||||||
AI_AIR_DISPATCHER = {
|
AI_AIR_DISPATCHER = {
|
||||||
ClassName = "AI_AIR_DISPATCHER",
|
ClassName = "AI_AIR_DISPATCHER",
|
||||||
@@ -949,7 +946,6 @@ do -- AI_AIR_DISPATCHER
|
|||||||
--- @field #AI_AIR_DISPATCHER.DefenseQueue DefenseQueue
|
--- @field #AI_AIR_DISPATCHER.DefenseQueue DefenseQueue
|
||||||
AI_AIR_DISPATCHER.DefenseQueue = {}
|
AI_AIR_DISPATCHER.DefenseQueue = {}
|
||||||
|
|
||||||
|
|
||||||
--- Defense approach types
|
--- Defense approach types
|
||||||
-- @type #AI_AIR_DISPATCHER.DefenseApproach
|
-- @type #AI_AIR_DISPATCHER.DefenseApproach
|
||||||
AI_AIR_DISPATCHER.DefenseApproach = {
|
AI_AIR_DISPATCHER.DefenseApproach = {
|
||||||
@@ -958,26 +954,26 @@ do -- AI_AIR_DISPATCHER
|
|||||||
}
|
}
|
||||||
|
|
||||||
--- AI_AIR_DISPATCHER constructor.
|
--- 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 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 #AI_AIR_DISPATCHER self
|
||||||
-- @param Functional.Detection#DETECTION_BASE Detection The DETECTION object that will detects targets using the the Early Warning Radar network.
|
-- @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
|
-- @return #AI_AIR_DISPATCHER self
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Setup the Detection, using DETECTION_AREAS.
|
-- -- Setup the Detection, using DETECTION_AREAS.
|
||||||
-- -- First define the SET of GROUPs that are defining the EWR network.
|
-- -- First define the SET of GROUPs that are defining the EWR network.
|
||||||
-- -- Here with prefixes DF CCCP AWACS, DF CCCP EWR.
|
-- -- Here with prefixes DF CCCP AWACS, DF CCCP EWR.
|
||||||
-- DetectionSetGroup = SET_GROUP:New()
|
-- DetectionSetGroup = SET_GROUP:New()
|
||||||
-- DetectionSetGroup:FilterPrefixes( { "DF CCCP AWACS", "DF CCCP EWR" } )
|
-- DetectionSetGroup:FilterPrefixes( { "DF CCCP AWACS", "DF CCCP EWR" } )
|
||||||
-- DetectionSetGroup:FilterStart()
|
-- DetectionSetGroup:FilterStart()
|
||||||
--
|
--
|
||||||
-- -- Define the DETECTION_AREAS, using the DetectionSetGroup, with a 30km grouping radius.
|
-- -- Define the DETECTION_AREAS, using the DetectionSetGroup, with a 30km grouping radius.
|
||||||
-- Detection = DETECTION_AREAS:New( DetectionSetGroup, 30000 )
|
-- Detection = DETECTION_AREAS:New( DetectionSetGroup, 30000 )
|
||||||
--
|
--
|
||||||
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
||||||
-- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection ) --
|
-- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection )
|
||||||
--
|
--
|
||||||
function AI_AIR_DISPATCHER:New( Detection )
|
function AI_AIR_DISPATCHER:New( Detection )
|
||||||
|
|
||||||
@@ -1435,17 +1431,17 @@ do -- AI_AIR_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the default damage treshold when defenders will RTB.
|
--- Set the default damage threshold 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.
|
-- 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 #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
|
-- @return #AI_AIR_DISPATCHER
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
||||||
-- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection )
|
-- 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.
|
-- AIRDispatcher:SetDefaultDamageThreshold( 0.90 ) -- Go RTB when the airplane 90% damaged.
|
||||||
--
|
--
|
||||||
function AI_AIR_DISPATCHER:SetDefaultDamageThreshold( DamageThreshold )
|
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.
|
--- Defines the default amount of extra planes that will take-off as part of the defense system.
|
||||||
-- @param #AI_AIR_DISPATCHER self
|
-- @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,
|
-- 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...
|
-- 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.
|
-- 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.
|
--- Defines the amount of extra planes that will take-off as part of the defense system.
|
||||||
-- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param #string SquadronName The name of the squadron.
|
-- @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,
|
-- 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...
|
-- 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.
|
-- 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.
|
--- Gets the overhead of planes as part of the defense system, in comparison with the attackers.
|
||||||
-- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param #string SquadronName The name of the squadron.
|
-- @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,
|
-- 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...
|
-- 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.
|
-- 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
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the default fuel treshold when defenders will RTB or Refuel in the air.
|
--- Set the default fuel threshold 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.
|
-- 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 #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
|
-- @return #AI_AIR_DISPATCHER
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
||||||
-- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection )
|
-- 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.
|
-- AIRDispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||||
--
|
--
|
||||||
function AI_AIR_DISPATCHER:SetDefaultFuelThreshold( FuelThreshold )
|
function AI_AIR_DISPATCHER:SetDefaultFuelThreshold( FuelThreshold )
|
||||||
@@ -2695,18 +2691,18 @@ do -- AI_AIR_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the fuel treshold for the squadron when defenders will RTB or Refuel in the air.
|
--- Set the fuel threshold 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.
|
-- 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 #AI_AIR_DISPATCHER self
|
||||||
-- @param #string SquadronName The name of the squadron.
|
-- @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
|
-- @return #AI_AIR_DISPATCHER
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
||||||
-- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection )
|
-- 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.
|
-- AIRDispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||||
--
|
--
|
||||||
function AI_AIR_DISPATCHER:SetSquadronFuelThreshold( SquadronName, FuelThreshold )
|
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.
|
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
||||||
-- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection )
|
-- 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.
|
-- AIRDispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||||
--
|
--
|
||||||
-- -- Now Setup the default tanker.
|
-- -- 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.
|
-- -- Now Setup the AIR dispatcher, and initialize it using the Detection object.
|
||||||
-- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection )
|
-- 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.
|
-- AIRDispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank.
|
||||||
--
|
--
|
||||||
-- -- Now Setup the squadron tanker.
|
-- -- Now Setup the squadron tanker.
|
||||||
@@ -2847,7 +2843,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
-- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
function AI_AIR_DISPATCHER:CountDefendersEngaged( AttackerDetection, AttackerCount )
|
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 DefendersEngaged = 0
|
||||||
local DefendersTotal = 0
|
local DefendersTotal = 0
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.
|
-- Until a fuel or damage threshold 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.
|
-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -533,6 +533,10 @@ function AI_AIR_ENGAGE:onafterEngage( DefenderGroup, From, Event, To, AttackSetU
|
|||||||
DefenderCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
DefenderCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetCoord = AttackSetUnit:GetFirst():GetPointVec3()
|
local TargetCoord = AttackSetUnit:GetFirst():GetPointVec3()
|
||||||
|
if not TargetCoord then
|
||||||
|
self:Return()
|
||||||
|
return
|
||||||
|
end
|
||||||
TargetCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
TargetCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.
|
-- Until a fuel or damage threshold 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.
|
-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
-- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets.
|
-- * **@{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.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.
|
-- * **@{#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
|
-- ## 3. Set the Range of Engagement
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
-- Upon started, The AI will **Route** itself towards the random 3D point within a patrol zone,
|
-- 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.
|
-- 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.
|
-- 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.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
-- It will keep patrolling there, until it is notified to RTB or move to another BOMB Zone.
|
-- 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.
|
-- 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.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
-- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets.
|
-- * **@{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.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.
|
-- * **@{#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**
|
-- ## 3. Modify the Engage Zone behaviour to pinpoint a **map object** or **scenery object**
|
||||||
--
|
--
|
||||||
@@ -515,8 +515,8 @@ function AI_BAI_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
|
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
@@ -602,7 +602,7 @@ function AI_BAI_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
|
|
||||||
self:SetRefreshTimeInterval( 2 )
|
self:SetRefreshTimeInterval( 2 )
|
||||||
self:SetDetectionActivated()
|
self:SetDetectionActivated()
|
||||||
self:__Target( -2 ) -- Start Targetting
|
self:__Target( -2 ) -- Start targeting
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/AIB%20-%20AI%20Balancing)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AIB%20-%20AI%20Balancing)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
--
|
--
|
||||||
-- * Patrol AI airplanes within a given zone.
|
-- * Patrol AI airplanes within a given zone.
|
||||||
-- * Trigger detected events when enemy airplanes are detected.
|
-- * 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.
|
-- * Engage the enemy when detected.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/CAP%20-%20Combat%20Air%20Patrol)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/CAP%20-%20Combat%20Air%20Patrol)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -65,8 +65,8 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.
|
-- Until a fuel or damage threshold 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.
|
-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
-- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets.
|
-- * **@{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.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.
|
-- * **@{#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
|
-- ## 3. Set the Range of Engagement
|
||||||
--
|
--
|
||||||
@@ -428,8 +428,10 @@ function AI_CAP_ZONE:onafterEngage( Controllable, From, Event, To )
|
|||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
|
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
if not CurrentVec2 then return self end
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
|
||||||
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/CAS%20-%20Close%20Air%20Support)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/CAS%20-%20Close%20Air%20Support)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
-- Upon started, The AI will **Route** itself towards the random 3D point within a patrol zone,
|
-- 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.
|
-- 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.
|
-- 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.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
-- It will keep patrolling there, until it is notified to RTB or move to another CAS Zone.
|
-- 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.
|
-- 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.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
-- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets.
|
-- * **@{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.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.
|
-- * **@{#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.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -459,8 +459,8 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
|
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
@@ -520,7 +520,7 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
|
|
||||||
self:SetRefreshTimeInterval( 2 )
|
self:SetRefreshTimeInterval( 2 )
|
||||||
self:SetDetectionActivated()
|
self:SetDetectionActivated()
|
||||||
self:__Target( -2 ) -- Start Targetting
|
self:__Target( -2 ) -- Start targeting
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -174,8 +174,8 @@ function AI_CARGO_DISPATCHER_HELICOPTER:New( HelicopterSet, CargoSet, PickupZone
|
|||||||
self:SetPickupSpeed( 350, 150 )
|
self:SetPickupSpeed( 350, 150 )
|
||||||
self:SetDeploySpeed( 350, 150 )
|
self:SetDeploySpeed( 350, 150 )
|
||||||
|
|
||||||
self:SetPickupRadius( 0, 0 )
|
self:SetPickupRadius( 40, 12 )
|
||||||
self:SetDeployRadius( 0, 0 )
|
self:SetDeployRadius( 40, 12 )
|
||||||
|
|
||||||
self:SetPickupHeight( 500, 200 )
|
self:SetPickupHeight( 500, 200 )
|
||||||
self:SetDeployHeight( 500, 200 )
|
self:SetDeployHeight( 500, 200 )
|
||||||
@@ -186,6 +186,9 @@ end
|
|||||||
|
|
||||||
function AI_CARGO_DISPATCHER_HELICOPTER:AICargo( Helicopter, CargoSet )
|
function AI_CARGO_DISPATCHER_HELICOPTER:AICargo( Helicopter, CargoSet )
|
||||||
|
|
||||||
return AI_CARGO_HELICOPTER:New( Helicopter, CargoSet )
|
local dispatcher = AI_CARGO_HELICOPTER:New( Helicopter, CargoSet )
|
||||||
|
dispatcher:SetLandingSpeedAndHeight(27, 6)
|
||||||
|
return dispatcher
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module AI.AI_Cargo_Dispatcher_Ship
|
-- @module AI.AI_Cargo_Dispatcher_Ship
|
||||||
-- @image AI_Cargo_Dispatching_For_Ship.JPG
|
-- @image AI_Cargo_Dispatcher.JPG
|
||||||
|
|
||||||
--- @type AI_CARGO_DISPATCHER_SHIP
|
--- @type AI_CARGO_DISPATCHER_SHIP
|
||||||
-- @extends AI.AI_Cargo_Dispatcher#AI_CARGO_DISPATCHER
|
-- @extends AI.AI_Cargo_Dispatcher#AI_CARGO_DISPATCHER
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module AI.AI_Cargo_Ship
|
-- @module AI.AI_Cargo_Ship
|
||||||
-- @image AI_Cargo_Dispatching_For_Ship.JPG
|
-- @image AI_Cargo_Dispatcher.JPG
|
||||||
|
|
||||||
--- @type AI_CARGO_SHIP
|
--- @type AI_CARGO_SHIP
|
||||||
-- @extends AI.AI_Cargo#AI_CARGO
|
-- @extends AI.AI_Cargo#AI_CARGO
|
||||||
|
|||||||
@@ -1140,7 +1140,7 @@ end
|
|||||||
-- @param DCS#Vec3 CV2 Vec3
|
-- @param DCS#Vec3 CV2 Vec3
|
||||||
function AI_FORMATION:FollowMe(FollowGroup, ClientUnit, CT1, CV1, CT2, CV2)
|
function AI_FORMATION:FollowMe(FollowGroup, ClientUnit, CT1, CV1, CT2, CV2)
|
||||||
|
|
||||||
if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation then
|
if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation and not self:Is("Stopped") then
|
||||||
|
|
||||||
self:T({Mode=FollowGroup:GetState( FollowGroup, "Mode" )})
|
self:T({Mode=FollowGroup:GetState( FollowGroup, "Mode" )})
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
--
|
--
|
||||||
-- * Patrol AI airplanes within a given zone.
|
-- * Patrol AI airplanes within a given zone.
|
||||||
-- * Trigger detected events when enemy airplanes are detected.
|
-- * Trigger detected events when enemy airplanes are detected.
|
||||||
-- * Manage a fuel treshold to RTB on time.
|
-- * Manage a fuel threshold to RTB on time.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/PAT%20-%20Patrolling)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/PAT%20-%20Patrolling)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -72,8 +72,8 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.
|
-- Until a fuel or damage threshold 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.
|
-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
-- * **RTB** ( Group ): Route the AI to the home base.
|
-- * **RTB** ( Group ): Route the AI to the home base.
|
||||||
-- * **Detect** ( Group ): The AI is detecting targets.
|
-- * **Detect** ( Group ): The AI is detecting targets.
|
||||||
-- * **Detected** ( Group ): The AI has detected new 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
|
-- ## 3. Set or Get the AI controllable
|
||||||
--
|
--
|
||||||
@@ -133,8 +133,8 @@
|
|||||||
-- ## 6. Manage the "out of fuel" in the AI_PATROL_ZONE
|
-- ## 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.
|
-- 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.
|
-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel threshold is calculated.
|
||||||
-- When the fuel treshold is reached, the AI will continue for a given time its patrol task in orbit,
|
-- 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.
|
-- while a new AI is targetted to the AI_PATROL_ZONE.
|
||||||
-- Once the time is finished, the old AI will return to the base.
|
-- 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.
|
-- 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
|
-- ## 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.
|
-- 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.
|
-- Use the method @{#AI_PATROL_ZONE.ManageDamage}() to have this proces in place.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
@@ -581,11 +581,11 @@ function AI_PATROL_ZONE:ClearDetectedUnits()
|
|||||||
end
|
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.
|
--- 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.
|
-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel threshold 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.
|
-- 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.
|
-- Once the time is finished, the old AI will return to the base.
|
||||||
-- @param #AI_PATROL_ZONE self
|
-- @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.
|
-- @param #number PatrolOutOfFuelOrbitTime The amount of seconds the out of fuel AIControllable will orbit before returning to the base.
|
||||||
-- @return #AI_PATROL_ZONE self
|
-- @return #AI_PATROL_ZONE self
|
||||||
function AI_PATROL_ZONE:ManageFuel( PatrolFuelThresholdPercentage, PatrolOutOfFuelOrbitTime )
|
function AI_PATROL_ZONE:ManageFuel( PatrolFuelThresholdPercentage, PatrolOutOfFuelOrbitTime )
|
||||||
@@ -596,14 +596,14 @@ function AI_PATROL_ZONE:ManageFuel( PatrolFuelThresholdPercentage, PatrolOutOfFu
|
|||||||
return self
|
return self
|
||||||
end
|
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.
|
-- 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).
|
-- the AI will return immediately to the home base (RTB).
|
||||||
-- Note that for groups, the average damage of the complete group will be calculated.
|
-- 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 #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
|
-- @return #AI_PATROL_ZONE self
|
||||||
function AI_PATROL_ZONE:ManageDamage( PatrolDamageThreshold )
|
function AI_PATROL_ZONE:ManageDamage( PatrolDamageThreshold )
|
||||||
|
|
||||||
@@ -725,8 +725,8 @@ function AI_PATROL_ZONE:onafterRoute( Controllable, From, Event, To )
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local life = self.Controllable:GetLife() or 0
|
||||||
if self.Controllable:IsAlive() then
|
if self.Controllable:IsAlive() and life > 1 then
|
||||||
-- Determine if the AIControllable is within the PatrolZone.
|
-- Determine if the AIControllable is within the PatrolZone.
|
||||||
-- If not, make a waypoint within the to that the AIControllable will fly at maximum speed to that point.
|
-- If not, make a waypoint within the to that the AIControllable will fly at maximum speed to that point.
|
||||||
|
|
||||||
@@ -743,8 +743,9 @@ function AI_PATROL_ZONE:onafterRoute( Controllable, From, Event, To )
|
|||||||
if self.Controllable:InAir() == false then
|
if self.Controllable:InAir() == false then
|
||||||
self:T( "Not in the air, finding route path within PatrolZone" )
|
self:T( "Not in the air, finding route path within PatrolZone" )
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
if not CurrentVec2 then return end
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
--Done: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
@@ -758,8 +759,9 @@ function AI_PATROL_ZONE:onafterRoute( Controllable, From, Event, To )
|
|||||||
else
|
else
|
||||||
self:T( "In the air, finding route path within PatrolZone" )
|
self:T( "In the air, finding route path within PatrolZone" )
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
if not CurrentVec2 then return end
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
@@ -870,9 +872,10 @@ function AI_PATROL_ZONE:onafterRTB()
|
|||||||
|
|
||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
|
if not CurrentVec2 then return end
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
--local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
||||||
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
|
|||||||
@@ -194,7 +194,7 @@
|
|||||||
-- * is of type `Workmaterials`
|
-- * is of type `Workmaterials`
|
||||||
-- * will report when a carrier is within 500 meters
|
-- * 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 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:
|
-- So the overall syntax of the #CARGO naming tag and arguments are:
|
||||||
--
|
--
|
||||||
@@ -206,27 +206,29 @@
|
|||||||
-- * **NR=** Provide the maximum range in meters when the cargo units will be boarded within the carrier during boarding.
|
-- * **NR=** Provide the maximum range in meters when the cargo units will be boarded within the carrier during boarding.
|
||||||
-- Note that this option is optional, so can be omitted. The default value of the RR is 10 meters.
|
-- Note that this option is optional, so can be omitted. The default value of the RR is 10 meters.
|
||||||
--
|
--
|
||||||
-- ## 5.2) The \#CARGO tag to create CARGO_CRATE objects:
|
-- ## 5.2) The \#CARGO tag to create CARGO_CRATE or CARGO_SLINGLOAD objects:
|
||||||
--
|
--
|
||||||
-- You can also use the \#CARGO tag on **static** objects, including **static cargo** objects of the mission editor.
|
-- You can also use the \#CARGO tag on **static** objects, including **static cargo** objects of the mission editor.
|
||||||
--
|
--
|
||||||
-- For example, the following #CARGO naming in the **static name** of the object, will create a CARGO_CRATE object when the mission starts.
|
-- For example, the following #CARGO naming in the **static name** of the object, will create a CARGO_CRATE object when the mission starts.
|
||||||
--
|
--
|
||||||
-- `Static #CARGO(T=Workmaterials,RR=500,NR=25)`
|
-- `Static #CARGO(T=Workmaterials,C=CRATE,RR=500,NR=25)`
|
||||||
--
|
--
|
||||||
-- This will create a CARGO_CRATE object:
|
-- This will create a CARGO_CRATE object:
|
||||||
--
|
--
|
||||||
-- * with the group name `Static #CARGO`
|
-- * with the group name `Static #CARGO`
|
||||||
-- * is of type `Workmaterials`
|
-- * is of type `Workmaterials`
|
||||||
|
-- * is of category `CRATE` (as opposed to `SLING`)
|
||||||
-- * will report when a carrier is within 500 meters
|
-- * 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 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:
|
-- So the overall syntax of the #CARGO naming tag and arguments are:
|
||||||
--
|
--
|
||||||
-- `StaticName #CARGO(T=CargoTypeName,RR=Range,NR=Range)`
|
-- `StaticName #CARGO(T=CargoTypeName,C=Category,RR=Range,NR=Range)`
|
||||||
--
|
--
|
||||||
-- * **T=** Provide a text that contains the type name of the cargo object. This type name can be used to filter cargo within a SET_CARGO object.
|
-- * **T=** Provide a text that contains the type name of the cargo object. This type name can be used to filter cargo within a SET_CARGO object.
|
||||||
|
-- * **C=** Provide either `CRATE` or `SLING` to have this static created as a CARGO_CRATE or CARGO_SLINGLOAD respectivly.
|
||||||
-- * **RR=** Provide the minimal range in meters when the report to the carrier, and board to the carrier.
|
-- * **RR=** Provide the minimal range in meters when the report to the carrier, and board to the carrier.
|
||||||
-- Note that this option is optional, so can be omitted. The default value of the RR is 250 meters.
|
-- Note that this option is optional, so can be omitted. The default value of the RR is 250 meters.
|
||||||
-- * **NR=** Provide the maximum range in meters when the cargo units will be boarded within the carrier during boarding.
|
-- * **NR=** Provide the maximum range in meters when the cargo units will be boarded within the carrier during boarding.
|
||||||
|
|||||||
@@ -0,0 +1,943 @@
|
|||||||
|
--- **Core** - A* Pathfinding.
|
||||||
|
--
|
||||||
|
-- **Main Features:**
|
||||||
|
--
|
||||||
|
-- * Find path from A to B.
|
||||||
|
-- * Pre-defined as well as custom valid neighbour functions.
|
||||||
|
-- * Pre-defined as well as custom cost functions.
|
||||||
|
-- * Easy rectangular grid setup.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### Author: **funkyfranky**
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Core.Astar
|
||||||
|
-- @image CORE_Astar.png
|
||||||
|
|
||||||
|
|
||||||
|
--- ASTAR class.
|
||||||
|
-- @type ASTAR
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #boolean Debug Debug mode. Messages to all about status.
|
||||||
|
-- @field #string lid Class id string for output to DCS log file.
|
||||||
|
-- @field #table nodes Table of nodes.
|
||||||
|
-- @field #number counter Node counter.
|
||||||
|
-- @field #number Nnodes Number of nodes.
|
||||||
|
-- @field #number nvalid Number of nvalid calls.
|
||||||
|
-- @field #number nvalidcache Number of cached valid evals.
|
||||||
|
-- @field #number ncost Number of cost evaluations.
|
||||||
|
-- @field #number ncostcache Number of cached cost evals.
|
||||||
|
-- @field #ASTAR.Node startNode Start node.
|
||||||
|
-- @field #ASTAR.Node endNode End node.
|
||||||
|
-- @field Core.Point#COORDINATE startCoord Start coordinate.
|
||||||
|
-- @field Core.Point#COORDINATE endCoord End coordinate.
|
||||||
|
-- @field #function ValidNeighbourFunc Function to check if a node is valid.
|
||||||
|
-- @field #table ValidNeighbourArg Optional arguments passed to the valid neighbour function.
|
||||||
|
-- @field #function CostFunc Function to calculate the heuristic "cost" to go from one node to another.
|
||||||
|
-- @field #table CostArg Optional arguments passed to the cost function.
|
||||||
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
--- *When nothing goes right... Go left!*
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # The ASTAR Concept
|
||||||
|
--
|
||||||
|
-- Pathfinding algorithm.
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- # Start and Goal
|
||||||
|
--
|
||||||
|
-- The first thing we need to define is obviously the place where we want to start and where we want to go eventually.
|
||||||
|
--
|
||||||
|
-- ## Start
|
||||||
|
--
|
||||||
|
-- The start
|
||||||
|
--
|
||||||
|
-- ## Goal
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- # Nodes
|
||||||
|
--
|
||||||
|
-- ## Rectangular Grid
|
||||||
|
--
|
||||||
|
-- A rectangular grid can be created using the @{#ASTAR.CreateGrid}(*ValidSurfaceTypes, BoxHY, SpaceX, deltaX, deltaY, MarkGrid*), where
|
||||||
|
--
|
||||||
|
-- * *ValidSurfaceTypes* is a table of valid surface types. By default all surface types are valid.
|
||||||
|
-- * *BoxXY* is the width of the grid perpendicular the the line between start and end node. Default is 40,000 meters (40 km).
|
||||||
|
-- * *SpaceX* is the additional space behind the start and end nodes. Default is 20,000 meters (20 km).
|
||||||
|
-- * *deltaX* is the grid spacing between nodes in the direction of start and end node. Default is 2,000 meters (2 km).
|
||||||
|
-- * *deltaY* is the grid spacing perpendicular to the direction of start and end node. Default is the same as *deltaX*.
|
||||||
|
-- * *MarkGrid* If set to *true*, this places marker on the F10 map on each grid node. Note that this can stall DCS if too many nodes are created.
|
||||||
|
--
|
||||||
|
-- ## Valid Surfaces
|
||||||
|
--
|
||||||
|
-- Certain unit types can only travel on certain surfaces types, for example
|
||||||
|
--
|
||||||
|
-- * Naval units can only travel on water (that also excludes shallow water in DCS currently),
|
||||||
|
-- * Ground units can only traval on land.
|
||||||
|
--
|
||||||
|
-- By restricting the surface type in the grid construction, we also reduce the number of nodes, which makes the algorithm more efficient.
|
||||||
|
--
|
||||||
|
-- ## Box Width (BoxHY)
|
||||||
|
--
|
||||||
|
-- The box width needs to be large enough to capture all paths you want to consider.
|
||||||
|
--
|
||||||
|
-- ## Space in X
|
||||||
|
--
|
||||||
|
-- The space in X value is important if the algorithm needs to to backwards from the start node or needs to extend even further than the end node.
|
||||||
|
--
|
||||||
|
-- ## Grid Spacing
|
||||||
|
--
|
||||||
|
-- The grid spacing is an important factor as it determines the number of nodes and hence the performance of the algorithm. It should be as large as possible.
|
||||||
|
-- However, if the value is too large, the algorithm might fail to get a valid path.
|
||||||
|
--
|
||||||
|
-- A good estimate of the grid spacing is to set it to be smaller (~ half the size) of the smallest gap you need to path.
|
||||||
|
--
|
||||||
|
-- # Valid Neighbours
|
||||||
|
--
|
||||||
|
-- The A* algorithm needs to know if a transition from one node to another is allowed or not. By default, hopping from one node to another is always possible.
|
||||||
|
--
|
||||||
|
-- ## Line of Sight
|
||||||
|
--
|
||||||
|
-- For naval
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- # Heuristic Cost
|
||||||
|
--
|
||||||
|
-- In order to determine the optimal path, the pathfinding algorithm needs to know, how costly it is to go from one node to another.
|
||||||
|
-- Often, this can simply be determined by the distance between two nodes. Therefore, the default cost function is set to be the 2D distance between two nodes.
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- # Calculate the Path
|
||||||
|
--
|
||||||
|
-- Finally, we have to calculate the path. This is done by the @{ASTAR.GetPath}(*ExcludeStart, ExcludeEnd*) function. This function returns a table of nodes, which
|
||||||
|
-- describe the optimal path from the start node to the end node.
|
||||||
|
--
|
||||||
|
-- By default, the start and end node are include in the table that is returned.
|
||||||
|
--
|
||||||
|
-- Note that a valid path must not always exist. So you should check if the function returns *nil*.
|
||||||
|
--
|
||||||
|
-- Common reasons that a path cannot be found are:
|
||||||
|
--
|
||||||
|
-- * The grid is too small ==> increase grid size, e.g. *BoxHY* and/or *SpaceX* if you use a rectangular grid.
|
||||||
|
-- * The grid spacing is too large ==> decrease *deltaX* and/or *deltaY*
|
||||||
|
-- * There simply is no valid path ==> you are screwed :(
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- # Examples
|
||||||
|
--
|
||||||
|
-- ## Strait of Hormuz
|
||||||
|
--
|
||||||
|
-- Carrier Group finds its way through the Stait of Hormuz.
|
||||||
|
--
|
||||||
|
-- ##
|
||||||
|
--
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- @field #ASTAR
|
||||||
|
ASTAR = {
|
||||||
|
ClassName = "ASTAR",
|
||||||
|
Debug = nil,
|
||||||
|
lid = nil,
|
||||||
|
nodes = {},
|
||||||
|
counter = 1,
|
||||||
|
Nnodes = 0,
|
||||||
|
ncost = 0,
|
||||||
|
ncostcache = 0,
|
||||||
|
nvalid = 0,
|
||||||
|
nvalidcache = 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Node data.
|
||||||
|
-- @type ASTAR.Node
|
||||||
|
-- @field #number id Node id.
|
||||||
|
-- @field Core.Point#COORDINATE coordinate Coordinate of the node.
|
||||||
|
-- @field #number surfacetype Surface type.
|
||||||
|
-- @field #table valid Cached valid/invalid nodes.
|
||||||
|
-- @field #table cost Cached cost.
|
||||||
|
|
||||||
|
--- ASTAR infinity.
|
||||||
|
-- @field #number INF
|
||||||
|
ASTAR.INF=1/0
|
||||||
|
|
||||||
|
--- ASTAR class version.
|
||||||
|
-- @field #string version
|
||||||
|
ASTAR.version="0.4.0"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- TODO list
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- TODO: Add more valid neighbour functions.
|
||||||
|
-- TODO: Write docs.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Constructor
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Create a new ASTAR object.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:New()
|
||||||
|
|
||||||
|
-- Inherit everything from INTEL class.
|
||||||
|
local self=BASE:Inherit(self, BASE:New()) --#ASTAR
|
||||||
|
|
||||||
|
self.lid="ASTAR | "
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- User functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Set coordinate from where to start.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate Start coordinate.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetStartCoordinate(Coordinate)
|
||||||
|
|
||||||
|
self.startCoord=Coordinate
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set coordinate where you want to go.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate end coordinate.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetEndCoordinate(Coordinate)
|
||||||
|
|
||||||
|
self.endCoord=Coordinate
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Create a node from a given coordinate.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The coordinate where to create the node.
|
||||||
|
-- @return #ASTAR.Node The node.
|
||||||
|
function ASTAR:GetNodeFromCoordinate(Coordinate)
|
||||||
|
|
||||||
|
local node={} --#ASTAR.Node
|
||||||
|
|
||||||
|
node.coordinate=Coordinate
|
||||||
|
node.surfacetype=Coordinate:GetSurfaceType()
|
||||||
|
node.id=self.counter
|
||||||
|
|
||||||
|
node.valid={}
|
||||||
|
node.cost={}
|
||||||
|
|
||||||
|
self.counter=self.counter+1
|
||||||
|
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Add a node to the table of grid nodes.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #ASTAR.Node Node The node to be added.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:AddNode(Node)
|
||||||
|
|
||||||
|
self.nodes[Node.id]=Node
|
||||||
|
self.Nnodes=self.Nnodes+1
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a node to the table of grid nodes specifying its coordinate.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The coordinate where the node is created.
|
||||||
|
-- @return #ASTAR.Node The node.
|
||||||
|
function ASTAR:AddNodeFromCoordinate(Coordinate)
|
||||||
|
|
||||||
|
local node=self:GetNodeFromCoordinate(Coordinate)
|
||||||
|
|
||||||
|
self:AddNode(node)
|
||||||
|
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if the coordinate of a node has is at a valid surface type.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #ASTAR.Node Node The node to be added.
|
||||||
|
-- @param #table SurfaceTypes Surface types, for example `{land.SurfaceType.WATER}`. By default all surface types are valid.
|
||||||
|
-- @return #boolean If true, surface type of node is valid.
|
||||||
|
function ASTAR:CheckValidSurfaceType(Node, SurfaceTypes)
|
||||||
|
|
||||||
|
if SurfaceTypes then
|
||||||
|
|
||||||
|
if type(SurfaceTypes)~="table" then
|
||||||
|
SurfaceTypes={SurfaceTypes}
|
||||||
|
end
|
||||||
|
|
||||||
|
for _,surface in pairs(SurfaceTypes) do
|
||||||
|
if surface==Node.surfacetype then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a function to determine if a neighbour of a node is valid.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #function NeighbourFunction Function that needs to return *true* for a neighbour to be valid.
|
||||||
|
-- @param ... Condition function arguments if any.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetValidNeighbourFunction(NeighbourFunction, ...)
|
||||||
|
|
||||||
|
self.ValidNeighbourFunc=NeighbourFunction
|
||||||
|
|
||||||
|
self.ValidNeighbourArg={}
|
||||||
|
if arg then
|
||||||
|
self.ValidNeighbourArg=arg
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set valid neighbours to require line of sight between two nodes.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #number CorridorWidth Width of LoS corridor in meters.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetValidNeighbourLoS(CorridorWidth)
|
||||||
|
|
||||||
|
self:SetValidNeighbourFunction(ASTAR.LoS, CorridorWidth)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set valid neighbours to be in a certain distance.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #number MaxDistance Max distance between nodes in meters. Default is 2000 m.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetValidNeighbourDistance(MaxDistance)
|
||||||
|
|
||||||
|
self:SetValidNeighbourFunction(ASTAR.DistMax, MaxDistance)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set valid neighbours to be in a certain distance.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #number MaxDistance Max distance between nodes in meters. Default is 2000 m.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetValidNeighbourRoad(MaxDistance)
|
||||||
|
|
||||||
|
self:SetValidNeighbourFunction(ASTAR.Road, MaxDistance)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set the function which calculates the "cost" to go from one to another node.
|
||||||
|
-- The first to arguments of this function are always the two nodes under consideration. But you can add optional arguments.
|
||||||
|
-- Very often the distance between nodes is a good measure for the cost.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #function CostFunction Function that returns the "cost".
|
||||||
|
-- @param ... Condition function arguments if any.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetCostFunction(CostFunction, ...)
|
||||||
|
|
||||||
|
self.CostFunc=CostFunction
|
||||||
|
|
||||||
|
self.CostArg={}
|
||||||
|
if arg then
|
||||||
|
self.CostArg=arg
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set heuristic cost to go from one node to another to be their 2D distance.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetCostDist2D()
|
||||||
|
|
||||||
|
self:SetCostFunction(ASTAR.Dist2D)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set heuristic cost to go from one node to another to be their 3D distance.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetCostDist3D()
|
||||||
|
|
||||||
|
self:SetCostFunction(ASTAR.Dist3D)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set heuristic cost to go from one node to another to be their 3D distance.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:SetCostRoad()
|
||||||
|
|
||||||
|
self:SetCostFunction(ASTAR)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Grid functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Create a rectangular grid of nodes between star and end coordinate.
|
||||||
|
-- The coordinate system is oriented along the line between start and end point.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #table ValidSurfaceTypes Valid surface types. By default is all surfaces are allowed.
|
||||||
|
-- @param #number BoxHY Box "height" in meters along the y-coordinate. Default 40000 meters (40 km).
|
||||||
|
-- @param #number SpaceX Additional space in meters before start and after end coordinate. Default 10000 meters (10 km).
|
||||||
|
-- @param #number deltaX Increment in the direction of start to end coordinate in meters. Default 2000 meters.
|
||||||
|
-- @param #number deltaY Increment perpendicular to the direction of start to end coordinate in meters. Default is same as deltaX.
|
||||||
|
-- @param #boolean MarkGrid If true, create F10 map markers at grid nodes.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:CreateGrid(ValidSurfaceTypes, BoxHY, SpaceX, deltaX, deltaY, MarkGrid)
|
||||||
|
|
||||||
|
-- Note that internally
|
||||||
|
-- x coordinate is z: x-->z Line from start to end
|
||||||
|
-- y coordinate is x: y-->x Perpendicular
|
||||||
|
|
||||||
|
-- Grid length and width.
|
||||||
|
local Dz=SpaceX or 10000
|
||||||
|
local Dx=BoxHY and BoxHY/2 or 20000
|
||||||
|
|
||||||
|
-- Increments.
|
||||||
|
local dz=deltaX or 2000
|
||||||
|
local dx=deltaY or dz
|
||||||
|
|
||||||
|
-- Heading from start to end coordinate.
|
||||||
|
local angle=self.startCoord:HeadingTo(self.endCoord)
|
||||||
|
|
||||||
|
--Distance between start and end.
|
||||||
|
local dist=self.startCoord:Get2DDistance(self.endCoord)+2*Dz
|
||||||
|
|
||||||
|
-- Origin of map. Needed to translate back to wanted position.
|
||||||
|
local co=COORDINATE:New(0, 0, 0)
|
||||||
|
local do1=co:Get2DDistance(self.startCoord)
|
||||||
|
local ho1=co:HeadingTo(self.startCoord)
|
||||||
|
|
||||||
|
-- Start of grid.
|
||||||
|
local xmin=-Dx
|
||||||
|
local zmin=-Dz
|
||||||
|
|
||||||
|
-- Number of grid points.
|
||||||
|
local nz=dist/dz+1
|
||||||
|
local nx=2*Dx/dx+1
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
local text=string.format("Building grid with nx=%d ny=%d => total=%d nodes", nx, nz, nx*nz)
|
||||||
|
self:T(self.lid..text)
|
||||||
|
|
||||||
|
-- Loop over x and z coordinate to create a 2D grid.
|
||||||
|
for i=1,nx do
|
||||||
|
|
||||||
|
-- x coordinate perpendicular to z.
|
||||||
|
local x=xmin+dx*(i-1)
|
||||||
|
|
||||||
|
for j=1,nz do
|
||||||
|
|
||||||
|
-- z coordinate connecting start and end.
|
||||||
|
local z=zmin+dz*(j-1)
|
||||||
|
|
||||||
|
-- Rotate 2D.
|
||||||
|
local vec3=UTILS.Rotate2D({x=x, y=0, z=z}, angle)
|
||||||
|
|
||||||
|
-- Coordinate of the node.
|
||||||
|
local c=COORDINATE:New(vec3.z, vec3.y, vec3.x):Translate(do1, ho1, true)
|
||||||
|
|
||||||
|
-- Create a node at this coordinate.
|
||||||
|
local node=self:GetNodeFromCoordinate(c)
|
||||||
|
|
||||||
|
-- Check if node has valid surface type.
|
||||||
|
if self:CheckValidSurfaceType(node, ValidSurfaceTypes) then
|
||||||
|
|
||||||
|
if MarkGrid then
|
||||||
|
c:MarkToAll(string.format("i=%d, j=%d surface=%d", i, j, node.surfacetype))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add node to grid.
|
||||||
|
self:AddNode(node)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
local text=string.format("Done building grid!")
|
||||||
|
self:T2(self.lid..text)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Valid neighbour functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Function to check if two nodes have line of sight (LoS).
|
||||||
|
-- @param #ASTAR.Node nodeA First node.
|
||||||
|
-- @param #ASTAR.Node nodeB Other node.
|
||||||
|
-- @param #number corridor (Optional) Width of corridor in meters.
|
||||||
|
-- @return #boolean If true, two nodes have LoS.
|
||||||
|
function ASTAR.LoS(nodeA, nodeB, corridor)
|
||||||
|
|
||||||
|
local offset=1
|
||||||
|
|
||||||
|
local dx=corridor and corridor/2 or nil
|
||||||
|
local dy=dx
|
||||||
|
|
||||||
|
local cA=nodeA.coordinate:GetVec3()
|
||||||
|
local cB=nodeB.coordinate:GetVec3()
|
||||||
|
cA.y=offset
|
||||||
|
cB.y=offset
|
||||||
|
|
||||||
|
local los=land.isVisible(cA, cB)
|
||||||
|
|
||||||
|
if los and corridor then
|
||||||
|
|
||||||
|
-- Heading from A to B.
|
||||||
|
local heading=nodeA.coordinate:HeadingTo(nodeB.coordinate)
|
||||||
|
|
||||||
|
local Ap=UTILS.VecTranslate(cA, dx, heading+90)
|
||||||
|
local Bp=UTILS.VecTranslate(cB, dx, heading+90)
|
||||||
|
|
||||||
|
los=land.isVisible(Ap, Bp)
|
||||||
|
|
||||||
|
if los then
|
||||||
|
|
||||||
|
local Am=UTILS.VecTranslate(cA, dx, heading-90)
|
||||||
|
local Bm=UTILS.VecTranslate(cB, dx, heading-90)
|
||||||
|
|
||||||
|
los=land.isVisible(Am, Bm)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return los
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Function to check if two nodes have a road connection.
|
||||||
|
-- @param #ASTAR.Node nodeA First node.
|
||||||
|
-- @param #ASTAR.Node nodeB Other node.
|
||||||
|
-- @return #boolean If true, two nodes are connected via a road.
|
||||||
|
function ASTAR.Road(nodeA, nodeB)
|
||||||
|
|
||||||
|
local path=land.findPathOnRoads("roads", nodeA.coordinate.x, nodeA.coordinate.z, nodeB.coordinate.x, nodeB.coordinate.z)
|
||||||
|
|
||||||
|
if path then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Function to check if distance between two nodes is less than a threshold distance.
|
||||||
|
-- @param #ASTAR.Node nodeA First node.
|
||||||
|
-- @param #ASTAR.Node nodeB Other node.
|
||||||
|
-- @param #number distmax Max distance in meters. Default is 2000 m.
|
||||||
|
-- @return #boolean If true, distance between the two nodes is below threshold.
|
||||||
|
function ASTAR.DistMax(nodeA, nodeB, distmax)
|
||||||
|
|
||||||
|
distmax=distmax or 2000
|
||||||
|
|
||||||
|
local dist=nodeA.coordinate:Get2DDistance(nodeB.coordinate)
|
||||||
|
|
||||||
|
return dist<=distmax
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Heuristic cost functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Heuristic cost is given by the 2D distance between the nodes.
|
||||||
|
-- @param #ASTAR.Node nodeA First node.
|
||||||
|
-- @param #ASTAR.Node nodeB Other node.
|
||||||
|
-- @return #number Distance between the two nodes.
|
||||||
|
function ASTAR.Dist2D(nodeA, nodeB)
|
||||||
|
local dist=nodeA.coordinate:Get2DDistance(nodeB)
|
||||||
|
return dist
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Heuristic cost is given by the 3D distance between the nodes.
|
||||||
|
-- @param #ASTAR.Node nodeA First node.
|
||||||
|
-- @param #ASTAR.Node nodeB Other node.
|
||||||
|
-- @return #number Distance between the two nodes.
|
||||||
|
function ASTAR.Dist3D(nodeA, nodeB)
|
||||||
|
local dist=nodeA.coordinate:Get3DDistance(nodeB.coordinate)
|
||||||
|
return dist
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Heuristic cost is given by the distance between the nodes on road.
|
||||||
|
-- @param #ASTAR.Node nodeA First node.
|
||||||
|
-- @param #ASTAR.Node nodeB Other node.
|
||||||
|
-- @return #number Distance between the two nodes.
|
||||||
|
function ASTAR.DistRoad(nodeA, nodeB)
|
||||||
|
|
||||||
|
-- Get the path.
|
||||||
|
local path=land.findPathOnRoads("roads", nodeA.coordinate.x, nodeA.coordinate.z, nodeB.coordinate.x, nodeB.coordinate.z)
|
||||||
|
|
||||||
|
if path then
|
||||||
|
|
||||||
|
local dist=0
|
||||||
|
|
||||||
|
for i=2,#path do
|
||||||
|
local b=path[i] --DCS#Vec2
|
||||||
|
local a=path[i-1] --DCS#Vec2
|
||||||
|
|
||||||
|
dist=dist+UTILS.VecDist2D(a,b)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return dist
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return math.huge
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Misc functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Find the closest node from a given coordinate.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate.
|
||||||
|
-- @return #ASTAR.Node Cloest node to the coordinate.
|
||||||
|
-- @return #number Distance to closest node in meters.
|
||||||
|
function ASTAR:FindClosestNode(Coordinate)
|
||||||
|
|
||||||
|
local distMin=math.huge
|
||||||
|
local closeNode=nil
|
||||||
|
|
||||||
|
for _,_node in pairs(self.nodes) do
|
||||||
|
local node=_node --#ASTAR.Node
|
||||||
|
|
||||||
|
local dist=node.coordinate:Get2DDistance(Coordinate)
|
||||||
|
|
||||||
|
if dist<distMin then
|
||||||
|
distMin=dist
|
||||||
|
closeNode=node
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return closeNode, distMin
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Find the start node.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #ASTAR.Node Node The node to be added to the nodes table.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:FindStartNode()
|
||||||
|
|
||||||
|
local node, dist=self:FindClosestNode(self.startCoord)
|
||||||
|
|
||||||
|
self.startNode=node
|
||||||
|
|
||||||
|
if dist>1000 then
|
||||||
|
self:T(self.lid.."Adding start node to node grid!")
|
||||||
|
self:AddNode(node)
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a node.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #ASTAR.Node Node The node to be added to the nodes table.
|
||||||
|
-- @return #ASTAR self
|
||||||
|
function ASTAR:FindEndNode()
|
||||||
|
|
||||||
|
local node, dist=self:FindClosestNode(self.endCoord)
|
||||||
|
|
||||||
|
self.endNode=node
|
||||||
|
|
||||||
|
if dist>1000 then
|
||||||
|
self:T(self.lid.."Adding end node to node grid!")
|
||||||
|
self:AddNode(node)
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Main A* pathfinding function
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- A* pathfinding function. This seaches the path along nodes between start and end nodes/coordinates.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #boolean ExcludeStartNode If *true*, do not include start node in found path. Default is to include it.
|
||||||
|
-- @param #boolean ExcludeEndNode If *true*, do not include end node in found path. Default is to include it.
|
||||||
|
-- @return #table Table of nodes from start to finish.
|
||||||
|
function ASTAR:GetPath(ExcludeStartNode, ExcludeEndNode)
|
||||||
|
|
||||||
|
self:FindStartNode()
|
||||||
|
self:FindEndNode()
|
||||||
|
|
||||||
|
local nodes=self.nodes
|
||||||
|
local start=self.startNode
|
||||||
|
local goal=self.endNode
|
||||||
|
|
||||||
|
-- Sets.
|
||||||
|
local openset = {}
|
||||||
|
local closedset = {}
|
||||||
|
local came_from = {}
|
||||||
|
local g_score = {}
|
||||||
|
local f_score = {}
|
||||||
|
|
||||||
|
openset[start.id]=true
|
||||||
|
local Nopen=1
|
||||||
|
|
||||||
|
-- Initial scores.
|
||||||
|
g_score[start.id]=0
|
||||||
|
f_score[start.id]=g_score[start.id]+self:_HeuristicCost(start, goal)
|
||||||
|
|
||||||
|
-- Set start time.
|
||||||
|
local T0=timer.getAbsTime()
|
||||||
|
|
||||||
|
-- Debug message.
|
||||||
|
local text=string.format("Starting A* pathfinding with %d Nodes", self.Nnodes)
|
||||||
|
self:T(self.lid..text)
|
||||||
|
|
||||||
|
local Tstart=UTILS.GetOSTime()
|
||||||
|
|
||||||
|
-- Loop while we still have an open set.
|
||||||
|
while Nopen > 0 do
|
||||||
|
|
||||||
|
-- Get current node.
|
||||||
|
local current=self:_LowestFscore(openset, f_score)
|
||||||
|
|
||||||
|
-- Check if we are at the end node.
|
||||||
|
if current.id==goal.id then
|
||||||
|
|
||||||
|
local path=self:_UnwindPath({}, came_from, goal)
|
||||||
|
|
||||||
|
if not ExcludeEndNode then
|
||||||
|
table.insert(path, goal)
|
||||||
|
end
|
||||||
|
|
||||||
|
if ExcludeStartNode then
|
||||||
|
table.remove(path, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
local Tstop=UTILS.GetOSTime()
|
||||||
|
|
||||||
|
local dT=nil
|
||||||
|
if Tstart and Tstop then
|
||||||
|
dT=Tstop-Tstart
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug message.
|
||||||
|
local text=string.format("Found path with %d nodes (%d total)", #path, self.Nnodes)
|
||||||
|
if dT then
|
||||||
|
text=text..string.format(", OS Time %.6f sec", dT)
|
||||||
|
end
|
||||||
|
text=text..string.format(", Nvalid=%d [%d cached]", self.nvalid, self.nvalidcache)
|
||||||
|
text=text..string.format(", Ncost=%d [%d cached]", self.ncost, self.ncostcache)
|
||||||
|
self:T(self.lid..text)
|
||||||
|
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Move Node from open to closed set.
|
||||||
|
openset[current.id]=nil
|
||||||
|
Nopen=Nopen-1
|
||||||
|
closedset[current.id]=true
|
||||||
|
|
||||||
|
-- Get neighbour nodes.
|
||||||
|
local neighbors=self:_NeighbourNodes(current, nodes)
|
||||||
|
|
||||||
|
-- Loop over neighbours.
|
||||||
|
for _,neighbor in pairs(neighbors) do
|
||||||
|
|
||||||
|
if self:_NotIn(closedset, neighbor.id) then
|
||||||
|
|
||||||
|
local tentative_g_score=g_score[current.id]+self:_DistNodes(current, neighbor)
|
||||||
|
|
||||||
|
if self:_NotIn(openset, neighbor.id) or tentative_g_score < g_score[neighbor.id] then
|
||||||
|
|
||||||
|
came_from[neighbor]=current
|
||||||
|
|
||||||
|
g_score[neighbor.id]=tentative_g_score
|
||||||
|
f_score[neighbor.id]=g_score[neighbor.id]+self:_HeuristicCost(neighbor, goal)
|
||||||
|
|
||||||
|
if self:_NotIn(openset, neighbor.id) then
|
||||||
|
-- Add to open set.
|
||||||
|
openset[neighbor.id]=true
|
||||||
|
Nopen=Nopen+1
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug message.
|
||||||
|
local text=string.format("WARNING: Could NOT find valid path!")
|
||||||
|
self:E(self.lid..text)
|
||||||
|
MESSAGE:New(text, 60, "ASTAR"):ToAllIf(self.Debug)
|
||||||
|
|
||||||
|
return nil -- no valid path
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- A* pathfinding helper functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Heuristic "cost" function to go from node A to node B. Default is the distance between the nodes.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #ASTAR.Node nodeA Node A.
|
||||||
|
-- @param #ASTAR.Node nodeB Node B.
|
||||||
|
-- @return #number "Cost" to go from node A to node B.
|
||||||
|
function ASTAR:_HeuristicCost(nodeA, nodeB)
|
||||||
|
|
||||||
|
-- Counter.
|
||||||
|
self.ncost=self.ncost+1
|
||||||
|
|
||||||
|
-- Get chached cost if available.
|
||||||
|
local cost=nodeA.cost[nodeB.id]
|
||||||
|
if cost~=nil then
|
||||||
|
self.ncostcache=self.ncostcache+1
|
||||||
|
return cost
|
||||||
|
end
|
||||||
|
|
||||||
|
local cost=nil
|
||||||
|
if self.CostFunc then
|
||||||
|
cost=self.CostFunc(nodeA, nodeB, unpack(self.CostArg))
|
||||||
|
else
|
||||||
|
cost=self:_DistNodes(nodeA, nodeB)
|
||||||
|
end
|
||||||
|
|
||||||
|
nodeA.cost[nodeB.id]=cost
|
||||||
|
nodeB.cost[nodeA.id]=cost -- Symmetric problem.
|
||||||
|
|
||||||
|
return cost
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if going from a node to a neighbour is possible.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #ASTAR.Node node A node.
|
||||||
|
-- @param #ASTAR.Node neighbor Neighbour node.
|
||||||
|
-- @return #boolean If true, transition between nodes is possible.
|
||||||
|
function ASTAR:_IsValidNeighbour(node, neighbor)
|
||||||
|
|
||||||
|
-- Counter.
|
||||||
|
self.nvalid=self.nvalid+1
|
||||||
|
|
||||||
|
local valid=node.valid[neighbor.id]
|
||||||
|
if valid~=nil then
|
||||||
|
--env.info(string.format("Node %d has valid=%s neighbour %d", node.id, tostring(valid), neighbor.id))
|
||||||
|
self.nvalidcache=self.nvalidcache+1
|
||||||
|
return valid
|
||||||
|
end
|
||||||
|
|
||||||
|
local valid=nil
|
||||||
|
if self.ValidNeighbourFunc then
|
||||||
|
valid=self.ValidNeighbourFunc(node, neighbor, unpack(self.ValidNeighbourArg))
|
||||||
|
else
|
||||||
|
valid=true
|
||||||
|
end
|
||||||
|
|
||||||
|
node.valid[neighbor.id]=valid
|
||||||
|
neighbor.valid[node.id]=valid -- Symmetric problem.
|
||||||
|
|
||||||
|
return valid
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculate 2D distance between two nodes.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #ASTAR.Node nodeA Node A.
|
||||||
|
-- @param #ASTAR.Node nodeB Node B.
|
||||||
|
-- @return #number Distance between nodes in meters.
|
||||||
|
function ASTAR:_DistNodes(nodeA, nodeB)
|
||||||
|
return nodeA.coordinate:Get2DDistance(nodeB.coordinate)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Function that calculates the lowest F score.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #table set The set of nodes IDs.
|
||||||
|
-- @param #number f_score F score.
|
||||||
|
-- @return #ASTAR.Node Best node.
|
||||||
|
function ASTAR:_LowestFscore(set, f_score)
|
||||||
|
|
||||||
|
local lowest, bestNode = ASTAR.INF, nil
|
||||||
|
|
||||||
|
for nid,node in pairs(set) do
|
||||||
|
|
||||||
|
local score=f_score[nid]
|
||||||
|
|
||||||
|
if score<lowest then
|
||||||
|
lowest, bestNode = score, nid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self.nodes[bestNode]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Function to get valid neighbours of a node.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #ASTAR.Node theNode The node.
|
||||||
|
-- @param #table nodes Possible neighbours.
|
||||||
|
-- @param #table Valid neighbour nodes.
|
||||||
|
function ASTAR:_NeighbourNodes(theNode, nodes)
|
||||||
|
|
||||||
|
local neighbors = {}
|
||||||
|
|
||||||
|
for _,node in pairs(nodes) do
|
||||||
|
|
||||||
|
if theNode.id~=node.id then
|
||||||
|
|
||||||
|
local isvalid=self:_IsValidNeighbour(theNode, node)
|
||||||
|
|
||||||
|
if isvalid then
|
||||||
|
table.insert(neighbors, node)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return neighbors
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Function to check if a node is not in a set.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #table set Set of nodes.
|
||||||
|
-- @param #ASTAR.Node theNode The node to check.
|
||||||
|
-- @return #boolean If true, the node is not in the set.
|
||||||
|
function ASTAR:_NotIn(set, theNode)
|
||||||
|
return set[theNode]==nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Unwind path function.
|
||||||
|
-- @param #ASTAR self
|
||||||
|
-- @param #table flat_path Flat path.
|
||||||
|
-- @param #table map Map.
|
||||||
|
-- @param #ASTAR.Node current_node The current node.
|
||||||
|
-- @return #table Unwinded path.
|
||||||
|
function ASTAR:_UnwindPath( flat_path, map, current_node )
|
||||||
|
|
||||||
|
if map [current_node] then
|
||||||
|
table.insert (flat_path, 1, map[current_node])
|
||||||
|
return self:_UnwindPath(flat_path, map, map[current_node])
|
||||||
|
else
|
||||||
|
return flat_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -229,7 +229,8 @@ FORMATION = {
|
|||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @return #BASE
|
-- @return #BASE
|
||||||
function BASE:New()
|
function BASE:New()
|
||||||
local self = routines.utils.deepCopy( self ) -- Create a new self instance
|
--local self = routines.utils.deepCopy( self ) -- Create a new self instance
|
||||||
|
local self = UTILS.DeepCopy(self)
|
||||||
|
|
||||||
_ClassID = _ClassID + 1
|
_ClassID = _ClassID + 1
|
||||||
self.ClassID = _ClassID
|
self.ClassID = _ClassID
|
||||||
@@ -463,131 +464,152 @@ do -- Event Handling
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Event handling function prototypes
|
-- Event handling function prototypes - Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
|
|
||||||
--- Occurs whenever any unit in a mission fires a weapon. But not any machine gun or auto cannon based weapon, those are handled by EVENT.ShootingStart.
|
--- Occurs whenever any unit in a mission fires a weapon. But not any machine gun or autocannon based weapon, those are handled by EVENT.ShootingStart.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventShot
|
-- @function [parent=#BASE] OnEventShot
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs whenever an object is hit by a weapon.
|
--- Occurs whenever an object is hit by a weapon.
|
||||||
-- initiator : The unit object the fired the weapon.
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- weapon: Weapon object that hit the target.
|
-- initiator : The unit object the fired the weapon
|
||||||
|
-- weapon: Weapon object that hit the target
|
||||||
-- target: The Object that was hit.
|
-- target: The Object that was hit.
|
||||||
-- @function [parent=#BASE] OnEventHit
|
-- @function [parent=#BASE] OnEventHit
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when an aircraft takes off from an airbase, farp, or ship.
|
--- Occurs when an aircraft takes off from an airbase, farp, or ship.
|
||||||
-- initiator : The unit that took off.
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships.
|
-- initiator : The unit that tookoff
|
||||||
|
-- place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships
|
||||||
-- @function [parent=#BASE] OnEventTakeoff
|
-- @function [parent=#BASE] OnEventTakeoff
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when an aircraft lands at an airbase, farp or ship
|
--- Occurs when an aircraft lands at an airbase, farp or ship
|
||||||
-- initiator : The unit that has landed.
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- place: Object that the unit landed on. Can be an Airbase Object, FARP, or Ships.
|
-- initiator : The unit that has landed
|
||||||
|
-- place: Object that the unit landed on. Can be an Airbase Object, FARP, or Ships
|
||||||
-- @function [parent=#BASE] OnEventLand
|
-- @function [parent=#BASE] OnEventLand
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any aircraft crashes into the ground and is completely destroyed.
|
--- Occurs when any aircraft crashes into the ground and is completely destroyed.
|
||||||
-- initiator : The unit that has crashed.
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
|
-- initiator : The unit that has crashed
|
||||||
-- @function [parent=#BASE] OnEventCrash
|
-- @function [parent=#BASE] OnEventCrash
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when a pilot ejects from an aircraft
|
--- Occurs when a pilot ejects from an aircraft
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that has ejected
|
-- initiator : The unit that has ejected
|
||||||
-- @function [parent=#BASE] OnEventEjection
|
-- @function [parent=#BASE] OnEventEjection
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when an aircraft connects with a tanker and begins taking on fuel.
|
--- Occurs when an aircraft connects with a tanker and begins taking on fuel.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that is receiving fuel.
|
-- initiator : The unit that is receiving fuel.
|
||||||
-- @function [parent=#BASE] OnEventRefueling
|
-- @function [parent=#BASE] OnEventRefueling
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when an object is dead.
|
--- Occurs when an object is dead.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that is dead.
|
-- initiator : The unit that is dead.
|
||||||
-- @function [parent=#BASE] OnEventDead
|
-- @function [parent=#BASE] OnEventDead
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when an object is completely destroyed.
|
--- Occurs when an Event for an object is triggered.
|
||||||
-- initiator : The unit that is was destroyed.
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
|
-- initiator : The unit that triggered the event.
|
||||||
-- @function [parent=#BASE] OnEvent
|
-- @function [parent=#BASE] OnEvent
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when the pilot of an aircraft is killed. Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane.
|
--- Occurs when the pilot of an aircraft is killed. Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that the pilot has died in.
|
-- initiator : The unit that the pilot has died in.
|
||||||
-- @function [parent=#BASE] OnEventPilotDead
|
-- @function [parent=#BASE] OnEventPilotDead
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when a ground unit captures either an airbase or a farp.
|
--- Occurs when a ground unit captures either an airbase or a farp.
|
||||||
-- initiator : The unit that captured the base.
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
|
-- initiator : The unit that captured the base
|
||||||
-- place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.
|
-- place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.
|
||||||
-- @function [parent=#BASE] OnEventBaseCaptured
|
-- @function [parent=#BASE] OnEventBaseCaptured
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when a mission starts.
|
--- Occurs when a mission starts
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventMissionStart
|
-- @function [parent=#BASE] OnEventMissionStart
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when a mission ends.
|
--- Occurs when a mission ends
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventMissionEnd
|
-- @function [parent=#BASE] OnEventMissionEnd
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when an aircraft is finished taking fuel.
|
--- Occurs when an aircraft is finished taking fuel.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that was receiving fuel.
|
-- initiator : The unit that was receiving fuel.
|
||||||
-- @function [parent=#BASE] OnEventRefuelingStop
|
-- @function [parent=#BASE] OnEventRefuelingStop
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any object is spawned into the mission.
|
--- Occurs when any object is spawned into the mission.
|
||||||
-- initiator : The unit that was spawned.
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
|
-- initiator : The unit that was spawned
|
||||||
-- @function [parent=#BASE] OnEventBirth
|
-- @function [parent=#BASE] OnEventBirth
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any system fails on a human controlled aircraft.
|
--- Occurs when any system fails on a human controlled aircraft.
|
||||||
-- initiator : The unit that had the failure.
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
|
-- initiator : The unit that had the failure
|
||||||
-- @function [parent=#BASE] OnEventHumanFailure
|
-- @function [parent=#BASE] OnEventHumanFailure
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any aircraft starts its engines.
|
--- Occurs when any aircraft starts its engines.
|
||||||
-- initiator : The unit that is starting its engines..
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
|
-- initiator : The unit that is starting its engines.
|
||||||
-- @function [parent=#BASE] OnEventEngineStartup
|
-- @function [parent=#BASE] OnEventEngineStartup
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any aircraft shuts down its engines.
|
--- Occurs when any aircraft shuts down its engines.
|
||||||
-- initiator : The unit that is stopping its engines..
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
|
-- initiator : The unit that is stopping its engines.
|
||||||
-- @function [parent=#BASE] OnEventEngineShutdown
|
-- @function [parent=#BASE] OnEventEngineShutdown
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any player assumes direct control of a unit.
|
--- Occurs when any player assumes direct control of a unit. Note - not Mulitplayer safe. Use PlayerEnterAircraft.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that is being taken control of.
|
-- initiator : The unit that is being taken control of.
|
||||||
-- @function [parent=#BASE] OnEventPlayerEnterUnit
|
-- @function [parent=#BASE] OnEventPlayerEnterUnit
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any player relieves control of a unit to the AI.
|
--- Occurs when any player relieves control of a unit to the AI.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that the player left.
|
-- initiator : The unit that the player left.
|
||||||
-- @function [parent=#BASE] OnEventPlayerLeaveUnit
|
-- @function [parent=#BASE] OnEventPlayerLeaveUnit
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any unit begins firing a weapon that has a high rate of fire. Most common with aircraft cannons (GAU-8), auto cannons, and machine guns.
|
--- Occurs when any unit begins firing a weapon that has a high rate of fire. Most common with aircraft cannons (GAU-8), autocannons, and machine guns.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that is doing the shooting.
|
-- initiator : The unit that is doing the shooting.
|
||||||
-- target: The unit that is being targeted.
|
-- target: The unit that is being targeted.
|
||||||
-- @function [parent=#BASE] OnEventShootingStart
|
-- @function [parent=#BASE] OnEventShootingStart
|
||||||
@@ -595,24 +617,28 @@ do -- Event Handling
|
|||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when any unit stops firing its weapon. Event will always correspond with a shooting start event.
|
--- Occurs when any unit stops firing its weapon. Event will always correspond with a shooting start event.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- initiator : The unit that was doing the shooting.
|
-- initiator : The unit that was doing the shooting.
|
||||||
-- @function [parent=#BASE] OnEventShootingEnd
|
-- @function [parent=#BASE] OnEventShootingEnd
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when a new mark was added.
|
--- Occurs when a new mark was added.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- MarkID: ID of the mark.
|
-- MarkID: ID of the mark.
|
||||||
-- @function [parent=#BASE] OnEventMarkAdded
|
-- @function [parent=#BASE] OnEventMarkAdded
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when a mark was removed.
|
--- Occurs when a mark was removed.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- MarkID: ID of the mark.
|
-- MarkID: ID of the mark.
|
||||||
-- @function [parent=#BASE] OnEventMarkRemoved
|
-- @function [parent=#BASE] OnEventMarkRemoved
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when a mark text was changed.
|
--- Occurs when a mark text was changed.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- MarkID: ID of the mark.
|
-- MarkID: ID of the mark.
|
||||||
-- @function [parent=#BASE] OnEventMarkChange
|
-- @function [parent=#BASE] OnEventMarkChange
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
@@ -628,13 +654,15 @@ do -- Event Handling
|
|||||||
|
|
||||||
--- Occurs when any modification to the "Score" as seen on the debrief menu would occur.
|
--- Occurs when any modification to the "Score" as seen on the debrief menu would occur.
|
||||||
-- There is no information on what values the score was changed to. Event is likely similar to player_comment in this regard.
|
-- There is no information on what values the score was changed to. Event is likely similar to player_comment in this regard.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventScore
|
-- @function [parent=#BASE] OnEventScore
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs on the death of a unit. Contains more and different information. Similar to unit_lost it will occur for aircraft before the aircraft crash event occurs.
|
--- Occurs on the death of a unit. Contains more and different information. Similar to unit_lost it will occur for aircraft before the aircraft crash event occurs.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
--
|
--
|
||||||
-- * initiator: The unit that killed the target.
|
-- * initiator: The unit that killed the target
|
||||||
-- * target: Target Object
|
-- * target: Target Object
|
||||||
-- * weapon: Weapon Object
|
-- * weapon: Weapon Object
|
||||||
--
|
--
|
||||||
@@ -644,11 +672,13 @@ do -- Event Handling
|
|||||||
|
|
||||||
--- Occurs when any modification to the "Score" as seen on the debrief menu would occur.
|
--- Occurs when any modification to the "Score" as seen on the debrief menu would occur.
|
||||||
-- There is no information on what values the score was changed to. Event is likely similar to player_comment in this regard.
|
-- There is no information on what values the score was changed to. Event is likely similar to player_comment in this regard.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventScore
|
-- @function [parent=#BASE] OnEventScore
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when the game thinks an object is destroyed.
|
--- Occurs when the game thinks an object is destroyed.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
--
|
--
|
||||||
-- * initiator: The unit that is was destroyed.
|
-- * initiator: The unit that is was destroyed.
|
||||||
--
|
--
|
||||||
@@ -657,6 +687,7 @@ do -- Event Handling
|
|||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs shortly after the landing animation of an ejected pilot touching the ground and standing up. Event does not occur if the pilot lands in the water and sub combs to Davey Jones Locker.
|
--- Occurs shortly after the landing animation of an ejected pilot touching the ground and standing up. Event does not occur if the pilot lands in the water and sub combs to Davey Jones Locker.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
--
|
--
|
||||||
-- * initiator: Static object representing the ejected pilot. Place : Aircraft that the pilot ejected from.
|
-- * initiator: Static object representing the ejected pilot. Place : Aircraft that the pilot ejected from.
|
||||||
-- * place: may not return as a valid object if the aircraft has crashed into the ground and no longer exists.
|
-- * place: may not return as a valid object if the aircraft has crashed into the ground and no longer exists.
|
||||||
@@ -667,36 +698,43 @@ do -- Event Handling
|
|||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Paratrooper landing.
|
--- Paratrooper landing.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventParatrooperLanding
|
-- @function [parent=#BASE] OnEventParatrooperLanding
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Discard chair after ejection.
|
--- Discard chair after ejection.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventDiscardChairAfterEjection
|
-- @function [parent=#BASE] OnEventDiscardChairAfterEjection
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Weapon add. Fires when entering a mission per pylon with the name of the weapon (double pylons not counted, infinite wep reload not counted.
|
--- Weapon add. Fires when entering a mission per pylon with the name of the weapon (double pylons not counted, infinite wep reload not counted.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventParatrooperLanding
|
-- @function [parent=#BASE] OnEventParatrooperLanding
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Trigger zone.
|
--- Trigger zone.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventTriggerZone
|
-- @function [parent=#BASE] OnEventTriggerZone
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Landing quality mark.
|
--- Landing quality mark.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventLandingQualityMark
|
-- @function [parent=#BASE] OnEventLandingQualityMark
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- BDA.
|
--- BDA.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- @function [parent=#BASE] OnEventBDA
|
-- @function [parent=#BASE] OnEventBDA
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
-- @param Core.Event#EVENTDATA EventData The EventData structure.
|
||||||
|
|
||||||
--- Occurs when a player enters a slot and takes control of an aircraft.
|
--- Occurs when a player enters a slot and takes control of an aircraft.
|
||||||
|
-- Have a look at the class @{Core.EVENT#EVENT} as these are just the prototypes.
|
||||||
-- **NOTE**: This is a workaround of a long standing DCS bug with the PLAYER_ENTER_UNIT event.
|
-- **NOTE**: This is a workaround of a long standing DCS bug with the PLAYER_ENTER_UNIT event.
|
||||||
-- initiator : The unit that is being taken control of.
|
-- initiator : The unit that is being taken control of.
|
||||||
-- @function [parent=#BASE] OnEventPlayerEnterAircraft
|
-- @function [parent=#BASE] OnEventPlayerEnterAircraft
|
||||||
@@ -731,30 +769,48 @@ end
|
|||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param DCS#Time EventTime The time stamp of the event.
|
-- @param DCS#Time EventTime The time stamp of the event.
|
||||||
-- @param DCS#Object Initiator The initiating object of the event.
|
-- @param DCS#Object Initiator The initiating object of the event.
|
||||||
function BASE:CreateEventCrash( EventTime, Initiator )
|
function BASE:CreateEventCrash( EventTime, Initiator, IniObjectCategory )
|
||||||
self:F( { EventTime, Initiator } )
|
self:F( { EventTime, Initiator } )
|
||||||
|
|
||||||
local Event = {
|
local Event = {
|
||||||
id = world.event.S_EVENT_CRASH,
|
id = world.event.S_EVENT_CRASH,
|
||||||
time = EventTime,
|
time = EventTime,
|
||||||
initiator = Initiator,
|
initiator = Initiator,
|
||||||
|
IniObjectCategory = IniObjectCategory,
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Creation of a Crash Event.
|
||||||
|
-- @param #BASE self
|
||||||
|
-- @param DCS#Time EventTime The time stamp of the event.
|
||||||
|
-- @param DCS#Object Initiator The initiating object of the event.
|
||||||
|
function BASE:CreateEventUnitLost(EventTime, Initiator)
|
||||||
|
self:F( { EventTime, Initiator } )
|
||||||
|
|
||||||
|
local Event = {
|
||||||
|
id = world.event.S_EVENT_UNIT_LOST,
|
||||||
|
time = EventTime,
|
||||||
|
initiator = Initiator,
|
||||||
|
}
|
||||||
|
|
||||||
|
world.onEvent( Event )
|
||||||
|
end
|
||||||
|
|
||||||
--- Creation of a Dead Event.
|
--- Creation of a Dead Event.
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param DCS#Time EventTime The time stamp of the event.
|
-- @param DCS#Time EventTime The time stamp of the event.
|
||||||
-- @param DCS#Object Initiator The initiating object of the event.
|
-- @param DCS#Object Initiator The initiating object of the event.
|
||||||
function BASE:CreateEventDead( EventTime, Initiator )
|
function BASE:CreateEventDead( EventTime, Initiator, IniObjectCategory )
|
||||||
self:F( { EventTime, Initiator } )
|
self:F( { EventTime, Initiator, IniObjectCategory } )
|
||||||
|
|
||||||
local Event = {
|
local Event = {
|
||||||
id = world.event.S_EVENT_DEAD,
|
id = world.event.S_EVENT_DEAD,
|
||||||
time = EventTime,
|
time = EventTime,
|
||||||
initiator = Initiator,
|
initiator = Initiator,
|
||||||
}
|
IniObjectCategory = IniObjectCategory,
|
||||||
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
@@ -791,22 +847,21 @@ function BASE:CreateEventTakeoff( EventTime, Initiator )
|
|||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creation of a `S_EVENT_PLAYER_ENTER_AIRCRAFT` event.
|
--- Creation of a `S_EVENT_PLAYER_ENTER_AIRCRAFT` event.
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Wrapper.Unit#UNIT PlayerUnit The aircraft unit the player entered.
|
-- @param Wrapper.Unit#UNIT PlayerUnit The aircraft unit the player entered.
|
||||||
function BASE:CreateEventPlayerEnterAircraft( PlayerUnit )
|
function BASE:CreateEventPlayerEnterAircraft( PlayerUnit )
|
||||||
self:F( { PlayerUnit } )
|
self:F( { PlayerUnit } )
|
||||||
|
|
||||||
local Event = {
|
local Event = {
|
||||||
id = EVENTS.PlayerEnterAircraft,
|
id = EVENTS.PlayerEnterAircraft,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
initiator = PlayerUnit:GetDCSObject(),
|
initiator = PlayerUnit:GetDCSObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent(Event)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: Complete DCS#Event structure.
|
|
||||||
--- The main event handling function... This function captures all events generated for the class.
|
--- The main event handling function... This function captures all events generated for the class.
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param DCS#Event event
|
-- @param DCS#Event event
|
||||||
@@ -845,31 +900,37 @@ do -- Scheduling
|
|||||||
-- @param #number Start Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
|
-- @param #number Start Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
|
||||||
-- @param #function SchedulerFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.
|
-- @param #function SchedulerFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.
|
||||||
-- @param #table ... Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
|
-- @param #table ... Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
|
||||||
-- @return #number The ScheduleID of the planned schedule.
|
-- @return #string The Schedule ID of the planned schedule.
|
||||||
function BASE:ScheduleOnce( Start, SchedulerFunction, ... )
|
function BASE:ScheduleOnce( Start, SchedulerFunction, ... )
|
||||||
self:F2( { Start } )
|
|
||||||
self:T3( { ... } )
|
|
||||||
|
|
||||||
|
-- Object name.
|
||||||
local ObjectName = "-"
|
local ObjectName = "-"
|
||||||
ObjectName = self.ClassName .. self.ClassID
|
ObjectName = self.ClassName .. self.ClassID
|
||||||
|
|
||||||
self:F3( { "ScheduleOnce: ", ObjectName, Start } )
|
-- Debug info.
|
||||||
|
self:F3( { "ScheduleOnce: ", ObjectName, Start } )
|
||||||
|
|
||||||
if not self.Scheduler then
|
if not self.Scheduler then
|
||||||
self.Scheduler = SCHEDULER:New( self )
|
self.Scheduler = SCHEDULER:New( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- FF this was wrong!
|
||||||
|
--[[
|
||||||
local ScheduleID = _SCHEDULEDISPATCHER:AddSchedule(
|
local ScheduleID = _SCHEDULEDISPATCHER:AddSchedule(
|
||||||
self,
|
self,
|
||||||
SchedulerFunction,
|
SchedulerFunction,
|
||||||
{ ... },
|
{ ... },
|
||||||
Start,
|
Start,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
nil
|
nil
|
||||||
)
|
)
|
||||||
|
]]
|
||||||
|
|
||||||
self._.Schedules[#self._.Schedules + 1] = ScheduleID
|
-- NOTE: MasterObject (first parameter) needs to be nil or it will be the first argument passed to the SchedulerFunction!
|
||||||
|
local ScheduleID = self.Scheduler:Schedule(nil, SchedulerFunction, {...}, Start)
|
||||||
|
|
||||||
|
self._.Schedules[#self._.Schedules+1] = ScheduleID
|
||||||
|
|
||||||
return self._.Schedules[#self._.Schedules]
|
return self._.Schedules[#self._.Schedules]
|
||||||
end
|
end
|
||||||
@@ -882,7 +943,7 @@ do -- Scheduling
|
|||||||
-- @param #number Stop Specifies the amount of seconds when the scheduler will be stopped.
|
-- @param #number Stop Specifies the amount of seconds when the scheduler will be stopped.
|
||||||
-- @param #function SchedulerFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.
|
-- @param #function SchedulerFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.
|
||||||
-- @param #table ... Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
|
-- @param #table ... Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
|
||||||
-- @return #number The ScheduleID of the planned schedule.
|
-- @return #string The Schedule ID of the planned schedule.
|
||||||
function BASE:ScheduleRepeat( Start, Repeat, RandomizeFactor, Stop, SchedulerFunction, ... )
|
function BASE:ScheduleRepeat( Start, Repeat, RandomizeFactor, Stop, SchedulerFunction, ... )
|
||||||
self:F2( { Start } )
|
self:F2( { Start } )
|
||||||
self:T3( { ... } )
|
self:T3( { ... } )
|
||||||
@@ -896,31 +957,32 @@ do -- Scheduling
|
|||||||
self.Scheduler = SCHEDULER:New( self )
|
self.Scheduler = SCHEDULER:New( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- NOTE: MasterObject (first parameter) should(!) be nil as it will be the first argument passed to the SchedulerFunction!
|
||||||
local ScheduleID = self.Scheduler:Schedule(
|
local ScheduleID = self.Scheduler:Schedule(
|
||||||
self,
|
nil,
|
||||||
SchedulerFunction,
|
SchedulerFunction,
|
||||||
{ ... },
|
{ ... },
|
||||||
Start,
|
Start,
|
||||||
Repeat,
|
Repeat,
|
||||||
RandomizeFactor,
|
RandomizeFactor,
|
||||||
Stop,
|
Stop,
|
||||||
4
|
4
|
||||||
)
|
)
|
||||||
|
|
||||||
self._.Schedules[#self._.Schedules + 1] = ScheduleID
|
self._.Schedules[#self._.Schedules+1] = ScheduleID
|
||||||
|
|
||||||
return self._.Schedules[#self._.Schedules]
|
return self._.Schedules[#self._.Schedules]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Stops the Schedule.
|
--- Stops the Schedule.
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param #function SchedulerFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.
|
-- @param #string SchedulerID (Optional) Scheduler ID to be stopped. If nil, all pending schedules are stopped.
|
||||||
function BASE:ScheduleStop( SchedulerFunction )
|
function BASE:ScheduleStop( SchedulerID )
|
||||||
|
|
||||||
self:F3( { "ScheduleStop:" } )
|
self:F3( { "ScheduleStop:" } )
|
||||||
|
|
||||||
if self.Scheduler then
|
if self.Scheduler then
|
||||||
_SCHEDULEDISPATCHER:Stop( self.Scheduler, self._.Schedules[SchedulerFunction] )
|
--_SCHEDULEDISPATCHER:Stop( self.Scheduler, self._.Schedules[SchedulerFunction] )
|
||||||
|
_SCHEDULEDISPATCHER:Stop(self.Scheduler, SchedulerID)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1061,7 +1123,7 @@ end
|
|||||||
|
|
||||||
--- Set tracing for a class
|
--- Set tracing for a class
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param #string Class
|
-- @param #string Class Class name.
|
||||||
function BASE:TraceClass( Class )
|
function BASE:TraceClass( Class )
|
||||||
_TraceClass[Class] = true
|
_TraceClass[Class] = true
|
||||||
_TraceClassMethod[Class] = {}
|
_TraceClassMethod[Class] = {}
|
||||||
@@ -1070,8 +1132,8 @@ end
|
|||||||
|
|
||||||
--- Set tracing for a specific method of class
|
--- Set tracing for a specific method of class
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param #string Class
|
-- @param #string Class Class name.
|
||||||
-- @param #string Method
|
-- @param #string Method Method.
|
||||||
function BASE:TraceClassMethod( Class, Method )
|
function BASE:TraceClassMethod( Class, Method )
|
||||||
if not _TraceClassMethod[Class] then
|
if not _TraceClassMethod[Class] then
|
||||||
_TraceClassMethod[Class] = {}
|
_TraceClassMethod[Class] = {}
|
||||||
|
|||||||
@@ -16,29 +16,29 @@
|
|||||||
--- *In order for the light to shine so brightly, the darkness must be present.* -- Francis Bacon
|
--- *In order for the light to shine so brightly, the darkness must be present.* -- Francis Bacon
|
||||||
--
|
--
|
||||||
-- After attaching a @{#BEACON} to your @{Wrapper.Positionable#POSITIONABLE}, you need to select the right function to activate the kind of beacon you want.
|
-- After attaching a @{#BEACON} to your @{Wrapper.Positionable#POSITIONABLE}, you need to select the right function to activate the kind of beacon you want.
|
||||||
-- There are two types of BEACONs available : the AA TACAN Beacon and the general purpose Radio Beacon.
|
-- There are two types of BEACONs available : the (aircraft) TACAN Beacon and the general purpose Radio Beacon.
|
||||||
-- Note that in both case, you can set an optional parameter : the `BeaconDuration`. This can be very usefull to simulate the battery time if your BEACON is
|
-- Note that in both case, you can set an optional parameter : the `BeaconDuration`. This can be very usefull to simulate the battery time if your BEACON is
|
||||||
-- attach to a cargo crate, for exemple.
|
-- attach to a cargo crate, for exemple.
|
||||||
--
|
--
|
||||||
-- ## AA TACAN Beacon usage
|
-- ## Aircraft TACAN Beacon usage
|
||||||
--
|
--
|
||||||
-- This beacon only works with airborne @{Wrapper.Unit#UNIT} or a @{Wrapper.Group#GROUP}. Use @{#BEACON:AATACAN}() to set the beacon parameters and start the beacon.
|
-- This beacon only works with airborne @{Wrapper.Unit#UNIT} or a @{Wrapper.Group#GROUP}. Use @{#BEACON.ActivateTACAN}() to set the beacon parameters and start the beacon.
|
||||||
-- Use @#BEACON:StopAATACAN}() to stop it.
|
-- Use @{#BEACON.StopRadioBeacon}() to stop it.
|
||||||
--
|
--
|
||||||
-- ## General Purpose Radio Beacon usage
|
-- ## General Purpose Radio Beacon usage
|
||||||
--
|
--
|
||||||
-- This beacon will work with any @{Wrapper.Positionable#POSITIONABLE}, but **it won't follow the @{Wrapper.Positionable#POSITIONABLE}** ! This means that you should only use it with
|
-- This beacon will work with any @{Wrapper.Positionable#POSITIONABLE}, but **it won't follow the @{Wrapper.Positionable#POSITIONABLE}** ! This means that you should only use it with
|
||||||
-- @{Wrapper.Positionable#POSITIONABLE} that don't move, or move very slowly. Use @{#BEACON:RadioBeacon}() to set the beacon parameters and start the beacon.
|
-- @{Wrapper.Positionable#POSITIONABLE} that don't move, or move very slowly. Use @{#BEACON.RadioBeacon}() to set the beacon parameters and start the beacon.
|
||||||
-- Use @{#BEACON:StopRadioBeacon}() to stop it.
|
-- Use @{#BEACON.StopRadioBeacon}() to stop it.
|
||||||
--
|
--
|
||||||
-- @type BEACON
|
-- @type BEACON
|
||||||
-- @field #string ClassName Name of the class "BEACON".
|
-- @field #string ClassName Name of the class "BEACON".
|
||||||
-- @field Wrapper.Controllable#CONTROLLABLE Positionable The @{#CONTROLLABLE} that will receive radio capabilities.
|
-- @field Wrapper.Controllable#CONTROLLABLE Positionable The @{#CONTROLLABLE} that will receive radio capabilities.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
BEACON = {
|
BEACON = {
|
||||||
ClassName = "BEACON",
|
ClassName = "BEACON",
|
||||||
Positionable = nil,
|
Positionable = nil,
|
||||||
name = nil,
|
name = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Beacon types supported by DCS.
|
--- Beacon types supported by DCS.
|
||||||
@@ -95,13 +95,13 @@ BEACON.Type={
|
|||||||
-- @field #number TACAN TACtical Air Navigation system on ground.
|
-- @field #number TACAN TACtical Air Navigation system on ground.
|
||||||
-- @field #number TACAN_TANKER_X TACtical Air Navigation system for tankers on X band.
|
-- @field #number TACAN_TANKER_X TACtical Air Navigation system for tankers on X band.
|
||||||
-- @field #number TACAN_TANKER_Y TACtical Air Navigation system for tankers on Y band.
|
-- @field #number TACAN_TANKER_Y TACtical Air Navigation system for tankers on Y band.
|
||||||
-- @field #number VOR Very High Frequency Omnidirectional Range
|
-- @field #number VOR Very High Frequency Omni-Directional Range
|
||||||
-- @field #number ILS_LOCALIZER ILS localizer
|
-- @field #number ILS_LOCALIZER ILS localizer
|
||||||
-- @field #number ILS_GLIDESLOPE ILS glide slope.
|
-- @field #number ILS_GLIDESLOPE ILS glide slope.
|
||||||
-- @field #number PRGM_LOCALIZER PRGM localizer.
|
-- @field #number PRGM_LOCALIZER PRGM localizer.
|
||||||
-- @field #number PRGM_GLIDESLOPE PRGM glide slope.
|
-- @field #number PRGM_GLIDESLOPE PRGM glide slope.
|
||||||
-- @field #number BROADCAST_STATION Broadcast station.
|
-- @field #number BROADCAST_STATION Broadcast station.
|
||||||
-- @field #number VORTAC Radio-based navigational aid for aircraft pilots consisting of a co-located VHF omnidirectional range (VOR) beacon and a tactical air navigation system (TACAN) beacon.
|
-- @field #number VORTAC Radio-based navigational aid for aircraft pilots consisting of a co-located VHF omni-directional range (VOR) beacon and a tactical air navigation system (TACAN) beacon.
|
||||||
-- @field #number TACAN_AA_MODE_X TACtical Air Navigation for aircraft on X band.
|
-- @field #number TACAN_AA_MODE_X TACtical Air Navigation for aircraft on X band.
|
||||||
-- @field #number TACAN_AA_MODE_Y TACtical Air Navigation for aircraft on Y band.
|
-- @field #number TACAN_AA_MODE_Y TACtical Air Navigation for aircraft on Y band.
|
||||||
-- @field #number VORDME Radio beacon that combines a VHF omnidirectional range (VOR) with a distance measuring equipment (DME).
|
-- @field #number VORDME Radio beacon that combines a VHF omnidirectional range (VOR) with a distance measuring equipment (DME).
|
||||||
@@ -131,27 +131,28 @@ BEACON.System={
|
|||||||
-- If you want to create a BEACON, you probably should use @{Wrapper.Positionable#POSITIONABLE.GetBeacon}() instead.
|
-- If you want to create a BEACON, you probably should use @{Wrapper.Positionable#POSITIONABLE.GetBeacon}() instead.
|
||||||
-- @param #BEACON self
|
-- @param #BEACON self
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE Positionable The @{Positionable} that will receive radio capabilities.
|
-- @param Wrapper.Positionable#POSITIONABLE Positionable The @{Positionable} that will receive radio capabilities.
|
||||||
-- @return #BEACON Beacon object or #nil if the POSITIONABLE is invalid.
|
-- @return #BEACON Beacon object or #nil if the positionable is invalid.
|
||||||
function BEACON:New( Positionable )
|
function BEACON:New(Positionable)
|
||||||
|
|
||||||
-- Inherit BASE.
|
-- Inherit BASE.
|
||||||
local self = BASE:Inherit( self, BASE:New() ) -- #BEACON
|
local self=BASE:Inherit(self, BASE:New()) --#BEACON
|
||||||
|
|
||||||
-- Debug.
|
-- Debug.
|
||||||
self:F( Positionable )
|
self:F(Positionable)
|
||||||
|
|
||||||
-- Set positionable.
|
-- Set positionable.
|
||||||
if Positionable:GetPointVec2() then -- It's stupid, but the only way I found to make sure POSITIONABLE is valid
|
if Positionable:GetPointVec2() then -- It's stupid, but the only way I found to make sure positionable is valid
|
||||||
self.Positionable = Positionable
|
self.Positionable = Positionable
|
||||||
self.name = Positionable:GetName()
|
self.name=Positionable:GetName()
|
||||||
self:I( string.format( "New BEACON %s", tostring( self.name ) ) )
|
self:I(string.format("New BEACON %s", tostring(self.name)))
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
self:E( { "The passed POSITIONABLE is invalid, no BEACON created", Positionable } )
|
self:E({"The passed positionable is invalid, no BEACON created", Positionable})
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Activates a TACAN BEACON.
|
--- Activates a TACAN BEACON.
|
||||||
-- @param #BEACON self
|
-- @param #BEACON self
|
||||||
-- @param #number Channel TACAN channel, i.e. the "10" part in "10Y".
|
-- @param #number Channel TACAN channel, i.e. the "10" part in "10Y".
|
||||||
@@ -161,53 +162,58 @@ end
|
|||||||
-- @param #number Duration How long will the beacon last in seconds. Omit for forever.
|
-- @param #number Duration How long will the beacon last in seconds. Omit for forever.
|
||||||
-- @return #BEACON self
|
-- @return #BEACON self
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
|
||||||
-- -- Let's create a TACAN Beacon for a tanker
|
-- -- Let's create a TACAN Beacon for a tanker
|
||||||
-- local myUnit = UNIT:FindByName("MyUnit")
|
-- local myUnit = UNIT:FindByName("MyUnit")
|
||||||
-- local myBeacon = myUnit:GetBeacon() -- Creates the beacon
|
-- local myBeacon = myUnit:GetBeacon() -- Creates the beacon
|
||||||
--
|
--
|
||||||
-- myBeacon:ActivateTACAN(20, "Y", "TEXACO", true) -- Activate the beacon
|
-- myBeacon:ActivateTACAN(20, "Y", "TEXACO", true) -- Activate the beacon
|
||||||
--
|
function BEACON:ActivateTACAN(Channel, Mode, Message, Bearing, Duration)
|
||||||
function BEACON:ActivateTACAN( Channel, Mode, Message, Bearing, Duration )
|
self:T({channel=Channel, mode=Mode, callsign=Message, bearing=Bearing, duration=Duration})
|
||||||
self:T( { channel = Channel, mode = Mode, callsign = Message, bearing = Bearing, duration = Duration } )
|
|
||||||
|
Mode=Mode or "Y"
|
||||||
|
|
||||||
-- Get frequency.
|
-- Get frequency.
|
||||||
local Frequency = UTILS.TACANToFrequency( Channel, Mode )
|
local Frequency=UTILS.TACANToFrequency(Channel, Mode)
|
||||||
|
|
||||||
-- Check.
|
-- Check.
|
||||||
if not Frequency then
|
if not Frequency then
|
||||||
self:E( { "The passed TACAN channel is invalid, the BEACON is not emitting" } )
|
self:E({"The passed TACAN channel is invalid, the BEACON is not emitting"})
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Beacon type.
|
-- Beacon type.
|
||||||
local Type = BEACON.Type.TACAN
|
local Type=BEACON.Type.TACAN
|
||||||
|
|
||||||
-- Beacon system.
|
-- Beacon system.
|
||||||
local System = BEACON.System.TACAN
|
local System=BEACON.System.TACAN
|
||||||
|
|
||||||
-- Check if unit is an aircraft and set system accordingly.
|
-- Check if unit is an aircraft and set system accordingly.
|
||||||
local AA = self.Positionable:IsAir()
|
local AA=self.Positionable:IsAir()
|
||||||
|
|
||||||
|
|
||||||
if AA then
|
if AA then
|
||||||
System = 5 -- NOTE: 5 is how you cat the correct tanker behaviour! --BEACON.System.TACAN_TANKER
|
System=5 --NOTE: 5 is how you cat the correct tanker behaviour! --BEACON.System.TACAN_TANKER
|
||||||
-- Check if "Y" mode is selected for aircraft.
|
-- Check if "Y" mode is selected for aircraft.
|
||||||
if Mode ~= "Y" then
|
if Mode=="X" then
|
||||||
self:E( { "WARNING: The POSITIONABLE you want to attach the AA TACAN Beacon is an aircraft: Mode should Y! The BEACON is not emitting.", self.Positionable } )
|
--self:E({"WARNING: The POSITIONABLE you want to attach the AA Tacan Beacon is an aircraft: Mode should Y!", self.Positionable})
|
||||||
|
System=BEACON.System.TACAN_TANKER_X
|
||||||
|
else
|
||||||
|
System=BEACON.System.TACAN_TANKER_Y
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Attached unit.
|
-- Attached unit.
|
||||||
local UnitID = self.Positionable:GetID()
|
local UnitID=self.Positionable:GetID()
|
||||||
|
|
||||||
-- Debug.
|
-- Debug.
|
||||||
self:I( { string.format( "BEACON Activating TACAN %s: Channel=%d%s, Morse=%s, Bearing=%s, Duration=%s!", tostring( self.name ), Channel, Mode, Message, tostring( Bearing ), tostring( Duration ) ) } )
|
self:I({string.format("BEACON Activating TACAN %s: Channel=%d%s, Morse=%s, Bearing=%s, Duration=%s!", tostring(self.name), Channel, Mode, Message, tostring(Bearing), tostring(Duration))})
|
||||||
|
|
||||||
-- Start beacon.
|
-- Start beacon.
|
||||||
self.Positionable:CommandActivateBeacon( Type, System, Frequency, UnitID, Channel, Mode, AA, Message, Bearing )
|
self.Positionable:CommandActivateBeacon(Type, System, Frequency, UnitID, Channel, Mode, AA, Message, Bearing)
|
||||||
|
|
||||||
-- Stop scheduler.
|
-- Stop scheduler.
|
||||||
if Duration then
|
if Duration then
|
||||||
self.Positionable:DeactivateBeacon( Duration )
|
self.Positionable:DeactivateBeacon(Duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -219,27 +225,54 @@ end
|
|||||||
-- @param #string Callsign The Message that is going to be coded in Morse and broadcasted by the beacon.
|
-- @param #string Callsign The Message that is going to be coded in Morse and broadcasted by the beacon.
|
||||||
-- @param #number Duration How long will the beacon last in seconds. Omit for forever.
|
-- @param #number Duration How long will the beacon last in seconds. Omit for forever.
|
||||||
-- @return #BEACON self
|
-- @return #BEACON self
|
||||||
function BEACON:ActivateICLS( Channel, Callsign, Duration )
|
function BEACON:ActivateICLS(Channel, Callsign, Duration)
|
||||||
self:F( { Channel = Channel, Callsign = Callsign, Duration = Duration } )
|
self:F({Channel=Channel, Callsign=Callsign, Duration=Duration})
|
||||||
|
|
||||||
-- Attached unit.
|
-- Attached unit.
|
||||||
local UnitID = self.Positionable:GetID()
|
local UnitID=self.Positionable:GetID()
|
||||||
|
|
||||||
-- Debug
|
-- Debug
|
||||||
self:T2( { "ICLS BEACON started!" } )
|
self:T2({"ICLS BEACON started!"})
|
||||||
|
|
||||||
-- Start beacon.
|
-- Start beacon.
|
||||||
self.Positionable:CommandActivateICLS( Channel, UnitID, Callsign )
|
self.Positionable:CommandActivateICLS(Channel, UnitID, Callsign)
|
||||||
|
|
||||||
-- Stop scheduler
|
-- Stop scheduler
|
||||||
if Duration then -- Schedule the stop of the BEACON if asked by the MD
|
if Duration then -- Schedule the stop of the BEACON if asked by the MD
|
||||||
self.Positionable:DeactivateBeacon( Duration )
|
self.Positionable:DeactivateBeacon(Duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Activates a TACAN BEACON on an Aircraft.
|
--- Activates a LINK4 BEACON. The unit the BEACON is attached to should be an aircraft carrier supporting this system.
|
||||||
|
-- @param #BEACON self
|
||||||
|
-- @param #number Frequency LINK4 FRequency in MHz, eg 336.
|
||||||
|
-- @param #string Morse The ID that is going to be coded in Morse and broadcasted by the beacon.
|
||||||
|
-- @param #number Duration How long will the beacon last in seconds. Omit for forever.
|
||||||
|
-- @return #BEACON self
|
||||||
|
function BEACON:ActivateLink4(Frequency, Morse, Duration)
|
||||||
|
self:F({Frequency=Frequency, Morse=Morse, Duration=Duration})
|
||||||
|
|
||||||
|
-- Attached unit.
|
||||||
|
local UnitID=self.Positionable:GetID()
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
self:T2({"LINK4 BEACON started!"})
|
||||||
|
|
||||||
|
-- Start beacon.
|
||||||
|
self.Positionable:CommandActivateLink4(Frequency,UnitID,Morse)
|
||||||
|
|
||||||
|
-- Stop sheduler
|
||||||
|
if Duration then -- Schedule the stop of the BEACON if asked by the MD
|
||||||
|
self.Positionable:CommandDeactivateLink4(Duration)
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- DEPRECATED: Please use @{BEACON:ActivateTACAN}() instead.
|
||||||
|
-- Activates a TACAN BEACON on an Aircraft.
|
||||||
-- @param #BEACON self
|
-- @param #BEACON self
|
||||||
-- @param #number TACANChannel (the "10" part in "10Y"). Note that AA TACAN are only available on Y Channels
|
-- @param #number TACANChannel (the "10" part in "10Y"). Note that AA TACAN are only available on Y Channels
|
||||||
-- @param #string Message The Message that is going to be coded in Morse and broadcasted by the beacon
|
-- @param #string Message The Message that is going to be coded in Morse and broadcasted by the beacon
|
||||||
@@ -247,54 +280,55 @@ end
|
|||||||
-- @param #number BeaconDuration How long will the beacon last in seconds. Omit for forever.
|
-- @param #number BeaconDuration How long will the beacon last in seconds. Omit for forever.
|
||||||
-- @return #BEACON self
|
-- @return #BEACON self
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
|
||||||
-- -- Let's create a TACAN Beacon for a tanker
|
-- -- Let's create a TACAN Beacon for a tanker
|
||||||
-- local myUnit = UNIT:FindByName("MyUnit")
|
-- local myUnit = UNIT:FindByName("MyUnit")
|
||||||
-- local myBeacon = myUnit:GetBeacon() -- Creates the beacon
|
-- local myBeacon = myUnit:GetBeacon() -- Creates the beacon
|
||||||
--
|
--
|
||||||
-- myBeacon:AATACAN(20, "TEXACO", true) -- Activate the beacon
|
-- myBeacon:AATACAN(20, "TEXACO", true) -- Activate the beacon
|
||||||
--
|
function BEACON:AATACAN(TACANChannel, Message, Bearing, BeaconDuration)
|
||||||
function BEACON:AATACAN( TACANChannel, Message, Bearing, BeaconDuration )
|
self:F({TACANChannel, Message, Bearing, BeaconDuration})
|
||||||
self:F( { TACANChannel, Message, Bearing, BeaconDuration } )
|
|
||||||
|
|
||||||
local IsValid = true
|
local IsValid = true
|
||||||
|
|
||||||
if not self.Positionable:IsAir() then
|
if not self.Positionable:IsAir() then
|
||||||
self:E( { "The POSITIONABLE you want to attach the AA TACAN Beacon is not an aircraft! The BEACON is not emitting", self.Positionable } )
|
self:E({"The POSITIONABLE you want to attach the AA Tacan Beacon is not an aircraft ! The BEACON is not emitting", self.Positionable})
|
||||||
IsValid = false
|
IsValid = false
|
||||||
end
|
end
|
||||||
|
|
||||||
local Frequency = self:_TACANToFrequency( TACANChannel, "Y" )
|
local Frequency = self:_TACANToFrequency(TACANChannel, "Y")
|
||||||
if not Frequency then
|
if not Frequency then
|
||||||
self:E( { "The passed TACAN channel is invalid, the BEACON is not emitting" } )
|
self:E({"The passed TACAN channel is invalid, the BEACON is not emitting"})
|
||||||
IsValid = false
|
IsValid = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- I'm using the beacon type 4 (BEACON_TYPE_TACAN). For System, I'm using 5 (TACAN_TANKER_MODE_Y) if the bearing shows its bearing
|
-- I'm using the beacon type 4 (BEACON_TYPE_TACAN). For System, I'm using 5 (TACAN_TANKER_MODE_Y) if the bearing shows its bearing or 14 (TACAN_AA_MODE_Y) if it does not
|
||||||
-- or 14 (TACAN_AA_MODE_Y) if it does not
|
|
||||||
local System
|
local System
|
||||||
if Bearing then
|
if Bearing then
|
||||||
System = 5
|
System = BEACON.System.TACAN_TANKER_Y
|
||||||
else
|
else
|
||||||
System = 14
|
System = BEACON.System.TACAN_AA_MODE_Y
|
||||||
end
|
end
|
||||||
|
|
||||||
if IsValid then -- Starts the BEACON
|
if IsValid then -- Starts the BEACON
|
||||||
self:T2( { "AA TACAN BEACON started !" } )
|
self:T2({"AA TACAN BEACON started !"})
|
||||||
self.Positionable:SetCommand( {
|
self.Positionable:SetCommand({
|
||||||
id = "ActivateBeacon",
|
id = "ActivateBeacon",
|
||||||
params = {
|
params = {
|
||||||
type = 4,
|
type = BEACON.Type.TACAN,
|
||||||
system = System,
|
system = System,
|
||||||
callsign = Message,
|
callsign = Message,
|
||||||
|
AA = true,
|
||||||
frequency = Frequency,
|
frequency = Frequency,
|
||||||
},
|
bearing = Bearing,
|
||||||
} )
|
modeChannel = "Y",
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if BeaconDuration then -- Schedule the stop of the BEACON if asked by the MD
|
if BeaconDuration then -- Schedule the stop of the BEACON if asked by the MD
|
||||||
SCHEDULER:New( nil, function()
|
SCHEDULER:New(nil,
|
||||||
|
function()
|
||||||
self:StopAATACAN()
|
self:StopAATACAN()
|
||||||
end, {}, BeaconDuration )
|
end, {}, BeaconDuration)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -307,19 +341,21 @@ end
|
|||||||
function BEACON:StopAATACAN()
|
function BEACON:StopAATACAN()
|
||||||
self:F()
|
self:F()
|
||||||
if not self.Positionable then
|
if not self.Positionable then
|
||||||
self:E( { "Start the beacon first before stopping it!" } )
|
self:E({"Start the beacon first before stoping it !"})
|
||||||
else
|
else
|
||||||
self.Positionable:SetCommand( {
|
self.Positionable:SetCommand({
|
||||||
id = 'DeactivateBeacon',
|
id = 'DeactivateBeacon',
|
||||||
params = {},
|
params = {
|
||||||
} )
|
}
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Activates a general purpose Radio Beacon
|
--- Activates a general purpose Radio Beacon
|
||||||
-- This uses the very generic singleton function "trigger.action.radioTransmission()" provided by DCS to broadcast a sound file on a specific frequency.
|
-- This uses the very generic singleton function "trigger.action.radioTransmission()" provided by DCS to broadcast a sound file on a specific frequency.
|
||||||
-- Although any frequency could be used, only 2 DCS Modules can home on radio beacons at the time of writing : the Huey and the Mi-8.
|
-- Although any frequency could be used, only a few DCS Modules can home on radio beacons at the time of writing, i.e. the Mi-8, Huey, Gazelle etc.
|
||||||
-- They can home in on these specific frequencies :
|
-- The following e.g. can home in on these specific frequencies :
|
||||||
-- * **Mi8**
|
-- * **Mi8**
|
||||||
-- * R-828 -> 20-60MHz
|
-- * R-828 -> 20-60MHz
|
||||||
-- * ARKUD -> 100-150MHz (canal 1 : 114166, canal 2 : 114333, canal 3 : 114583, canal 4 : 121500, canal 5 : 123100, canal 6 : 124100) AM
|
-- * ARKUD -> 100-150MHz (canal 1 : 114166, canal 2 : 114333, canal 3 : 114583, canal 4 : 121500, canal 5 : 123100, canal 6 : 124100) AM
|
||||||
@@ -342,63 +378,64 @@ end
|
|||||||
--
|
--
|
||||||
-- -- Set the beacon and start it
|
-- -- Set the beacon and start it
|
||||||
-- UnitBeacon:RadioBeacon("MySoundFileSOS.ogg", 40, radio.modulation.FM, 20, 5*60)
|
-- UnitBeacon:RadioBeacon("MySoundFileSOS.ogg", 40, radio.modulation.FM, 20, 5*60)
|
||||||
function BEACON:RadioBeacon( FileName, Frequency, Modulation, Power, BeaconDuration )
|
function BEACON:RadioBeacon(FileName, Frequency, Modulation, Power, BeaconDuration)
|
||||||
self:F( { FileName, Frequency, Modulation, Power, BeaconDuration } )
|
self:F({FileName, Frequency, Modulation, Power, BeaconDuration})
|
||||||
local IsValid = false
|
local IsValid = false
|
||||||
|
|
||||||
-- Check the filename
|
-- Check the filename
|
||||||
if type( FileName ) == "string" then
|
if type(FileName) == "string" then
|
||||||
if FileName:find( ".ogg" ) or FileName:find( ".wav" ) then
|
if FileName:find(".ogg") or FileName:find(".wav") then
|
||||||
if not FileName:find( "l10n/DEFAULT/" ) then
|
if not FileName:find("l10n/DEFAULT/") then
|
||||||
FileName = "l10n/DEFAULT/" .. FileName
|
FileName = "l10n/DEFAULT/" .. FileName
|
||||||
end
|
end
|
||||||
IsValid = true
|
IsValid = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not IsValid then
|
if not IsValid then
|
||||||
self:E( { "File name invalid. Maybe something wrong with the extension? ", FileName } )
|
self:E({"File name invalid. Maybe something wrong with the extension ? ", FileName})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check the Frequency
|
-- Check the Frequency
|
||||||
if type( Frequency ) ~= "number" and IsValid then
|
if type(Frequency) ~= "number" and IsValid then
|
||||||
self:E( { "Frequency invalid. ", Frequency } )
|
self:E({"Frequency invalid. ", Frequency})
|
||||||
IsValid = false
|
IsValid = false
|
||||||
end
|
end
|
||||||
Frequency = Frequency * 1000000 -- Conversion to Hz
|
Frequency = Frequency * 1000000 -- Conversion to Hz
|
||||||
|
|
||||||
-- Check the modulation
|
-- Check the modulation
|
||||||
if Modulation ~= radio.modulation.AM and Modulation ~= radio.modulation.FM and IsValid then -- TODO: Maybe make this future proof if ED decides to add an other modulation ?
|
if Modulation ~= radio.modulation.AM and Modulation ~= radio.modulation.FM and IsValid then --TODO Maybe make this future proof if ED decides to add an other modulation ?
|
||||||
self:E( { "Modulation is invalid. Use DCS's enum radio.modulation.", Modulation } )
|
self:E({"Modulation is invalid. Use DCS's enum radio.modulation.", Modulation})
|
||||||
IsValid = false
|
IsValid = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check the Power
|
-- Check the Power
|
||||||
if type( Power ) ~= "number" and IsValid then
|
if type(Power) ~= "number" and IsValid then
|
||||||
self:E( { "Power is invalid. ", Power } )
|
self:E({"Power is invalid. ", Power})
|
||||||
IsValid = false
|
IsValid = false
|
||||||
end
|
end
|
||||||
Power = math.floor( math.abs( Power ) ) -- TODO: Find what is the maximum power allowed by DCS and limit power to that
|
Power = math.floor(math.abs(Power)) --TODO Find what is the maximum power allowed by DCS and limit power to that
|
||||||
|
|
||||||
if IsValid then
|
if IsValid then
|
||||||
self:T2( { "Activating Beacon on ", Frequency, Modulation } )
|
self:T2({"Activating Beacon on ", Frequency, Modulation})
|
||||||
-- Note that this is looped. I have to give this transmission a unique name, I use the class ID
|
-- Note that this is looped. I have to give this transmission a unique name, I use the class ID
|
||||||
trigger.action.radioTransmission( FileName, self.Positionable:GetPositionVec3(), Modulation, true, Frequency, Power, tostring( self.ID ) )
|
trigger.action.radioTransmission(FileName, self.Positionable:GetPositionVec3(), Modulation, true, Frequency, Power, tostring(self.ID))
|
||||||
|
|
||||||
if BeaconDuration then -- Schedule the stop of the BEACON if asked by the MD
|
if BeaconDuration then -- Schedule the stop of the BEACON if asked by the MD
|
||||||
SCHEDULER:New( nil, function()
|
SCHEDULER:New( nil,
|
||||||
self:StopRadioBeacon()
|
function()
|
||||||
end, {}, BeaconDuration )
|
self:StopRadioBeacon()
|
||||||
end
|
end, {}, BeaconDuration)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Stops the AA TACAN BEACON
|
--- Stops the Radio Beacon
|
||||||
-- @param #BEACON self
|
-- @param #BEACON self
|
||||||
-- @return #BEACON self
|
-- @return #BEACON self
|
||||||
function BEACON:StopRadioBeacon()
|
function BEACON:StopRadioBeacon()
|
||||||
self:F()
|
self:F()
|
||||||
-- The unique name of the transmission is the class ID
|
-- The unique name of the transmission is the class ID
|
||||||
trigger.action.stopRadioTransmission( tostring( self.ID ) )
|
trigger.action.stopRadioTransmission(tostring(self.ID))
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -406,21 +443,21 @@ end
|
|||||||
-- @param #BEACON self
|
-- @param #BEACON self
|
||||||
-- @param #number TACANChannel
|
-- @param #number TACANChannel
|
||||||
-- @param #string TACANMode
|
-- @param #string TACANMode
|
||||||
-- @return #number Frequency
|
-- @return #number Frequecy
|
||||||
-- @return #nil if parameters are invalid
|
-- @return #nil if parameters are invalid
|
||||||
function BEACON:_TACANToFrequency( TACANChannel, TACANMode )
|
function BEACON:_TACANToFrequency(TACANChannel, TACANMode)
|
||||||
self:F3( { TACANChannel, TACANMode } )
|
self:F3({TACANChannel, TACANMode})
|
||||||
|
|
||||||
if type( TACANChannel ) ~= "number" then
|
if type(TACANChannel) ~= "number" then
|
||||||
if TACANMode ~= "X" and TACANMode ~= "Y" then
|
if TACANMode ~= "X" and TACANMode ~= "Y" then
|
||||||
return nil -- error in arguments
|
return nil -- error in arguments
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This code is largely based on ED's code, in DCS World\Scripts\World\Radio\BeaconTypes.lua, line 137.
|
-- This code is largely based on ED's code, in DCS World\Scripts\World\Radio\BeaconTypes.lua, line 137.
|
||||||
-- I have no idea what it does but it seems to work
|
-- I have no idea what it does but it seems to work
|
||||||
local A = 1151 -- 'X', channel >= 64
|
local A = 1151 -- 'X', channel >= 64
|
||||||
local B = 64 -- channel >= 64
|
local B = 64 -- channel >= 64
|
||||||
|
|
||||||
if TACANChannel < 64 then
|
if TACANChannel < 64 then
|
||||||
B = 1
|
B = 1
|
||||||
|
|||||||
@@ -0,0 +1,295 @@
|
|||||||
|
--- **Core** - Define any or all conditions to be evaluated.
|
||||||
|
--
|
||||||
|
-- **Main Features:**
|
||||||
|
--
|
||||||
|
-- * Add arbitrary numbers of conditon functions
|
||||||
|
-- * Evaluate *any* or *all* conditions
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ## Example Missions:
|
||||||
|
--
|
||||||
|
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Operation).
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### Author: **funkyfranky**
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Core.Condition
|
||||||
|
-- @image Core_Conditon.png
|
||||||
|
|
||||||
|
--- CONDITON class.
|
||||||
|
-- @type CONDITION
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #string lid Class id string for output to DCS log file.
|
||||||
|
-- @field #boolean isAny General functions are evaluated as any condition.
|
||||||
|
-- @field #boolean negateResult Negeate result of evaluation.
|
||||||
|
-- @field #table functionsGen General condition functions.
|
||||||
|
-- @field #table functionsAny Any condition functions.
|
||||||
|
-- @field #table functionsAll All condition functions.
|
||||||
|
--
|
||||||
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
--- *Better three hours too soon than a minute too late.* - William Shakespeare
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # The CONDITION Concept
|
||||||
|
--
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- @field #CONDITION
|
||||||
|
CONDITION = {
|
||||||
|
ClassName = "CONDITION",
|
||||||
|
lid = nil,
|
||||||
|
functionsGen = {},
|
||||||
|
functionsAny = {},
|
||||||
|
functionsAll = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Condition function.
|
||||||
|
-- @type CONDITION.Function
|
||||||
|
-- @field #function func Callback function to check for a condition. Should return a `#boolean`.
|
||||||
|
-- @field #table arg (Optional) Arguments passed to the condition callback function if any.
|
||||||
|
|
||||||
|
--- CONDITION class version.
|
||||||
|
-- @field #string version
|
||||||
|
CONDITION.version="0.1.0"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- TODO list
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- TODO: Make FSM.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Constructor
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Create a new CONDITION object.
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #string Name (Optional) Name used in the logs.
|
||||||
|
-- @return #CONDITION self
|
||||||
|
function CONDITION:New(Name)
|
||||||
|
|
||||||
|
-- Inherit BASE.
|
||||||
|
local self=BASE:Inherit(self, BASE:New()) --#CONDITION
|
||||||
|
|
||||||
|
self.name=Name or "Condition X"
|
||||||
|
|
||||||
|
self.lid=string.format("%s | ", self.name)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set that general condition functions return `true` if `any` function returns `true`. Default is that *all* functions must return `true`.
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #boolean Any If `true`, *any* condition can be true. Else *all* conditions must result `true`.
|
||||||
|
-- @return #CONDITION self
|
||||||
|
function CONDITION:SetAny(Any)
|
||||||
|
self.isAny=Any
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Negate result.
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #boolean Negate If `true`, result is negated else not.
|
||||||
|
-- @return #CONDITION self
|
||||||
|
function CONDITION:SetNegateResult(Negate)
|
||||||
|
self.negateResult=Negate
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a function that is evaluated. It must return a `#boolean` value, *i.e.* either `true` or `false` (or `nil`).
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #function Function The function to call.
|
||||||
|
-- @param ... (Optional) Parameters passed to the function (if any).
|
||||||
|
--
|
||||||
|
-- @usage
|
||||||
|
-- local function isAequalB(a, b)
|
||||||
|
-- return a==b
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- myCondition:AddFunction(isAequalB, a, b)
|
||||||
|
--
|
||||||
|
-- @return #CONDITION self
|
||||||
|
function CONDITION:AddFunction(Function, ...)
|
||||||
|
|
||||||
|
-- Condition function.
|
||||||
|
local condition=self:_CreateCondition(Function, ...)
|
||||||
|
|
||||||
|
-- Add to table.
|
||||||
|
table.insert(self.functionsGen, condition)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a function that is evaluated. It must return a `#boolean` value, *i.e.* either `true` or `false` (or `nil`).
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #function Function The function to call.
|
||||||
|
-- @param ... (Optional) Parameters passed to the function (if any).
|
||||||
|
-- @return #CONDITION self
|
||||||
|
function CONDITION:AddFunctionAny(Function, ...)
|
||||||
|
|
||||||
|
-- Condition function.
|
||||||
|
local condition=self:_CreateCondition(Function, ...)
|
||||||
|
|
||||||
|
-- Add to table.
|
||||||
|
table.insert(self.functionsAny, condition)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a function that is evaluated. It must return a `#boolean` value, *i.e.* either `true` or `false` (or `nil`).
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #function Function The function to call.
|
||||||
|
-- @param ... (Optional) Parameters passed to the function (if any).
|
||||||
|
-- @return #CONDITION self
|
||||||
|
function CONDITION:AddFunctionAll(Function, ...)
|
||||||
|
|
||||||
|
-- Condition function.
|
||||||
|
local condition=self:_CreateCondition(Function, ...)
|
||||||
|
|
||||||
|
-- Add to table.
|
||||||
|
table.insert(self.functionsAll, condition)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Evaluate conditon functions.
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #boolean AnyTrue If `true`, evaluation return `true` if *any* condition function returns `true`. By default, *all* condition functions must return true.
|
||||||
|
-- @return #boolean Result of condition functions.
|
||||||
|
function CONDITION:Evaluate(AnyTrue)
|
||||||
|
|
||||||
|
-- Check if at least one function was given.
|
||||||
|
if #self.functionsAll + #self.functionsAny + #self.functionsAll == 0 then
|
||||||
|
if self.negateResult then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Any condition for gen.
|
||||||
|
local evalAny=self.isAny
|
||||||
|
if AnyTrue~=nil then
|
||||||
|
evalAny=AnyTrue
|
||||||
|
end
|
||||||
|
|
||||||
|
local isGen=nil
|
||||||
|
if evalAny then
|
||||||
|
isGen=self:_EvalConditionsAny(self.functionsGen)
|
||||||
|
else
|
||||||
|
isGen=self:_EvalConditionsAll(self.functionsGen)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Is any?
|
||||||
|
local isAny=self:_EvalConditionsAny(self.functionsAny)
|
||||||
|
|
||||||
|
-- Is all?
|
||||||
|
local isAll=self:_EvalConditionsAll(self.functionsAll)
|
||||||
|
|
||||||
|
-- Result.
|
||||||
|
local result=isGen and isAny and isAll
|
||||||
|
|
||||||
|
-- Negate result.
|
||||||
|
if self.negateResult then
|
||||||
|
result=not result
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug message.
|
||||||
|
self:T(self.lid..string.format("Evaluate: isGen=%s, isAny=%s, isAll=%s (negate=%s) ==> result=%s", tostring(isGen), tostring(isAny), tostring(isAll), tostring(self.negateResult), tostring(result)))
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if all given condition are true.
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #table functions Functions to evaluate.
|
||||||
|
-- @return #boolean If true, all conditions were true (or functions was empty/nil). Returns false if at least one condition returned false.
|
||||||
|
function CONDITION:_EvalConditionsAll(functions)
|
||||||
|
|
||||||
|
-- At least one condition?
|
||||||
|
local gotone=false
|
||||||
|
|
||||||
|
|
||||||
|
-- Any stop condition must be true.
|
||||||
|
for _,_condition in pairs(functions or {}) do
|
||||||
|
local condition=_condition --#CONDITION.Function
|
||||||
|
|
||||||
|
-- At least one condition was defined.
|
||||||
|
gotone=true
|
||||||
|
|
||||||
|
-- Call function.
|
||||||
|
local istrue=condition.func(unpack(condition.arg))
|
||||||
|
|
||||||
|
-- Any false will return false.
|
||||||
|
if not istrue then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- All conditions were true.
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Check if any of the given conditions is true.
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #table functions Functions to evaluate.
|
||||||
|
-- @return #boolean If true, at least one condition is true (or functions was emtpy/nil).
|
||||||
|
function CONDITION:_EvalConditionsAny(functions)
|
||||||
|
|
||||||
|
-- At least one condition?
|
||||||
|
local gotone=false
|
||||||
|
|
||||||
|
-- Any stop condition must be true.
|
||||||
|
for _,_condition in pairs(functions or {}) do
|
||||||
|
local condition=_condition --#CONDITION.Function
|
||||||
|
|
||||||
|
-- At least one condition was defined.
|
||||||
|
gotone=true
|
||||||
|
|
||||||
|
-- Call function.
|
||||||
|
local istrue=condition.func(unpack(condition.arg))
|
||||||
|
|
||||||
|
-- Any true will return true.
|
||||||
|
if istrue then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- No condition was true.
|
||||||
|
if gotone then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
-- No functions passed.
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Create conditon function object.
|
||||||
|
-- @param #CONDITION self
|
||||||
|
-- @param #function Function The function to call.
|
||||||
|
-- @param ... (Optional) Parameters passed to the function (if any).
|
||||||
|
-- @return #CONDITION.Function Condition function.
|
||||||
|
function CONDITION:_CreateCondition(Function, ...)
|
||||||
|
|
||||||
|
local condition={} --#CONDITION.Function
|
||||||
|
|
||||||
|
condition.func=Function
|
||||||
|
condition.arg={}
|
||||||
|
if arg then
|
||||||
|
condition.arg=arg
|
||||||
|
end
|
||||||
|
|
||||||
|
return condition
|
||||||
|
end
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -32,11 +32,11 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- 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.
|
-- * _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.
|
-- * 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 teh subscribed UNIT object.
|
-- * 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.
|
-- * 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.
|
-- * Any other object: Various other objects can subscribe to DCS events. Each DCS event triggered will be published to each subscribed object.
|
||||||
--
|
--
|
||||||
@@ -141,6 +141,7 @@
|
|||||||
-- EventData.IniUnit:SmokeGreen()
|
-- EventData.IniUnit:SmokeGreen()
|
||||||
-- end
|
-- end
|
||||||
--
|
--
|
||||||
|
--
|
||||||
-- Find below an overview which events populate which information categories:
|
-- Find below an overview which events populate which information categories:
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
@@ -171,6 +172,7 @@
|
|||||||
-- @module Core.Event
|
-- @module Core.Event
|
||||||
-- @image Core_Event.JPG
|
-- @image Core_Event.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type EVENT
|
--- @type EVENT
|
||||||
-- @field #EVENT.Events Events
|
-- @field #EVENT.Events Events
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
@@ -192,6 +194,7 @@ world.event.S_EVENT_DELETE_ZONE_GOAL = world.event.S_EVENT_MAX + 1005
|
|||||||
world.event.S_EVENT_REMOVE_UNIT = world.event.S_EVENT_MAX + 1006
|
world.event.S_EVENT_REMOVE_UNIT = world.event.S_EVENT_MAX + 1006
|
||||||
world.event.S_EVENT_PLAYER_ENTER_AIRCRAFT = world.event.S_EVENT_MAX + 1007
|
world.event.S_EVENT_PLAYER_ENTER_AIRCRAFT = world.event.S_EVENT_MAX + 1007
|
||||||
|
|
||||||
|
|
||||||
--- The different types of events supported by MOOSE.
|
--- The different types of events supported by MOOSE.
|
||||||
-- Use this structure to subscribe to events using the @{Core.Base#BASE.HandleEvent}() method.
|
-- Use this structure to subscribe to events using the @{Core.Base#BASE.HandleEvent}() method.
|
||||||
-- @type EVENTS
|
-- @type EVENTS
|
||||||
@@ -224,13 +227,13 @@ EVENTS = {
|
|||||||
MarkChange = world.event.S_EVENT_MARK_CHANGE,
|
MarkChange = world.event.S_EVENT_MARK_CHANGE,
|
||||||
MarkRemoved = world.event.S_EVENT_MARK_REMOVED,
|
MarkRemoved = world.event.S_EVENT_MARK_REMOVED,
|
||||||
-- Moose Events
|
-- Moose Events
|
||||||
NewCargo = world.event.S_EVENT_NEW_CARGO,
|
NewCargo = world.event.S_EVENT_NEW_CARGO,
|
||||||
DeleteCargo = world.event.S_EVENT_DELETE_CARGO,
|
DeleteCargo = world.event.S_EVENT_DELETE_CARGO,
|
||||||
NewZone = world.event.S_EVENT_NEW_ZONE,
|
NewZone = world.event.S_EVENT_NEW_ZONE,
|
||||||
DeleteZone = world.event.S_EVENT_DELETE_ZONE,
|
DeleteZone = world.event.S_EVENT_DELETE_ZONE,
|
||||||
NewZoneGoal = world.event.S_EVENT_NEW_ZONE_GOAL,
|
NewZoneGoal = world.event.S_EVENT_NEW_ZONE_GOAL,
|
||||||
DeleteZoneGoal = world.event.S_EVENT_DELETE_ZONE_GOAL,
|
DeleteZoneGoal = world.event.S_EVENT_DELETE_ZONE_GOAL,
|
||||||
RemoveUnit = world.event.S_EVENT_REMOVE_UNIT,
|
RemoveUnit = world.event.S_EVENT_REMOVE_UNIT,
|
||||||
PlayerEnterAircraft = world.event.S_EVENT_PLAYER_ENTER_AIRCRAFT,
|
PlayerEnterAircraft = world.event.S_EVENT_PLAYER_ENTER_AIRCRAFT,
|
||||||
-- Added with DCS 2.5.6
|
-- Added with DCS 2.5.6
|
||||||
DetailedFailure = world.event.S_EVENT_DETAILED_FAILURE or -1, --We set this to -1 for backward compatibility to DCS 2.5.5 and earlier
|
DetailedFailure = world.event.S_EVENT_DETAILED_FAILURE or -1, --We set this to -1 for backward compatibility to DCS 2.5.5 and earlier
|
||||||
@@ -301,6 +304,8 @@ EVENTS = {
|
|||||||
-- @field Core.ZONE#ZONE Zone The zone object.
|
-- @field Core.ZONE#ZONE Zone The zone object.
|
||||||
-- @field #string ZoneName The name of the zone.
|
-- @field #string ZoneName The name of the zone.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local _EVENTMETA = {
|
local _EVENTMETA = {
|
||||||
[world.event.S_EVENT_SHOT] = {
|
[world.event.S_EVENT_SHOT] = {
|
||||||
Order = 1,
|
Order = 1,
|
||||||
@@ -557,6 +562,7 @@ local _EVENTMETA = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- The Events structure
|
--- The Events structure
|
||||||
-- @type EVENT.Events
|
-- @type EVENT.Events
|
||||||
-- @field #number IniUnit
|
-- @field #number IniUnit
|
||||||
@@ -570,11 +576,12 @@ function EVENT:New()
|
|||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
|
||||||
-- Add world event handler.
|
-- Add world event handler.
|
||||||
self.EventHandler = world.addEventHandler( self )
|
self.EventHandler = world.addEventHandler(self)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Initializes the Events structure for the event.
|
--- Initializes the Events structure for the event.
|
||||||
-- @param #EVENT self
|
-- @param #EVENT self
|
||||||
-- @param DCS#world.event EventID Event ID.
|
-- @param DCS#world.event EventID Event ID.
|
||||||
@@ -588,7 +595,7 @@ function EVENT:Init( EventID, EventClass )
|
|||||||
self.Events[EventID] = {}
|
self.Events[EventID] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Each event has a sub-table of EventClasses, ordered by EventPriority.
|
-- Each event has a subtable of EventClasses, ordered by EventPriority.
|
||||||
local EventPriority = EventClass:GetEventPriority()
|
local EventPriority = EventClass:GetEventPriority()
|
||||||
|
|
||||||
if not self.Events[EventID][EventPriority] then
|
if not self.Events[EventID][EventPriority] then
|
||||||
@@ -596,7 +603,7 @@ function EVENT:Init( EventID, EventClass )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not self.Events[EventID][EventPriority][EventClass] then
|
if not self.Events[EventID][EventPriority][EventClass] then
|
||||||
self.Events[EventID][EventPriority][EventClass] = {}
|
self.Events[EventID][EventPriority][EventClass] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.Events[EventID][EventPriority][EventClass]
|
return self.Events[EventID][EventPriority][EventClass]
|
||||||
@@ -607,7 +614,7 @@ end
|
|||||||
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
|
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
|
||||||
-- @param DCS#world.event EventID Event ID.
|
-- @param DCS#world.event EventID Event ID.
|
||||||
-- @return #EVENT self
|
-- @return #EVENT self
|
||||||
function EVENT:RemoveEvent( EventClass, EventID )
|
function EVENT:RemoveEvent( EventClass, EventID )
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:F2( { "Removing subscription for class: ", EventClass:GetClassNameAndID() } )
|
self:F2( { "Removing subscription for class: ", EventClass:GetClassNameAndID() } )
|
||||||
@@ -631,7 +638,7 @@ end
|
|||||||
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
|
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
|
||||||
-- @param DCS#world.event EventID Event ID.
|
-- @param DCS#world.event EventID Event ID.
|
||||||
-- @return #EVENT.Events
|
-- @return #EVENT.Events
|
||||||
function EVENT:Reset( EventObject ) -- R2.1
|
function EVENT:Reset( EventObject ) --R2.1
|
||||||
|
|
||||||
self:F( { "Resetting subscriptions for class: ", EventObject:GetClassNameAndID() } )
|
self:F( { "Resetting subscriptions for class: ", EventObject:GetClassNameAndID() } )
|
||||||
|
|
||||||
@@ -650,11 +657,12 @@ function EVENT:Reset( EventObject ) -- R2.1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Clears all event subscriptions for a @{Core.Base#BASE} derived object.
|
--- Clears all event subscriptions for a @{Core.Base#BASE} derived object.
|
||||||
-- @param #EVENT self
|
-- @param #EVENT self
|
||||||
-- @param Core.Base#BASE EventClass The self class object for which the events are removed.
|
-- @param Core.Base#BASE EventClass The self class object for which the events are removed.
|
||||||
-- @return #EVENT self
|
-- @return #EVENT self
|
||||||
function EVENT:RemoveAll( EventClass )
|
function EVENT:RemoveAll(EventClass)
|
||||||
|
|
||||||
local EventClassName = EventClass:GetClassNameAndID()
|
local EventClassName = EventClass:GetClassNameAndID()
|
||||||
|
|
||||||
@@ -668,6 +676,8 @@ function EVENT:RemoveAll( EventClass )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Create an OnDead event handler for a group
|
--- Create an OnDead event handler for a group
|
||||||
-- @param #EVENT self
|
-- @param #EVENT self
|
||||||
-- @param #table EventTemplate
|
-- @param #table EventTemplate
|
||||||
@@ -699,6 +709,7 @@ function EVENT:OnEventGeneric( EventFunction, EventClass, EventID )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set a new listener for an `S_EVENT_X` event for a UNIT.
|
--- Set a new listener for an `S_EVENT_X` event for a UNIT.
|
||||||
-- @param #EVENT self
|
-- @param #EVENT self
|
||||||
-- @param #string UnitName The name of the UNIT.
|
-- @param #string UnitName The name of the UNIT.
|
||||||
@@ -786,6 +797,7 @@ do -- OnDead
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
do -- OnLand
|
do -- OnLand
|
||||||
|
|
||||||
--- Create an OnLand event handler for a group
|
--- Create an OnLand event handler for a group
|
||||||
@@ -852,7 +864,7 @@ do -- Event Creation
|
|||||||
id = EVENTS.NewCargo,
|
id = EVENTS.NewCargo,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
cargo = Cargo,
|
cargo = Cargo,
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
@@ -867,7 +879,7 @@ do -- Event Creation
|
|||||||
id = EVENTS.DeleteCargo,
|
id = EVENTS.DeleteCargo,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
cargo = Cargo,
|
cargo = Cargo,
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
@@ -882,7 +894,7 @@ do -- Event Creation
|
|||||||
id = EVENTS.NewZone,
|
id = EVENTS.NewZone,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
zone = Zone,
|
zone = Zone,
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
@@ -897,7 +909,7 @@ do -- Event Creation
|
|||||||
id = EVENTS.DeleteZone,
|
id = EVENTS.DeleteZone,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
zone = Zone,
|
zone = Zone,
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
@@ -912,11 +924,12 @@ do -- Event Creation
|
|||||||
id = EVENTS.NewZoneGoal,
|
id = EVENTS.NewZoneGoal,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
ZoneGoal = ZoneGoal,
|
ZoneGoal = ZoneGoal,
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Creation of a ZoneGoal Deletion Event.
|
--- Creation of a ZoneGoal Deletion Event.
|
||||||
-- @param #EVENT self
|
-- @param #EVENT self
|
||||||
-- @param Core.ZoneGoal#ZONE_GOAL ZoneGoal The ZoneGoal created.
|
-- @param Core.ZoneGoal#ZONE_GOAL ZoneGoal The ZoneGoal created.
|
||||||
@@ -927,11 +940,12 @@ do -- Event Creation
|
|||||||
id = EVENTS.DeleteZoneGoal,
|
id = EVENTS.DeleteZoneGoal,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
ZoneGoal = ZoneGoal,
|
ZoneGoal = ZoneGoal,
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Creation of a S_EVENT_PLAYER_ENTER_UNIT Event.
|
--- Creation of a S_EVENT_PLAYER_ENTER_UNIT Event.
|
||||||
-- @param #EVENT self
|
-- @param #EVENT self
|
||||||
-- @param Wrapper.Unit#UNIT PlayerUnit.
|
-- @param Wrapper.Unit#UNIT PlayerUnit.
|
||||||
@@ -941,8 +955,8 @@ do -- Event Creation
|
|||||||
local Event = {
|
local Event = {
|
||||||
id = EVENTS.PlayerEnterUnit,
|
id = EVENTS.PlayerEnterUnit,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
initiator = PlayerUnit:GetDCSObject(),
|
initiator = PlayerUnit:GetDCSObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
@@ -956,8 +970,8 @@ do -- Event Creation
|
|||||||
local Event = {
|
local Event = {
|
||||||
id = EVENTS.PlayerEnterAircraft,
|
id = EVENTS.PlayerEnterAircraft,
|
||||||
time = timer.getTime(),
|
time = timer.getTime(),
|
||||||
initiator = PlayerUnit:GetDCSObject(),
|
initiator = PlayerUnit:GetDCSObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
world.onEvent( Event )
|
world.onEvent( Event )
|
||||||
end
|
end
|
||||||
@@ -969,24 +983,25 @@ end
|
|||||||
-- @param #EVENTDATA Event Event data table.
|
-- @param #EVENTDATA Event Event data table.
|
||||||
function EVENT:onEvent( Event )
|
function EVENT:onEvent( Event )
|
||||||
|
|
||||||
|
--- Function to handle errors.
|
||||||
local ErrorHandler = function( errmsg )
|
local ErrorHandler = function( errmsg )
|
||||||
|
|
||||||
env.info( "Error in SCHEDULER function:" .. errmsg )
|
env.info( "Error in SCHEDULER function:" .. errmsg )
|
||||||
if BASE.Debug ~= nil then
|
if BASE.Debug ~= nil then
|
||||||
env.info( debug.traceback() )
|
env.info( debug.traceback() )
|
||||||
end
|
end
|
||||||
|
|
||||||
return errmsg
|
return errmsg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Get event meta data.
|
-- Get event meta data.
|
||||||
local EventMeta = _EVENTMETA[Event.id]
|
local EventMeta = _EVENTMETA[Event.id]
|
||||||
|
|
||||||
-- Check if this is a known event?
|
-- Check if this is a known event?
|
||||||
if EventMeta then
|
if EventMeta then
|
||||||
|
|
||||||
if self and self.Events and self.Events[Event.id] and self.MissionEnd == false and (Event.initiator ~= nil or (Event.initiator == nil and Event.id ~= EVENTS.PlayerLeaveUnit)) then
|
if self and self.Events and self.Events[Event.id] and self.MissionEnd==false and (Event.initiator~=nil or (Event.initiator==nil and Event.id~=EVENTS.PlayerLeaveUnit)) then
|
||||||
|
|
||||||
|
-- Check if mission has ended.
|
||||||
if Event.id and Event.id == EVENTS.MissionEnd then
|
if Event.id and Event.id == EVENTS.MissionEnd then
|
||||||
self.MissionEnd = true
|
self.MissionEnd = true
|
||||||
end
|
end
|
||||||
@@ -995,49 +1010,26 @@ function EVENT:onEvent( Event )
|
|||||||
|
|
||||||
Event.IniObjectCategory = Event.initiator:getCategory()
|
Event.IniObjectCategory = Event.initiator:getCategory()
|
||||||
|
|
||||||
if Event.IniObjectCategory == Object.Category.UNIT then
|
if Event.IniObjectCategory == Object.Category.STATIC then
|
||||||
Event.IniDCSUnit = Event.initiator
|
---
|
||||||
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
-- Static
|
||||||
Event.IniUnitName = Event.IniDCSUnitName
|
---
|
||||||
Event.IniDCSGroup = Event.IniDCSUnit:getGroup()
|
if Event.id==31 then
|
||||||
Event.IniUnit = UNIT:FindByName( Event.IniDCSUnitName )
|
|
||||||
if not Event.IniUnit then
|
|
||||||
-- Unit can be a CLIENT. Most likely this will be the case ...
|
|
||||||
Event.IniUnit = CLIENT:FindByName( Event.IniDCSUnitName, '', true )
|
|
||||||
end
|
|
||||||
Event.IniDCSGroupName = ""
|
|
||||||
if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then
|
|
||||||
Event.IniDCSGroupName = Event.IniDCSGroup:getName()
|
|
||||||
Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
|
|
||||||
-- if Event.IniGroup then
|
|
||||||
Event.IniGroupName = Event.IniDCSGroupName
|
|
||||||
-- end
|
|
||||||
end
|
|
||||||
Event.IniPlayerName = Event.IniDCSUnit:getPlayerName()
|
|
||||||
Event.IniCoalition = Event.IniDCSUnit:getCoalition()
|
|
||||||
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
|
||||||
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
|
||||||
end
|
|
||||||
|
|
||||||
if Event.IniObjectCategory == Object.Category.STATIC then
|
|
||||||
|
|
||||||
if Event.id == 31 then
|
|
||||||
|
|
||||||
-- Event.initiator is a Static object representing the pilot. But getName() errors due to DCS bug.
|
-- Event.initiator is a Static object representing the pilot. But getName() errors due to DCS bug.
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
local ID = Event.initiator.id_
|
local ID=Event.initiator.id_
|
||||||
Event.IniDCSUnitName = string.format( "Ejected Pilot ID %s", tostring( ID ) )
|
Event.IniDCSUnitName = string.format("Ejected Pilot ID %s", tostring(ID))
|
||||||
Event.IniUnitName = Event.IniDCSUnitName
|
Event.IniUnitName = Event.IniDCSUnitName
|
||||||
Event.IniCoalition = 0
|
Event.IniCoalition = 0
|
||||||
Event.IniCategory = 0
|
Event.IniCategory = 0
|
||||||
Event.IniTypeName = "Ejected Pilot"
|
Event.IniTypeName = "Ejected Pilot"
|
||||||
elseif Event.id == 33 then -- ejection seat discarded
|
elseif Event.id == 33 then -- ejection seat discarded
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
local ID = Event.initiator.id_
|
local ID=Event.initiator.id_
|
||||||
Event.IniDCSUnitName = string.format( "Ejection Seat ID %s", tostring( ID ) )
|
Event.IniDCSUnitName = string.format("Ejection Seat ID %s", tostring(ID))
|
||||||
Event.IniUnitName = Event.IniDCSUnitName
|
Event.IniUnitName = Event.IniDCSUnitName
|
||||||
Event.IniCoalition = 0
|
Event.IniCoalition = 0
|
||||||
Event.IniCategory = 0
|
Event.IniCategory = 0
|
||||||
Event.IniTypeName = "Ejection Seat"
|
Event.IniTypeName = "Ejection Seat"
|
||||||
else
|
else
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
@@ -1048,9 +1040,47 @@ function EVENT:onEvent( Event )
|
|||||||
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
||||||
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Dead events of units can be delayed and the initiator changed to a static.
|
||||||
|
-- Take care of that.
|
||||||
|
local Unit=UNIT:FindByName(Event.IniDCSUnitName)
|
||||||
|
if Unit then
|
||||||
|
Event.IniObjectCategory = Object.Category.UNIT
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if Event.IniObjectCategory == Object.Category.UNIT then
|
||||||
|
---
|
||||||
|
-- Unit
|
||||||
|
---
|
||||||
|
Event.IniDCSUnit = Event.initiator
|
||||||
|
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
||||||
|
Event.IniUnitName = Event.IniDCSUnitName
|
||||||
|
Event.IniDCSGroup = Event.IniDCSUnit:getGroup()
|
||||||
|
Event.IniUnit = UNIT:FindByName( Event.IniDCSUnitName )
|
||||||
|
|
||||||
|
if not Event.IniUnit then
|
||||||
|
-- Unit can be a CLIENT. Most likely this will be the case ...
|
||||||
|
Event.IniUnit = CLIENT:FindByName( Event.IniDCSUnitName, '', true )
|
||||||
|
end
|
||||||
|
|
||||||
|
Event.IniDCSGroupName = Event.IniUnit and Event.IniUnit.GroupName or ""
|
||||||
|
if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then
|
||||||
|
Event.IniDCSGroupName = Event.IniDCSGroup:getName()
|
||||||
|
Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
|
||||||
|
Event.IniGroupName = Event.IniDCSGroupName
|
||||||
|
end
|
||||||
|
|
||||||
|
Event.IniPlayerName = Event.IniDCSUnit:getPlayerName()
|
||||||
|
Event.IniCoalition = Event.IniDCSUnit:getCoalition()
|
||||||
|
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
||||||
|
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
||||||
end
|
end
|
||||||
|
|
||||||
if Event.IniObjectCategory == Object.Category.CARGO then
|
if Event.IniObjectCategory == Object.Category.CARGO then
|
||||||
|
---
|
||||||
|
-- Cargo
|
||||||
|
---
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
||||||
Event.IniUnitName = Event.IniDCSUnitName
|
Event.IniUnitName = Event.IniDCSUnitName
|
||||||
@@ -1061,19 +1091,26 @@ function EVENT:onEvent( Event )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Event.IniObjectCategory == Object.Category.SCENERY then
|
if Event.IniObjectCategory == Object.Category.SCENERY then
|
||||||
|
---
|
||||||
|
-- Scenery
|
||||||
|
---
|
||||||
|
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
||||||
Event.IniUnitName = Event.IniDCSUnitName
|
Event.IniUnitName = Event.IniDCSUnitName
|
||||||
Event.IniUnit = SCENERY:Register( Event.IniDCSUnitName, Event.initiator )
|
Event.IniUnit = SCENERY:Register( Event.IniDCSUnitName, Event.initiator )
|
||||||
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
||||||
Event.IniTypeName = Event.initiator:isExist() and Event.IniDCSUnit:getTypeName() or "SCENERY" -- TODO: Bug fix for 2.1!
|
Event.IniTypeName = Event.initiator:isExist() and Event.IniDCSUnit:getTypeName() or "SCENERY"
|
||||||
end
|
end
|
||||||
|
|
||||||
if Event.IniObjectCategory == Object.Category.BASE then
|
if Event.IniObjectCategory == Object.Category.BASE then
|
||||||
|
---
|
||||||
|
-- Base Object
|
||||||
|
---
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
||||||
Event.IniUnitName = Event.IniDCSUnitName
|
Event.IniUnitName = Event.IniDCSUnitName
|
||||||
Event.IniUnit = AIRBASE:FindByName( Event.IniDCSUnitName )
|
Event.IniUnit = AIRBASE:FindByName(Event.IniDCSUnitName)
|
||||||
Event.IniCoalition = Event.IniDCSUnit:getCoalition()
|
Event.IniCoalition = Event.IniDCSUnit:getCoalition()
|
||||||
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
||||||
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
||||||
@@ -1082,6 +1119,11 @@ function EVENT:onEvent( Event )
|
|||||||
|
|
||||||
if Event.target then
|
if Event.target then
|
||||||
|
|
||||||
|
---
|
||||||
|
-- TARGET
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Target category.
|
||||||
Event.TgtObjectCategory = Event.target:getCategory()
|
Event.TgtObjectCategory = Event.target:getCategory()
|
||||||
|
|
||||||
if Event.TgtObjectCategory == Object.Category.UNIT then
|
if Event.TgtObjectCategory == Object.Category.UNIT then
|
||||||
@@ -1094,9 +1136,7 @@ function EVENT:onEvent( Event )
|
|||||||
if Event.TgtDCSGroup and Event.TgtDCSGroup:isExist() then
|
if Event.TgtDCSGroup and Event.TgtDCSGroup:isExist() then
|
||||||
Event.TgtDCSGroupName = Event.TgtDCSGroup:getName()
|
Event.TgtDCSGroupName = Event.TgtDCSGroup:getName()
|
||||||
Event.TgtGroup = GROUP:FindByName( Event.TgtDCSGroupName )
|
Event.TgtGroup = GROUP:FindByName( Event.TgtDCSGroupName )
|
||||||
-- if Event.TgtGroup then
|
|
||||||
Event.TgtGroupName = Event.TgtDCSGroupName
|
Event.TgtGroupName = Event.TgtDCSGroupName
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
Event.TgtPlayerName = Event.TgtDCSUnit:getPlayerName()
|
Event.TgtPlayerName = Event.TgtDCSUnit:getPlayerName()
|
||||||
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
||||||
@@ -1115,18 +1155,18 @@ function EVENT:onEvent( Event )
|
|||||||
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
||||||
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
||||||
else
|
else
|
||||||
Event.TgtDCSUnitName = string.format( "No target object for Event ID %s", tostring( Event.id ) )
|
Event.TgtDCSUnitName = string.format("No target object for Event ID %s", tostring(Event.id))
|
||||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
Event.TgtUnit = nil
|
Event.TgtUnit = nil
|
||||||
Event.TgtCoalition = 0
|
Event.TgtCoalition = 0
|
||||||
Event.TgtCategory = 0
|
Event.TgtCategory = 0
|
||||||
if Event.id == 6 then
|
if Event.id == 6 then
|
||||||
Event.TgtTypeName = "Ejected Pilot"
|
Event.TgtTypeName = "Ejected Pilot"
|
||||||
Event.TgtDCSUnitName = string.format( "Ejected Pilot ID %s", tostring( Event.IniDCSUnitName ) )
|
Event.TgtDCSUnitName = string.format("Ejected Pilot ID %s", tostring(Event.IniDCSUnitName))
|
||||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
elseif Event.id == 33 then
|
elseif Event.id == 33 then
|
||||||
Event.TgtTypeName = "Ejection Seat"
|
Event.TgtTypeName = "Ejection Seat"
|
||||||
Event.TgtDCSUnitName = string.format( "Ejection Seat ID %s", tostring( Event.IniDCSUnitName ) )
|
Event.TgtDCSUnitName = string.format("Ejection Seat ID %s", tostring(Event.IniDCSUnitName))
|
||||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
else
|
else
|
||||||
Event.TgtTypeName = "Static"
|
Event.TgtTypeName = "Static"
|
||||||
@@ -1144,6 +1184,7 @@ function EVENT:onEvent( Event )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Weapon.
|
||||||
if Event.weapon then
|
if Event.weapon then
|
||||||
Event.Weapon = Event.weapon
|
Event.Weapon = Event.weapon
|
||||||
Event.WeaponName = Event.Weapon:getTypeName()
|
Event.WeaponName = Event.Weapon:getTypeName()
|
||||||
@@ -1152,49 +1193,48 @@ function EVENT:onEvent( Event )
|
|||||||
Event.WeaponCoalition = Event.WeaponUNIT and Event.Weapon:getCoalition()
|
Event.WeaponCoalition = Event.WeaponUNIT and Event.Weapon:getCoalition()
|
||||||
Event.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category
|
Event.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category
|
||||||
Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName()
|
Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName()
|
||||||
-- Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
|
--Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Place should be given for takeoff and landing events as well as base captured. It should be a DCS airbase.
|
-- Place should be given for takeoff and landing events as well as base captured. It should be a DCS airbase.
|
||||||
if Event.place then
|
if Event.place then
|
||||||
if Event.id == EVENTS.LandingAfterEjection then
|
if Event.id==EVENTS.LandingAfterEjection then
|
||||||
-- Place is here the UNIT of which the pilot ejected.
|
-- Place is here the UNIT of which the pilot ejected.
|
||||||
-- local name=Event.place:getName() -- This returns a DCS error "Airbase doesn't exit" :(
|
--local name=Event.place:getName() -- This returns a DCS error "Airbase doesn't exit" :(
|
||||||
-- However, this is not a big thing, as the aircraft the pilot ejected from is usually long crashed before the ejected pilot touches the ground.
|
-- However, this is not a big thing, as the aircraft the pilot ejected from is usually long crashed before the ejected pilot touches the ground.
|
||||||
-- Event.Place=UNIT:Find(Event.place)
|
--Event.Place=UNIT:Find(Event.place)
|
||||||
else
|
else
|
||||||
Event.Place = AIRBASE:Find( Event.place )
|
Event.Place=AIRBASE:Find(Event.place)
|
||||||
Event.PlaceName = Event.Place:GetName()
|
Event.PlaceName=Event.Place:GetName()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Mark points.
|
-- Mark points.
|
||||||
if Event.idx then
|
if Event.idx then
|
||||||
Event.MarkID = Event.idx
|
Event.MarkID=Event.idx
|
||||||
Event.MarkVec3 = Event.pos
|
Event.MarkVec3=Event.pos
|
||||||
Event.MarkCoordinate = COORDINATE:NewFromVec3( Event.pos )
|
Event.MarkCoordinate=COORDINATE:NewFromVec3(Event.pos)
|
||||||
Event.MarkText = Event.text
|
Event.MarkText=Event.text
|
||||||
Event.MarkCoalition = Event.coalition
|
Event.MarkCoalition=Event.coalition
|
||||||
Event.MarkGroupID = Event.groupID
|
Event.MarkGroupID = Event.groupID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Cargo object.
|
||||||
if Event.cargo then
|
if Event.cargo then
|
||||||
Event.Cargo = Event.cargo
|
Event.Cargo = Event.cargo
|
||||||
Event.CargoName = Event.cargo.Name
|
Event.CargoName = Event.cargo.Name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Zone object.
|
||||||
if Event.zone then
|
if Event.zone then
|
||||||
Event.Zone = Event.zone
|
Event.Zone = Event.zone
|
||||||
Event.ZoneName = Event.zone.ZoneName
|
Event.ZoneName = Event.zone.ZoneName
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Priority order.
|
||||||
local PriorityOrder = EventMeta.Order
|
local PriorityOrder = EventMeta.Order
|
||||||
local PriorityBegin = PriorityOrder == -1 and 5 or 1
|
local PriorityBegin = PriorityOrder == -1 and 5 or 1
|
||||||
local PriorityEnd = PriorityOrder == -1 and 1 or 5
|
local PriorityEnd = PriorityOrder == -1 and 1 or 5
|
||||||
|
|
||||||
if Event.IniObjectCategory ~= Object.Category.STATIC then
|
|
||||||
self:F( { EventMeta.Text, Event, Event.IniDCSUnitName, Event.TgtDCSUnitName, PriorityOrder } )
|
|
||||||
end
|
|
||||||
|
|
||||||
for EventPriority = PriorityBegin, PriorityEnd, PriorityOrder do
|
for EventPriority = PriorityBegin, PriorityEnd, PriorityOrder do
|
||||||
|
|
||||||
@@ -1203,12 +1243,12 @@ function EVENT:onEvent( Event )
|
|||||||
-- Okay, we got the event from DCS. Now loop the SORTED self.EventSorted[] table for the received Event.id, and for each EventData registered, check if a function needs to be called.
|
-- Okay, we got the event from DCS. Now loop the SORTED self.EventSorted[] table for the received Event.id, and for each EventData registered, check if a function needs to be called.
|
||||||
for EventClass, EventData in pairs( self.Events[Event.id][EventPriority] ) do
|
for EventClass, EventData in pairs( self.Events[Event.id][EventPriority] ) do
|
||||||
|
|
||||||
-- if Event.IniObjectCategory ~= Object.Category.STATIC then
|
--if Event.IniObjectCategory ~= Object.Category.STATIC then
|
||||||
-- self:E( { "Evaluating: ", EventClass:GetClassNameAndID() } )
|
-- self:E( { "Evaluating: ", EventClass:GetClassNameAndID() } )
|
||||||
-- end
|
--end
|
||||||
|
|
||||||
Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
|
Event.IniGroup = Event.IniGroup or GROUP:FindByName( Event.IniDCSGroupName )
|
||||||
Event.TgtGroup = GROUP:FindByName( Event.TgtDCSGroupName )
|
Event.TgtGroup = Event.TgtGroup or GROUP:FindByName( Event.TgtDCSGroupName )
|
||||||
|
|
||||||
-- If the EventData is for a UNIT, the call directly the EventClass EventFunction for that UNIT.
|
-- If the EventData is for a UNIT, the call directly the EventClass EventFunction for that UNIT.
|
||||||
if EventData.EventUnit then
|
if EventData.EventUnit then
|
||||||
@@ -1218,39 +1258,35 @@ function EVENT:onEvent( Event )
|
|||||||
Event.id == EVENTS.PlayerEnterUnit or
|
Event.id == EVENTS.PlayerEnterUnit or
|
||||||
Event.id == EVENTS.Crash or
|
Event.id == EVENTS.Crash or
|
||||||
Event.id == EVENTS.Dead or
|
Event.id == EVENTS.Dead or
|
||||||
Event.id == EVENTS.RemoveUnit then
|
Event.id == EVENTS.RemoveUnit or
|
||||||
|
Event.id == EVENTS.UnitLost then
|
||||||
|
|
||||||
local UnitName = EventClass:GetName()
|
local UnitName = EventClass:GetName()
|
||||||
|
|
||||||
if (EventMeta.Side == "I" and UnitName == Event.IniDCSUnitName) or
|
if ( EventMeta.Side == "I" and UnitName == Event.IniDCSUnitName ) or
|
||||||
(EventMeta.Side == "T" and UnitName == Event.TgtDCSUnitName) then
|
( EventMeta.Side == "T" and UnitName == Event.TgtDCSUnitName ) then
|
||||||
|
|
||||||
-- First test if a EventFunction is Set, otherwise search for the default function
|
-- First test if a EventFunction is Set, otherwise search for the default function
|
||||||
if EventData.EventFunction then
|
if EventData.EventFunction then
|
||||||
|
|
||||||
if Event.IniObjectCategory ~= 3 then
|
local Result, Value = xpcall(
|
||||||
self:F( { "Calling EventFunction for UNIT ", EventClass:GetClassNameAndID(), ", Unit ", Event.IniUnitName, EventPriority } )
|
function()
|
||||||
end
|
return EventData.EventFunction( EventClass, Event )
|
||||||
|
end, ErrorHandler )
|
||||||
local Result, Value = xpcall( function()
|
|
||||||
return EventData.EventFunction( EventClass, Event )
|
|
||||||
end, ErrorHandler )
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
|
-- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
|
||||||
local EventFunction = EventClass[EventMeta.Event]
|
local EventFunction = EventClass[ EventMeta.Event ]
|
||||||
if EventFunction and type( EventFunction ) == "function" then
|
if EventFunction and type( EventFunction ) == "function" then
|
||||||
|
|
||||||
-- Now call the default event function.
|
-- Now call the default event function.
|
||||||
if Event.IniObjectCategory ~= 3 then
|
local Result, Value = xpcall(
|
||||||
self:F( { "Calling " .. EventMeta.Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } )
|
function()
|
||||||
end
|
return EventFunction( EventClass, Event )
|
||||||
|
end, ErrorHandler )
|
||||||
local Result, Value = xpcall( function()
|
|
||||||
return EventFunction( EventClass, Event )
|
|
||||||
end, ErrorHandler )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -1268,45 +1304,40 @@ function EVENT:onEvent( Event )
|
|||||||
Event.id == EVENTS.PlayerEnterUnit or
|
Event.id == EVENTS.PlayerEnterUnit or
|
||||||
Event.id == EVENTS.Crash or
|
Event.id == EVENTS.Crash or
|
||||||
Event.id == EVENTS.Dead or
|
Event.id == EVENTS.Dead or
|
||||||
Event.id == EVENTS.RemoveUnit then
|
Event.id == EVENTS.RemoveUnit or
|
||||||
|
Event.id == EVENTS.UnitLost then
|
||||||
|
|
||||||
-- We can get the name of the EventClass, which is now always a GROUP object.
|
-- We can get the name of the EventClass, which is now always a GROUP object.
|
||||||
local GroupName = EventClass:GetName()
|
local GroupName = EventClass:GetName()
|
||||||
|
|
||||||
if (EventMeta.Side == "I" and GroupName == Event.IniDCSGroupName) or
|
if ( EventMeta.Side == "I" and GroupName == Event.IniDCSGroupName ) or
|
||||||
(EventMeta.Side == "T" and GroupName == Event.TgtDCSGroupName) then
|
( EventMeta.Side == "T" and GroupName == Event.TgtDCSGroupName ) then
|
||||||
|
|
||||||
-- First test if a EventFunction is Set, otherwise search for the default function
|
-- First test if a EventFunction is Set, otherwise search for the default function
|
||||||
if EventData.EventFunction then
|
if EventData.EventFunction then
|
||||||
|
|
||||||
if Event.IniObjectCategory ~= 3 then
|
local Result, Value = xpcall(
|
||||||
self:F( { "Calling EventFunction for GROUP ", EventClass:GetClassNameAndID(), ", Unit ", Event.IniUnitName, EventPriority } )
|
function()
|
||||||
end
|
return EventData.EventFunction( EventClass, Event, unpack( EventData.Params ) )
|
||||||
|
end, ErrorHandler )
|
||||||
local Result, Value = xpcall( function()
|
|
||||||
return EventData.EventFunction( EventClass, Event, unpack( EventData.Params ) )
|
|
||||||
end, ErrorHandler )
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
|
-- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
|
||||||
local EventFunction = EventClass[EventMeta.Event]
|
local EventFunction = EventClass[ EventMeta.Event ]
|
||||||
if EventFunction and type( EventFunction ) == "function" then
|
if EventFunction and type( EventFunction ) == "function" then
|
||||||
|
|
||||||
-- Now call the default event function.
|
-- Now call the default event function.
|
||||||
if Event.IniObjectCategory ~= 3 then
|
local Result, Value = xpcall(
|
||||||
self:F( { "Calling " .. EventMeta.Event .. " for GROUP ", EventClass:GetClassNameAndID(), EventPriority } )
|
function()
|
||||||
end
|
return EventFunction( EventClass, Event, unpack( EventData.Params ) )
|
||||||
|
end, ErrorHandler )
|
||||||
local Result, Value = xpcall( function()
|
|
||||||
return EventFunction( EventClass, Event, unpack( EventData.Params ) )
|
|
||||||
end, ErrorHandler )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- The EventClass is not alive anymore, we remove it from the EventHandlers...
|
-- The EventClass is not alive anymore, we remove it from the EventHandlers...
|
||||||
-- self:RemoveEvent( EventClass, Event.id )
|
--self:RemoveEvent( EventClass, Event.id )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
||||||
@@ -1318,28 +1349,25 @@ function EVENT:onEvent( Event )
|
|||||||
if EventData.EventFunction then
|
if EventData.EventFunction then
|
||||||
|
|
||||||
-- There is an EventFunction defined, so call the EventFunction.
|
-- There is an EventFunction defined, so call the EventFunction.
|
||||||
if Event.IniObjectCategory ~= 3 then
|
local Result, Value = xpcall(
|
||||||
self:F2( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), EventPriority } )
|
function()
|
||||||
end
|
return EventData.EventFunction( EventClass, Event )
|
||||||
local Result, Value = xpcall( function()
|
end, ErrorHandler )
|
||||||
return EventData.EventFunction( EventClass, Event )
|
|
||||||
end, ErrorHandler )
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
|
-- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
|
||||||
local EventFunction = EventClass[EventMeta.Event]
|
local EventFunction = EventClass[ EventMeta.Event ]
|
||||||
if EventFunction and type( EventFunction ) == "function" then
|
if EventFunction and type( EventFunction ) == "function" then
|
||||||
|
|
||||||
-- Now call the default event function.
|
-- Now call the default event function.
|
||||||
if Event.IniObjectCategory ~= 3 then
|
local Result, Value = xpcall(
|
||||||
self:F2( { "Calling " .. EventMeta.Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } )
|
function()
|
||||||
end
|
local Result, Value = EventFunction( EventClass, Event )
|
||||||
|
return Result, Value
|
||||||
|
end, ErrorHandler )
|
||||||
|
|
||||||
local Result, Value = xpcall( function()
|
|
||||||
local Result, Value = EventFunction( EventClass, Event )
|
|
||||||
return Result, Value
|
|
||||||
end, ErrorHandler )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1362,7 +1390,7 @@ function EVENT:onEvent( Event )
|
|||||||
self:T( { EventMeta.Text, Event } )
|
self:T( { EventMeta.Text, Event } )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E( string.format( "WARNING: Could not get EVENTMETA data for event ID=%d! Is this an unknown/new DCS event?", tostring( Event.id ) ) )
|
self:E(string.format("WARNING: Could not get EVENTMETA data for event ID=%d! Is this an unknown/new DCS event?", tostring(Event.id)))
|
||||||
end
|
end
|
||||||
|
|
||||||
Event = nil
|
Event = nil
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
-- 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**.
|
-- 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**.
|
-- 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**.
|
-- A **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 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**,
|
-- 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**.
|
-- 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.
|
-- orders him to destroy x targets and account the results.
|
||||||
-- Other examples of ready made FSM could be:
|
-- Other examples of ready made FSM could be:
|
||||||
--
|
--
|
||||||
-- * route a plane to a zone flown by a human
|
-- * Route a plane to a zone flown by a human.
|
||||||
-- * detect targets by an AI and report to humans
|
-- * Detect targets by an AI and report to humans.
|
||||||
-- * account for destroyed targets by human players
|
-- * Account for destroyed targets by human players.
|
||||||
-- * handle AI infantry to deploy from or embark to a helicopter or airplane or vehicle
|
-- * Handle AI infantry to deploy from or embark to a helicopter or airplane or vehicle.
|
||||||
-- * let an AI patrol a zone
|
-- * 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**.
|
-- 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.
|
-- 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,
|
-- **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**.
|
-- and tailored** by mission designers through **the implementation of Transition Handlers**.
|
||||||
-- Each of these FSM implementation classes start either with:
|
-- 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 **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 an FSM implementation executing a @{TASK} executed by Groups of players. These TASK\_ classes derive the @{#FSM_TASK} 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.
|
-- * 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.
|
-- 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.
|
-- 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.
|
-- 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_TASK}: Models Finite State Machines for @{Task}s.
|
||||||
-- * @{#FSM_PROCESS}: Models Finite State Machines for @{Task} actions, which control @{Client}s.
|
-- * @{#FSM_PROCESS}: Models Finite State Machines for @{Task} actions, which control @{Client}s.
|
||||||
@@ -405,7 +405,7 @@ do -- FSM
|
|||||||
Transition.To = To
|
Transition.To = To
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
self:T2( Transition )
|
--self:T3( Transition )
|
||||||
|
|
||||||
self._Transitions[Transition] = Transition
|
self._Transitions[Transition] = Transition
|
||||||
self:_eventmap( self.Events, Transition )
|
self:_eventmap( self.Events, Transition )
|
||||||
@@ -426,7 +426,7 @@ do -- FSM
|
|||||||
-- @param #table ReturnEvents A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
|
-- @param #table ReturnEvents A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
|
||||||
-- @return Core.Fsm#FSM_PROCESS The SubFSM.
|
-- @return Core.Fsm#FSM_PROCESS The SubFSM.
|
||||||
function FSM:AddProcess( From, Event, Process, ReturnEvents )
|
function FSM:AddProcess( From, Event, Process, ReturnEvents )
|
||||||
self:T( { From, Event } )
|
--self:T3( { From, Event } )
|
||||||
|
|
||||||
local Sub = {}
|
local Sub = {}
|
||||||
Sub.From = From
|
Sub.From = From
|
||||||
@@ -525,7 +525,7 @@ do -- FSM
|
|||||||
Process._Scores[State].ScoreText = ScoreText
|
Process._Scores[State].ScoreText = ScoreText
|
||||||
Process._Scores[State].Score = Score
|
Process._Scores[State].Score = Score
|
||||||
|
|
||||||
self:T( Process._Scores )
|
--self:T3( Process._Scores )
|
||||||
|
|
||||||
return Process
|
return Process
|
||||||
end
|
end
|
||||||
@@ -561,17 +561,17 @@ do -- FSM
|
|||||||
-- @param #table EventStructure Event structure.
|
-- @param #table EventStructure Event structure.
|
||||||
function FSM:_eventmap( Events, EventStructure )
|
function FSM:_eventmap( Events, EventStructure )
|
||||||
|
|
||||||
local Event = EventStructure.Event
|
local Event = EventStructure.Event
|
||||||
local __Event = "__" .. EventStructure.Event
|
local __Event = "__" .. EventStructure.Event
|
||||||
|
|
||||||
self[Event] = self[Event] or self:_create_transition( Event )
|
self[Event] = self[Event] or self:_create_transition(Event)
|
||||||
self[__Event] = self[__Event] or self:_delayed_transition( Event )
|
self[__Event] = self[__Event] or self:_delayed_transition(Event)
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
self:T2( "Added methods: " .. Event .. ", " .. __Event )
|
--self:T3( "Added methods: " .. Event .. ", " .. __Event )
|
||||||
|
|
||||||
Events[Event] = self.Events[Event] or { map = {} }
|
Events[Event] = self.Events[Event] or { map = {} }
|
||||||
self:_add_to_map( Events[Event].map, EventStructure )
|
self:_add_to_map( Events[Event].map, EventStructure )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -784,7 +784,7 @@ do -- FSM
|
|||||||
return function( self, DelaySeconds, ... )
|
return function( self, DelaySeconds, ... )
|
||||||
|
|
||||||
-- Debug.
|
-- Debug.
|
||||||
self:T2( "Delayed Event: " .. EventName )
|
self:T3( "Delayed Event: " .. EventName )
|
||||||
|
|
||||||
local CallID = 0
|
local CallID = 0
|
||||||
if DelaySeconds ~= nil then
|
if DelaySeconds ~= nil then
|
||||||
@@ -802,23 +802,23 @@ do -- FSM
|
|||||||
self._EventSchedules[EventName] = CallID
|
self._EventSchedules[EventName] = CallID
|
||||||
|
|
||||||
-- Debug output.
|
-- Debug output.
|
||||||
self:T2( string.format( "NEGATIVE Event %s delayed by %.1f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring( CallID ) ) )
|
self:T2(string.format("NEGATIVE Event %s delayed by %.3f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
|
||||||
else
|
else
|
||||||
self:T2( string.format( "NEGATIVE Event %s delayed by %.1f sec CANCELLED as we already have such an event in the queue.", EventName, DelaySeconds ) )
|
self:T2(string.format("NEGATIVE Event %s delayed by %.3f sec CANCELLED as we already have such an event in the queue.", EventName, DelaySeconds))
|
||||||
-- reschedule
|
-- reschedule
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
||||||
CallID = self.CallScheduler:Schedule( self, self._handler, { EventName, ... }, DelaySeconds or 1, nil, nil, nil, 4, true )
|
CallID = self.CallScheduler:Schedule( self, self._handler, { EventName, ... }, DelaySeconds or 1, nil, nil, nil, 4, true )
|
||||||
|
|
||||||
self:T2( string.format( "Event %s delayed by %.1f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring( CallID ) ) )
|
self:T2(string.format("Event %s delayed by %.3f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error( "FSM: An asynchronous event trigger requires a DelaySeconds parameter!!! This can be positive or negative! Sorry, but will not process this." )
|
error( "FSM: An asynchronous event trigger requires a DelaySeconds parameter!!! This can be positive or negative! Sorry, but will not process this." )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug.
|
-- Debug.
|
||||||
self:T2( { CallID = CallID } )
|
--self:T3( { CallID = CallID } )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -841,7 +841,7 @@ do -- FSM
|
|||||||
function FSM:_gosub( ParentFrom, ParentEvent )
|
function FSM:_gosub( ParentFrom, ParentEvent )
|
||||||
local fsmtable = {}
|
local fsmtable = {}
|
||||||
if self.subs[ParentFrom] and self.subs[ParentFrom][ParentEvent] then
|
if self.subs[ParentFrom] and self.subs[ParentFrom][ParentEvent] then
|
||||||
self:T( { ParentFrom, ParentEvent, self.subs[ParentFrom], self.subs[ParentFrom][ParentEvent] } )
|
--self:T3( { ParentFrom, ParentEvent, self.subs[ParentFrom], self.subs[ParentFrom][ParentEvent] } )
|
||||||
return self.subs[ParentFrom][ParentEvent]
|
return self.subs[ParentFrom][ParentEvent]
|
||||||
else
|
else
|
||||||
return {}
|
return {}
|
||||||
@@ -888,7 +888,7 @@ do -- FSM
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T3( { Map, Event } )
|
--self:T3( { Map, Event } )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get current state.
|
--- Get current state.
|
||||||
@@ -908,7 +908,7 @@ do -- FSM
|
|||||||
--- Check if FSM is in state.
|
--- Check if FSM is in state.
|
||||||
-- @param #FSM self
|
-- @param #FSM self
|
||||||
-- @param #string State State name.
|
-- @param #string State State name.
|
||||||
-- @param #boolean If true, FSM is in this state.
|
-- @return #boolean If true, FSM is in this state.
|
||||||
function FSM:Is( State )
|
function FSM:Is( State )
|
||||||
return self.current == State
|
return self.current == State
|
||||||
end
|
end
|
||||||
@@ -916,8 +916,8 @@ do -- FSM
|
|||||||
--- Check if FSM is in state.
|
--- Check if FSM is in state.
|
||||||
-- @param #FSM self
|
-- @param #FSM self
|
||||||
-- @param #string State State name.
|
-- @param #string State State name.
|
||||||
-- @param #boolean If true, FSM is in this state.
|
-- @return #boolean If true, FSM is in this state.
|
||||||
function FSM:is( state )
|
function FSM:is(state)
|
||||||
return self.current == state
|
return self.current == state
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1146,7 +1146,7 @@ do -- FSM_PROCESS
|
|||||||
-- @param #FSM_PROCESS self
|
-- @param #FSM_PROCESS self
|
||||||
-- @return #FSM_PROCESS
|
-- @return #FSM_PROCESS
|
||||||
function FSM_PROCESS:Copy( Controllable, Task )
|
function FSM_PROCESS:Copy( Controllable, Task )
|
||||||
self:T( { self:GetClassNameAndID() } )
|
--self:T3( { self:GetClassNameAndID() } )
|
||||||
|
|
||||||
local NewFsm = self:New( Controllable, Task ) -- Core.Fsm#FSM_PROCESS
|
local NewFsm = self:New( Controllable, Task ) -- Core.Fsm#FSM_PROCESS
|
||||||
|
|
||||||
@@ -1171,13 +1171,13 @@ do -- FSM_PROCESS
|
|||||||
|
|
||||||
-- Copy End States
|
-- Copy End States
|
||||||
for EndStateID, EndState in pairs( self:GetEndStates() ) do
|
for EndStateID, EndState in pairs( self:GetEndStates() ) do
|
||||||
self:T( EndState )
|
--self:T3( EndState )
|
||||||
NewFsm:AddEndState( EndState )
|
NewFsm:AddEndState( EndState )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Copy the score tables
|
-- Copy the score tables
|
||||||
for ScoreID, Score in pairs( self:GetScores() ) do
|
for ScoreID, Score in pairs( self:GetScores() ) do
|
||||||
self:T( Score )
|
--self:T3( Score )
|
||||||
NewFsm:AddScore( ScoreID, Score.ScoreText, Score.Score )
|
NewFsm:AddScore( ScoreID, Score.ScoreText, Score.Score )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1422,7 +1422,7 @@ do -- FSM_SET
|
|||||||
-- @param #FSM_SET self
|
-- @param #FSM_SET self
|
||||||
-- @return Core.Set#SET_BASE
|
-- @return Core.Set#SET_BASE
|
||||||
function FSM_SET:Get()
|
function FSM_SET:Get()
|
||||||
return self.Controllable
|
return self.Set
|
||||||
end
|
end
|
||||||
|
|
||||||
function FSM_SET:_call_handler( step, trigger, params, EventName )
|
function FSM_SET:_call_handler( step, trigger, params, EventName )
|
||||||
|
|||||||
@@ -0,0 +1,267 @@
|
|||||||
|
--- **Core** - MarkerOps_Base.
|
||||||
|
--
|
||||||
|
-- **Main Features:**
|
||||||
|
--
|
||||||
|
-- * Create an easy way to tap into markers added to the F10 map by users.
|
||||||
|
-- * Recognize own tag and list of keywords.
|
||||||
|
-- * Matched keywords are handed down to functions.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### Author: **Applevangelist**
|
||||||
|
--
|
||||||
|
-- Date: 5 May 2021
|
||||||
|
-- Last Update: Sep 2022
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
---
|
||||||
|
-- @module Core.MarkerOps_Base
|
||||||
|
-- @image MOOSE_Core.JPG
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
-- MARKEROPS_BASE Class Definition.
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- MARKEROPS_BASE class.
|
||||||
|
-- @type MARKEROPS_BASE
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #string Tag Tag to identify commands.
|
||||||
|
-- @field #table Keywords Table of keywords to recognize.
|
||||||
|
-- @field #string version Version of #MARKEROPS_BASE.
|
||||||
|
-- @field #boolean Casesensitive Enforce case when identifying the Tag, i.e. tag ~= Tag
|
||||||
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
--- *Fiat lux.* -- Latin proverb.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # The MARKEROPS_BASE Concept
|
||||||
|
--
|
||||||
|
-- This class enable scripting text-based actions from markers.
|
||||||
|
--
|
||||||
|
-- @field #MARKEROPS_BASE
|
||||||
|
MARKEROPS_BASE = {
|
||||||
|
ClassName = "MARKEROPS",
|
||||||
|
Tag = "mytag",
|
||||||
|
Keywords = {},
|
||||||
|
version = "0.1.0",
|
||||||
|
debug = false,
|
||||||
|
Casesensitive = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Function to instantiate a new #MARKEROPS_BASE object.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string Tagname Name to identify us from the event text.
|
||||||
|
-- @param #table Keywords Table of keywords recognized from the event text.
|
||||||
|
-- @param #boolean Casesensitive (Optional) Switch case sensitive identification of Tagname. Defaults to true.
|
||||||
|
-- @return #MARKEROPS_BASE self
|
||||||
|
function MARKEROPS_BASE:New(Tagname,Keywords,Casesensitive)
|
||||||
|
-- Inherit FSM
|
||||||
|
local self=BASE:Inherit(self, FSM:New()) -- #MARKEROPS_BASE
|
||||||
|
|
||||||
|
-- Set some string id for output to DCS.log file.
|
||||||
|
self.lid=string.format("MARKEROPS_BASE %s | ", tostring(self.version))
|
||||||
|
|
||||||
|
self.Tag = Tagname or "mytag"-- #string
|
||||||
|
self.Keywords = Keywords or {} -- #table - might want to use lua regex here, too
|
||||||
|
self.debug = false
|
||||||
|
self.Casesensitive = true
|
||||||
|
|
||||||
|
if Casesensitive and Casesensitive == false then
|
||||||
|
self.Casesensitive = false
|
||||||
|
end
|
||||||
|
|
||||||
|
-----------------------
|
||||||
|
--- FSM Transitions ---
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
-- Start State.
|
||||||
|
self:SetStartState("Stopped")
|
||||||
|
|
||||||
|
-- Add FSM transitions.
|
||||||
|
-- From State --> Event --> To State
|
||||||
|
self:AddTransition("Stopped", "Start", "Running") -- Start the FSM.
|
||||||
|
self:AddTransition("*", "MarkAdded", "*") -- Start the FSM.
|
||||||
|
self:AddTransition("*", "MarkChanged", "*") -- Start the FSM.
|
||||||
|
self:AddTransition("*", "MarkDeleted", "*") -- Start the FSM.
|
||||||
|
self:AddTransition("Running", "Stop", "Stopped") -- Stop the FSM.
|
||||||
|
|
||||||
|
self:HandleEvent(EVENTS.MarkAdded, self.OnEventMark)
|
||||||
|
self:HandleEvent(EVENTS.MarkChange, self.OnEventMark)
|
||||||
|
self:HandleEvent(EVENTS.MarkRemoved, self.OnEventMark)
|
||||||
|
|
||||||
|
-- start
|
||||||
|
self:I(self.lid..string.format("started for %s",self.Tag))
|
||||||
|
self:__Start(1)
|
||||||
|
return self
|
||||||
|
|
||||||
|
-------------------
|
||||||
|
-- PSEUDO Functions
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
--- On after "MarkAdded" event. Triggered when a Marker is added to the F10 map.
|
||||||
|
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkAdded
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
-- @param #string Text The text on the marker
|
||||||
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
|
||||||
|
--- On after "MarkChanged" event. Triggered when a Marker is changed on the F10 map.
|
||||||
|
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkChanged
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
-- @param #string Text The text on the marker
|
||||||
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
|
||||||
|
--- On after "MarkDeleted" event. Triggered when a Marker is deleted from the F10 map.
|
||||||
|
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkDeleted
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
|
||||||
|
--- "Stop" trigger. Used to stop the function an unhandle events
|
||||||
|
-- @function [parent=#MARKEROPS_BASE] Stop
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (internal) Handle events.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param Core.Event#EVENTDATA Event
|
||||||
|
function MARKEROPS_BASE:OnEventMark(Event)
|
||||||
|
self:T({Event})
|
||||||
|
if Event == nil or Event.idx == nil then
|
||||||
|
self:E("Skipping onEvent. Event or Event.idx unknown.")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
--position
|
||||||
|
local vec3={y=Event.pos.y, x=Event.pos.x, z=Event.pos.z}
|
||||||
|
local coord=COORDINATE:NewFromVec3(vec3)
|
||||||
|
if self.debug then
|
||||||
|
local coordtext = coord:ToStringLLDDM()
|
||||||
|
local text = tostring(Event.text)
|
||||||
|
local m = MESSAGE:New(string.format("Mark added at %s with text: %s",coordtext,text),10,"Info",false):ToAll()
|
||||||
|
end
|
||||||
|
-- decision
|
||||||
|
if Event.id==world.event.S_EVENT_MARK_ADDED then
|
||||||
|
self:T({event="S_EVENT_MARK_ADDED", carrier=self.groupname, vec3=Event.pos})
|
||||||
|
-- Handle event
|
||||||
|
local Eventtext = tostring(Event.text)
|
||||||
|
if Eventtext~=nil then
|
||||||
|
if self:_MatchTag(Eventtext) then
|
||||||
|
local matchtable = self:_MatchKeywords(Eventtext)
|
||||||
|
self:MarkAdded(Eventtext,matchtable,coord)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Event.id==world.event.S_EVENT_MARK_CHANGE then
|
||||||
|
self:T({event="S_EVENT_MARK_CHANGE", carrier=self.groupname, vec3=Event.pos})
|
||||||
|
-- Handle event.
|
||||||
|
local Eventtext = tostring(Event.text)
|
||||||
|
if Eventtext~=nil then
|
||||||
|
if self:_MatchTag(Eventtext) then
|
||||||
|
local matchtable = self:_MatchKeywords(Eventtext)
|
||||||
|
self:MarkChanged(Eventtext,matchtable,coord)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Event.id==world.event.S_EVENT_MARK_REMOVED then
|
||||||
|
self:T({event="S_EVENT_MARK_REMOVED", carrier=self.groupname, vec3=Event.pos})
|
||||||
|
-- Hande event.
|
||||||
|
local Eventtext = tostring(Event.text)
|
||||||
|
if Eventtext~=nil then
|
||||||
|
if self:_MatchTag(Eventtext) then
|
||||||
|
self:MarkDeleted()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (internal) Match tag.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string Eventtext Text added to the marker.
|
||||||
|
-- @return #boolean
|
||||||
|
function MARKEROPS_BASE:_MatchTag(Eventtext)
|
||||||
|
local matches = false
|
||||||
|
if not self.Casesensitive then
|
||||||
|
local type = string.lower(self.Tag) -- #string
|
||||||
|
if string.find(string.lower(Eventtext),type) then
|
||||||
|
matches = true --event text contains tag
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local type = self.Tag -- #string
|
||||||
|
if string.find(Eventtext,type) then
|
||||||
|
matches = true --event text contains tag
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return matches
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (internal) Match keywords table.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string Eventtext Text added to the marker.
|
||||||
|
-- @return #table
|
||||||
|
function MARKEROPS_BASE:_MatchKeywords(Eventtext)
|
||||||
|
local matchtable = {}
|
||||||
|
local keytable = self.Keywords
|
||||||
|
for _index,_word in pairs (keytable) do
|
||||||
|
if string.find(string.lower(Eventtext),string.lower(_word))then
|
||||||
|
table.insert(matchtable,_word)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return matchtable
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On before "MarkAdded" event. Triggered when a Marker is added to the F10 map.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
-- @param #string Text The text on the marker
|
||||||
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
function MARKEROPS_BASE:onbeforeMarkAdded(From,Event,To,Text,Keywords,Coord)
|
||||||
|
self:T({self.lid,From,Event,To,Text,Keywords,Coord:ToStringLLDDM()})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On before "MarkChanged" event. Triggered when a Marker is changed on the F10 map.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
-- @param #string Text The text on the marker
|
||||||
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
function MARKEROPS_BASE:onbeforeMarkChanged(From,Event,To,Text,Keywords,Coord)
|
||||||
|
self:T({self.lid,From,Event,To,Text,Keywords,Coord:ToStringLLDDM()})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On before "MarkDeleted" event. Triggered when a Marker is removed from the F10 map.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
function MARKEROPS_BASE:onbeforeMarkDeleted(From,Event,To)
|
||||||
|
self:T({self.lid,From,Event,To})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On enter "Stopped" event. Unsubscribe events.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
function MARKEROPS_BASE:onenterStopped(From,Event,To)
|
||||||
|
self:T({self.lid,From,Event,To})
|
||||||
|
-- unsubscribe from events
|
||||||
|
self:UnHandleEvent(EVENTS.MarkAdded)
|
||||||
|
self:UnHandleEvent(EVENTS.MarkChange)
|
||||||
|
self:UnHandleEvent(EVENTS.MarkRemoved)
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
-- MARKEROPS_BASE Class Definition End.
|
||||||
|
--------------------------------------------------------------------------
|
||||||
@@ -64,7 +64,6 @@ MENU_INDEX.Coalition[coalition.side.RED].Menus = {}
|
|||||||
MENU_INDEX.Group = {}
|
MENU_INDEX.Group = {}
|
||||||
|
|
||||||
function MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
function MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
|
|
||||||
local Path = ParentMenu and "@" .. table.concat( ParentMenu.MenuPath or {}, "@" ) or ""
|
local Path = ParentMenu and "@" .. table.concat( ParentMenu.MenuPath or {}, "@" ) or ""
|
||||||
if ParentMenu then
|
if ParentMenu then
|
||||||
if ParentMenu:IsInstanceOf( "MENU_GROUP" ) or ParentMenu:IsInstanceOf( "MENU_GROUP_COMMAND" ) then
|
if ParentMenu:IsInstanceOf( "MENU_GROUP" ) or ParentMenu:IsInstanceOf( "MENU_GROUP_COMMAND" ) then
|
||||||
@@ -92,22 +91,20 @@ function MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
|||||||
|
|
||||||
Path = Path .. "@" .. MenuText
|
Path = Path .. "@" .. MenuText
|
||||||
return Path
|
return Path
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:PrepareMission()
|
function MENU_INDEX:PrepareMission()
|
||||||
self.MenuMission.Menus = self.MenuMission.Menus or {}
|
self.MenuMission.Menus = self.MenuMission.Menus or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:PrepareCoalition( CoalitionSide )
|
function MENU_INDEX:PrepareCoalition( CoalitionSide )
|
||||||
self.Coalition[CoalitionSide] = self.Coalition[CoalitionSide] or {}
|
self.Coalition[CoalitionSide] = self.Coalition[CoalitionSide] or {}
|
||||||
self.Coalition[CoalitionSide].Menus = self.Coalition[CoalitionSide].Menus or {}
|
self.Coalition[CoalitionSide].Menus = self.Coalition[CoalitionSide].Menus or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param Wrapper.Group#GROUP Group
|
-- @param Wrapper.Group#GROUP Group
|
||||||
function MENU_INDEX:PrepareGroup( Group )
|
function MENU_INDEX:PrepareGroup( Group )
|
||||||
if Group and Group:IsAlive() ~= nil then -- something was changed here!
|
if Group and Group:IsAlive() ~= nil then -- something was changed here!
|
||||||
local GroupName = Group:GetName()
|
local GroupName = Group:GetName()
|
||||||
self.Group[GroupName] = self.Group[GroupName] or {}
|
self.Group[GroupName] = self.Group[GroupName] or {}
|
||||||
self.Group[GroupName].Menus = self.Group[GroupName].Menus or {}
|
self.Group[GroupName].Menus = self.Group[GroupName].Menus or {}
|
||||||
@@ -115,32 +112,22 @@ function MENU_INDEX:PrepareGroup( Group )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:HasMissionMenu( Path )
|
function MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
return self.MenuMission.Menus[Path]
|
return self.MenuMission.Menus[Path]
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:SetMissionMenu( Path, Menu )
|
function MENU_INDEX:SetMissionMenu( Path, Menu )
|
||||||
|
|
||||||
self.MenuMission.Menus[Path] = Menu
|
self.MenuMission.Menus[Path] = Menu
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:ClearMissionMenu( Path )
|
function MENU_INDEX:ClearMissionMenu( Path )
|
||||||
|
|
||||||
self.MenuMission.Menus[Path] = nil
|
self.MenuMission.Menus[Path] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
function MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
||||||
|
|
||||||
return self.Coalition[Coalition].Menus[Path]
|
return self.Coalition[Coalition].Menus[Path]
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:SetCoalitionMenu( Coalition, Path, Menu )
|
function MENU_INDEX:SetCoalitionMenu( Coalition, Path, Menu )
|
||||||
|
|
||||||
self.Coalition[Coalition].Menus[Path] = Menu
|
self.Coalition[Coalition].Menus[Path] = Menu
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:ClearCoalitionMenu( Coalition, Path )
|
function MENU_INDEX:ClearCoalitionMenu( Coalition, Path )
|
||||||
|
|
||||||
self.Coalition[Coalition].Menus[Path] = nil
|
self.Coalition[Coalition].Menus[Path] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -151,46 +138,36 @@ function MENU_INDEX:HasGroupMenu( Group, Path )
|
|||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:SetGroupMenu( Group, Path, Menu )
|
function MENU_INDEX:SetGroupMenu( Group, Path, Menu )
|
||||||
|
|
||||||
local MenuGroupName = Group:GetName()
|
local MenuGroupName = Group:GetName()
|
||||||
Group:F( { MenuGroupName = MenuGroupName, Path = Path } )
|
Group:F({MenuGroupName=MenuGroupName,Path=Path})
|
||||||
self.Group[MenuGroupName].Menus[Path] = Menu
|
self.Group[MenuGroupName].Menus[Path] = Menu
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:ClearGroupMenu( Group, Path )
|
function MENU_INDEX:ClearGroupMenu( Group, Path )
|
||||||
|
|
||||||
local MenuGroupName = Group:GetName()
|
local MenuGroupName = Group:GetName()
|
||||||
self.Group[MenuGroupName].Menus[Path] = nil
|
self.Group[MenuGroupName].Menus[Path] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:Refresh( Group )
|
function MENU_INDEX:Refresh( Group )
|
||||||
|
for MenuID, Menu in pairs( self.MenuMission.Menus ) do
|
||||||
|
Menu:Refresh()
|
||||||
|
end
|
||||||
|
for MenuID, Menu in pairs( self.Coalition[coalition.side.BLUE].Menus ) do
|
||||||
|
Menu:Refresh()
|
||||||
|
end
|
||||||
|
for MenuID, Menu in pairs( self.Coalition[coalition.side.RED].Menus ) do
|
||||||
|
Menu:Refresh()
|
||||||
|
end
|
||||||
|
local GroupName = Group:GetName()
|
||||||
|
for MenuID, Menu in pairs( self.Group[GroupName].Menus ) do
|
||||||
|
Menu:Refresh()
|
||||||
|
end
|
||||||
|
|
||||||
for MenuID, Menu in pairs( self.MenuMission.Menus ) do
|
return self
|
||||||
Menu:Refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
for MenuID, Menu in pairs( self.Coalition[coalition.side.BLUE].Menus ) do
|
|
||||||
Menu:Refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
for MenuID, Menu in pairs( self.Coalition[coalition.side.RED].Menus ) do
|
|
||||||
Menu:Refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
local GroupName = Group:GetName()
|
|
||||||
for MenuID, Menu in pairs( self.Group[GroupName].Menus ) do
|
|
||||||
Menu:Refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_BASE
|
do -- MENU_BASE
|
||||||
|
|
||||||
--- @type MENU_BASE
|
--- @type MENU_BASE
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- Defines the main MENU class where other MENU classes are derived from.
|
--- Defines the main MENU class where other MENU classes are derived from.
|
||||||
-- This is an abstract class, so don't use it.
|
-- This is an abstract class, so don't use it.
|
||||||
-- @field #MENU_BASE
|
-- @field #MENU_BASE
|
||||||
@@ -210,14 +187,13 @@ do -- MENU_BASE
|
|||||||
if ParentMenu ~= nil then
|
if ParentMenu ~= nil then
|
||||||
MenuParentPath = ParentMenu.MenuPath
|
MenuParentPath = ParentMenu.MenuPath
|
||||||
end
|
end
|
||||||
|
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
|
||||||
self.MenuPath = nil
|
self.MenuPath = nil
|
||||||
self.MenuText = MenuText
|
self.MenuText = MenuText
|
||||||
self.ParentMenu = ParentMenu
|
self.ParentMenu = ParentMenu
|
||||||
self.MenuParentPath = MenuParentPath
|
self.MenuParentPath = MenuParentPath
|
||||||
self.Path = (self.ParentMenu and "@" .. table.concat( self.MenuParentPath or {}, "@" ) or "") .. "@" .. self.MenuText
|
self.Path = ( self.ParentMenu and "@" .. table.concat( self.MenuParentPath or {}, "@" ) or "" ) .. "@" .. self.MenuText
|
||||||
self.Menus = {}
|
self.Menus = {}
|
||||||
self.MenuCount = 0
|
self.MenuCount = 0
|
||||||
self.MenuStamp = timer.getTime()
|
self.MenuStamp = timer.getTime()
|
||||||
@@ -230,7 +206,6 @@ do -- MENU_BASE
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_BASE:SetParentMenu( MenuText, Menu )
|
function MENU_BASE:SetParentMenu( MenuText, Menu )
|
||||||
if self.ParentMenu then
|
if self.ParentMenu then
|
||||||
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
||||||
@@ -238,23 +213,21 @@ do -- MENU_BASE
|
|||||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_BASE:ClearParentMenu( MenuText )
|
function MENU_BASE:ClearParentMenu( MenuText )
|
||||||
if self.ParentMenu and self.ParentMenu.Menus[MenuText] then
|
if self.ParentMenu and self.ParentMenu.Menus[MenuText] then
|
||||||
self.ParentMenu.Menus[MenuText] = nil
|
self.ParentMenu.Menus[MenuText] = nil
|
||||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
||||||
if self.ParentMenu.MenuCount == 0 then
|
if self.ParentMenu.MenuCount == 0 then
|
||||||
-- self.ParentMenu:Remove()
|
--self.ParentMenu:Remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets a @{Menu} to remove automatically the parent menu when the menu removed is the last child menu of that parent @{Menu}.
|
--- Sets a @{Menu} to remove automatically the parent menu when the menu removed is the last child menu of that parent @{Menu}.
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @param #boolean RemoveParent If true, the parent menu is automatically removed when this menu is the last child menu of that parent @{Menu}.
|
-- @param #boolean RemoveParent If true, the parent menu is automatically removed when this menu is the last child menu of that parent @{Menu}.
|
||||||
-- @return #MENU_BASE
|
-- @return #MENU_BASE
|
||||||
function MENU_BASE:SetRemoveParent( RemoveParent )
|
function MENU_BASE:SetRemoveParent( RemoveParent )
|
||||||
-- self:F( { RemoveParent } )
|
--self:F( { RemoveParent } )
|
||||||
self.MenuRemoveParent = RemoveParent
|
self.MenuRemoveParent = RemoveParent
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -276,6 +249,7 @@ do -- MENU_BASE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Gets a menu stamp for later prevention of menu removal.
|
--- Gets a menu stamp for later prevention of menu removal.
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @return MenuStamp
|
-- @return MenuStamp
|
||||||
@@ -283,6 +257,7 @@ do -- MENU_BASE
|
|||||||
return timer.getTime()
|
return timer.getTime()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Sets a time stamp for later prevention of menu removal.
|
--- Sets a time stamp for later prevention of menu removal.
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @param MenuStamp
|
-- @param MenuStamp
|
||||||
@@ -302,9 +277,7 @@ do -- MENU_BASE
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_COMMAND_BASE
|
do -- MENU_COMMAND_BASE
|
||||||
|
|
||||||
--- @type MENU_COMMAND_BASE
|
--- @type MENU_COMMAND_BASE
|
||||||
-- @field #function MenuCallHandler
|
-- @field #function MenuCallHandler
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
@@ -326,7 +299,6 @@ do -- MENU_COMMAND_BASE
|
|||||||
function MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, CommandMenuArguments )
|
function MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, CommandMenuArguments )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) ) -- #MENU_COMMAND_BASE
|
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) ) -- #MENU_COMMAND_BASE
|
||||||
|
|
||||||
-- When a menu function goes into error, DCS displays an obscure menu message.
|
-- When a menu function goes into error, DCS displays an obscure menu message.
|
||||||
-- This error handler catches the menu error and displays the full call stack.
|
-- This error handler catches the menu error and displays the full call stack.
|
||||||
local ErrorHandler = function( errmsg )
|
local ErrorHandler = function( errmsg )
|
||||||
@@ -359,7 +331,6 @@ do -- MENU_COMMAND_BASE
|
|||||||
self.CommandMenuFunction = CommandMenuFunction
|
self.CommandMenuFunction = CommandMenuFunction
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- This sets the new command arguments of a menu,
|
--- This sets the new command arguments of a menu,
|
||||||
-- so that if a menu is regenerated, or if command arguments change,
|
-- so that if a menu is regenerated, or if command arguments change,
|
||||||
-- that the arguments set for the menu are loosely coupled with the menu itself!!!
|
-- that the arguments set for the menu are loosely coupled with the menu itself!!!
|
||||||
@@ -370,14 +341,11 @@ do -- MENU_COMMAND_BASE
|
|||||||
self.CommandMenuArguments = CommandMenuArguments
|
self.CommandMenuArguments = CommandMenuArguments
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_MISSION
|
do -- MENU_MISSION
|
||||||
|
|
||||||
--- @type MENU_MISSION
|
--- @type MENU_MISSION
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
--- Manages the main menus for a complete mission.
|
--- Manages the main menus for a complete mission.
|
||||||
--
|
--
|
||||||
-- You can add menus with the @{#MENU_MISSION.New} method, which constructs a MENU_MISSION object and returns you the object reference.
|
-- You can add menus with the @{#MENU_MISSION.New} method, which constructs a MENU_MISSION object and returns you the object reference.
|
||||||
@@ -397,7 +365,6 @@ do -- MENU_MISSION
|
|||||||
MENU_INDEX:PrepareMission()
|
MENU_INDEX:PrepareMission()
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
if MissionMenu then
|
if MissionMenu then
|
||||||
return MissionMenu
|
return MissionMenu
|
||||||
else
|
else
|
||||||
@@ -415,12 +382,11 @@ do -- MENU_MISSION
|
|||||||
-- @param #MENU_MISSION self
|
-- @param #MENU_MISSION self
|
||||||
-- @return #MENU_MISSION
|
-- @return #MENU_MISSION
|
||||||
function MENU_MISSION:Refresh()
|
function MENU_MISSION:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItem( self.MenuPath )
|
missionCommands.removeItem( self.MenuPath )
|
||||||
self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath )
|
self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath )
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_MISSION. Note that the main menu is kept!
|
--- Removes the sub menus recursively of this MENU_MISSION. Note that the main menu is kept!
|
||||||
@@ -444,11 +410,10 @@ do -- MENU_MISSION
|
|||||||
MENU_INDEX:PrepareMission()
|
MENU_INDEX:PrepareMission()
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
if MissionMenu == self then
|
if MissionMenu == self then
|
||||||
self:RemoveSubMenus()
|
self:RemoveSubMenus()
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
self:F( { Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Text = self.MenuText, Path = self.MenuPath } )
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
missionCommands.removeItem( self.MenuPath )
|
missionCommands.removeItem( self.MenuPath )
|
||||||
@@ -466,7 +431,6 @@ do -- MENU_MISSION
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_MISSION_COMMAND
|
do -- MENU_MISSION_COMMAND
|
||||||
|
|
||||||
--- @type MENU_MISSION_COMMAND
|
--- @type MENU_MISSION_COMMAND
|
||||||
@@ -494,7 +458,6 @@ do -- MENU_MISSION_COMMAND
|
|||||||
MENU_INDEX:PrepareMission()
|
MENU_INDEX:PrepareMission()
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
if MissionMenu then
|
if MissionMenu then
|
||||||
MissionMenu:SetCommandMenuFunction( CommandMenuFunction )
|
MissionMenu:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
MissionMenu:SetCommandMenuArguments( arg )
|
MissionMenu:SetCommandMenuArguments( arg )
|
||||||
@@ -508,17 +471,15 @@ do -- MENU_MISSION_COMMAND
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a mission
|
--- Refreshes a radio item for a mission
|
||||||
-- @param #MENU_MISSION_COMMAND self
|
-- @param #MENU_MISSION_COMMAND self
|
||||||
-- @return #MENU_MISSION_COMMAND
|
-- @return #MENU_MISSION_COMMAND
|
||||||
function MENU_MISSION_COMMAND:Refresh()
|
function MENU_MISSION_COMMAND:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItem( self.MenuPath )
|
missionCommands.removeItem( self.MenuPath )
|
||||||
missionCommands.addCommand( self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
missionCommands.addCommand( self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a radio command item for a coalition
|
--- Removes a radio command item for a coalition
|
||||||
@@ -529,10 +490,9 @@ do -- MENU_MISSION_COMMAND
|
|||||||
MENU_INDEX:PrepareMission()
|
MENU_INDEX:PrepareMission()
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
if MissionMenu == self then
|
if MissionMenu == self then
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
self:F( { Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Text = self.MenuText, Path = self.MenuPath } )
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
missionCommands.removeItem( self.MenuPath )
|
missionCommands.removeItem( self.MenuPath )
|
||||||
@@ -548,11 +508,8 @@ do -- MENU_MISSION_COMMAND
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_COALITION
|
do -- MENU_COALITION
|
||||||
|
|
||||||
--- @type MENU_COALITION
|
--- @type MENU_COALITION
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
@@ -601,7 +558,7 @@ do -- MENU_COALITION
|
|||||||
--
|
--
|
||||||
-- @field #MENU_COALITION
|
-- @field #MENU_COALITION
|
||||||
MENU_COALITION = {
|
MENU_COALITION = {
|
||||||
ClassName = "MENU_COALITION",
|
ClassName = "MENU_COALITION"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_COALITION constructor. Creates a new MENU_COALITION object and creates the menu for a complete coalition.
|
--- MENU_COALITION constructor. Creates a new MENU_COALITION object and creates the menu for a complete coalition.
|
||||||
@@ -611,15 +568,12 @@ do -- MENU_COALITION
|
|||||||
-- @param #table ParentMenu The parent menu. This parameter can be ignored if you want the menu to be located at the parent menu of DCS world (under F10 other).
|
-- @param #table ParentMenu The parent menu. This parameter can be ignored if you want the menu to be located at the parent menu of DCS world (under F10 other).
|
||||||
-- @return #MENU_COALITION self
|
-- @return #MENU_COALITION self
|
||||||
function MENU_COALITION:New( Coalition, MenuText, ParentMenu )
|
function MENU_COALITION:New( Coalition, MenuText, ParentMenu )
|
||||||
|
|
||||||
MENU_INDEX:PrepareCoalition( Coalition )
|
MENU_INDEX:PrepareCoalition( Coalition )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
||||||
|
|
||||||
if CoalitionMenu then
|
if CoalitionMenu then
|
||||||
return CoalitionMenu
|
return CoalitionMenu
|
||||||
else
|
else
|
||||||
|
|
||||||
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||||
MENU_INDEX:SetCoalitionMenu( Coalition, Path, self )
|
MENU_INDEX:SetCoalitionMenu( Coalition, Path, self )
|
||||||
|
|
||||||
@@ -630,17 +584,15 @@ do -- MENU_COALITION
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a coalition
|
--- Refreshes a radio item for a coalition
|
||||||
-- @param #MENU_COALITION self
|
-- @param #MENU_COALITION self
|
||||||
-- @return #MENU_COALITION
|
-- @return #MENU_COALITION
|
||||||
function MENU_COALITION:Refresh()
|
function MENU_COALITION:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
||||||
missionCommands.addSubMenuForCoalition( self.Coalition, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForCoalition( self.Coalition, self.MenuText, self.MenuParentPath )
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_COALITION. Note that the main menu is kept!
|
--- Removes the sub menus recursively of this MENU_COALITION. Note that the main menu is kept!
|
||||||
@@ -663,11 +615,10 @@ do -- MENU_COALITION
|
|||||||
MENU_INDEX:PrepareCoalition( self.Coalition )
|
MENU_INDEX:PrepareCoalition( self.Coalition )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
|
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
|
||||||
|
|
||||||
if CoalitionMenu == self then
|
if CoalitionMenu == self then
|
||||||
self:RemoveSubMenus()
|
self:RemoveSubMenus()
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
self:F( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
||||||
@@ -683,9 +634,7 @@ do -- MENU_COALITION
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_COALITION_COMMAND
|
do -- MENU_COALITION_COMMAND
|
||||||
|
|
||||||
--- @type MENU_COALITION_COMMAND
|
--- @type MENU_COALITION_COMMAND
|
||||||
@@ -698,7 +647,7 @@ do -- MENU_COALITION_COMMAND
|
|||||||
--
|
--
|
||||||
-- @field #MENU_COALITION_COMMAND
|
-- @field #MENU_COALITION_COMMAND
|
||||||
MENU_COALITION_COMMAND = {
|
MENU_COALITION_COMMAND = {
|
||||||
ClassName = "MENU_COALITION_COMMAND",
|
ClassName = "MENU_COALITION_COMMAND"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_COALITION constructor. Creates a new radio command item for a coalition, which can invoke a function with parameters.
|
--- MENU_COALITION constructor. Creates a new radio command item for a coalition, which can invoke a function with parameters.
|
||||||
@@ -714,7 +663,6 @@ do -- MENU_COALITION_COMMAND
|
|||||||
MENU_INDEX:PrepareCoalition( Coalition )
|
MENU_INDEX:PrepareCoalition( Coalition )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
||||||
|
|
||||||
if CoalitionMenu then
|
if CoalitionMenu then
|
||||||
CoalitionMenu:SetCommandMenuFunction( CommandMenuFunction )
|
CoalitionMenu:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
CoalitionMenu:SetCommandMenuArguments( arg )
|
CoalitionMenu:SetCommandMenuArguments( arg )
|
||||||
@@ -729,19 +677,17 @@ do -- MENU_COALITION_COMMAND
|
|||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a coalition
|
--- Refreshes a radio item for a coalition
|
||||||
-- @param #MENU_COALITION_COMMAND self
|
-- @param #MENU_COALITION_COMMAND self
|
||||||
-- @return #MENU_COALITION_COMMAND
|
-- @return #MENU_COALITION_COMMAND
|
||||||
function MENU_COALITION_COMMAND:Refresh()
|
function MENU_COALITION_COMMAND:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
||||||
missionCommands.addCommandForCoalition( self.Coalition, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
missionCommands.addCommandForCoalition( self.Coalition, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a radio command item for a coalition
|
--- Removes a radio command item for a coalition
|
||||||
@@ -752,10 +698,9 @@ do -- MENU_COALITION_COMMAND
|
|||||||
MENU_INDEX:PrepareCoalition( self.Coalition )
|
MENU_INDEX:PrepareCoalition( self.Coalition )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
|
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
|
||||||
|
|
||||||
if CoalitionMenu == self then
|
if CoalitionMenu == self then
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
self:F( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
||||||
@@ -771,22 +716,20 @@ do -- MENU_COALITION_COMMAND
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- MENU_GROUP
|
--- MENU_GROUP
|
||||||
|
|
||||||
do
|
do
|
||||||
-- This local variable is used to cache the menus registered under groups.
|
-- 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.
|
-- 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.
|
-- the same menus twice during initialization logic.
|
||||||
-- These menu classes are handling this logic with this variable.
|
-- These menu classes are handling this logic with this variable.
|
||||||
local _MENUGROUPS = {}
|
local _MENUGROUPS = {}
|
||||||
|
|
||||||
--- @type MENU_GROUP
|
--- @type MENU_GROUP
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
|
|
||||||
--- Manages the main menus for @{Wrapper.Group}s.
|
--- Manages the main menus for @{Wrapper.Group}s.
|
||||||
--
|
--
|
||||||
-- You can add menus with the @{#MENU_GROUP.New} method, which constructs a MENU_GROUP object and returns you the object reference.
|
-- You can add menus with the @{#MENU_GROUP.New} method, which constructs a MENU_GROUP object and returns you the object reference.
|
||||||
@@ -844,7 +787,7 @@ do
|
|||||||
--
|
--
|
||||||
-- @field #MENU_GROUP
|
-- @field #MENU_GROUP
|
||||||
MENU_GROUP = {
|
MENU_GROUP = {
|
||||||
ClassName = "MENU_GROUP",
|
ClassName = "MENU_GROUP"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_GROUP constructor. Creates a new radio menu item for a group.
|
--- MENU_GROUP constructor. Creates a new radio menu item for a group.
|
||||||
@@ -858,16 +801,13 @@ do
|
|||||||
MENU_INDEX:PrepareGroup( Group )
|
MENU_INDEX:PrepareGroup( Group )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
||||||
|
|
||||||
if GroupMenu then
|
if GroupMenu then
|
||||||
return GroupMenu
|
return GroupMenu
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||||
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
||||||
|
|
||||||
self.Group = Group
|
self.Group = Group
|
||||||
self.GroupID = Group:GetID()
|
self.GroupID = Group:GetID()
|
||||||
|
|
||||||
self.MenuPath = missionCommands.addSubMenuForGroup( self.GroupID, MenuText, self.MenuParentPath )
|
self.MenuPath = missionCommands.addSubMenuForGroup( self.GroupID, MenuText, self.MenuParentPath )
|
||||||
|
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
@@ -880,7 +820,6 @@ do
|
|||||||
-- @param #MENU_GROUP self
|
-- @param #MENU_GROUP self
|
||||||
-- @return #MENU_GROUP
|
-- @return #MENU_GROUP
|
||||||
function MENU_GROUP:Refresh()
|
function MENU_GROUP:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
@@ -890,6 +829,30 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Refreshes a new radio item for a group and submenus, ordering by (numerical) MenuTag
|
||||||
|
-- @param #MENU_GROUP self
|
||||||
|
-- @return #MENU_GROUP
|
||||||
|
function MENU_GROUP:RefreshAndOrderByTag()
|
||||||
|
|
||||||
|
do
|
||||||
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
|
|
||||||
|
local MenuTable = {}
|
||||||
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
|
local tag = Menu.MenuTag or math.random(1,10000)
|
||||||
|
MenuTable[#MenuTable+1] = {Tag=tag, Enty=Menu}
|
||||||
|
end
|
||||||
|
table.sort(MenuTable, function (k1, k2) return k1.tag < k2.tag end )
|
||||||
|
for _, Menu in pairs( MenuTable ) do
|
||||||
|
Menu.Entry:Refresh()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_GROUP.
|
--- Removes the sub menus recursively of this MENU_GROUP.
|
||||||
@@ -898,7 +861,6 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #MENU_GROUP self
|
-- @return #MENU_GROUP self
|
||||||
function MENU_GROUP:RemoveSubMenus( MenuStamp, MenuTag )
|
function MENU_GROUP:RemoveSubMenus( MenuStamp, MenuTag )
|
||||||
|
|
||||||
for MenuText, Menu in pairs( self.Menus or {} ) do
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Remove( MenuStamp, MenuTag )
|
Menu:Remove( MenuStamp, MenuTag )
|
||||||
end
|
end
|
||||||
@@ -913,15 +875,13 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP:Remove( MenuStamp, MenuTag )
|
function MENU_GROUP:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( self.Group )
|
MENU_INDEX:PrepareGroup( self.Group )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
||||||
|
|
||||||
if GroupMenu == self then
|
if GroupMenu == self then
|
||||||
self:RemoveSubMenus( MenuStamp, MenuTag )
|
self:RemoveSubMenus( MenuStamp, MenuTag )
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
@@ -939,6 +899,7 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @type MENU_GROUP_COMMAND
|
--- @type MENU_GROUP_COMMAND
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
@@ -948,7 +909,7 @@ do
|
|||||||
--
|
--
|
||||||
-- @field #MENU_GROUP_COMMAND
|
-- @field #MENU_GROUP_COMMAND
|
||||||
MENU_GROUP_COMMAND = {
|
MENU_GROUP_COMMAND = {
|
||||||
ClassName = "MENU_GROUP_COMMAND",
|
ClassName = "MENU_GROUP_COMMAND"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Creates a new radio command item for a group
|
--- Creates a new radio command item for a group
|
||||||
@@ -960,18 +921,15 @@ do
|
|||||||
-- @param CommandMenuArgument An argument for the function.
|
-- @param CommandMenuArgument An argument for the function.
|
||||||
-- @return #MENU_GROUP_COMMAND
|
-- @return #MENU_GROUP_COMMAND
|
||||||
function MENU_GROUP_COMMAND:New( Group, MenuText, ParentMenu, CommandMenuFunction, ... )
|
function MENU_GROUP_COMMAND:New( Group, MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( Group )
|
MENU_INDEX:PrepareGroup( Group )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
||||||
|
|
||||||
if GroupMenu then
|
if GroupMenu then
|
||||||
GroupMenu:SetCommandMenuFunction( CommandMenuFunction )
|
GroupMenu:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
GroupMenu:SetCommandMenuArguments( arg )
|
GroupMenu:SetCommandMenuArguments( arg )
|
||||||
return GroupMenu
|
return GroupMenu
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||||
|
|
||||||
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
||||||
|
|
||||||
self.Group = Group
|
self.Group = Group
|
||||||
@@ -982,19 +940,17 @@ do
|
|||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a group
|
--- Refreshes a radio item for a group
|
||||||
-- @param #MENU_GROUP_COMMAND self
|
-- @param #MENU_GROUP_COMMAND self
|
||||||
-- @return #MENU_GROUP_COMMAND
|
-- @return #MENU_GROUP_COMMAND
|
||||||
function MENU_GROUP_COMMAND:Refresh()
|
function MENU_GROUP_COMMAND:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a menu structure for a group.
|
--- Removes a menu structure for a group.
|
||||||
@@ -1003,16 +959,14 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP_COMMAND:Remove( MenuStamp, MenuTag )
|
function MENU_GROUP_COMMAND:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( self.Group )
|
MENU_INDEX:PrepareGroup( self.Group )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
||||||
|
|
||||||
if GroupMenu == self then
|
if GroupMenu == self then
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
end
|
end
|
||||||
MENU_INDEX:ClearGroupMenu( self.Group, Path )
|
MENU_INDEX:ClearGroupMenu( self.Group, Path )
|
||||||
@@ -1026,16 +980,13 @@ do
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- MENU_GROUP_DELAYED
|
--- MENU_GROUP_DELAYED
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
--- @type MENU_GROUP_DELAYED
|
--- @type MENU_GROUP_DELAYED
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
|
|
||||||
--- The MENU_GROUP_DELAYED class manages the main menus for groups.
|
--- The MENU_GROUP_DELAYED class manages the main menus for groups.
|
||||||
-- You can add menus with the @{#MENU_GROUP.New} method, which constructs a MENU_GROUP object and returns you the object reference.
|
-- You can add menus with the @{#MENU_GROUP.New} method, which constructs a MENU_GROUP object and returns you the object reference.
|
||||||
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_GROUP.Remove}.
|
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_GROUP.Remove}.
|
||||||
@@ -1045,7 +996,7 @@ do
|
|||||||
--
|
--
|
||||||
-- @field #MENU_GROUP_DELAYED
|
-- @field #MENU_GROUP_DELAYED
|
||||||
MENU_GROUP_DELAYED = {
|
MENU_GROUP_DELAYED = {
|
||||||
ClassName = "MENU_GROUP_DELAYED",
|
ClassName = "MENU_GROUP_DELAYED"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_GROUP_DELAYED constructor. Creates a new radio menu item for a group.
|
--- MENU_GROUP_DELAYED constructor. Creates a new radio menu item for a group.
|
||||||
@@ -1059,16 +1010,13 @@ do
|
|||||||
MENU_INDEX:PrepareGroup( Group )
|
MENU_INDEX:PrepareGroup( Group )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
||||||
|
|
||||||
if GroupMenu then
|
if GroupMenu then
|
||||||
return GroupMenu
|
return GroupMenu
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||||
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
||||||
|
|
||||||
self.Group = Group
|
self.Group = Group
|
||||||
self.GroupID = Group:GetID()
|
self.GroupID = Group:GetID()
|
||||||
|
|
||||||
if self.MenuParentPath then
|
if self.MenuParentPath then
|
||||||
self.MenuPath = UTILS.DeepCopy( self.MenuParentPath )
|
self.MenuPath = UTILS.DeepCopy( self.MenuParentPath )
|
||||||
else
|
else
|
||||||
@@ -1086,7 +1034,6 @@ do
|
|||||||
-- @param #MENU_GROUP_DELAYED self
|
-- @param #MENU_GROUP_DELAYED self
|
||||||
-- @return #MENU_GROUP_DELAYED
|
-- @return #MENU_GROUP_DELAYED
|
||||||
function MENU_GROUP_DELAYED:Set()
|
function MENU_GROUP_DELAYED:Set()
|
||||||
|
|
||||||
do
|
do
|
||||||
if not self.MenuSet then
|
if not self.MenuSet then
|
||||||
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
@@ -1097,14 +1044,12 @@ do
|
|||||||
Menu:Set()
|
Menu:Set()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a new radio item for a group and submenus
|
--- Refreshes a new radio item for a group and submenus
|
||||||
-- @param #MENU_GROUP_DELAYED self
|
-- @param #MENU_GROUP_DELAYED self
|
||||||
-- @return #MENU_GROUP_DELAYED
|
-- @return #MENU_GROUP_DELAYED
|
||||||
function MENU_GROUP_DELAYED:Refresh()
|
function MENU_GROUP_DELAYED:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
@@ -1114,6 +1059,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_GROUP_DELAYED.
|
--- Removes the sub menus recursively of this MENU_GROUP_DELAYED.
|
||||||
@@ -1122,7 +1068,6 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #MENU_GROUP_DELAYED self
|
-- @return #MENU_GROUP_DELAYED self
|
||||||
function MENU_GROUP_DELAYED:RemoveSubMenus( MenuStamp, MenuTag )
|
function MENU_GROUP_DELAYED:RemoveSubMenus( MenuStamp, MenuTag )
|
||||||
|
|
||||||
for MenuText, Menu in pairs( self.Menus or {} ) do
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Remove( MenuStamp, MenuTag )
|
Menu:Remove( MenuStamp, MenuTag )
|
||||||
end
|
end
|
||||||
@@ -1137,15 +1082,13 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP_DELAYED:Remove( MenuStamp, MenuTag )
|
function MENU_GROUP_DELAYED:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( self.Group )
|
MENU_INDEX:PrepareGroup( self.Group )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
||||||
|
|
||||||
if GroupMenu == self then
|
if GroupMenu == self then
|
||||||
self:RemoveSubMenus( MenuStamp, MenuTag )
|
self:RemoveSubMenus( MenuStamp, MenuTag )
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
@@ -1163,6 +1106,7 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @type MENU_GROUP_COMMAND_DELAYED
|
--- @type MENU_GROUP_COMMAND_DELAYED
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
@@ -1173,7 +1117,7 @@ do
|
|||||||
--
|
--
|
||||||
-- @field #MENU_GROUP_COMMAND_DELAYED
|
-- @field #MENU_GROUP_COMMAND_DELAYED
|
||||||
MENU_GROUP_COMMAND_DELAYED = {
|
MENU_GROUP_COMMAND_DELAYED = {
|
||||||
ClassName = "MENU_GROUP_COMMAND_DELAYED",
|
ClassName = "MENU_GROUP_COMMAND_DELAYED"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Creates a new radio command item for a group
|
--- Creates a new radio command item for a group
|
||||||
@@ -1185,18 +1129,15 @@ do
|
|||||||
-- @param CommandMenuArgument An argument for the function.
|
-- @param CommandMenuArgument An argument for the function.
|
||||||
-- @return #MENU_GROUP_COMMAND_DELAYED
|
-- @return #MENU_GROUP_COMMAND_DELAYED
|
||||||
function MENU_GROUP_COMMAND_DELAYED:New( Group, MenuText, ParentMenu, CommandMenuFunction, ... )
|
function MENU_GROUP_COMMAND_DELAYED:New( Group, MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( Group )
|
MENU_INDEX:PrepareGroup( Group )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
||||||
|
|
||||||
if GroupMenu then
|
if GroupMenu then
|
||||||
GroupMenu:SetCommandMenuFunction( CommandMenuFunction )
|
GroupMenu:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
GroupMenu:SetCommandMenuArguments( arg )
|
GroupMenu:SetCommandMenuArguments( arg )
|
||||||
return GroupMenu
|
return GroupMenu
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||||
|
|
||||||
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
||||||
|
|
||||||
self.Group = Group
|
self.Group = Group
|
||||||
@@ -1212,33 +1153,29 @@ do
|
|||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a group
|
--- Refreshes a radio item for a group
|
||||||
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
||||||
-- @return #MENU_GROUP_COMMAND_DELAYED
|
-- @return #MENU_GROUP_COMMAND_DELAYED
|
||||||
function MENU_GROUP_COMMAND_DELAYED:Set()
|
function MENU_GROUP_COMMAND_DELAYED:Set()
|
||||||
|
|
||||||
do
|
do
|
||||||
if not self.MenuSet then
|
if not self.MenuSet then
|
||||||
self.MenuPath = missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
self.MenuPath = missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
self.MenuSet = true
|
self.MenuSet = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a group
|
--- Refreshes a radio item for a group
|
||||||
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
||||||
-- @return #MENU_GROUP_COMMAND_DELAYED
|
-- @return #MENU_GROUP_COMMAND_DELAYED
|
||||||
function MENU_GROUP_COMMAND_DELAYED:Refresh()
|
function MENU_GROUP_COMMAND_DELAYED:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a menu structure for a group.
|
--- Removes a menu structure for a group.
|
||||||
@@ -1247,14 +1184,12 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP_COMMAND_DELAYED:Remove( MenuStamp, MenuTag )
|
function MENU_GROUP_COMMAND_DELAYED:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( self.Group )
|
MENU_INDEX:PrepareGroup( self.Group )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
||||||
|
|
||||||
if GroupMenu == self then
|
if GroupMenu == self then
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
@@ -1270,6 +1205,4 @@ do
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
-- * Send message to all players.
|
-- * Send message to all players.
|
||||||
-- * Send messages to a coalition.
|
-- * Send messages to a coalition.
|
||||||
-- * Send messages to a specific group.
|
-- * Send messages to a specific group.
|
||||||
|
-- * Send messages to a specific unit or client.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
--
|
--
|
||||||
-- * To a @{Client} using @{#MESSAGE.ToClient}().
|
-- * To a @{Client} using @{#MESSAGE.ToClient}().
|
||||||
-- * To a @{Wrapper.Group} using @{#MESSAGE.ToGroup}()
|
-- * To a @{Wrapper.Group} using @{#MESSAGE.ToGroup}()
|
||||||
|
-- * To a @{Wrapper.Unit} using @{#MESSAGE.ToUnit}()
|
||||||
-- * To a coalition using @{#MESSAGE.ToCoalition}().
|
-- * To a coalition using @{#MESSAGE.ToCoalition}().
|
||||||
-- * To the red coalition using @{#MESSAGE.ToRed}().
|
-- * To the red coalition using @{#MESSAGE.ToRed}().
|
||||||
-- * To the blue coalition using @{#MESSAGE.ToBlue}().
|
-- * To the blue coalition using @{#MESSAGE.ToBlue}().
|
||||||
@@ -194,19 +196,22 @@ function MESSAGE:ToClient( Client, Settings )
|
|||||||
if Client and Client:GetClientGroupID() then
|
if Client and Client:GetClientGroupID() then
|
||||||
|
|
||||||
if self.MessageType then
|
if self.MessageType then
|
||||||
local Settings = Settings or (Client and _DATABASE:GetPlayerSettings( Client:GetPlayerName() )) or _SETTINGS -- Core.Settings#SETTINGS
|
local Settings = Settings or ( Client and _DATABASE:GetPlayerSettings( Client:GetPlayerName() ) ) or _SETTINGS -- Core.Settings#SETTINGS
|
||||||
self.MessageDuration = Settings:GetMessageTime( self.MessageType )
|
self.MessageDuration = Settings:GetMessageTime( self.MessageType )
|
||||||
self.MessageCategory = "" -- self.MessageType .. ": "
|
self.MessageCategory = "" -- self.MessageType .. ": "
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.MessageDuration ~= 0 then
|
local Unit = Client:GetClient()
|
||||||
local ClientGroupID = Client:GetClientGroupID()
|
|
||||||
self:T( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ) .. " / " .. self.MessageDuration )
|
|
||||||
trigger.action.outTextForGroup( ClientGroupID, self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
if self.MessageDuration ~= 0 then
|
||||||
|
local ClientGroupID = Client:GetClientGroupID()
|
||||||
|
self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
|
||||||
|
--trigger.action.outTextForGroup( ClientGroupID, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen)
|
||||||
|
trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sends a MESSAGE to a Group.
|
--- Sends a MESSAGE to a Group.
|
||||||
@@ -232,6 +237,55 @@ function MESSAGE:ToGroup( Group, Settings )
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sends a MESSAGE to a Unit.
|
||||||
|
-- @param #MESSAGE self
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit to which the message is displayed.
|
||||||
|
-- @return #MESSAGE Message object.
|
||||||
|
function MESSAGE:ToUnit( Unit, Settings )
|
||||||
|
self:F( Unit.IdentifiableName )
|
||||||
|
|
||||||
|
if Unit then
|
||||||
|
|
||||||
|
if self.MessageType then
|
||||||
|
local Settings = Settings or ( Unit and _DATABASE:GetPlayerSettings( Unit:GetPlayerName() ) ) or _SETTINGS -- Core.Settings#SETTINGS
|
||||||
|
self.MessageDuration = Settings:GetMessageTime( self.MessageType )
|
||||||
|
self.MessageCategory = "" -- self.MessageType .. ": "
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.MessageDuration ~= 0 then
|
||||||
|
self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
|
||||||
|
trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration, self.ClearScreen )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Sends a MESSAGE to a Unit.
|
||||||
|
-- @param #MESSAGE self
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit to which the message is displayed.
|
||||||
|
-- @return #MESSAGE Message object.
|
||||||
|
function MESSAGE:ToUnit( Unit, Settings )
|
||||||
|
self:F( Unit.IdentifiableName )
|
||||||
|
|
||||||
|
if Unit then
|
||||||
|
|
||||||
|
if self.MessageType then
|
||||||
|
local Settings = Settings or ( Unit and _DATABASE:GetPlayerSettings( Unit:GetPlayerName() ) ) or _SETTINGS -- Core.Settings#SETTINGS
|
||||||
|
self.MessageDuration = Settings:GetMessageTime( self.MessageType )
|
||||||
|
self.MessageCategory = "" -- self.MessageType .. ": "
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.MessageDuration ~= 0 then
|
||||||
|
self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
|
||||||
|
trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration, self.ClearScreen )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Sends a MESSAGE to the Blue coalition.
|
--- Sends a MESSAGE to the Blue coalition.
|
||||||
-- @param #MESSAGE self
|
-- @param #MESSAGE self
|
||||||
-- @return #MESSAGE
|
-- @return #MESSAGE
|
||||||
|
|||||||
+1043
-696
File diff suppressed because it is too large
Load Diff
@@ -109,9 +109,11 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
||||||
|
|
||||||
if Scheduler.MasterObject then
|
if Scheduler.MasterObject then
|
||||||
|
--env.info("FF Object Scheduler")
|
||||||
self.ObjectSchedulers[CallID] = Scheduler
|
self.ObjectSchedulers[CallID] = Scheduler
|
||||||
self:F3( { CallID = CallID, ObjectScheduler = tostring( self.ObjectSchedulers[CallID] ), MasterObject = tostring( Scheduler.MasterObject ) } )
|
self:F3( { CallID = CallID, ObjectScheduler = tostring( self.ObjectSchedulers[CallID] ), MasterObject = tostring( Scheduler.MasterObject ) } )
|
||||||
else
|
else
|
||||||
|
--env.info("FF Persistent Scheduler")
|
||||||
self.PersistentSchedulers[CallID] = Scheduler
|
self.PersistentSchedulers[CallID] = Scheduler
|
||||||
self:F3( { CallID = CallID, PersistentScheduler = self.PersistentSchedulers[CallID] } )
|
self:F3( { CallID = CallID, PersistentScheduler = self.PersistentSchedulers[CallID] } )
|
||||||
end
|
end
|
||||||
@@ -121,8 +123,8 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self.Schedule[Scheduler][CallID] = {} -- #SCHEDULEDISPATCHER.ScheduleData
|
self.Schedule[Scheduler][CallID] = {} -- #SCHEDULEDISPATCHER.ScheduleData
|
||||||
self.Schedule[Scheduler][CallID].Function = ScheduleFunction
|
self.Schedule[Scheduler][CallID].Function = ScheduleFunction
|
||||||
self.Schedule[Scheduler][CallID].Arguments = ScheduleArguments
|
self.Schedule[Scheduler][CallID].Arguments = ScheduleArguments
|
||||||
self.Schedule[Scheduler][CallID].StartTime = timer.getTime() + (Start or 0)
|
self.Schedule[Scheduler][CallID].StartTime = timer.getTime() + ( Start or 0 )
|
||||||
self.Schedule[Scheduler][CallID].Start = Start + 0.1
|
self.Schedule[Scheduler][CallID].Start = Start + 0.001
|
||||||
self.Schedule[Scheduler][CallID].Repeat = Repeat or 0
|
self.Schedule[Scheduler][CallID].Repeat = Repeat or 0
|
||||||
self.Schedule[Scheduler][CallID].Randomize = Randomize or 0
|
self.Schedule[Scheduler][CallID].Randomize = Randomize or 0
|
||||||
self.Schedule[Scheduler][CallID].Stop = Stop
|
self.Schedule[Scheduler][CallID].Stop = Stop
|
||||||
@@ -217,6 +219,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
if ShowTrace then
|
if ShowTrace then
|
||||||
SchedulerObject:T( Prefix .. Name .. ":" .. Line .. " (" .. Source .. ")" )
|
SchedulerObject:T( Prefix .. Name .. ":" .. Line .. " (" .. Source .. ")" )
|
||||||
end
|
end
|
||||||
|
-- The master object is passed as first parameter. A few :Schedule() calls in MOOSE expect this currently. But in principle it should be removed.
|
||||||
return ScheduleFunction( SchedulerObject, unpack( ScheduleArguments ) )
|
return ScheduleFunction( SchedulerObject, unpack( ScheduleArguments ) )
|
||||||
end
|
end
|
||||||
Status, Result = xpcall( Timer, ErrorHandler )
|
Status, Result = xpcall( Timer, ErrorHandler )
|
||||||
@@ -314,7 +317,7 @@ end
|
|||||||
--- Stop dispatcher.
|
--- Stop dispatcher.
|
||||||
-- @param #SCHEDULEDISPATCHER self
|
-- @param #SCHEDULEDISPATCHER self
|
||||||
-- @param Core.Scheduler#SCHEDULER Scheduler Scheduler object.
|
-- @param Core.Scheduler#SCHEDULER Scheduler Scheduler object.
|
||||||
-- @param #table CallID Call ID.
|
-- @param #string CallID (Optional) Scheduler Call ID. If nil, all pending schedules are stopped recursively.
|
||||||
function SCHEDULEDISPATCHER:Stop( Scheduler, CallID )
|
function SCHEDULEDISPATCHER:Stop( Scheduler, CallID )
|
||||||
self:F2( { Stop = CallID, Scheduler = Scheduler } )
|
self:F2( { Stop = CallID, Scheduler = Scheduler } )
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
--
|
--
|
||||||
-- # Demo Missions
|
-- # Demo Missions
|
||||||
--
|
--
|
||||||
-- ### [SCHEDULER Demo Missions source code](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/SCH%20-%20Scheduler)
|
-- ### [SCHEDULER Demo Missions source code](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCH%20-%20Scheduler)
|
||||||
--
|
--
|
||||||
-- ### [SCHEDULER Demo Missions, only for beta testers](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCH%20-%20Scheduler)
|
-- ### [SCHEDULER Demo Missions, only for beta testers](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCH%20-%20Scheduler)
|
||||||
--
|
--
|
||||||
@@ -237,7 +237,7 @@ end
|
|||||||
-- @param #number Stop Time interval in seconds after which the scheduler will be stopped.
|
-- @param #number Stop Time interval in seconds after which the scheduler will be stopped.
|
||||||
-- @param #number TraceLevel Trace level [0,3]. Default 3.
|
-- @param #number TraceLevel Trace level [0,3]. Default 3.
|
||||||
-- @param Core.Fsm#FSM Fsm Finite state model.
|
-- @param Core.Fsm#FSM Fsm Finite state model.
|
||||||
-- @return #table The ScheduleID of the planned schedule.
|
-- @return #string The Schedule ID of the planned schedule.
|
||||||
function SCHEDULER:Schedule( MasterObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop, TraceLevel, Fsm )
|
function SCHEDULER:Schedule( MasterObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop, TraceLevel, Fsm )
|
||||||
self:F2( { Start, Repeat, RandomizeFactor, Stop } )
|
self:F2( { Start, Repeat, RandomizeFactor, Stop } )
|
||||||
self:T3( { SchedulerArguments } )
|
self:T3( { SchedulerArguments } )
|
||||||
@@ -271,7 +271,7 @@ end
|
|||||||
|
|
||||||
--- (Re-)Starts the schedules or a specific schedule if a valid ScheduleID is provided.
|
--- (Re-)Starts the schedules or a specific schedule if a valid ScheduleID is provided.
|
||||||
-- @param #SCHEDULER self
|
-- @param #SCHEDULER self
|
||||||
-- @param #string ScheduleID (Optional) The ScheduleID of the planned (repeating) schedule.
|
-- @param #string ScheduleID (Optional) The Schedule ID of the planned (repeating) schedule.
|
||||||
function SCHEDULER:Start( ScheduleID )
|
function SCHEDULER:Start( ScheduleID )
|
||||||
self:F3( { ScheduleID } )
|
self:F3( { ScheduleID } )
|
||||||
self:T( string.format( "Starting scheduler ID=%s", tostring( ScheduleID ) ) )
|
self:T( string.format( "Starting scheduler ID=%s", tostring( ScheduleID ) ) )
|
||||||
|
|||||||
@@ -201,9 +201,7 @@ do -- SET_BASE
|
|||||||
self:F2( { ObjectName = ObjectName } )
|
self:F2( { ObjectName = ObjectName } )
|
||||||
|
|
||||||
local TriggerEvent = true
|
local TriggerEvent = true
|
||||||
if NoTriggerEvent == false then
|
if NoTriggerEvent then TriggerEvent = false end
|
||||||
TriggerEvent = false
|
|
||||||
end
|
|
||||||
|
|
||||||
local Object = self.Set[ObjectName]
|
local Object = self.Set[ObjectName]
|
||||||
|
|
||||||
@@ -265,11 +263,11 @@ do -- SET_BASE
|
|||||||
-- @return Core.Base#BASE The added BASE Object.
|
-- @return Core.Base#BASE The added BASE Object.
|
||||||
function SET_BASE:SortByName()
|
function SET_BASE:SortByName()
|
||||||
|
|
||||||
local function sort( a, b )
|
local function sort(a, b)
|
||||||
return a < b
|
return a<b
|
||||||
end
|
end
|
||||||
|
|
||||||
table.sort( self.Index )
|
table.sort(self.Index)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -277,15 +275,16 @@ do -- SET_BASE
|
|||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @param Core.Set#SET_BASE SetToAdd Set to add.
|
-- @param Core.Set#SET_BASE SetToAdd Set to add.
|
||||||
-- @return #SET_BASE self
|
-- @return #SET_BASE self
|
||||||
function SET_BASE:AddSet( SetToAdd )
|
function SET_BASE:AddSet(SetToAdd)
|
||||||
|
|
||||||
for _, ObjectB in pairs( SetToAdd.Set ) do
|
for _,ObjectB in pairs(SetToAdd.Set) do
|
||||||
self:AddObject( ObjectB )
|
self:AddObject(ObjectB)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the *union* of two sets.
|
--- Get the *union* of two sets.
|
||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @param Core.Set#SET_BASE SetB Set *B*.
|
-- @param Core.Set#SET_BASE SetB Set *B*.
|
||||||
@@ -309,15 +308,16 @@ do -- SET_BASE
|
|||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @param Core.Set#SET_BASE SetB Set other set, called *B*.
|
-- @param Core.Set#SET_BASE SetB Set other set, called *B*.
|
||||||
-- @return Core.Set#SET_BASE A set of objects that is included in set *A* **and** in set *B*.
|
-- @return Core.Set#SET_BASE A set of objects that is included in set *A* **and** in set *B*.
|
||||||
function SET_BASE:GetSetIntersection( SetB )
|
|
||||||
|
|
||||||
local intersection = SET_BASE:New()
|
function SET_BASE:GetSetIntersection(SetB)
|
||||||
|
|
||||||
local union = self:GetSetUnion( SetB )
|
local intersection=SET_BASE:New()
|
||||||
|
|
||||||
for _, Object in pairs( union.Set ) do
|
local union=self:GetSetUnion(SetB)
|
||||||
if self:IsIncludeObject( Object ) and SetB:IsIncludeObject( Object ) then
|
|
||||||
intersection:AddObject( intersection )
|
for _,Object in pairs(union.Set) do
|
||||||
|
if self:IsIncludeObject(Object) and SetB:IsIncludeObject(Object) then
|
||||||
|
intersection:AddObject(Object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -330,11 +330,11 @@ do -- SET_BASE
|
|||||||
-- @return Core.Set#SET_BASE The set of objects that are in set *B* but **not** in this set *A*.
|
-- @return Core.Set#SET_BASE The set of objects that are in set *B* but **not** in this set *A*.
|
||||||
function SET_BASE:GetSetComplement( SetB )
|
function SET_BASE:GetSetComplement( SetB )
|
||||||
|
|
||||||
local complement = self:GetSetUnion( SetB )
|
local complement = self:GetSetUnion(SetB)
|
||||||
local intersection = self:GetSetIntersection( SetB )
|
local intersection = self:GetSetIntersection(SetB)
|
||||||
|
|
||||||
for _, Object in pairs( intersection.Set ) do
|
for _,Object in pairs(intersection.Set) do
|
||||||
complement:Remove( Object.ObjectName, true )
|
complement:Remove(Object.ObjectName,true)
|
||||||
end
|
end
|
||||||
|
|
||||||
return complement
|
return complement
|
||||||
@@ -765,6 +765,7 @@ do -- SET_BASE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
----- Iterate the SET_BASE and call an iterator function for each **alive** unit, providing the Unit and optional parameters.
|
----- Iterate the SET_BASE and call an iterator function for each **alive** unit, providing the Unit and optional parameters.
|
||||||
---- @param #SET_BASE self
|
---- @param #SET_BASE self
|
||||||
---- @param #function IteratorFunction The function that will be called when there is an alive unit in the SET_BASE. The function needs to accept a UNIT parameter.
|
---- @param #function IteratorFunction The function that will be called when there is an alive unit in the SET_BASE. The function needs to accept a UNIT parameter.
|
||||||
@@ -1004,7 +1005,7 @@ do -- SET_GROUP
|
|||||||
|
|
||||||
--- Gets the Set.
|
--- Gets the Set.
|
||||||
-- @param #SET_GROUP self
|
-- @param #SET_GROUP self
|
||||||
-- @return #SET_GROUP self
|
-- @return #table Table of objects
|
||||||
function SET_GROUP:GetAliveSet()
|
function SET_GROUP:GetAliveSet()
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
@@ -1060,14 +1061,20 @@ do -- SET_GROUP
|
|||||||
-- Note that for each unit in the group that is set, a default cargo bay limit is initialized.
|
-- Note that for each unit in the group that is set, a default cargo bay limit is initialized.
|
||||||
-- @param Core.Set#SET_GROUP self
|
-- @param Core.Set#SET_GROUP self
|
||||||
-- @param Wrapper.Group#GROUP group The group which should be added to the set.
|
-- @param Wrapper.Group#GROUP group The group which should be added to the set.
|
||||||
|
-- @param #boolean DontSetCargoBayLimit If true, do not attempt to auto-add the cargo bay limit per unit in this group.
|
||||||
-- @return Core.Set#SET_GROUP self
|
-- @return Core.Set#SET_GROUP self
|
||||||
function SET_GROUP:AddGroup( group )
|
function SET_GROUP:AddGroup( group, DontSetCargoBayLimit )
|
||||||
|
|
||||||
self:Add( group:GetName(), group )
|
self:Add( group:GetName(), group )
|
||||||
|
|
||||||
-- I set the default cargo bay weight limit each time a new group is added to the set.
|
if not DontSetCargoBayLimit then
|
||||||
for UnitID, UnitData in pairs( group:GetUnits() ) do
|
-- I set the default cargo bay weight limit each time a new group is added to the set.
|
||||||
UnitData:SetCargoBayWeightLimit()
|
-- TODO Why is this here in the first place?
|
||||||
|
for UnitID, UnitData in pairs( group:GetUnits() ) do
|
||||||
|
if UnitData and UnitData:IsAlive() then
|
||||||
|
UnitData:SetCargoBayWeightLimit()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -1123,7 +1130,9 @@ do -- SET_GROUP
|
|||||||
local NearestGroup = nil -- Wrapper.Group#GROUP
|
local NearestGroup = nil -- Wrapper.Group#GROUP
|
||||||
local ClosestDistance = nil
|
local ClosestDistance = nil
|
||||||
|
|
||||||
for ObjectID, ObjectData in pairs( self.Set ) do
|
local Set = self:GetAliveSet()
|
||||||
|
|
||||||
|
for ObjectID, ObjectData in pairs( Set ) do
|
||||||
if NearestGroup == nil then
|
if NearestGroup == nil then
|
||||||
NearestGroup = ObjectData
|
NearestGroup = ObjectData
|
||||||
ClosestDistance = PointVec2:DistanceFromPointVec2( ObjectData:GetCoordinate() )
|
ClosestDistance = PointVec2:DistanceFromPointVec2( ObjectData:GetCoordinate() )
|
||||||
@@ -1163,6 +1172,30 @@ do -- SET_GROUP
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Builds a set of groups in zones.
|
||||||
|
-- @param #SET_GROUP self
|
||||||
|
-- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE
|
||||||
|
-- @return #SET_GROUP self
|
||||||
|
function SET_GROUP:FilterZones( Zones )
|
||||||
|
if not self.Filter.Zones then
|
||||||
|
self.Filter.Zones = {}
|
||||||
|
end
|
||||||
|
local zones = {}
|
||||||
|
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
||||||
|
zones = Zones.Set
|
||||||
|
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then
|
||||||
|
self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!")
|
||||||
|
return self
|
||||||
|
else
|
||||||
|
zones = Zones
|
||||||
|
end
|
||||||
|
for _,Zone in pairs( zones ) do
|
||||||
|
local zonename = Zone:GetName()
|
||||||
|
self.Filter.Zones[zonename] = Zone
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Builds a set of groups of coalitions.
|
--- Builds a set of groups of coalitions.
|
||||||
-- Possible current coalitions are red, blue and neutral.
|
-- Possible current coalitions are red, blue and neutral.
|
||||||
-- @param #SET_GROUP self
|
-- @param #SET_GROUP self
|
||||||
@@ -1327,7 +1360,11 @@ do -- SET_GROUP
|
|||||||
if Event.IniDCSUnit then
|
if Event.IniDCSUnit then
|
||||||
local ObjectName, Object = self:FindInDatabase( Event )
|
local ObjectName, Object = self:FindInDatabase( Event )
|
||||||
if ObjectName then
|
if ObjectName then
|
||||||
if Event.IniDCSGroup:getSize() == 1 then -- Only remove if the last unit of the group was destroyed.
|
local size = 1
|
||||||
|
if Event.IniDCSGroup then
|
||||||
|
size = Event.IniDCSGroup:getSize()
|
||||||
|
end
|
||||||
|
if size == 1 then -- Only remove if the last unit of the group was destroyed.
|
||||||
self:Remove( ObjectName )
|
self:Remove( ObjectName )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1417,17 +1454,18 @@ do -- SET_GROUP
|
|||||||
-- @param #SET_GROUP self
|
-- @param #SET_GROUP self
|
||||||
-- @param #number Delay Delay in seconds.
|
-- @param #number Delay Delay in seconds.
|
||||||
-- @return #SET_GROUP self
|
-- @return #SET_GROUP self
|
||||||
function SET_GROUP:Activate( Delay )
|
function SET_GROUP:Activate(Delay)
|
||||||
local Set = self:GetSet()
|
local Set = self:GetSet()
|
||||||
for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP
|
for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP
|
||||||
local group = GroupData -- Wrapper.Group#GROUP
|
local group=GroupData --Wrapper.Group#GROUP
|
||||||
if group and group:IsAlive() == false then
|
if group and group:IsAlive()==false then
|
||||||
group:Activate( Delay )
|
group:Activate(Delay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence completely in a @{Zone}, providing the GROUP and optional parameters to the called function.
|
--- Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence completely in a @{Zone}, providing the GROUP and optional parameters to the called function.
|
||||||
-- @param #SET_GROUP self
|
-- @param #SET_GROUP self
|
||||||
-- @param Core.Zone#ZONE ZoneObject The Zone to be tested for.
|
-- @param Core.Zone#ZONE ZoneObject The Zone to be tested for.
|
||||||
@@ -1815,7 +1853,7 @@ do -- SET_GROUP
|
|||||||
local MGroupZone = false
|
local MGroupZone = false
|
||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
self:T3( "Zone:", ZoneName )
|
self:T3( "Zone:", ZoneName )
|
||||||
if MGroup:IsInZone( Zone ) then
|
if MGroup:IsInZone(Zone) then
|
||||||
MGroupZone = true
|
MGroupZone = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2158,13 +2196,13 @@ do -- SET_UNIT
|
|||||||
local zones = {}
|
local zones = {}
|
||||||
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
||||||
zones = Zones.Set
|
zones = Zones.Set
|
||||||
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then
|
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then
|
||||||
self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" )
|
self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!")
|
||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
zones = Zones
|
zones = Zones
|
||||||
end
|
end
|
||||||
for _, Zone in pairs( zones ) do
|
for _,Zone in pairs( zones ) do
|
||||||
local zonename = Zone:GetName()
|
local zonename = Zone:GetName()
|
||||||
self.Filter.Zones[zonename] = Zone
|
self.Filter.Zones[zonename] = Zone
|
||||||
end
|
end
|
||||||
@@ -2342,6 +2380,7 @@ do -- SET_UNIT
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Iterate the SET_UNIT and call an iterator function for each **alive** UNIT, providing the UNIT and optional parameters.
|
--- Iterate the SET_UNIT and call an iterator function for each **alive** UNIT, providing the UNIT and optional parameters.
|
||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
-- @param #function IteratorFunction The function that will be called when there is an alive UNIT in the SET_UNIT. The function needs to accept a UNIT parameter.
|
-- @param #function IteratorFunction The function that will be called when there is an alive UNIT in the SET_UNIT. The function needs to accept a UNIT parameter.
|
||||||
@@ -2395,6 +2434,7 @@ do -- SET_UNIT
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Iterate the SET_UNIT **sorted *per Threat Level** and call an iterator function for each **alive** UNIT, providing the UNIT and optional parameters.
|
--- Iterate the SET_UNIT **sorted *per Threat Level** and call an iterator function for each **alive** UNIT, providing the UNIT and optional parameters.
|
||||||
--
|
--
|
||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
@@ -2784,6 +2824,8 @@ do -- SET_UNIT
|
|||||||
return FriendlyUnitCount
|
return FriendlyUnitCount
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
----- Iterate the SET_UNIT and call an iterator function for each **alive** player, providing the Unit of the player and optional parameters.
|
----- Iterate the SET_UNIT and call an iterator function for each **alive** player, providing the Unit of the player and optional parameters.
|
||||||
---- @param #SET_UNIT self
|
---- @param #SET_UNIT self
|
||||||
---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_UNIT. The function needs to accept a UNIT parameter.
|
---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_UNIT. The function needs to accept a UNIT parameter.
|
||||||
@@ -2913,11 +2955,11 @@ do -- SET_UNIT
|
|||||||
local MGroupZone = false
|
local MGroupZone = false
|
||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
self:T3( "Zone:", ZoneName )
|
self:T3( "Zone:", ZoneName )
|
||||||
if MUnit:IsInZone( Zone ) then
|
if MUnit:IsInZone(Zone) then
|
||||||
MGroupZone = true
|
MGroupZone = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
MUnitInclude = MUnitInclude and MGroupZone
|
MUnitInclude = MUnitInclude and MGroupZone
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T2( MUnitInclude )
|
self:T2( MUnitInclude )
|
||||||
@@ -3141,7 +3183,8 @@ do -- SET_STATIC
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Builds a set of statics in zones.
|
|
||||||
|
--- Builds a set of statics in zones.
|
||||||
-- @param #SET_STATIC self
|
-- @param #SET_STATIC self
|
||||||
-- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE
|
-- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE
|
||||||
-- @return #SET_STATIC self
|
-- @return #SET_STATIC self
|
||||||
@@ -3152,13 +3195,13 @@ do -- SET_STATIC
|
|||||||
local zones = {}
|
local zones = {}
|
||||||
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
||||||
zones = Zones.Set
|
zones = Zones.Set
|
||||||
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then
|
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then
|
||||||
self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" )
|
self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!")
|
||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
zones = Zones
|
zones = Zones
|
||||||
end
|
end
|
||||||
for _, Zone in pairs( zones ) do
|
for _,Zone in pairs( zones ) do
|
||||||
local zonename = Zone:GetName()
|
local zonename = Zone:GetName()
|
||||||
self.Filter.Zones[zonename] = Zone
|
self.Filter.Zones[zonename] = Zone
|
||||||
end
|
end
|
||||||
@@ -3363,6 +3406,7 @@ do -- SET_STATIC
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Iterate the SET_STATIC and call an iterator function for each **alive** STATIC, providing the STATIC and optional parameters.
|
--- Iterate the SET_STATIC and call an iterator function for each **alive** STATIC, providing the STATIC and optional parameters.
|
||||||
-- @param #SET_STATIC self
|
-- @param #SET_STATIC self
|
||||||
-- @param #function IteratorFunction The function that will be called when there is an alive STATIC in the SET_STATIC. The function needs to accept a STATIC parameter.
|
-- @param #function IteratorFunction The function that will be called when there is an alive STATIC in the SET_STATIC. The function needs to accept a STATIC parameter.
|
||||||
@@ -3645,7 +3689,7 @@ do -- SET_STATIC
|
|||||||
local MStaticZone = false
|
local MStaticZone = false
|
||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
self:T3( "Zone:", ZoneName )
|
self:T3( "Zone:", ZoneName )
|
||||||
if MStatic and MStatic:IsInZone( Zone ) then
|
if MStatic and MStatic:IsInZone(Zone) then
|
||||||
MStaticZone = true
|
MStaticZone = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3932,7 +3976,7 @@ do -- SET_CLIENT
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Builds a set of clients in zones.
|
--- Builds a set of clients in zones.
|
||||||
-- @param #SET_CLIENT self
|
-- @param #SET_CLIENT self
|
||||||
-- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE
|
-- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE
|
||||||
-- @return #SET_TABLE self
|
-- @return #SET_TABLE self
|
||||||
@@ -3943,13 +3987,13 @@ do -- SET_CLIENT
|
|||||||
local zones = {}
|
local zones = {}
|
||||||
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
||||||
zones = Zones.Set
|
zones = Zones.Set
|
||||||
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then
|
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then
|
||||||
self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" )
|
self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!")
|
||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
zones = Zones
|
zones = Zones
|
||||||
end
|
end
|
||||||
for _, Zone in pairs( zones ) do
|
for _,Zone in pairs( zones ) do
|
||||||
local zonename = Zone:GetName()
|
local zonename = Zone:GetName()
|
||||||
self.Filter.Zones[zonename] = Zone
|
self.Filter.Zones[zonename] = Zone
|
||||||
end
|
end
|
||||||
@@ -4069,6 +4113,26 @@ do -- SET_CLIENT
|
|||||||
return CountU
|
return CountU
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Gets the alive set.
|
||||||
|
-- @param #SET_CLIENT self
|
||||||
|
-- @return #table Table of SET objects
|
||||||
|
function SET_CLIENT:GetAliveSet()
|
||||||
|
|
||||||
|
local AliveSet = SET_CLIENT:New()
|
||||||
|
|
||||||
|
-- Clean the Set before returning with only the alive Groups.
|
||||||
|
for GroupName, GroupObject in pairs(self.Set) do
|
||||||
|
local GroupObject=GroupObject --Wrapper.Client#CLIENT
|
||||||
|
|
||||||
|
if GroupObject and GroupObject:IsAlive() then
|
||||||
|
AliveSet:Add(GroupName, GroupObject)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return AliveSet.Set or {}
|
||||||
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #SET_CLIENT self
|
-- @param #SET_CLIENT self
|
||||||
-- @param Wrapper.Client#CLIENT MClient
|
-- @param Wrapper.Client#CLIENT MClient
|
||||||
@@ -4158,7 +4222,7 @@ do -- SET_CLIENT
|
|||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
self:T3( "Zone:", ZoneName )
|
self:T3( "Zone:", ZoneName )
|
||||||
local unit = MClient:GetClientGroupUnit()
|
local unit = MClient:GetClientGroupUnit()
|
||||||
if unit and unit:IsInZone( Zone ) then
|
if unit and unit:IsInZone(Zone) then
|
||||||
MClientZone = true
|
MClientZone = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -4322,19 +4386,20 @@ do -- SET_PLAYER
|
|||||||
local zones = {}
|
local zones = {}
|
||||||
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
||||||
zones = Zones.Set
|
zones = Zones.Set
|
||||||
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then
|
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then
|
||||||
self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" )
|
self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!")
|
||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
zones = Zones
|
zones = Zones
|
||||||
end
|
end
|
||||||
for _, Zone in pairs( zones ) do
|
for _,Zone in pairs( zones ) do
|
||||||
local zonename = Zone:GetName()
|
local zonename = Zone:GetName()
|
||||||
self.Filter.Zones[zonename] = Zone
|
self.Filter.Zones[zonename] = Zone
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Builds a set of clients out of categories joined by players.
|
--- Builds a set of clients out of categories joined by players.
|
||||||
-- Possible current categories are plane, helicopter, ground, ship.
|
-- Possible current categories are plane, helicopter, ground, ship.
|
||||||
-- @param #SET_PLAYER self
|
-- @param #SET_PLAYER self
|
||||||
@@ -4583,7 +4648,7 @@ do -- SET_PLAYER
|
|||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
self:T3( "Zone:", ZoneName )
|
self:T3( "Zone:", ZoneName )
|
||||||
local unit = MClient:GetClientGroupUnit()
|
local unit = MClient:GetClientGroupUnit()
|
||||||
if unit and unit:IsInZone( Zone ) then
|
if unit and unit:IsInZone(Zone) then
|
||||||
MClientZone = true
|
MClientZone = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5603,7 +5668,28 @@ do -- SET_ZONE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
--- Draw all zones in the set on the F10 map.
|
||||||
|
-- @param #SET_ZONE self
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
||||||
|
-- @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 #SET_ZONE self
|
||||||
|
function SET_ZONE:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
|
||||||
|
for _,_zone in pairs(self.Set) do
|
||||||
|
local zone=_zone --Core.Zone#ZONE
|
||||||
|
zone:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Private function.
|
||||||
-- @param #SET_ZONE self
|
-- @param #SET_ZONE self
|
||||||
-- @param Core.Zone#ZONE_BASE MZone
|
-- @param Core.Zone#ZONE_BASE MZone
|
||||||
-- @return #SET_ZONE self
|
-- @return #SET_ZONE self
|
||||||
@@ -5618,7 +5704,7 @@ do -- SET_ZONE
|
|||||||
if self.Filter.Prefixes then
|
if self.Filter.Prefixes then
|
||||||
local MZonePrefix = false
|
local MZonePrefix = false
|
||||||
for ZonePrefixId, ZonePrefix in pairs( self.Filter.Prefixes ) do
|
for ZonePrefixId, ZonePrefix in pairs( self.Filter.Prefixes ) do
|
||||||
self:T3( { "Prefix:", string.find( MZoneName, ZonePrefix, 1 ), ZonePrefix } )
|
self:T2( { "Prefix:", string.find( MZoneName, ZonePrefix, 1 ), ZonePrefix } )
|
||||||
if string.find( MZoneName, ZonePrefix, 1 ) then
|
if string.find( MZoneName, ZonePrefix, 1 ) then
|
||||||
MZonePrefix = true
|
MZonePrefix = true
|
||||||
end
|
end
|
||||||
@@ -6003,6 +6089,8 @@ do -- SET_ZONE_GOAL
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
do -- SET_OPSGROUP
|
do -- SET_OPSGROUP
|
||||||
|
|
||||||
--- @type SET_OPSGROUP
|
--- @type SET_OPSGROUP
|
||||||
@@ -6108,13 +6196,14 @@ do -- SET_OPSGROUP
|
|||||||
}, -- FilterMeta
|
}, -- FilterMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Creates a new SET_OPSGROUP object, building a set of groups belonging to a coalitions, categories, countries, types or with defined prefix names.
|
--- Creates a new SET_OPSGROUP object, building a set of groups belonging to a coalitions, categories, countries, types or with defined prefix names.
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @return #SET_OPSGROUP
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:New()
|
function SET_OPSGROUP:New()
|
||||||
|
|
||||||
-- Inherit SET_BASE.
|
-- Inherit SET_BASE.
|
||||||
local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.GROUPS ) ) -- #SET_OPSGROUP
|
local self = BASE:Inherit(self, SET_BASE:New(_DATABASE.GROUPS)) -- #SET_OPSGROUP
|
||||||
|
|
||||||
-- Include non activated
|
-- Include non activated
|
||||||
self:FilterActive( false )
|
self:FilterActive( false )
|
||||||
@@ -6130,11 +6219,11 @@ do -- SET_OPSGROUP
|
|||||||
local AliveSet = SET_OPSGROUP:New()
|
local AliveSet = SET_OPSGROUP:New()
|
||||||
|
|
||||||
-- Clean the Set before returning with only the alive Groups.
|
-- Clean the Set before returning with only the alive Groups.
|
||||||
for GroupName, GroupObject in pairs( self.Set ) do
|
for GroupName, GroupObject in pairs(self.Set) do
|
||||||
local GroupObject = GroupObject -- Wrapper.Group#GROUP
|
local GroupObject=GroupObject --Wrapper.Group#GROUP
|
||||||
|
|
||||||
if GroupObject and GroupObject:IsAlive() then
|
if GroupObject and GroupObject:IsAlive() then
|
||||||
AliveSet:Add( GroupName, GroupObject )
|
AliveSet:Add(GroupName, GroupObject)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6146,52 +6235,60 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #string ObjectName The name of the object.
|
-- @param #string ObjectName The name of the object.
|
||||||
-- @param Core.Base#BASE Object The object itself.
|
-- @param Core.Base#BASE Object The object itself.
|
||||||
-- @return Core.Base#BASE The added BASE Object.
|
-- @return Core.Base#BASE The added BASE Object.
|
||||||
function SET_OPSGROUP:Add( ObjectName, Object )
|
function SET_OPSGROUP:Add(ObjectName, Object)
|
||||||
self:T( { ObjectName = ObjectName, Object = Object } )
|
self:T( { ObjectName = ObjectName, Object = Object } )
|
||||||
|
|
||||||
-- Ensure that the existing element is removed from the Set before a new one is inserted to the Set
|
-- Ensure that the existing element is removed from the Set before a new one is inserted to the Set
|
||||||
if self.Set[ObjectName] then
|
if self.Set[ObjectName] then
|
||||||
self:Remove( ObjectName, true )
|
self:Remove(ObjectName, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local object = nil -- Ops.OpsGroup#OPSGROUP
|
local object=nil --Ops.OpsGroup#OPSGROUP
|
||||||
if Object:IsInstanceOf( "GROUP" ) then
|
if Object:IsInstanceOf("GROUP") then
|
||||||
|
|
||||||
---
|
---
|
||||||
-- GROUP Object
|
-- GROUP Object
|
||||||
---
|
---
|
||||||
|
|
||||||
-- Fist, look up in the DATABASE if an OPSGROUP already exists.
|
-- Fist, look up in the DATABASE if an OPSGROUP already exists.
|
||||||
object = _DATABASE:FindOpsGroup( ObjectName )
|
object=_DATABASE:FindOpsGroup(ObjectName)
|
||||||
|
|
||||||
if not object then
|
if not object then
|
||||||
|
|
||||||
if Object:IsShip() then
|
if Object:IsShip() then
|
||||||
object = NAVYGROUP:New( Object )
|
object=NAVYGROUP:New(Object)
|
||||||
elseif Object:IsGround() then
|
elseif Object:IsGround() then
|
||||||
object = ARMYGROUP:New( Object )
|
object=ARMYGROUP:New(Object)
|
||||||
elseif Object:IsAir() then
|
elseif Object:IsAir() then
|
||||||
object = FLIGHTGROUP:New( Object )
|
object=FLIGHTGROUP:New(Object)
|
||||||
else
|
else
|
||||||
env.error( "ERROR: Unknown category of group object!" )
|
env.error("ERROR: Unknown category of group object!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif Object:IsInstanceOf( "OPSGROUP" ) then
|
elseif Object:IsInstanceOf("OPSGROUP") then
|
||||||
-- We already have an OPSGROUP.
|
-- We already have an OPSGROUP.
|
||||||
object = Object
|
object=Object
|
||||||
else
|
else
|
||||||
env.error( "ERROR: Object must be a GROUP or OPSGROUP!" )
|
env.error("ERROR: Object must be a GROUP or OPSGROUP!")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add object to set.
|
-- Add object to set.
|
||||||
self.Set[ObjectName] = object
|
self.Set[ObjectName]=object
|
||||||
|
|
||||||
-- Add Object name to Index.
|
-- Add Object name to Index.
|
||||||
table.insert( self.Index, ObjectName )
|
table.insert(self.Index, ObjectName)
|
||||||
|
|
||||||
-- Trigger Added event.
|
-- Trigger Added event.
|
||||||
self:Added( ObjectName, object )
|
self:Added(ObjectName, object)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Adds a @{Core.Base#BASE} object in the @{Core.Set#SET_BASE}, using the Object Name as the index.
|
||||||
|
-- @param #SET_BASE self
|
||||||
|
-- @param Ops.OpsGroup#OPSGROUP Object Ops group
|
||||||
|
-- @return Core.Base#BASE The added BASE Object.
|
||||||
|
function SET_OPSGROUP:AddObject(Object)
|
||||||
|
self:Add(Object.groupname, Object)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a GROUP or OPSGROUP object to the set.
|
--- Add a GROUP or OPSGROUP object to the set.
|
||||||
@@ -6199,11 +6296,11 @@ do -- SET_OPSGROUP
|
|||||||
-- @param Core.Set#SET_OPSGROUP self
|
-- @param Core.Set#SET_OPSGROUP self
|
||||||
-- @param Wrapper.Group#GROUP group The GROUP which should be added to the set. Can also be given as an #OPSGROUP object.
|
-- @param Wrapper.Group#GROUP group The GROUP which should be added to the set. Can also be given as an #OPSGROUP object.
|
||||||
-- @return Core.Set#SET_OPSGROUP self
|
-- @return Core.Set#SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:AddGroup( group )
|
function SET_OPSGROUP:AddGroup(group)
|
||||||
|
|
||||||
local groupname = group:GetName()
|
local groupname=group:GetName()
|
||||||
|
|
||||||
self:Add( groupname, group )
|
self:Add(groupname, group )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -6214,10 +6311,10 @@ do -- SET_OPSGROUP
|
|||||||
-- @return Core.Set#SET_OPSGROUP self
|
-- @return Core.Set#SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:AddGroupsByName( AddGroupNames )
|
function SET_OPSGROUP:AddGroupsByName( AddGroupNames )
|
||||||
|
|
||||||
local AddGroupNamesArray = (type( AddGroupNames ) == "table") and AddGroupNames or { AddGroupNames }
|
local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames }
|
||||||
|
|
||||||
for AddGroupID, AddGroupName in pairs( AddGroupNamesArray ) do
|
for AddGroupID, AddGroupName in pairs( AddGroupNamesArray ) do
|
||||||
self:Add( AddGroupName, GROUP:FindByName( AddGroupName ) )
|
self:Add(AddGroupName, GROUP:FindByName(AddGroupName))
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -6229,7 +6326,7 @@ do -- SET_OPSGROUP
|
|||||||
-- @return Core.Set#SET_OPSGROUP self
|
-- @return Core.Set#SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:RemoveGroupsByName( RemoveGroupNames )
|
function SET_OPSGROUP:RemoveGroupsByName( RemoveGroupNames )
|
||||||
|
|
||||||
local RemoveGroupNamesArray = (type( RemoveGroupNames ) == "table") and RemoveGroupNames or { RemoveGroupNames }
|
local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames }
|
||||||
|
|
||||||
for RemoveGroupID, RemoveGroupName in pairs( RemoveGroupNamesArray ) do
|
for RemoveGroupID, RemoveGroupName in pairs( RemoveGroupNamesArray ) do
|
||||||
self:Remove( RemoveGroupName )
|
self:Remove( RemoveGroupName )
|
||||||
@@ -6242,7 +6339,7 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #string GroupName Name of the group.
|
-- @param #string GroupName Name of the group.
|
||||||
-- @return Ops.OpsGroup#OPSGROUP The found OPSGROUP (FLIGHTGROUP, ARMYGROUP or NAVYGROUP) or `#nil` if the group is not in the set.
|
-- @return Ops.OpsGroup#OPSGROUP The found OPSGROUP (FLIGHTGROUP, ARMYGROUP or NAVYGROUP) or `#nil` if the group is not in the set.
|
||||||
function SET_OPSGROUP:FindGroup( GroupName )
|
function SET_OPSGROUP:FindGroup(GroupName)
|
||||||
local GroupFound = self.Set[GroupName]
|
local GroupFound = self.Set[GroupName]
|
||||||
return GroupFound
|
return GroupFound
|
||||||
end
|
end
|
||||||
@@ -6251,8 +6348,8 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #string GroupName Name of the group.
|
-- @param #string GroupName Name of the group.
|
||||||
-- @return Ops.FlightGroup#FLIGHTGROUP The found FLIGHTGROUP or `#nil` if the group is not in the set.
|
-- @return Ops.FlightGroup#FLIGHTGROUP The found FLIGHTGROUP or `#nil` if the group is not in the set.
|
||||||
function SET_OPSGROUP:FindFlightGroup( GroupName )
|
function SET_OPSGROUP:FindFlightGroup(GroupName)
|
||||||
local GroupFound = self:FindGroup( GroupName )
|
local GroupFound = self:FindGroup(GroupName)
|
||||||
return GroupFound
|
return GroupFound
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6260,17 +6357,18 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #string GroupName Name of the group.
|
-- @param #string GroupName Name of the group.
|
||||||
-- @return Ops.ArmyGroup#ARMYGROUP The found ARMYGROUP or `#nil` if the group is not in the set.
|
-- @return Ops.ArmyGroup#ARMYGROUP The found ARMYGROUP or `#nil` if the group is not in the set.
|
||||||
function SET_OPSGROUP:FindArmyGroup( GroupName )
|
function SET_OPSGROUP:FindArmyGroup(GroupName)
|
||||||
local GroupFound = self:FindGroup( GroupName )
|
local GroupFound = self:FindGroup(GroupName)
|
||||||
return GroupFound
|
return GroupFound
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Finds a NAVYGROUP based on the group name.
|
--- Finds a NAVYGROUP based on the group name.
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #string GroupName Name of the group.
|
-- @param #string GroupName Name of the group.
|
||||||
-- @return Ops.NavyGroup#NAVYGROUP The found NAVYGROUP or `#nil` if the group is not in the set.
|
-- @return Ops.NavyGroup#NAVYGROUP The found NAVYGROUP or `#nil` if the group is not in the set.
|
||||||
function SET_OPSGROUP:FindNavyGroup( GroupName )
|
function SET_OPSGROUP:FindNavyGroup(GroupName)
|
||||||
local GroupFound = self:FindGroup( GroupName )
|
local GroupFound = self:FindGroup(GroupName)
|
||||||
return GroupFound
|
return GroupFound
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6279,16 +6377,16 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #string Coalitions Can take the following values: "red", "blue", "neutral" or combinations as a table, for example `{"red", "neutral"}`.
|
-- @param #string Coalitions Can take the following values: "red", "blue", "neutral" or combinations as a table, for example `{"red", "neutral"}`.
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:FilterCoalitions( Coalitions )
|
function SET_OPSGROUP:FilterCoalitions(Coalitions)
|
||||||
|
|
||||||
-- Create an empty set.
|
-- Create an empty set.
|
||||||
if not self.Filter.Coalitions then
|
if not self.Filter.Coalitions then
|
||||||
self.Filter.Coalitions = {}
|
self.Filter.Coalitions={}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ensure we got a table.
|
-- Ensure we got a table.
|
||||||
if type( Coalitions ) ~= "table" then
|
if type(Coalitions)~="table" then
|
||||||
Coalitions = { Coalitions }
|
Coalitions = {Coalitions}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set filter.
|
-- Set filter.
|
||||||
@@ -6299,6 +6397,7 @@ do -- SET_OPSGROUP
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Builds a set of groups out of categories.
|
--- Builds a set of groups out of categories.
|
||||||
--
|
--
|
||||||
-- Possible current categories are:
|
-- Possible current categories are:
|
||||||
@@ -6314,11 +6413,11 @@ do -- SET_OPSGROUP
|
|||||||
function SET_OPSGROUP:FilterCategories( Categories )
|
function SET_OPSGROUP:FilterCategories( Categories )
|
||||||
|
|
||||||
if not self.Filter.Categories then
|
if not self.Filter.Categories then
|
||||||
self.Filter.Categories = {}
|
self.Filter.Categories={}
|
||||||
end
|
end
|
||||||
|
|
||||||
if type( Categories ) ~= "table" then
|
if type(Categories)~="table" then
|
||||||
Categories = { Categories }
|
Categories={Categories}
|
||||||
end
|
end
|
||||||
|
|
||||||
for CategoryID, Category in pairs( Categories ) do
|
for CategoryID, Category in pairs( Categories ) do
|
||||||
@@ -6332,7 +6431,7 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:FilterCategoryGround()
|
function SET_OPSGROUP:FilterCategoryGround()
|
||||||
self:FilterCategories( "ground" )
|
self:FilterCategories("ground")
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6340,15 +6439,15 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:FilterCategoryAirplane()
|
function SET_OPSGROUP:FilterCategoryAirplane()
|
||||||
self:FilterCategories( "plane" )
|
self:FilterCategories("plane")
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Builds a set of groups out of aircraft category (planes and helicopters).
|
--- Builds a set of groups out of aicraft category (planes and helicopters).
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:FilterCategoryAircraft()
|
function SET_OPSGROUP:FilterCategoryAircraft()
|
||||||
self:FilterCategories( { "plane", "helicopter" } )
|
self:FilterCategories({"plane", "helicopter"})
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6364,7 +6463,7 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:FilterCategoryShip()
|
function SET_OPSGROUP:FilterCategoryShip()
|
||||||
self:FilterCategories( "ship" )
|
self:FilterCategories("ship")
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6372,7 +6471,7 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #string Countries Can take those country strings known within DCS world.
|
-- @param #string Countries Can take those country strings known within DCS world.
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:FilterCountries( Countries )
|
function SET_OPSGROUP:FilterCountries(Countries)
|
||||||
|
|
||||||
-- Create empty table if necessary.
|
-- Create empty table if necessary.
|
||||||
if not self.Filter.Countries then
|
if not self.Filter.Countries then
|
||||||
@@ -6380,8 +6479,8 @@ do -- SET_OPSGROUP
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Ensure input is a table.
|
-- Ensure input is a table.
|
||||||
if type( Countries ) ~= "table" then
|
if type(Countries)~="table" then
|
||||||
Countries = { Countries }
|
Countries={Countries}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set filter.
|
-- Set filter.
|
||||||
@@ -6392,26 +6491,27 @@ do -- SET_OPSGROUP
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Builds a set of groups that contain the given string in their group name.
|
--- Builds a set of groups that contain the given string in their group name.
|
||||||
-- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all groups that **contain** the string.
|
-- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all groups that **contain** the string.
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #string Prefixes The string pattern(s) that needs to be contained in the group name. Can also be passed as a `#table` of strings.
|
-- @param #string Prefixes The string pattern(s) that needs to be contained in the group name. Can also be passed as a `#table` of strings.
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:FilterPrefixes( Prefixes )
|
function SET_OPSGROUP:FilterPrefixes(Prefixes)
|
||||||
|
|
||||||
-- Create emtpy table if necessary.
|
-- Create emtpy table if necessary.
|
||||||
if not self.Filter.GroupPrefixes then
|
if not self.Filter.GroupPrefixes then
|
||||||
self.Filter.GroupPrefixes = {}
|
self.Filter.GroupPrefixes={}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ensure we have a table.
|
-- Ensure we have a table.
|
||||||
if type( Prefixes ) ~= "table" then
|
if type(Prefixes)~="table" then
|
||||||
Prefixes = { Prefixes }
|
Prefixes={Prefixes}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set group prefixes.
|
-- Set group prefixes.
|
||||||
for PrefixID, Prefix in pairs( Prefixes ) do
|
for PrefixID, Prefix in pairs(Prefixes) do
|
||||||
self.Filter.GroupPrefixes[Prefix] = Prefix
|
self.Filter.GroupPrefixes[Prefix]=Prefix
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -6420,7 +6520,7 @@ do -- SET_OPSGROUP
|
|||||||
--- Builds a set of groups that are only active.
|
--- Builds a set of groups that are only active.
|
||||||
-- Only the groups that are active will be included within the set.
|
-- Only the groups that are active will be included within the set.
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #boolean Active (Optional) Include only active groups to the set.
|
-- @param #boolean Active (optional) Include only active groups to the set.
|
||||||
-- Include inactive groups if you provide false.
|
-- Include inactive groups if you provide false.
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
-- @usage
|
-- @usage
|
||||||
@@ -6438,11 +6538,12 @@ do -- SET_OPSGROUP
|
|||||||
-- GroupSet = SET_OPSGROUP:New():FilterActive( false ):FilterCoalition( "blue" ):FilterOnce()
|
-- GroupSet = SET_OPSGROUP:New():FilterActive( false ):FilterCoalition( "blue" ):FilterOnce()
|
||||||
--
|
--
|
||||||
function SET_OPSGROUP:FilterActive( Active )
|
function SET_OPSGROUP:FilterActive( Active )
|
||||||
Active = Active or not (Active == false)
|
Active = Active or not ( Active == false )
|
||||||
self.Filter.Active = Active
|
self.Filter.Active = Active
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Starts the filtering.
|
--- Starts the filtering.
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
@@ -6463,12 +6564,12 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param #number Delay Delay in seconds.
|
-- @param #number Delay Delay in seconds.
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:Activate( Delay )
|
function SET_OPSGROUP:Activate(Delay)
|
||||||
local Set = self:GetSet()
|
local Set = self:GetSet()
|
||||||
for GroupID, GroupData in pairs( Set ) do
|
for GroupID, GroupData in pairs(Set) do
|
||||||
local group = GroupData -- Ops.OpsGroup#OPSGROUP
|
local group=GroupData --Ops.OpsGroup#OPSGROUP
|
||||||
if group and group:IsAlive() == false then
|
if group and group:IsAlive()==false then
|
||||||
group:Activate( Delay )
|
group:Activate(Delay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -6499,7 +6600,7 @@ do -- SET_OPSGROUP
|
|||||||
-- @return #table The GROUP
|
-- @return #table The GROUP
|
||||||
function SET_OPSGROUP:AddInDatabase( Event )
|
function SET_OPSGROUP:AddInDatabase( Event )
|
||||||
|
|
||||||
if Event.IniObjectCategory == 1 then
|
if Event.IniObjectCategory==1 then
|
||||||
|
|
||||||
if not self.Database[Event.IniDCSGroupName] then
|
if not self.Database[Event.IniDCSGroupName] then
|
||||||
self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName )
|
self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName )
|
||||||
@@ -6516,7 +6617,7 @@ do -- SET_OPSGROUP
|
|||||||
-- @param Core.Event#EVENTDATA Event Event data table.
|
-- @param Core.Event#EVENTDATA Event Event data table.
|
||||||
-- @return #string The name of the GROUP
|
-- @return #string The name of the GROUP
|
||||||
-- @return #table The GROUP
|
-- @return #table The GROUP
|
||||||
function SET_OPSGROUP:FindInDatabase( Event )
|
function SET_OPSGROUP:FindInDatabase(Event)
|
||||||
return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName]
|
return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6527,7 +6628,7 @@ do -- SET_OPSGROUP
|
|||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:ForEachGroup( IteratorFunction, ... )
|
function SET_OPSGROUP:ForEachGroup( IteratorFunction, ... )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, arg, self:GetSet() )
|
self:ForEach(IteratorFunction, arg, self:GetSet())
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -6536,17 +6637,17 @@ do -- SET_OPSGROUP
|
|||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param Wrapper.Group#GROUP MGroup The group that is checked for inclusion.
|
-- @param Wrapper.Group#GROUP MGroup The group that is checked for inclusion.
|
||||||
-- @return #SET_OPSGROUP self
|
-- @return #SET_OPSGROUP self
|
||||||
function SET_OPSGROUP:IsIncludeObject( MGroup )
|
function SET_OPSGROUP:IsIncludeObject(MGroup)
|
||||||
|
|
||||||
-- Assume it is and check later if not.
|
-- Assume it is and check later if not.
|
||||||
local MGroupInclude = true
|
local MGroupInclude=true
|
||||||
|
|
||||||
-- Filter active.
|
-- Filter active.
|
||||||
if self.Filter.Active ~= nil then
|
if self.Filter.Active~=nil then
|
||||||
|
|
||||||
local MGroupActive = false
|
local MGroupActive = false
|
||||||
|
|
||||||
if self.Filter.Active == false or (self.Filter.Active == true and MGroup:IsActive() == true) then
|
if self.Filter.Active==false or (self.Filter.Active==true and MGroup:IsActive()==true) then
|
||||||
MGroupActive = true
|
MGroupActive = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6559,7 +6660,7 @@ do -- SET_OPSGROUP
|
|||||||
local MGroupCoalition = false
|
local MGroupCoalition = false
|
||||||
|
|
||||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||||
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == MGroup:GetCoalition() then
|
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName]==MGroup:GetCoalition() then
|
||||||
MGroupCoalition = true
|
MGroupCoalition = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -6573,7 +6674,7 @@ do -- SET_OPSGROUP
|
|||||||
local MGroupCategory = false
|
local MGroupCategory = false
|
||||||
|
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == MGroup:GetCategory() then
|
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName]==MGroup:GetCategory() then
|
||||||
MGroupCategory = true
|
MGroupCategory = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -6598,7 +6699,7 @@ do -- SET_OPSGROUP
|
|||||||
local MGroupPrefix = false
|
local MGroupPrefix = false
|
||||||
|
|
||||||
for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do
|
for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do
|
||||||
if string.find( MGroup:GetName(), GroupPrefix:gsub( "-", "%%-" ), 1 ) then -- Not sure why "-" is replaced by "%-" ?!
|
if string.find( MGroup:GetName(), GroupPrefix:gsub ("-", "%%-"), 1 ) then --Not sure why "-" is replaced by "%-" ?!
|
||||||
MGroupPrefix = true
|
MGroupPrefix = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ do -- SETTINGS
|
|||||||
self:SetMessageTime( MESSAGE.Type.Overview, 60 )
|
self:SetMessageTime( MESSAGE.Type.Overview, 60 )
|
||||||
self:SetMessageTime( MESSAGE.Type.Update, 15 )
|
self:SetMessageTime( MESSAGE.Type.Update, 15 )
|
||||||
self:SetEraModern()
|
self:SetEraModern()
|
||||||
|
self:SetLocale("en")
|
||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
local Settings = _DATABASE:GetPlayerSettings( PlayerName )
|
local Settings = _DATABASE:GetPlayerSettings( PlayerName )
|
||||||
@@ -283,6 +284,20 @@ do -- SETTINGS
|
|||||||
self.Metric = true
|
self.Metric = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets the SETTINGS default text locale.
|
||||||
|
-- @param #SETTINGS self
|
||||||
|
-- @param #string Locale
|
||||||
|
function SETTINGS:SetLocale(Locale)
|
||||||
|
self.Locale = Locale or "en"
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the SETTINGS text locale.
|
||||||
|
-- @param #SETTINGS self
|
||||||
|
-- @return #string
|
||||||
|
function SETTINGS:GetLocale()
|
||||||
|
return self.Locale or _SETTINGS:GetLocale()
|
||||||
|
end
|
||||||
|
|
||||||
--- Gets if the SETTINGS is metric.
|
--- Gets if the SETTINGS is metric.
|
||||||
-- @param #SETTINGS self
|
-- @param #SETTINGS self
|
||||||
-- @return #boolean true if metric.
|
-- @return #boolean true if metric.
|
||||||
@@ -300,7 +315,7 @@ do -- SETTINGS
|
|||||||
-- @param #SETTINGS self
|
-- @param #SETTINGS self
|
||||||
-- @return #boolean true if imperial.
|
-- @return #boolean true if imperial.
|
||||||
function SETTINGS:IsImperial()
|
function SETTINGS:IsImperial()
|
||||||
return (self.Metric ~= nil and self.Metric == false) or (self.Metric == nil and _SETTINGS:IsMetric())
|
return (self.Metric ~= nil and self.Metric == false) or (self.Metric == nil and _SETTINGS:IsImperial())
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets the SETTINGS LL accuracy.
|
--- Sets the SETTINGS LL accuracy.
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/SPA%20-%20Spawning)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SPA%20-%20Spawning)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -1373,7 +1373,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
SpawnTemplate.modulation = self.SpawnInitModu
|
SpawnTemplate.modulation = self.SpawnInitModu
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set country, coaliton and categroy.
|
-- Set country, coalition and category.
|
||||||
SpawnTemplate.CategoryID = self.SpawnInitCategory or SpawnTemplate.CategoryID
|
SpawnTemplate.CategoryID = self.SpawnInitCategory or SpawnTemplate.CategoryID
|
||||||
SpawnTemplate.CountryID = self.SpawnInitCountry or SpawnTemplate.CountryID
|
SpawnTemplate.CountryID = self.SpawnInitCountry or SpawnTemplate.CountryID
|
||||||
SpawnTemplate.CoalitionID = self.SpawnInitCoalition or SpawnTemplate.CoalitionID
|
SpawnTemplate.CoalitionID = self.SpawnInitCoalition or SpawnTemplate.CoalitionID
|
||||||
@@ -1418,7 +1418,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
end
|
end
|
||||||
-- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats.
|
-- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats.
|
||||||
-- if self.Repeat then
|
-- if self.Repeat then
|
||||||
-- _DATABASE:SetStatusGroup( SpawnTemplate.name, "ReSpawn" )
|
-- _DATABASE:SetStatusGroup( SpawnTemplate.name, "ReSpawn" )
|
||||||
-- end
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2360,7 +2360,7 @@ end
|
|||||||
-- The known AIRBASE objects are automatically imported at mission start by MOOSE.
|
-- The known AIRBASE objects are automatically imported at mission start by MOOSE.
|
||||||
-- Therefore, there isn't any New() constructor defined for AIRBASE objects.
|
-- 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.
|
-- 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!
|
-- You need to provide the **exact name** of the airbase as the parameter to the @{Wrapper.Airbase#AIRBASE.FindByName}() method!
|
||||||
--
|
--
|
||||||
@@ -2403,8 +2403,7 @@ end
|
|||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
-- @param DCS#Vec3 Vec3 The Vec3 coordinates where to spawn the group.
|
-- @param DCS#Vec3 Vec3 The Vec3 coordinates where to spawn the group.
|
||||||
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
||||||
-- @return Wrapper.Group#GROUP that was spawned.
|
-- @return Wrapper.Group#GROUP that was spawned or #nil if nothing was spawned.
|
||||||
-- @return #nil Nothing was spawned.
|
|
||||||
function SPAWN:SpawnFromVec3( Vec3, SpawnIndex )
|
function SPAWN:SpawnFromVec3( Vec3, SpawnIndex )
|
||||||
self:F( { self.SpawnTemplatePrefix, Vec3, SpawnIndex } )
|
self:F( { self.SpawnTemplatePrefix, Vec3, SpawnIndex } )
|
||||||
|
|
||||||
@@ -2472,8 +2471,7 @@ end
|
|||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
-- @param Core.Point#Coordinate Coordinate The Coordinate coordinates where to spawn the group.
|
-- @param Core.Point#Coordinate Coordinate The Coordinate coordinates where to spawn the group.
|
||||||
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
||||||
-- @return Wrapper.Group#GROUP that was spawned.
|
-- @return Wrapper.Group#GROUP that was spawned or #nil if nothing was spawned.
|
||||||
-- @return #nil Nothing was spawned.
|
|
||||||
function SPAWN:SpawnFromCoordinate( Coordinate, SpawnIndex )
|
function SPAWN:SpawnFromCoordinate( Coordinate, SpawnIndex )
|
||||||
self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
|
self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
|
||||||
|
|
||||||
@@ -2487,8 +2485,7 @@ end
|
|||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
-- @param Core.Point#POINT_VEC3 PointVec3 The PointVec3 coordinates where to spawn the group.
|
-- @param Core.Point#POINT_VEC3 PointVec3 The PointVec3 coordinates where to spawn the group.
|
||||||
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
||||||
-- @return Wrapper.Group#GROUP that was spawned.
|
-- @return Wrapper.Group#GROUP that was spawned or #nil if nothing was spawned.
|
||||||
-- @return #nil Nothing was spawned.
|
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- local SpawnPointVec3 = ZONE:New( ZoneName ):GetPointVec3( 2000 ) -- Get the center of the ZONE object at 2000 meters from the ground.
|
-- local SpawnPointVec3 = ZONE:New( ZoneName ):GetPointVec3( 2000 ) -- Get the center of the ZONE object at 2000 meters from the ground.
|
||||||
@@ -2511,8 +2508,7 @@ end
|
|||||||
-- @param #number MinHeight (optional) The minimum height to spawn an airborne group into the zone.
|
-- @param #number MinHeight (optional) The minimum height to spawn an airborne group into the zone.
|
||||||
-- @param #number MaxHeight (optional) The maximum height to spawn an airborne group into the zone.
|
-- @param #number MaxHeight (optional) The maximum height to spawn an airborne group into the zone.
|
||||||
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
||||||
-- @return Wrapper.Group#GROUP that was spawned.
|
-- @return Wrapper.Group#GROUP that was spawned or #nil if nothing was spawned.
|
||||||
-- @return #nil Nothing was spawned.
|
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- local SpawnVec2 = ZONE:New( ZoneName ):GetVec2()
|
-- local SpawnVec2 = ZONE:New( ZoneName ):GetVec2()
|
||||||
@@ -2544,8 +2540,7 @@ end
|
|||||||
-- @param #number MinHeight (optional) The minimum height to spawn an airborne group into the zone.
|
-- @param #number MinHeight (optional) The minimum height to spawn an airborne group into the zone.
|
||||||
-- @param #number MaxHeight (optional) The maximum height to spawn an airborne group into the zone.
|
-- @param #number MaxHeight (optional) The maximum height to spawn an airborne group into the zone.
|
||||||
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
||||||
-- @return Wrapper.Group#GROUP that was spawned.
|
-- @return Wrapper.Group#GROUP that was spawned or #nil if nothing was spawned.
|
||||||
-- @return #nil Nothing was spawned.
|
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- local SpawnPointVec2 = ZONE:New( ZoneName ):GetPointVec2()
|
-- local SpawnPointVec2 = ZONE:New( ZoneName ):GetPointVec2()
|
||||||
@@ -2599,8 +2594,7 @@ end
|
|||||||
-- @param #number MinHeight (optional) The minimum height to spawn an airborne group into the zone.
|
-- @param #number MinHeight (optional) The minimum height to spawn an airborne group into the zone.
|
||||||
-- @param #number MaxHeight (optional) The maximum height to spawn an airborne group into the zone.
|
-- @param #number MaxHeight (optional) The maximum height to spawn an airborne group into the zone.
|
||||||
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
||||||
-- @return Wrapper.Group#GROUP that was spawned.
|
-- @return Wrapper.Group#GROUP that was spawned or #nil if nothing was spawned.
|
||||||
-- @return #nil Nothing was spawned.
|
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- local SpawnStatic = STATIC:FindByName( StaticName )
|
-- local SpawnStatic = STATIC:FindByName( StaticName )
|
||||||
@@ -2631,8 +2625,7 @@ end
|
|||||||
-- @param #number MinHeight (optional) The minimum height to spawn an airborne group into the zone.
|
-- @param #number MinHeight (optional) The minimum height to spawn an airborne group into the zone.
|
||||||
-- @param #number MaxHeight (optional) The maximum height to spawn an airborne group into the zone.
|
-- @param #number MaxHeight (optional) The maximum height to spawn an airborne group into the zone.
|
||||||
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
-- @param #number SpawnIndex (optional) The index which group to spawn within the given zone.
|
||||||
-- @return Wrapper.Group#GROUP that was spawned.
|
-- @return Wrapper.Group#GROUP that was spawned or #nil if nothing was spawned.
|
||||||
-- @return #nil when nothing was spawned.
|
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- local SpawnZone = ZONE:New( ZoneName )
|
-- local SpawnZone = ZONE:New( ZoneName )
|
||||||
@@ -2827,18 +2820,37 @@ end
|
|||||||
-- The method will search for a #-mark, and will return the text before the #-mark.
|
-- The method will search for a #-mark, and will return the text before the #-mark.
|
||||||
-- It will return nil of no prefix was found.
|
-- It will return nil of no prefix was found.
|
||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
-- @param DCS#UNIT DCSUnit The @{DCSUnit} to be searched.
|
-- @param Wrapper.Group#GROUP SpawnGroup The GROUP object.
|
||||||
-- @return #string The prefix
|
-- @return #string The prefix or #nil if nothing was found.
|
||||||
-- @return #nil Nothing found
|
|
||||||
function SPAWN:_GetPrefixFromGroup( SpawnGroup )
|
function SPAWN:_GetPrefixFromGroup( SpawnGroup )
|
||||||
self:F3( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnGroup } )
|
|
||||||
|
|
||||||
local GroupName = SpawnGroup:GetName()
|
local GroupName = SpawnGroup:GetName()
|
||||||
|
|
||||||
if GroupName then
|
if GroupName then
|
||||||
local SpawnPrefix = string.match( GroupName, ".*#" )
|
|
||||||
|
local SpawnPrefix=self:_GetPrefixFromGroupName(GroupName)
|
||||||
|
|
||||||
|
return SpawnPrefix
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Return the prefix of a spawned group.
|
||||||
|
-- The method will search for a `#`-mark, and will return the text before the `#`-mark. It will return nil of no prefix was found.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #string SpawnGroupName The name of the spawned group.
|
||||||
|
-- @return #string The prefix or #nil if nothing was found.
|
||||||
|
function SPAWN:_GetPrefixFromGroupName(SpawnGroupName)
|
||||||
|
|
||||||
|
if SpawnGroupName then
|
||||||
|
|
||||||
|
local SpawnPrefix=string.match(SpawnGroupName, ".*#")
|
||||||
|
|
||||||
if SpawnPrefix then
|
if SpawnPrefix then
|
||||||
SpawnPrefix = SpawnPrefix:sub( 1, -2 )
|
SpawnPrefix = SpawnPrefix:sub(1, -2)
|
||||||
end
|
end
|
||||||
|
|
||||||
return SpawnPrefix
|
return SpawnPrefix
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2959,9 +2971,9 @@ end
|
|||||||
function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
||||||
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
|
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
|
||||||
|
|
||||||
-- if not self.SpawnTemplate then
|
-- if not self.SpawnTemplate then
|
||||||
-- self.SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix )
|
-- self.SpawnTemplate = self:_GetTemplate( SpawnTemplatePrefix )
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
local SpawnTemplate
|
local SpawnTemplate
|
||||||
if self.TweakedTemplate ~= nil and self.TweakedTemplate == true then
|
if self.TweakedTemplate ~= nil and self.TweakedTemplate == true then
|
||||||
@@ -3235,24 +3247,27 @@ function SPAWN:_OnBirth( EventData )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Obscolete
|
|
||||||
-- @todo Need to delete this... _DATABASE does this now ...
|
|
||||||
|
|
||||||
--- @param #SPAWN self
|
--- @param #SPAWN self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function SPAWN:_OnDeadOrCrash( EventData )
|
function SPAWN:_OnDeadOrCrash( EventData )
|
||||||
self:F( self.SpawnTemplatePrefix )
|
self:F( self.SpawnTemplatePrefix )
|
||||||
|
|
||||||
local SpawnGroup = EventData.IniGroup
|
local unit=UNIT:FindByName(EventData.IniUnitName)
|
||||||
|
|
||||||
|
if unit then
|
||||||
|
|
||||||
|
local EventPrefix = self:_GetPrefixFromGroupName(unit.GroupName)
|
||||||
|
|
||||||
if SpawnGroup then
|
|
||||||
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
|
||||||
if EventPrefix then -- EventPrefix can be nil if no # is found, which means, no spawnable group!
|
if EventPrefix then -- EventPrefix can be nil if no # is found, which means, no spawnable group!
|
||||||
self:T( { "Dead event: " .. EventPrefix } )
|
self:T( { "Dead event: " .. EventPrefix } )
|
||||||
if EventPrefix == self.SpawnTemplatePrefix or (self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix) then
|
|
||||||
self.AliveUnits = self.AliveUnits - 1
|
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||||
self:T( "Alive Units: " .. self.AliveUnits )
|
|
||||||
|
self.AliveUnits = self.AliveUnits - 1
|
||||||
|
|
||||||
|
self:T( "Alive Units: " .. self.AliveUnits )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3354,8 +3369,12 @@ function SPAWN:_SpawnCleanUpScheduler()
|
|||||||
local SpawnGroup, SpawnCursor = self:GetFirstAliveGroup()
|
local SpawnGroup, SpawnCursor = self:GetFirstAliveGroup()
|
||||||
self:T( { "CleanUp Scheduler:", SpawnGroup, SpawnCursor } )
|
self:T( { "CleanUp Scheduler:", SpawnGroup, SpawnCursor } )
|
||||||
|
|
||||||
|
local IsHelo = false
|
||||||
|
|
||||||
while SpawnGroup do
|
while SpawnGroup do
|
||||||
|
|
||||||
|
IsHelo = SpawnGroup:IsHelicopter()
|
||||||
|
|
||||||
local SpawnUnits = SpawnGroup:GetUnits()
|
local SpawnUnits = SpawnGroup:GetUnits()
|
||||||
|
|
||||||
for UnitID, UnitData in pairs( SpawnUnits ) do
|
for UnitID, UnitData in pairs( SpawnUnits ) do
|
||||||
@@ -3368,8 +3387,8 @@ function SPAWN:_SpawnCleanUpScheduler()
|
|||||||
self:T( { SpawnUnitName, Stamp } )
|
self:T( { SpawnUnitName, Stamp } )
|
||||||
|
|
||||||
if Stamp.Vec2 then
|
if Stamp.Vec2 then
|
||||||
if SpawnUnit:InAir() == false and SpawnUnit:GetVelocityKMH() < 1 then
|
if (SpawnUnit:InAir() == false and SpawnUnit:GetVelocityKMH() < 1) or IsHelo then
|
||||||
local NewVec2 = SpawnUnit:GetVec2()
|
local NewVec2 = SpawnUnit:GetVec2() or {x=0, y=0}
|
||||||
if (Stamp.Vec2.x == NewVec2.x and Stamp.Vec2.y == NewVec2.y) or (SpawnUnit:GetLife() <= 1) then
|
if (Stamp.Vec2.x == NewVec2.x and Stamp.Vec2.y == NewVec2.y) or (SpawnUnit:GetLife() <= 1) then
|
||||||
-- If the plane is not moving or dead , and is on the ground, assign it with a timestamp...
|
-- If the plane is not moving or dead , and is on the ground, assign it with a timestamp...
|
||||||
if Stamp.Time + self.SpawnCleanUpInterval < timer.getTime() then
|
if Stamp.Time + self.SpawnCleanUpInterval < timer.getTime() then
|
||||||
@@ -3387,8 +3406,8 @@ function SPAWN:_SpawnCleanUpScheduler()
|
|||||||
Stamp.Time = nil
|
Stamp.Time = nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if SpawnUnit:InAir() == false then
|
if SpawnUnit:InAir() == false or (IsHelo and SpawnUnit:GetLife() <= 1) then
|
||||||
Stamp.Vec2 = SpawnUnit:GetVec2()
|
Stamp.Vec2 = SpawnUnit:GetVec2() or {x=0, y=0}
|
||||||
if (SpawnUnit:GetVelocityKMH() < 1) then
|
if (SpawnUnit:GetVelocityKMH() < 1) then
|
||||||
Stamp.Time = timer.getTime()
|
Stamp.Time = timer.getTime()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,14 +46,14 @@
|
|||||||
-- @field #number InitOffsetAngle Link offset angle in degrees.
|
-- @field #number InitOffsetAngle Link offset angle in degrees.
|
||||||
-- @field #number InitStaticHeading Heading of the static.
|
-- @field #number InitStaticHeading Heading of the static.
|
||||||
-- @field #string InitStaticLivery Livery for aircraft.
|
-- @field #string InitStaticLivery Livery for aircraft.
|
||||||
-- @field #string InitStaticShape Shape of teh static.
|
-- @field #string InitStaticShape Shape of the static.
|
||||||
-- @field #string InitStaticType Type of the static.
|
-- @field #string InitStaticType Type of the static.
|
||||||
-- @field #string InitStaticCategory Categrory of the static.
|
-- @field #string InitStaticCategory Categrory of the static.
|
||||||
-- @field #string InitStaticName Name of the static.
|
-- @field #string InitStaticName Name of the static.
|
||||||
-- @field Core.Point#COORDINATE InitStaticCoordinate Coordinate where to spawn the static.
|
-- @field Core.Point#COORDINATE InitStaticCoordinate Coordinate where to spawn the static.
|
||||||
-- @field #boolean InitDead Set static to be dead if true.
|
-- @field #boolean InitStaticDead Set static to be dead if true.
|
||||||
-- @field #boolean InitCargo If true, static can act as cargo.
|
-- @field #boolean InitStaticCargo If true, static can act as cargo.
|
||||||
-- @field #number InitCargoMass Mass of cargo in kg.
|
-- @field #number InitStaticCargoMass Mass of cargo in kg.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ end
|
|||||||
-- @param #number Mass Mass of the cargo in kg.
|
-- @param #number Mass Mass of the cargo in kg.
|
||||||
-- @return #SPAWNSTATIC self
|
-- @return #SPAWNSTATIC self
|
||||||
function SPAWNSTATIC:InitCargoMass(Mass)
|
function SPAWNSTATIC:InitCargoMass(Mass)
|
||||||
self.InitCargoMass=Mass
|
self.InitStaticCargoMass=Mass
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -269,7 +269,16 @@ end
|
|||||||
-- @param #boolean IsCargo If true, this static can act as cargo.
|
-- @param #boolean IsCargo If true, this static can act as cargo.
|
||||||
-- @return #SPAWNSTATIC self
|
-- @return #SPAWNSTATIC self
|
||||||
function SPAWNSTATIC:InitCargo(IsCargo)
|
function SPAWNSTATIC:InitCargo(IsCargo)
|
||||||
self.InitCargo=IsCargo
|
self.InitStaticCargo=IsCargo
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Initialize as dead.
|
||||||
|
-- @param #SPAWNSTATIC self
|
||||||
|
-- @param #boolean IsCargo If true, this static is dead.
|
||||||
|
-- @return #SPAWNSTATIC self
|
||||||
|
function SPAWNSTATIC:InitDead(IsDead)
|
||||||
|
self.InitStaticDead=IsDead
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -417,16 +426,16 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID)
|
|||||||
Template.livery_id=self.InitStaticLivery
|
Template.livery_id=self.InitStaticLivery
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.InitDead~=nil then
|
if self.InitStaticDead~=nil then
|
||||||
Template.dead=self.InitDead
|
Template.dead=self.InitStaticDead
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.InitCargo~=nil then
|
if self.InitStaticCargo~=nil then
|
||||||
Template.canCargo=self.InitCargo
|
Template.canCargo=self.InitStaticCargo
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.InitCargoMass~=nil then
|
if self.InitStaticCargoMass~=nil then
|
||||||
Template.mass=self.InitCargoMass
|
Template.mass=self.InitStaticCargoMass
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.InitLinkUnit then
|
if self.InitLinkUnit then
|
||||||
@@ -479,6 +488,8 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID)
|
|||||||
-- ED's dirty way to spawn FARPS.
|
-- ED's dirty way to spawn FARPS.
|
||||||
Static=coalition.addGroup(CountryID, -1, TemplateGroup)
|
Static=coalition.addGroup(CountryID, -1, TemplateGroup)
|
||||||
else
|
else
|
||||||
|
self:T("Spawning Static")
|
||||||
|
self:T2({Template=Template})
|
||||||
Static=coalition.addStaticObject(CountryID, Template)
|
Static=coalition.addStaticObject(CountryID, Template)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,202 @@
|
|||||||
|
--- **Core** - TEXTANDSOUND (MOOSE gettext) system
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ## Main Features:
|
||||||
|
--
|
||||||
|
-- * A GetText for Moose
|
||||||
|
-- * Build a set of localized text entries, alongside their sounds and subtitles
|
||||||
|
-- * Aimed at class developers to offer localizable language support
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ## Example Missions:
|
||||||
|
--
|
||||||
|
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/).
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### Author: **applevangelist**
|
||||||
|
-- ## Date: April 2022
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- @module Core.TextAndSound
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- Text and Sound class.
|
||||||
|
-- @type TEXTANDSOUND
|
||||||
|
-- @field #string ClassName Name of this class.
|
||||||
|
-- @field #string version Versioning.
|
||||||
|
-- @field #string lid LID for log entries.
|
||||||
|
-- @field #string locale Default locale of this object.
|
||||||
|
-- @field #table entries Table of entries.
|
||||||
|
-- @field #string textclass Name of the class the texts belong to.
|
||||||
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
---
|
||||||
|
--
|
||||||
|
-- @field #TEXTANDSOUND
|
||||||
|
TEXTANDSOUND = {
|
||||||
|
ClassName = "TEXTANDSOUND",
|
||||||
|
version = "0.0.1",
|
||||||
|
lid = "",
|
||||||
|
locale = "en",
|
||||||
|
entries = {},
|
||||||
|
textclass = "",
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Text and Sound entry.
|
||||||
|
-- @type TEXTANDSOUND.Entry
|
||||||
|
-- @field #string Classname Name of the class this entry is for.
|
||||||
|
-- @field #string Locale Locale of this entry, defaults to "en".
|
||||||
|
-- @field #table Data The list of entries.
|
||||||
|
|
||||||
|
--- Text and Sound data
|
||||||
|
-- @type TEXTANDSOUND.Data
|
||||||
|
-- @field #string ID ID of this entry for retrieval.
|
||||||
|
-- @field #string Text Text of this entry.
|
||||||
|
-- @field #string Soundfile (optional) Soundfile File name of the corresponding sound file.
|
||||||
|
-- @field #number Soundlength (optional) Length of the sound file in seconds.
|
||||||
|
-- @field #string Subtitle (optional) Subtitle for the sound file.
|
||||||
|
|
||||||
|
--- Instantiate a new object
|
||||||
|
-- @param #TEXTANDSOUND self
|
||||||
|
-- @param #string ClassName Name of the class this instance is providing texts for.
|
||||||
|
-- @param #string Defaultlocale (Optional) Default locale of this instance, defaults to "en".
|
||||||
|
-- @return #TEXTANDSOUND self
|
||||||
|
function TEXTANDSOUND:New(ClassName,Defaultlocale)
|
||||||
|
-- Inherit everything from BASE class.
|
||||||
|
local self=BASE:Inherit(self, BASE:New())
|
||||||
|
-- Set some string id for output to DCS.log file.
|
||||||
|
self.lid=string.format("%s (%s) | ", self.ClassName, self.version)
|
||||||
|
self.locale = Defaultlocale or (_SETTINGS:GetLocale() or "en")
|
||||||
|
self.textclass = ClassName or "none"
|
||||||
|
self.entries = {}
|
||||||
|
local initentry = {} -- #TEXTANDSOUND.Entry
|
||||||
|
initentry.Classname = ClassName
|
||||||
|
initentry.Data = {}
|
||||||
|
initentry.Locale = self.locale
|
||||||
|
self.entries[self.locale] = initentry
|
||||||
|
self:I(self.lid .. "Instantiated.")
|
||||||
|
self:T({self.entries[self.locale]})
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add an entry
|
||||||
|
-- @param #TEXTANDSOUND self
|
||||||
|
-- @param #string Locale Locale to set for this entry, e.g. "de".
|
||||||
|
-- @param #string ID Unique(!) ID of this entry under this locale (i.e. use the same ID to get localized text for the entry in another language).
|
||||||
|
-- @param #string Text Text for this entry.
|
||||||
|
-- @param #string Soundfile (Optional) Sound file name for this entry.
|
||||||
|
-- @param #number Soundlength (Optional) Length of the sound file in seconds.
|
||||||
|
-- @param #string Subtitle (Optional) Subtitle to be used alongside the sound file.
|
||||||
|
-- @return #TEXTANDSOUND self
|
||||||
|
function TEXTANDSOUND:AddEntry(Locale,ID,Text,Soundfile,Soundlength,Subtitle)
|
||||||
|
self:T(self.lid .. "AddEntry")
|
||||||
|
local locale = Locale or self.locale
|
||||||
|
local dataentry = {} -- #TEXTANDSOUND.Data
|
||||||
|
dataentry.ID = ID or "1"
|
||||||
|
dataentry.Text = Text or "none"
|
||||||
|
dataentry.Soundfile = Soundfile
|
||||||
|
dataentry.Soundlength = Soundlength or 0
|
||||||
|
dataentry.Subtitle = Subtitle
|
||||||
|
if not self.entries[locale] then
|
||||||
|
local initentry = {} -- #TEXTANDSOUND.Entry
|
||||||
|
initentry.Classname = self.textclass -- class name entry
|
||||||
|
initentry.Data = {} -- data array
|
||||||
|
initentry.Locale = locale -- default locale
|
||||||
|
self.entries[locale] = initentry
|
||||||
|
end
|
||||||
|
self.entries[locale].Data[ID] = dataentry
|
||||||
|
self:T({self.entries[locale].Data})
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get an entry
|
||||||
|
-- @param #TEXTANDSOUND self
|
||||||
|
-- @param #string ID The unique ID of the data to be retrieved.
|
||||||
|
-- @param #string Locale (Optional) The locale of the text to be retrieved - defauls to default locale set with `New()`.
|
||||||
|
-- @return #string Text Text or nil if not found and no fallback.
|
||||||
|
-- @return #string Soundfile Filename or nil if not found and no fallback.
|
||||||
|
-- @return #string Soundlength Length of the sound or 0 if not found and no fallback.
|
||||||
|
-- @return #string Subtitle Text for subtitle or nil if not found and no fallback.
|
||||||
|
function TEXTANDSOUND:GetEntry(ID,Locale)
|
||||||
|
self:T(self.lid .. "GetEntry")
|
||||||
|
local locale = Locale or self.locale
|
||||||
|
if not self.entries[locale] then
|
||||||
|
-- fall back to default "en"
|
||||||
|
locale = self.locale
|
||||||
|
end
|
||||||
|
local Text,Soundfile,Soundlength,Subtitle = nil, nil, 0, nil
|
||||||
|
if self.entries[locale] then
|
||||||
|
if self.entries[locale].Data then
|
||||||
|
local data = self.entries[locale].Data[ID] -- #TEXTANDSOUND.Data
|
||||||
|
if data then
|
||||||
|
Text = data.Text
|
||||||
|
Soundfile = data.Soundfile
|
||||||
|
Soundlength = data.Soundlength
|
||||||
|
Subtitle = data.Subtitle
|
||||||
|
elseif self.entries[self.locale].Data[ID] then
|
||||||
|
-- no matching entry, try default
|
||||||
|
local data = self.entries[self.locale].Data[ID]
|
||||||
|
Text = data.Text
|
||||||
|
Soundfile = data.Soundfile
|
||||||
|
Soundlength = data.Soundlength
|
||||||
|
Subtitle = data.Subtitle
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return nil, nil, 0, nil
|
||||||
|
end
|
||||||
|
return Text,Soundfile,Soundlength,Subtitle
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the default locale of this object
|
||||||
|
-- @param #TEXTANDSOUND self
|
||||||
|
-- @return #string locale
|
||||||
|
function TEXTANDSOUND:GetDefaultLocale()
|
||||||
|
self:T(self.lid .. "GetDefaultLocale")
|
||||||
|
return self.locale
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set default locale of this object
|
||||||
|
-- @param #TEXTANDSOUND self
|
||||||
|
-- @param #string locale
|
||||||
|
-- @return #TEXTANDSOUND self
|
||||||
|
function TEXTANDSOUND:SetDefaultLocale(locale)
|
||||||
|
self:T(self.lid .. "SetDefaultLocale")
|
||||||
|
self.locale = locale or "en"
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if a locale exists
|
||||||
|
-- @param #TEXTANDSOUND self
|
||||||
|
-- @return #boolean outcome
|
||||||
|
function TEXTANDSOUND:HasLocale(Locale)
|
||||||
|
self:T(self.lid .. "HasLocale")
|
||||||
|
return self.entries[Locale] and true or false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Flush all entries to the log
|
||||||
|
-- @param #TEXTANDSOUND self
|
||||||
|
-- @return #TEXTANDSOUND self
|
||||||
|
function TEXTANDSOUND:FlushToLog()
|
||||||
|
self:I(self.lid .. "Flushing entries:")
|
||||||
|
local text = string.format("Textclass: %s | Default Locale: %s",self.textclass, self.locale)
|
||||||
|
for _,_entry in pairs(self.entries) do
|
||||||
|
local entry = _entry -- #TEXTANDSOUND.Entry
|
||||||
|
local text = string.format("Textclassname: %s | Locale: %s",entry.Classname, entry.Locale)
|
||||||
|
self:I(text)
|
||||||
|
for _ID,_data in pairs(entry.Data) do
|
||||||
|
local data = _data -- #TEXTANDSOUND.Data
|
||||||
|
local text = string.format("ID: %s\nText: %s\nSoundfile: %s With length: %d\nSubtitle: %s",tostring(_ID), data.Text or "none",data.Soundfile or "none",data.Soundlength or 0,data.Subtitle or "none")
|
||||||
|
self:I(text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
----------------------------------------------------------------
|
||||||
|
-- End TextAndSound
|
||||||
|
----------------------------------------------------------------
|
||||||
@@ -34,8 +34,6 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- 
|
|
||||||
--
|
|
||||||
-- # The TIMER Concept
|
-- # The TIMER Concept
|
||||||
--
|
--
|
||||||
-- The TIMER class is the little sister of the @{Core.Scheduler#SCHEDULER} class. It does the same thing but is a bit easier to use and has less overhead. It should be sufficient in many cases.
|
-- The TIMER class is the little sister of the @{Core.Scheduler#SCHEDULER} class. It does the same thing but is a bit easier to use and has less overhead. It should be sufficient in many cases.
|
||||||
@@ -107,19 +105,17 @@ TIMER = {
|
|||||||
--- Timer ID.
|
--- Timer ID.
|
||||||
_TIMERID=0
|
_TIMERID=0
|
||||||
|
|
||||||
--- Timer data base.
|
|
||||||
--_TIMERDB={}
|
|
||||||
|
|
||||||
--- TIMER class version.
|
--- TIMER class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
TIMER.version="0.1.1"
|
TIMER.version="0.1.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- TODO: A lot.
|
-- TODO: Randomization.
|
||||||
-- TODO: Write docs.
|
-- TODO: Pause/unpause.
|
||||||
|
-- DONE: Write docs.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Constructor
|
-- Constructor
|
||||||
@@ -156,9 +152,6 @@ function TIMER:New(Function, ...)
|
|||||||
-- Log id.
|
-- Log id.
|
||||||
self.lid=string.format("TIMER UID=%d | ", self.uid)
|
self.lid=string.format("TIMER UID=%d | ", self.uid)
|
||||||
|
|
||||||
-- Add to DB.
|
|
||||||
--_TIMERDB[self.uid]=self
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -174,7 +167,7 @@ function TIMER:Start(Tstart, dT, Duration)
|
|||||||
local Tnow=timer.getTime()
|
local Tnow=timer.getTime()
|
||||||
|
|
||||||
-- Start time in sec.
|
-- Start time in sec.
|
||||||
self.Tstart=Tstart and Tnow+Tstart or Tnow+0.001 -- one millisecond delay if Tstart=nil
|
self.Tstart=Tstart and Tnow+math.max(Tstart, 0.001) or Tnow+0.001 -- one millisecond delay if Tstart=nil
|
||||||
|
|
||||||
-- Set time interval.
|
-- Set time interval.
|
||||||
self.dT=dT
|
self.dT=dT
|
||||||
@@ -220,9 +213,6 @@ function TIMER:Stop(Delay)
|
|||||||
-- Not running any more.
|
-- Not running any more.
|
||||||
self.isrunning=false
|
self.isrunning=false
|
||||||
|
|
||||||
-- Remove DB entry.
|
|
||||||
--_TIMERDB[self.uid]=nil
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -239,6 +229,15 @@ function TIMER:SetMaxFunctionCalls(Nmax)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set time interval. Can also be set when the timer is already running and is applied after the next function call.
|
||||||
|
-- @param #TIMER self
|
||||||
|
-- @param #number dT Time interval in seconds.
|
||||||
|
-- @return #TIMER self
|
||||||
|
function TIMER:SetTimeInterval(dT)
|
||||||
|
self.dT=dT
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if the timer has been started and was not stopped.
|
--- Check if the timer has been started and was not stopped.
|
||||||
-- @param #TIMER self
|
-- @param #TIMER self
|
||||||
-- @return #boolean If `true`, the timer is running.
|
-- @return #boolean If `true`, the timer is running.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
-- * Create polygon zones.
|
-- * Create polygon zones.
|
||||||
-- * Create moving zones around a unit.
|
-- * Create moving zones around a unit.
|
||||||
-- * Create moving zones around a group.
|
-- * 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.
|
-- * Enquiry if a coordinate is within a zone.
|
||||||
-- * Smoke zones.
|
-- * Smoke zones.
|
||||||
-- * Set a zone probability to control zone selection.
|
-- * Set a zone probability to control zone selection.
|
||||||
@@ -20,10 +20,10 @@
|
|||||||
-- * Draw zones (circular and polygon) on the F10 map.
|
-- * 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.
|
-- * 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:
|
-- The object classes are using the zone classes to test the zone boundaries, which can take various forms:
|
||||||
--
|
--
|
||||||
@@ -59,6 +59,11 @@
|
|||||||
-- @field #number ZoneProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
-- @field #number ZoneProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
||||||
-- @field #number DrawID Unique ID of the drawn zone on the F10 map.
|
-- @field #number DrawID Unique ID of the drawn zone on the F10 map.
|
||||||
-- @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.
|
-- @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.
|
||||||
|
-- @field #table FillColor Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
||||||
|
-- @field #number drawCoalition Draw coalition.
|
||||||
|
-- @field #number ZoneID ID of zone. Only zones defined in the ME have an ID!
|
||||||
|
-- @field #table Table of any trigger zone properties from the ME. The key is the Name of the property, and the value is the property's Value.
|
||||||
|
-- @field #number Surface Type of surface. Only determined at the center of the zone!
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
|
||||||
@@ -102,13 +107,21 @@
|
|||||||
-- * @{#ZONE_BASE.SmokeZone}(): Smokes the zone boundaries in a color.
|
-- * @{#ZONE_BASE.SmokeZone}(): Smokes the zone boundaries in a color.
|
||||||
-- * @{#ZONE_BASE.FlareZone}(): Flares the zone boundaries in a color.
|
-- * @{#ZONE_BASE.FlareZone}(): Flares the zone boundaries in a color.
|
||||||
--
|
--
|
||||||
|
-- ## A zone might have additional Properties created in the DCS Mission Editor, which can be accessed:
|
||||||
|
--
|
||||||
|
-- *@{#ZONE_BASE.GetProperty}(): Returns the Value of the zone with the given PropertyName, or nil if no matching property exists.
|
||||||
|
-- *@{#ZONE_BASE.GetAllProperties}(): Returns the zone Properties table.
|
||||||
|
--
|
||||||
-- @field #ZONE_BASE
|
-- @field #ZONE_BASE
|
||||||
ZONE_BASE = {
|
ZONE_BASE = {
|
||||||
ClassName = "ZONE_BASE",
|
ClassName = "ZONE_BASE",
|
||||||
ZoneName = "",
|
ZoneName = "",
|
||||||
ZoneProbability = 1,
|
ZoneProbability = 1,
|
||||||
DrawID=nil,
|
DrawID=nil,
|
||||||
Color={}
|
Color={},
|
||||||
|
ZoneID=nil,
|
||||||
|
Properties={},
|
||||||
|
Sureface=nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -130,6 +143,8 @@ function ZONE_BASE:New( ZoneName )
|
|||||||
|
|
||||||
self.ZoneName = ZoneName
|
self.ZoneName = ZoneName
|
||||||
|
|
||||||
|
--_DATABASE:AddZone(ZoneName,self)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -170,6 +185,7 @@ end
|
|||||||
-- @param DCS#Vec3 Vec3 The point to test.
|
-- @param DCS#Vec3 Vec3 The point to test.
|
||||||
-- @return #boolean true if the Vec3 is within the zone.
|
-- @return #boolean true if the Vec3 is within the zone.
|
||||||
function ZONE_BASE:IsVec3InZone( Vec3 )
|
function ZONE_BASE:IsVec3InZone( Vec3 )
|
||||||
|
if not Vec3 then return false end
|
||||||
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
||||||
return InZone
|
return InZone
|
||||||
end
|
end
|
||||||
@@ -288,6 +304,23 @@ function ZONE_BASE:GetCoordinate( Height ) --R2.1
|
|||||||
return self.Coordinate
|
return self.Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get 2D distance to a coordinate.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate Reference coordinate. Can also be a DCS#Vec2 or DCS#Vec3 object.
|
||||||
|
-- @return #number Distance to the reference coordinate in meters.
|
||||||
|
function ZONE_BASE:Get2DDistance(Coordinate)
|
||||||
|
local a=self:GetVec2()
|
||||||
|
local b={}
|
||||||
|
if Coordinate.z then
|
||||||
|
b.x=Coordinate.x
|
||||||
|
b.y=Coordinate.z
|
||||||
|
else
|
||||||
|
b.x=Coordinate.x
|
||||||
|
b.y=Coordinate.y
|
||||||
|
end
|
||||||
|
local dist=UTILS.VecDist2D(a,b)
|
||||||
|
return dist
|
||||||
|
end
|
||||||
|
|
||||||
--- Define a random @{DCS#Vec2} within the zone.
|
--- Define a random @{DCS#Vec2} within the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
@@ -314,18 +347,41 @@ end
|
|||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return #nil The bounding square.
|
-- @return #nil The bounding square.
|
||||||
function ZONE_BASE:GetBoundingSquare()
|
function ZONE_BASE:GetBoundingSquare()
|
||||||
--return { x1 = 0, y1 = 0, x2 = 0, y2 = 0 }
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get surface type of the zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return DCS#SurfaceType Type of surface.
|
||||||
|
function ZONE_BASE:GetSurfaceType()
|
||||||
|
local coord=self:GetCoordinate()
|
||||||
|
local surface=coord:GetSurfaceType()
|
||||||
|
return surface
|
||||||
|
end
|
||||||
|
|
||||||
--- Bound the zone boundaries with a tires.
|
--- Bound the zone boundaries with a tires.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
function ZONE_BASE:BoundZone()
|
function ZONE_BASE:BoundZone()
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set draw coalition of zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @param #number Coalition Coalition. Default -1.
|
||||||
|
-- @return #ZONE_BASE self
|
||||||
|
function ZONE_BASE:SetDrawCoalition(Coalition)
|
||||||
|
self.drawCoalition=Coalition or -1
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get draw coalition of zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #number Draw coaliton.
|
||||||
|
function ZONE_BASE:GetDrawCoalition()
|
||||||
|
return self.drawCoalition or -1
|
||||||
|
end
|
||||||
|
|
||||||
--- Set color of zone.
|
--- Set color of zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param #table RGBcolor RGB color table. Default `{1, 0, 0}`.
|
-- @param #table RGBcolor RGB color table. Default `{1, 0, 0}`.
|
||||||
@@ -349,7 +405,7 @@ end
|
|||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return #table Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
-- @return #table Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
||||||
function ZONE_BASE:GetColor()
|
function ZONE_BASE:GetColor()
|
||||||
return self.Color
|
return self.Color or {1, 0, 0, 0.15}
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get RGB color of zone.
|
--- Get RGB color of zone.
|
||||||
@@ -357,9 +413,10 @@ end
|
|||||||
-- @return #table Table with three entries, e.g. {1, 0, 0}, which is the RGB color code.
|
-- @return #table Table with three entries, e.g. {1, 0, 0}, which is the RGB color code.
|
||||||
function ZONE_BASE:GetColorRGB()
|
function ZONE_BASE:GetColorRGB()
|
||||||
local rgb={}
|
local rgb={}
|
||||||
rgb[1]=self.Color[1]
|
local Color=self:GetColor()
|
||||||
rgb[2]=self.Color[2]
|
rgb[1]=Color[1]
|
||||||
rgb[3]=self.Color[3]
|
rgb[2]=Color[2]
|
||||||
|
rgb[3]=Color[3]
|
||||||
return rgb
|
return rgb
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -367,7 +424,55 @@ end
|
|||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return #number Alpha value.
|
-- @return #number Alpha value.
|
||||||
function ZONE_BASE:GetColorAlpha()
|
function ZONE_BASE:GetColorAlpha()
|
||||||
local alpha=self.Color[4]
|
local Color=self:GetColor()
|
||||||
|
local alpha=Color[4]
|
||||||
|
return alpha
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set fill 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:SetFillColor(RGBcolor, Alpha)
|
||||||
|
|
||||||
|
RGBcolor=RGBcolor or {1, 0, 0}
|
||||||
|
Alpha=Alpha or 0.15
|
||||||
|
|
||||||
|
self.FillColor={}
|
||||||
|
self.FillColor[1]=RGBcolor[1]
|
||||||
|
self.FillColor[2]=RGBcolor[2]
|
||||||
|
self.FillColor[3]=RGBcolor[3]
|
||||||
|
self.FillColor[4]=Alpha
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get fill color table of the zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #table Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
||||||
|
function ZONE_BASE:GetFillColor()
|
||||||
|
return self.FillColor or {1, 0, 0, 0.15}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get RGB fill color of zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #table Table with three entries, e.g. {1, 0, 0}, which is the RGB color code.
|
||||||
|
function ZONE_BASE:GetFillColorRGB()
|
||||||
|
local rgb={}
|
||||||
|
local FillColor=self:GetFillColor()
|
||||||
|
rgb[1]=FillColor[1]
|
||||||
|
rgb[2]=FillColor[2]
|
||||||
|
rgb[3]=FillColor[3]
|
||||||
|
return rgb
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get transperency Alpha fill value of zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #number Alpha value.
|
||||||
|
function ZONE_BASE:GetFillColorAlpha()
|
||||||
|
local FillColor=self:GetFillColor()
|
||||||
|
local alpha=FillColor[4]
|
||||||
return alpha
|
return alpha
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -459,6 +564,26 @@ function ZONE_BASE:GetZoneMaybe()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns the Value of the zone with the given PropertyName, or nil if no matching property exists.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @param #string PropertyName The name of a the TriggerZone Property to be retrieved.
|
||||||
|
-- @return #string The Value of the TriggerZone Property with the given PropertyName, or nil if absent.
|
||||||
|
-- @usage
|
||||||
|
--
|
||||||
|
-- local PropertiesZone = ZONE:FindByName("Properties Zone")
|
||||||
|
-- local Property = "ExampleProperty"
|
||||||
|
-- local PropertyValue = PropertiesZone:GetProperty(Property)
|
||||||
|
--
|
||||||
|
function ZONE_BASE:GetProperty(PropertyName)
|
||||||
|
return self.Properties[PropertyName]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns the zone Properties table.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #table The Key:Value table of TriggerZone properties of the zone.
|
||||||
|
function ZONE_BASE:GetAllProperties()
|
||||||
|
return self.Properties
|
||||||
|
end
|
||||||
|
|
||||||
--- The ZONE_RADIUS class, defined by a zone name, a location and a radius.
|
--- The ZONE_RADIUS class, defined by a zone name, a location and a radius.
|
||||||
-- @type ZONE_RADIUS
|
-- @type ZONE_RADIUS
|
||||||
@@ -601,7 +726,7 @@ function ZONE_RADIUS:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, Lin
|
|||||||
|
|
||||||
Color=Color or self:GetColorRGB()
|
Color=Color or self:GetColorRGB()
|
||||||
Alpha=Alpha or 1
|
Alpha=Alpha or 1
|
||||||
FillColor=FillColor or Color
|
FillColor=FillColor or UTILS.DeepCopy(Color)
|
||||||
FillAlpha=FillAlpha or self:GetColorAlpha()
|
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)
|
||||||
@@ -789,7 +914,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Scan the zone for the presence of units of the given ObjectCategories.
|
--- 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:
|
-- Note that **only after** a zone has been scanned, the zone can be evaluated by:
|
||||||
--
|
--
|
||||||
-- * @{ZONE_RADIUS.IsAllInZoneOfCoalition}(): Scan the presence of units in the zone of a coalition.
|
-- * @{ZONE_RADIUS.IsAllInZoneOfCoalition}(): Scan the presence of units in the zone of a coalition.
|
||||||
-- * @{ZONE_RADIUS.IsAllInZoneOfOtherCoalition}(): Scan the presence of units in the zone of an other coalition.
|
-- * @{ZONE_RADIUS.IsAllInZoneOfOtherCoalition}(): Scan the presence of units in the zone of an other coalition.
|
||||||
@@ -798,11 +923,11 @@ end
|
|||||||
-- * @{ZONE_RADIUS.IsNoneInZone}(): Scan if the zone is empty.
|
-- * @{ZONE_RADIUS.IsNoneInZone}(): Scan if the zone is empty.
|
||||||
-- @{#ZONE_RADIUS.
|
-- @{#ZONE_RADIUS.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param ObjectCategories An array of categories of the objects to find in the zone.
|
-- @param ObjectCategories An array of categories of the objects to find in the zone. E.g. `{Object.Category.UNIT}`
|
||||||
-- @param UnitCategories An array of unit categories of the objects to find in the zone.
|
-- @param UnitCategories An array of unit categories of the objects to find in the zone. E.g. `{Unit.Category.GROUND_UNIT,Unit.Category.SHIP}`
|
||||||
-- @usage
|
-- @usage
|
||||||
-- self.Zone:Scan()
|
-- myzone:Scan({Object.Category.UNIT},{Unit.Category.GROUND_UNIT})
|
||||||
-- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
-- local IsAttacked = myzone:IsSomeInZoneOfCoalition( self.Coalition )
|
||||||
function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
|
function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
|
||||||
|
|
||||||
self.ScanData = {}
|
self.ScanData = {}
|
||||||
@@ -872,7 +997,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
|
|||||||
local SceneryName = ZoneObject:getName()
|
local SceneryName = ZoneObject:getName()
|
||||||
self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {}
|
self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {}
|
||||||
self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject )
|
self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject )
|
||||||
self:F2( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
|
self:T( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1136,6 +1261,8 @@ end
|
|||||||
function ZONE_RADIUS:IsVec2InZone( Vec2 )
|
function ZONE_RADIUS:IsVec2InZone( Vec2 )
|
||||||
self:F2( Vec2 )
|
self:F2( Vec2 )
|
||||||
|
|
||||||
|
if not Vec2 then return false end
|
||||||
|
|
||||||
local ZoneVec2 = self:GetVec2()
|
local ZoneVec2 = self:GetVec2()
|
||||||
|
|
||||||
if ZoneVec2 then
|
if ZoneVec2 then
|
||||||
@@ -1153,7 +1280,7 @@ end
|
|||||||
-- @return #boolean true if the point is within the zone.
|
-- @return #boolean true if the point is within the zone.
|
||||||
function ZONE_RADIUS:IsVec3InZone( Vec3 )
|
function ZONE_RADIUS:IsVec3InZone( Vec3 )
|
||||||
self:F2( Vec3 )
|
self:F2( Vec3 )
|
||||||
|
if not Vec3 then return false end
|
||||||
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
||||||
|
|
||||||
return InZone
|
return InZone
|
||||||
@@ -1161,24 +1288,54 @@ end
|
|||||||
|
|
||||||
--- Returns a random Vec2 location within the zone.
|
--- Returns a random Vec2 location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (Optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
|
-- @param #table surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 100 times to find the right type!
|
||||||
-- @return DCS#Vec2 The random location within the zone.
|
-- @return DCS#Vec2 The random location within the zone.
|
||||||
function ZONE_RADIUS:GetRandomVec2( inner, outer )
|
function ZONE_RADIUS:GetRandomVec2(inner, outer, surfacetypes)
|
||||||
self:F( self.ZoneName, inner, outer )
|
|
||||||
|
|
||||||
local Point = {}
|
local Vec2 = self:GetVec2()
|
||||||
local Vec2 = self:GetVec2()
|
local _inner = inner or 0
|
||||||
local _inner = inner or 0
|
local _outer = outer or self:GetRadius()
|
||||||
local _outer = outer or self:GetRadius()
|
|
||||||
|
|
||||||
local angle = math.random() * math.pi * 2;
|
if surfacetypes and type(surfacetypes)~="table" then
|
||||||
Point.x = Vec2.x + math.cos( angle ) * math.random(_inner, _outer);
|
surfacetypes={surfacetypes}
|
||||||
Point.y = Vec2.y + math.sin( angle ) * math.random(_inner, _outer);
|
end
|
||||||
|
|
||||||
self:T( { Point } )
|
local function _getpoint()
|
||||||
|
local point = {}
|
||||||
|
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)
|
||||||
|
return point
|
||||||
|
end
|
||||||
|
|
||||||
return Point
|
local function _checkSurface(point)
|
||||||
|
local stype=land.getSurfaceType(point)
|
||||||
|
for _,sf in pairs(surfacetypes) do
|
||||||
|
if sf==stype then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local point=_getpoint()
|
||||||
|
|
||||||
|
if surfacetypes then
|
||||||
|
local N=1 ; local Nmax=100 ; local gotit=false
|
||||||
|
while gotit==false and N<=Nmax do
|
||||||
|
gotit=_checkSurface(point)
|
||||||
|
if gotit then
|
||||||
|
--env.info(string.format("Got random coordinate with surface type %d after N=%d/%d iterations", land.getSurfaceType(point), N, Nmax))
|
||||||
|
else
|
||||||
|
point=_getpoint()
|
||||||
|
N=N+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return point
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
||||||
@@ -1230,20 +1387,99 @@ end
|
|||||||
|
|
||||||
--- Returns a @{Core.Point#COORDINATE} object reflecting a random 3D location within the zone.
|
--- Returns a @{Core.Point#COORDINATE} object reflecting a random 3D location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (Optional) Minimal distance from the center of the zone in meters. Default is 0 m.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone in meters. Default is the radius of the zone.
|
||||||
-- @return Core.Point#COORDINATE
|
-- @param #table surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 1000 times to find the right type!
|
||||||
function ZONE_RADIUS:GetRandomCoordinate( inner, outer )
|
-- @return Core.Point#COORDINATE The random coordinate.
|
||||||
self:F( self.ZoneName, inner, outer )
|
function ZONE_RADIUS:GetRandomCoordinate(inner, outer, surfacetypes)
|
||||||
|
|
||||||
local Coordinate = COORDINATE:NewFromVec2( self:GetRandomVec2(inner, outer) )
|
local vec2=self:GetRandomVec2(inner, outer, surfacetypes)
|
||||||
|
|
||||||
self:T3( { Coordinate = Coordinate } )
|
local Coordinate = COORDINATE:NewFromVec2(vec2)
|
||||||
|
|
||||||
return Coordinate
|
return Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns a @{Core.Point#COORDINATE} object reflecting a random location within the zone where there are no **map objects** of type "Building".
|
||||||
|
-- Does not find statics you might have placed there. **Note** This might be quite CPU intensive, use with care.
|
||||||
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @param #number inner (Optional) Minimal distance from the center of the zone in meters. Default is 0m.
|
||||||
|
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone in meters. Default is the radius of the zone.
|
||||||
|
-- @param #number distance (Optional) Minumum distance from any building coordinate. Defaults to 100m.
|
||||||
|
-- @param #boolean markbuildings (Optional) Place markers on found buildings (if any).
|
||||||
|
-- @param #boolean markfinal (Optional) Place marker on the final coordinate (if any).
|
||||||
|
-- @return Core.Point#COORDINATE The random coordinate or `nil` if cannot be found in 1000 iterations.
|
||||||
|
function ZONE_RADIUS:GetRandomCoordinateWithoutBuildings(inner,outer,distance,markbuildings,markfinal)
|
||||||
|
|
||||||
|
local dist = distance or 100
|
||||||
|
|
||||||
|
local objects = {}
|
||||||
|
|
||||||
|
if self.ScanData and self.ScanData.Scenery then
|
||||||
|
objects = self:GetScannedScenery()
|
||||||
|
else
|
||||||
|
self:Scan({Object.Category.SCENERY})
|
||||||
|
objects = self:GetScannedScenery()
|
||||||
|
end
|
||||||
|
|
||||||
|
local T0 = timer.getTime()
|
||||||
|
local T1 = timer.getTime()
|
||||||
|
|
||||||
|
|
||||||
|
local buildings = {}
|
||||||
|
if self.ScanData and self.ScanData.BuildingCoordinates then
|
||||||
|
buildings = self.ScanData.BuildingCoordinates
|
||||||
|
else
|
||||||
|
-- build table of buildings coordinates
|
||||||
|
for _,_object in pairs (objects) do
|
||||||
|
for _,_scen in pairs (_object) do
|
||||||
|
local scenery = _scen -- Wrapper.Scenery#SCENERY
|
||||||
|
local description=scenery:GetDesc()
|
||||||
|
if description and description.attributes and description.attributes.Buildings then
|
||||||
|
if markbuildings then
|
||||||
|
MARKER:New(scenery:GetCoordinate(),"Building"):ToAll()
|
||||||
|
end
|
||||||
|
buildings[#buildings+1] = scenery:GetCoordinate()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.ScanData.BuildingCoordinates = buildings
|
||||||
|
end
|
||||||
|
|
||||||
|
-- max 1000 tries
|
||||||
|
local rcoord = nil
|
||||||
|
local found = false
|
||||||
|
local iterations = 0
|
||||||
|
|
||||||
|
for i=1,1000 do
|
||||||
|
iterations = iterations + 1
|
||||||
|
rcoord = self:GetRandomCoordinate(inner,outer)
|
||||||
|
found = false
|
||||||
|
for _,_coord in pairs (buildings) do
|
||||||
|
local coord = _coord -- Core.Point#COORDINATE
|
||||||
|
-- keep >50m dist from buildings
|
||||||
|
if coord:Get2DDistance(rcoord) > dist then
|
||||||
|
found = true
|
||||||
|
else
|
||||||
|
found = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if found then
|
||||||
|
-- we have a winner!
|
||||||
|
if markfinal then
|
||||||
|
MARKER:New(rcoord,"FREE"):ToAll()
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
T1=timer.getTime()
|
||||||
|
|
||||||
|
self:T(string.format("Found a coordinate: %s | Iterations: %d | Time: %d",tostring(found),iterations,T1-T0))
|
||||||
|
|
||||||
|
if found then return rcoord else return nil end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- @type ZONE
|
--- @type ZONE
|
||||||
-- @extends #ZONE_RADIUS
|
-- @extends #ZONE_RADIUS
|
||||||
@@ -1301,7 +1537,7 @@ function ZONE:New( ZoneName )
|
|||||||
|
|
||||||
-- Error!
|
-- Error!
|
||||||
if not Zone then
|
if not Zone then
|
||||||
error( "Zone " .. ZoneName .. " does not exist." )
|
env.error( "ERROR: Zone " .. ZoneName .. " does not exist!" )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1319,9 +1555,9 @@ function ZONE:New( ZoneName )
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Find a zone in the _DATABASE using the name of the zone.
|
--- Find a zone in the _DATABASE using the name of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE self
|
||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
-- @return #ZONE_BASE self
|
-- @return #ZONE self
|
||||||
function ZONE:FindByName( ZoneName )
|
function ZONE:FindByName( ZoneName )
|
||||||
|
|
||||||
local ZoneFound = _DATABASE:FindZone( ZoneName )
|
local ZoneFound = _DATABASE:FindZone( ZoneName )
|
||||||
@@ -1557,7 +1793,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- @type ZONE_POLYGON_BASE
|
--- @type ZONE_POLYGON_BASE
|
||||||
-- --@field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}.
|
-- @field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}.
|
||||||
-- @extends #ZONE_BASE
|
-- @extends #ZONE_BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -1795,7 +2031,7 @@ function ZONE_POLYGON_BASE:BoundZone( UnBound )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Draw the zone on the F10 map. **NOTE** Currently, only polygons with **exactly four points** are supported!
|
--- Draw the zone on the F10 map. **NOTE** Currently, only polygons **up to ten points** are supported!
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
||||||
@@ -1807,32 +2043,48 @@ end
|
|||||||
-- @return #ZONE_POLYGON_BASE self
|
-- @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])
|
if self._.Polygon and #self._.Polygon>=3 then
|
||||||
|
|
||||||
Color=Color or self:GetColorRGB()
|
local coordinate=COORDINATE:NewFromVec2(self._.Polygon[1])
|
||||||
Alpha=Alpha or 1
|
|
||||||
FillColor=FillColor or Color
|
|
||||||
FillAlpha=FillAlpha or self:GetColorAlpha()
|
|
||||||
|
|
||||||
|
Coalition=Coalition or self:GetDrawCoalition()
|
||||||
|
|
||||||
if #self._.Polygon==4 then
|
-- Set draw coalition.
|
||||||
|
self:SetDrawCoalition(Coalition)
|
||||||
|
|
||||||
local Coord2=COORDINATE:NewFromVec2(self._.Polygon[2])
|
Color=Color or self:GetColorRGB()
|
||||||
local Coord3=COORDINATE:NewFromVec2(self._.Polygon[3])
|
Alpha=Alpha or 1
|
||||||
local Coord4=COORDINATE:NewFromVec2(self._.Polygon[4])
|
|
||||||
|
|
||||||
self.DrawID=coordinate:QuadToAll(Coord2, Coord3, Coord4, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
-- Set color.
|
||||||
|
self:SetColor(Color, Alpha)
|
||||||
|
|
||||||
else
|
FillColor=FillColor or self:GetFillColorRGB()
|
||||||
|
if not FillColor then UTILS.DeepCopy(Color) end
|
||||||
|
FillAlpha=FillAlpha or self:GetFillColorAlpha()
|
||||||
|
if not FillAlpha then FillAlpha=0.15 end
|
||||||
|
|
||||||
local Coordinates=self:GetVerticiesCoordinates()
|
-- Set fill color.
|
||||||
table.remove(Coordinates, 1)
|
self:SetFillColor(FillColor, FillAlpha)
|
||||||
|
|
||||||
self.DrawID=coordinate:MarkupToAllFreeForm(Coordinates, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
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])
|
||||||
|
|
||||||
|
self.DrawID=coordinate:QuadToAll(Coord2, Coord3, Coord4, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
local Coordinates=self:GetVerticiesCoordinates()
|
||||||
|
table.remove(Coordinates, 1)
|
||||||
|
|
||||||
|
self.DrawID=coordinate:MarkupToAllFreeForm(Coordinates, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1913,7 +2165,7 @@ end
|
|||||||
-- @return #boolean true if the location is within the zone.
|
-- @return #boolean true if the location is within the zone.
|
||||||
function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
|
function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
|
||||||
self:F2( Vec2 )
|
self:F2( Vec2 )
|
||||||
|
if not Vec2 then return false end
|
||||||
local Next
|
local Next
|
||||||
local Prev
|
local Prev
|
||||||
local InPolygon = false
|
local InPolygon = false
|
||||||
@@ -1937,30 +2189,46 @@ function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
|
|||||||
return InPolygon
|
return InPolygon
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns if a point is within the zone.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param DCS#Vec3 Vec3 The point to test.
|
||||||
|
-- @return #boolean true if the point is within the zone.
|
||||||
|
function ZONE_POLYGON_BASE:IsVec3InZone( Vec3 )
|
||||||
|
self:F2( Vec3 )
|
||||||
|
|
||||||
|
if not Vec3 then return false end
|
||||||
|
|
||||||
|
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
||||||
|
|
||||||
|
return InZone
|
||||||
|
end
|
||||||
|
|
||||||
--- Define a random @{DCS#Vec2} within the zone.
|
--- Define a random @{DCS#Vec2} within the zone.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return DCS#Vec2 The Vec2 coordinate.
|
-- @return DCS#Vec2 The Vec2 coordinate.
|
||||||
function ZONE_POLYGON_BASE:GetRandomVec2()
|
function ZONE_POLYGON_BASE:GetRandomVec2()
|
||||||
self:F2()
|
|
||||||
|
|
||||||
--- It is a bit tricky to find a random point within a polygon. Right now i am doing it the dirty and inefficient way...
|
-- It is a bit tricky to find a random point within a polygon. Right now i am doing it the dirty and inefficient way...
|
||||||
local Vec2Found = false
|
|
||||||
local Vec2
|
-- Get the bounding square.
|
||||||
local BS = self:GetBoundingSquare()
|
local BS = self:GetBoundingSquare()
|
||||||
|
|
||||||
self:T2( BS )
|
local Nmax=1000 ; local n=0
|
||||||
|
while n<Nmax do
|
||||||
|
|
||||||
while Vec2Found == false do
|
-- Random point in the bounding square.
|
||||||
Vec2 = { x = math.random( BS.x1, BS.x2 ), y = math.random( BS.y1, BS.y2 ) }
|
local Vec2={x=math.random(BS.x1, BS.x2), y=math.random(BS.y1, BS.y2)}
|
||||||
self:T2( Vec2 )
|
|
||||||
if self:IsVec2InZone( Vec2 ) then
|
-- Check if this is in the polygon.
|
||||||
Vec2Found = true
|
if self:IsVec2InZone(Vec2) then
|
||||||
|
return Vec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
n=n+1
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T2( Vec2 )
|
self:E("Could not find a random point in the polygon zone!")
|
||||||
|
return nil
|
||||||
return Vec2
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return a @{Core.Point#POINT_VEC2} object representing a random 2D point at landheight within the zone.
|
--- Return a @{Core.Point#POINT_VEC2} object representing a random 2D point at landheight within the zone.
|
||||||
@@ -2075,12 +2343,12 @@ end
|
|||||||
--
|
--
|
||||||
-- ## Declare a ZONE_POLYGON directly in the DCS mission editor!
|
-- ## Declare a ZONE_POLYGON directly in the DCS mission editor!
|
||||||
--
|
--
|
||||||
-- You can declare a ZONE_POLYGON using the DCS mission editor by adding the ~ZONE_POLYGON tag in the group name.
|
-- You can declare a ZONE_POLYGON using the DCS mission editor by adding the #ZONE_POLYGON tag in the group name.
|
||||||
--
|
--
|
||||||
-- So, imagine you have a group declared in the mission editor, with group name `DefenseZone~ZONE_POLYGON`.
|
-- So, imagine you have a group declared in the mission editor, with group name `DefenseZone#ZONE_POLYGON`.
|
||||||
-- Then during mission startup, when loading Moose.lua, this group will be detected as a ZONE_POLYGON declaration.
|
-- Then during mission startup, when loading Moose.lua, this group will be detected as a ZONE_POLYGON declaration.
|
||||||
-- Within the background, a ZONE_POLYGON object will be created within the @{Core.Database} using the properties of the group.
|
-- Within the background, a ZONE_POLYGON object will be created within the @{Core.Database} using the properties of the group.
|
||||||
-- The ZONE_POLYGON name will be the group name without the ~ZONE_POLYGON tag.
|
-- The ZONE_POLYGON name will be the group name without the #ZONE_POLYGON tag.
|
||||||
--
|
--
|
||||||
-- So, you can search yourself for the ZONE_POLYGON by using the @{#ZONE_POLYGON.FindByName}() method.
|
-- So, you can search yourself for the ZONE_POLYGON by using the @{#ZONE_POLYGON.FindByName}() method.
|
||||||
-- In this example, `local PolygonZone = ZONE_POLYGON:FindByName( "DefenseZone" )` would return the ZONE_POLYGON object
|
-- In this example, `local PolygonZone = ZONE_POLYGON:FindByName( "DefenseZone" )` would return the ZONE_POLYGON object
|
||||||
@@ -2149,9 +2417,212 @@ function ZONE_POLYGON:FindByName( ZoneName )
|
|||||||
return ZoneFound
|
return ZoneFound
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do -- ZONE_ELASTIC
|
||||||
|
|
||||||
|
--- @type ZONE_ELASTIC
|
||||||
|
-- @field #table points Points in 2D.
|
||||||
|
-- @field #table setGroups Set of GROUPs.
|
||||||
|
-- @field #table setOpsGroups Set of OPSGROUPS.
|
||||||
|
-- @field #table setUnits Set of UNITs.
|
||||||
|
-- @field #number updateID Scheduler ID for updating.
|
||||||
|
-- @extends #ZONE_POLYGON_BASE
|
||||||
|
|
||||||
|
--- The ZONE_ELASTIC class defines a dynamic polygon zone, where only the convex hull is used.
|
||||||
|
--
|
||||||
|
-- @field #ZONE_ELASTIC
|
||||||
|
ZONE_ELASTIC = {
|
||||||
|
ClassName="ZONE_ELASTIC",
|
||||||
|
points={},
|
||||||
|
setGroups={}
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Constructor to create a ZONE_ELASTIC instance.
|
||||||
|
-- @param #ZONE_ELASTIC self
|
||||||
|
-- @param #string ZoneName Name of the zone.
|
||||||
|
-- @param DCS#Vec2 Points (Optional) Fixed points.
|
||||||
|
-- @return #ZONE_ELASTIC self
|
||||||
|
function ZONE_ELASTIC:New(ZoneName, Points)
|
||||||
|
|
||||||
|
local self=BASE:Inherit(self, ZONE_POLYGON_BASE:New(ZoneName, Points)) --#ZONE_ELASTIC
|
||||||
|
|
||||||
|
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
||||||
|
_EVENTDISPATCHER:CreateEventNewZone( self )
|
||||||
|
|
||||||
|
if Points then
|
||||||
|
self.points=Points
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a vertex (point) to the polygon.
|
||||||
|
-- @param #ZONE_ELASTIC self
|
||||||
|
-- @param DCS#Vec2 Vec2 Point in 2D (with x and y coordinates).
|
||||||
|
-- @return #ZONE_ELASTIC self
|
||||||
|
function ZONE_ELASTIC:AddVertex2D(Vec2)
|
||||||
|
|
||||||
|
-- Add vec2 to points.
|
||||||
|
table.insert(self.points, Vec2)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Add a vertex (point) to the polygon.
|
||||||
|
-- @param #ZONE_ELASTIC self
|
||||||
|
-- @param DCS#Vec3 Vec3 Point in 3D (with x, y and z coordinates). Only the x and z coordinates are used.
|
||||||
|
-- @return #ZONE_ELASTIC self
|
||||||
|
function ZONE_ELASTIC:AddVertex3D(Vec3)
|
||||||
|
|
||||||
|
-- Add vec2 from vec3 to points.
|
||||||
|
table.insert(self.points, {x=Vec3.x, y=Vec3.z})
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Add a set of groups. Positions of the group will be considered as polygon vertices when contructing the convex hull.
|
||||||
|
-- @param #ZONE_ELASTIC self
|
||||||
|
-- @param Core.Set#SET_GROUP SetGroup Set of groups.
|
||||||
|
-- @return #ZONE_ELASTIC self
|
||||||
|
function ZONE_ELASTIC:AddSetGroup(GroupSet)
|
||||||
|
|
||||||
|
-- Add set to table.
|
||||||
|
table.insert(self.setGroups, GroupSet)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Update the convex hull of the polygon.
|
||||||
|
-- This uses the [Graham scan](https://en.wikipedia.org/wiki/Graham_scan).
|
||||||
|
-- @param #ZONE_ELASTIC self
|
||||||
|
-- @param #number Delay Delay in seconds before the zone is updated. Default 0.
|
||||||
|
-- @param #boolean Draw Draw the zone. Default `nil`.
|
||||||
|
-- @return #ZONE_ELASTIC self
|
||||||
|
function ZONE_ELASTIC:Update(Delay, Draw)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(string.format("Updating ZONE_ELASTIC %s", tostring(self.ZoneName)))
|
||||||
|
|
||||||
|
-- Copy all points.
|
||||||
|
local points=UTILS.DeepCopy(self.points or {})
|
||||||
|
|
||||||
|
if self.setGroups then
|
||||||
|
for _,_setGroup in pairs(self.setGroups) do
|
||||||
|
local setGroup=_setGroup --Core.Set#SET_GROUP
|
||||||
|
for _,_group in pairs(setGroup.Set) do
|
||||||
|
local group=_group --Wrapper.Group#GROUP
|
||||||
|
if group and group:IsAlive() then
|
||||||
|
table.insert(points, group:GetVec2())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update polygon verticies from points.
|
||||||
|
self._.Polygon=self:_ConvexHull(points)
|
||||||
|
|
||||||
|
if Draw~=false then
|
||||||
|
if self.DrawID or Draw==true then
|
||||||
|
self:UndrawZone()
|
||||||
|
self:DrawZone()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Start the updating scheduler.
|
||||||
|
-- @param #ZONE_ELASTIC self
|
||||||
|
-- @param #number Tstart Time in seconds before the updating starts.
|
||||||
|
-- @param #number dT Time interval in seconds between updates. Default 60 sec.
|
||||||
|
-- @param #number Tstop Time in seconds after which the updating stops. Default `nil`.
|
||||||
|
-- @param #boolean Draw Draw the zone. Default `nil`.
|
||||||
|
-- @return #ZONE_ELASTIC self
|
||||||
|
function ZONE_ELASTIC:StartUpdate(Tstart, dT, Tstop, Draw)
|
||||||
|
|
||||||
|
self.updateID=self:ScheduleRepeat(Tstart, dT, 0, Tstop, ZONE_ELASTIC.Update, self, 0, Draw)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Stop the updating scheduler.
|
||||||
|
-- @param #ZONE_ELASTIC self
|
||||||
|
-- @param #number Delay Delay in seconds before the scheduler will be stopped. Default 0.
|
||||||
|
-- @return #ZONE_ELASTIC self
|
||||||
|
function ZONE_ELASTIC:StopUpdate(Delay)
|
||||||
|
|
||||||
|
if Delay and Delay>0 then
|
||||||
|
self:ScheduleOnce(Delay, ZONE_ELASTIC.StopUpdate, self)
|
||||||
|
else
|
||||||
|
|
||||||
|
if self.updateID then
|
||||||
|
|
||||||
|
self:ScheduleStop(self.updateID)
|
||||||
|
|
||||||
|
self.updateID=nil
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create a convec hull.
|
||||||
|
-- @param #ZONE_ELASTIC self
|
||||||
|
-- @param #table pl Points
|
||||||
|
-- @return #table Points
|
||||||
|
function ZONE_ELASTIC:_ConvexHull(pl)
|
||||||
|
|
||||||
|
if #pl == 0 then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(pl, function(left,right)
|
||||||
|
return left.x < right.x
|
||||||
|
end)
|
||||||
|
|
||||||
|
local h = {}
|
||||||
|
|
||||||
|
-- Function: ccw > 0 if three points make a counter-clockwise turn, clockwise if ccw < 0, and collinear if ccw = 0.
|
||||||
|
local function ccw(a,b,c)
|
||||||
|
return (b.x - a.x) * (c.y - a.y) > (b.y - a.y) * (c.x - a.x)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- lower hull
|
||||||
|
for i,pt in pairs(pl) do
|
||||||
|
while #h >= 2 and not ccw(h[#h-1], h[#h], pt) do
|
||||||
|
table.remove(h,#h)
|
||||||
|
end
|
||||||
|
table.insert(h,pt)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- upper hull
|
||||||
|
local t = #h + 1
|
||||||
|
for i=#pl, 1, -1 do
|
||||||
|
local pt = pl[i]
|
||||||
|
while #h >= t and not ccw(h[#h-1], h[#h], pt) do
|
||||||
|
table.remove(h, #h)
|
||||||
|
end
|
||||||
|
table.insert(h, pt)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.remove(h, #h)
|
||||||
|
|
||||||
|
return h
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
do -- ZONE_AIRBASE
|
do -- ZONE_AIRBASE
|
||||||
|
|
||||||
--- @type ZONE_AIRBASE
|
--- @type ZONE_AIRBASE
|
||||||
|
-- @field #boolean isShip If `true`, airbase is a ship.
|
||||||
|
-- @field #boolean isHelipad If `true`, airbase is a helipad.
|
||||||
|
-- @field #boolean isAirdrome If `true`, airbase is an airdrome.
|
||||||
-- @extends #ZONE_RADIUS
|
-- @extends #ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
@@ -2181,6 +2652,20 @@ do -- ZONE_AIRBASE
|
|||||||
self._.ZoneAirbase = Airbase
|
self._.ZoneAirbase = Airbase
|
||||||
self._.ZoneVec2Cache = self._.ZoneAirbase:GetVec2()
|
self._.ZoneVec2Cache = self._.ZoneAirbase:GetVec2()
|
||||||
|
|
||||||
|
if Airbase:IsShip() then
|
||||||
|
self.isShip=true
|
||||||
|
self.isHelipad=false
|
||||||
|
self.isAirdrome=false
|
||||||
|
elseif Airbase:IsHelipad() then
|
||||||
|
self.isShip=false
|
||||||
|
self.isHelipad=true
|
||||||
|
self.isAirdrome=false
|
||||||
|
elseif Airbase:IsAirdrome() then
|
||||||
|
self.isShip=false
|
||||||
|
self.isHelipad=false
|
||||||
|
self.isAirdrome=true
|
||||||
|
end
|
||||||
|
|
||||||
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
||||||
_EVENTDISPATCHER:CreateEventNewZone( self )
|
_EVENTDISPATCHER:CreateEventNewZone( self )
|
||||||
|
|
||||||
@@ -2194,9 +2679,9 @@ do -- ZONE_AIRBASE
|
|||||||
return self._.ZoneAirbase
|
return self._.ZoneAirbase
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the current location of the @{Wrapper.Group}.
|
--- Returns the current location of the AIRBASE.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
-- @return DCS#Vec2 The location of the zone based on the AIRBASE location.
|
||||||
function ZONE_AIRBASE:GetVec2()
|
function ZONE_AIRBASE:GetVec2()
|
||||||
self:F( self.ZoneName )
|
self:F( self.ZoneName )
|
||||||
|
|
||||||
@@ -2214,24 +2699,6 @@ do -- ZONE_AIRBASE
|
|||||||
return ZoneVec2
|
return ZoneVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a random location within the zone of the @{Wrapper.Group}.
|
|
||||||
-- @param #ZONE_AIRBASE self
|
|
||||||
-- @return DCS#Vec2 The random location of the zone based on the @{Wrapper.Group} location.
|
|
||||||
function ZONE_AIRBASE:GetRandomVec2()
|
|
||||||
self:F( self.ZoneName )
|
|
||||||
|
|
||||||
local Point = {}
|
|
||||||
local Vec2 = self._.ZoneAirbase:GetVec2()
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
self:T( { Point } )
|
|
||||||
|
|
||||||
return Point
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
|
|||||||
@@ -471,6 +471,22 @@ do -- Types
|
|||||||
--@field #boolean lateActivated
|
--@field #boolean lateActivated
|
||||||
--@field #boolean uncontrolled
|
--@field #boolean uncontrolled
|
||||||
|
|
||||||
|
--- DCS template data structure.
|
||||||
|
-- @type Template
|
||||||
|
-- @field #boolean uncontrolled Aircraft is uncontrolled.
|
||||||
|
-- @field #boolean lateActivation Group is late activated.
|
||||||
|
-- @field #number x 2D Position on x-axis in meters.
|
||||||
|
-- @field #number y 2D Position on y-axis in meters.
|
||||||
|
-- @field #table units Unit list.
|
||||||
|
--
|
||||||
|
|
||||||
|
--- Unit data structure.
|
||||||
|
--@type Template.Unit
|
||||||
|
--@field #string name Name of the unit.
|
||||||
|
--@field #number x
|
||||||
|
--@field #number y
|
||||||
|
--@field #number alt
|
||||||
|
|
||||||
end --
|
end --
|
||||||
|
|
||||||
|
|
||||||
@@ -487,8 +503,9 @@ do -- Object
|
|||||||
-- @field UNIT
|
-- @field UNIT
|
||||||
-- @field WEAPON
|
-- @field WEAPON
|
||||||
-- @field STATIC
|
-- @field STATIC
|
||||||
-- @field SCENERY
|
|
||||||
-- @field BASE
|
-- @field BASE
|
||||||
|
-- @field SCENERY
|
||||||
|
-- @field CARGO
|
||||||
|
|
||||||
--- @type Object.Desc
|
--- @type Object.Desc
|
||||||
-- @extends #Desc
|
-- @extends #Desc
|
||||||
@@ -499,6 +516,10 @@ do -- Object
|
|||||||
-- @param #Object self
|
-- @param #Object self
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
|
--- @function [parent=#Object] isActive
|
||||||
|
-- @param #Object self
|
||||||
|
-- @return #boolean
|
||||||
|
|
||||||
--- @function [parent=#Object] destroy
|
--- @function [parent=#Object] destroy
|
||||||
-- @param #Object self
|
-- @param #Object self
|
||||||
|
|
||||||
@@ -1131,6 +1152,11 @@ do -- Unit
|
|||||||
-- @param #Unit self
|
-- @param #Unit self
|
||||||
-- @return #Unit.Ammo
|
-- @return #Unit.Ammo
|
||||||
|
|
||||||
|
--- Returns the number of infantry that can be embark onto the aircraft. Only returns a value if run on airplanes or helicopters. Returns nil if run on ground or ship units.
|
||||||
|
-- @function [parent=#Unit] getDescentCapacity
|
||||||
|
-- @param #Unit self
|
||||||
|
-- @return #number Number of soldiers that embark.
|
||||||
|
|
||||||
--- Returns the unit sensors.
|
--- Returns the unit sensors.
|
||||||
-- @function [parent=#Unit] getSensors
|
-- @function [parent=#Unit] getSensors
|
||||||
-- @param #Unit self
|
-- @param #Unit self
|
||||||
@@ -1348,7 +1374,9 @@ do -- AI
|
|||||||
--- @type AI.Option.Ground
|
--- @type AI.Option.Ground
|
||||||
-- @field #AI.Option.Ground.id id
|
-- @field #AI.Option.Ground.id id
|
||||||
-- @field #AI.Option.Ground.val val
|
-- @field #AI.Option.Ground.val val
|
||||||
|
-- @field #AI.Option.Ground.mid mid
|
||||||
|
-- @field #AI.Option.Ground.mval mval
|
||||||
|
--
|
||||||
--- @type AI.Option.Naval
|
--- @type AI.Option.Naval
|
||||||
-- @field #AI.Option.Naval.id id
|
-- @field #AI.Option.Naval.id id
|
||||||
-- @field #AI.Option.Naval.val val
|
-- @field #AI.Option.Naval.val val
|
||||||
@@ -1371,6 +1399,11 @@ do -- AI
|
|||||||
-- @field PROHIBIT_AG
|
-- @field PROHIBIT_AG
|
||||||
-- @field MISSILE_ATTACK
|
-- @field MISSILE_ATTACK
|
||||||
-- @field PROHIBIT_WP_PASS_REPORT
|
-- @field PROHIBIT_WP_PASS_REPORT
|
||||||
|
-- @field OPTION_RADIO_USAGE_CONTACT
|
||||||
|
-- @field OPTION_RADIO_USAGE_ENGAGE
|
||||||
|
-- @field OPTION_RADIO_USAGE_KILL
|
||||||
|
-- @field JETT_TANKS_IF_EMPTY
|
||||||
|
-- @field FORCED_ATTACK
|
||||||
|
|
||||||
--- @type AI.Option.Air.id.FORMATION
|
--- @type AI.Option.Air.id.FORMATION
|
||||||
-- @field LINE_ABREAST
|
-- @field LINE_ABREAST
|
||||||
@@ -1440,19 +1473,35 @@ do -- AI
|
|||||||
--- @type AI.Option.Ground.id
|
--- @type AI.Option.Ground.id
|
||||||
-- @field NO_OPTION
|
-- @field NO_OPTION
|
||||||
-- @field ROE @{#AI.Option.Ground.val.ROE}
|
-- @field ROE @{#AI.Option.Ground.val.ROE}
|
||||||
|
-- @field FORMATION
|
||||||
-- @field DISPERSE_ON_ATTACK true or false
|
-- @field DISPERSE_ON_ATTACK true or false
|
||||||
-- @field ALARM_STATE @{#AI.Option.Ground.val.ALARM_STATE}
|
-- @field ALARM_STATE @{#AI.Option.Ground.val.ALARM_STATE}
|
||||||
-- @field ENGAGE_AIR_WEAPONS
|
-- @field ENGAGE_AIR_WEAPONS
|
||||||
|
-- @field AC_ENGAGEMENT_RANGE_RESTRICTION
|
||||||
|
|
||||||
|
--- @type AI.Option.Ground.mid -- Moose added
|
||||||
|
-- @field RESTRICT_AAA_MIN 27
|
||||||
|
-- @field RESTRICT_AAA_MAX 29
|
||||||
|
-- @field RESTRICT_TARGETS @{#AI.Option.Ground.mval.ENGAGE_TARGETS} 28
|
||||||
|
|
||||||
--- @type AI.Option.Ground.val
|
--- @type AI.Option.Ground.val
|
||||||
-- @field #AI.Option.Ground.val.ROE ROE
|
-- @field #AI.Option.Ground.val.ROE ROE
|
||||||
-- @field #AI.Option.Ground.val.ALARM_STATE ALARM_STATE
|
-- @field #AI.Option.Ground.val.ALARM_STATE ALARM_STATE
|
||||||
|
-- @field #AI.Option.Ground.val.ENGAGE_TARGETS RESTRICT_TARGETS
|
||||||
|
|
||||||
--- @type AI.Option.Ground.val.ROE
|
--- @type AI.Option.Ground.val.ROE
|
||||||
-- @field OPEN_FIRE
|
-- @field OPEN_FIRE
|
||||||
-- @field RETURN_FIRE
|
-- @field RETURN_FIRE
|
||||||
-- @field WEAPON_HOLD
|
-- @field WEAPON_HOLD
|
||||||
|
|
||||||
|
--- @type AI.Option.Ground.mval -- Moose added
|
||||||
|
-- @field #AI.Option.Ground.mval.ENGAGE_TARGETS ENGAGE_TARGETS
|
||||||
|
|
||||||
|
--- @type AI.Option.Ground.mval.ENGAGE_TARGETS -- Moose added
|
||||||
|
-- @field ANY_TARGET -- 0
|
||||||
|
-- @field AIR_UNITS_ONLY -- 1
|
||||||
|
-- @field GROUND_UNITS_ONLY -- 2
|
||||||
|
|
||||||
--- @type AI.Option.Ground.val.ALARM_STATE
|
--- @type AI.Option.Ground.val.ALARM_STATE
|
||||||
-- @field AUTO
|
-- @field AUTO
|
||||||
-- @field GREEN
|
-- @field GREEN
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -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 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 #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 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 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 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.
|
-- @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.
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ do -- DESIGNATE
|
|||||||
-- In order to prevent an overflow of designations due to many Detected Targets, there is a
|
-- In order to prevent an overflow of designations due to many Detected Targets, there is a
|
||||||
-- Maximum Designations scope that is set in the DesignationObject.
|
-- Maximum Designations scope that is set in the DesignationObject.
|
||||||
--
|
--
|
||||||
-- The method @{#DESIGNATE.SetMaximumDesignations}() will put a limit on the amount of designations put in scope of the DesignationObject.
|
-- The method @{#DESIGNATE.SetMaximumDesignations}() will put a limit on the amount of designations (target groups) put in scope of the DesignationObject.
|
||||||
-- Using the menu system, the player can "forget" a designation, so that gradually a new designation can be put in scope when detected.
|
-- Using the menu system, the player can "forget" a designation, so that gradually a new designation can be put in scope when detected.
|
||||||
--
|
--
|
||||||
-- # 4. Laser codes
|
-- # 4. Laser codes
|
||||||
@@ -562,7 +562,8 @@ do -- DESIGNATE
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the maximum amount of designations.
|
--- Set the maximum amount of designations (target groups). This will put a limit on the amount of designations in scope.
|
||||||
|
-- Using the menu system, the player can "forget" a designation, so that gradually a new designation can be put in scope when detected.
|
||||||
-- @param #DESIGNATE self
|
-- @param #DESIGNATE self
|
||||||
-- @param #number MaximumDesignations
|
-- @param #number MaximumDesignations
|
||||||
-- @return #DESIGNATE
|
-- @return #DESIGNATE
|
||||||
@@ -602,7 +603,7 @@ do -- DESIGNATE
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the maximum amount of markings FACs will do, per designated target group.
|
--- Set the maximum amount of markings FACs will do, per designated target group. This will limit the number of parallelly marked units of a target group.
|
||||||
-- @param #DESIGNATE self
|
-- @param #DESIGNATE self
|
||||||
-- @param #number MaximumMarkings Maximum markings FACs will do, per designated target group.
|
-- @param #number MaximumMarkings Maximum markings FACs will do, per designated target group.
|
||||||
-- @return #DESIGNATE
|
-- @return #DESIGNATE
|
||||||
@@ -911,8 +912,8 @@ do -- DESIGNATE
|
|||||||
for DesignateIndex, Designating in pairs( self.Designating ) do
|
for DesignateIndex, Designating in pairs( self.Designating ) do
|
||||||
local DetectedItem = DetectedItems[DesignateIndex]
|
local DetectedItem = DetectedItems[DesignateIndex]
|
||||||
if DetectedItem then
|
if DetectedItem then
|
||||||
local Report = self.Detection:DetectedItemReportSummary( DetectedItem, AttackGroup ):Text( ", " )
|
local Report = self.Detection:DetectedItemReportSummary( DetectedItem, AttackGroup, nil, true ):Text( ", " )
|
||||||
DetectedReport:Add( string.rep( "-", 140 ) )
|
DetectedReport:Add( string.rep( "-", 40 ) )
|
||||||
DetectedReport:Add( " - " .. Report )
|
DetectedReport:Add( " - " .. Report )
|
||||||
if string.find( Designating, "L" ) then
|
if string.find( Designating, "L" ) then
|
||||||
DetectedReport:Add( " - " .. "Lasing Targets" )
|
DetectedReport:Add( " - " .. "Lasing Targets" )
|
||||||
@@ -1192,8 +1193,8 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
local MarkingCount = 0
|
local MarkingCount = 0
|
||||||
local MarkedTypes = {}
|
local MarkedTypes = {}
|
||||||
local ReportTypes = REPORT:New()
|
--local ReportTypes = REPORT:New()
|
||||||
local ReportLaserCodes = REPORT:New()
|
--local ReportLaserCodes = REPORT:New()
|
||||||
|
|
||||||
TargetSetUnit:Flush( self )
|
TargetSetUnit:Flush( self )
|
||||||
|
|
||||||
@@ -1243,7 +1244,7 @@ do -- DESIGNATE
|
|||||||
if not Recce then
|
if not Recce then
|
||||||
|
|
||||||
self:F( "Lasing..." )
|
self:F( "Lasing..." )
|
||||||
self.RecceSet:Flush( self)
|
--self.RecceSet:Flush( self)
|
||||||
|
|
||||||
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
||||||
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
||||||
@@ -1282,13 +1283,13 @@ do -- DESIGNATE
|
|||||||
-- OK. We have assigned for the Recce a TargetUnit. We can exit the function.
|
-- OK. We have assigned for the Recce a TargetUnit. We can exit the function.
|
||||||
MarkingCount = MarkingCount + 1
|
MarkingCount = MarkingCount + 1
|
||||||
local TargetUnitType = TargetUnit:GetTypeName()
|
local TargetUnitType = TargetUnit:GetTypeName()
|
||||||
--RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.",
|
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.",
|
||||||
-- 5, self.AttackSet, DesignateName )
|
10, self.AttackSet, DesignateName )
|
||||||
if not MarkedTypes[TargetUnitType] then
|
if not MarkedTypes[TargetUnitType] then
|
||||||
MarkedTypes[TargetUnitType] = true
|
MarkedTypes[TargetUnitType] = true
|
||||||
ReportTypes:Add(TargetUnitType)
|
--ReportTypes:Add(TargetUnitType)
|
||||||
end
|
end
|
||||||
ReportLaserCodes:Add(RecceUnit.LaserCode)
|
--ReportLaserCodes:Add(RecceUnit.LaserCode)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -1303,16 +1304,16 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
if Recce then
|
if Recce then
|
||||||
Recce:LaseOff()
|
Recce:LaseOff()
|
||||||
Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet, self.DesignateName )
|
Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 10, self.AttackSet, self.DesignateName )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--MarkingCount = MarkingCount + 1
|
--MarkingCount = MarkingCount + 1
|
||||||
local TargetUnitType = TargetUnit:GetTypeName()
|
local TargetUnitType = TargetUnit:GetTypeName()
|
||||||
if not MarkedTypes[TargetUnitType] then
|
if not MarkedTypes[TargetUnitType] then
|
||||||
MarkedTypes[TargetUnitType] = true
|
MarkedTypes[TargetUnitType] = true
|
||||||
ReportTypes:Add(TargetUnitType)
|
--ReportTypes:Add(TargetUnitType)
|
||||||
end
|
end
|
||||||
ReportLaserCodes:Add(RecceUnit.LaserCode)
|
--ReportLaserCodes:Add(RecceUnit.LaserCode)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1322,19 +1323,19 @@ do -- DESIGNATE
|
|||||||
local TargetUnitType = TargetUnit:GetTypeName()
|
local TargetUnitType = TargetUnit:GetTypeName()
|
||||||
if not MarkedTypes[TargetUnitType] then
|
if not MarkedTypes[TargetUnitType] then
|
||||||
MarkedTypes[TargetUnitType] = true
|
MarkedTypes[TargetUnitType] = true
|
||||||
ReportTypes:Add(TargetUnitType)
|
--ReportTypes:Add(TargetUnitType)
|
||||||
end
|
end
|
||||||
ReportLaserCodes:Add(Recce.LaserCode)
|
--ReportLaserCodes:Add(Recce.LaserCode)
|
||||||
--Recce:MessageToSetGroup( self.DesignateName .. ": Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 5, self.AttackSet )
|
Recce:MessageToSetGroup( self.DesignateName .. ": Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 10, self.AttackSet )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
local MarkedTypesText = ReportTypes:Text(', ')
|
--local MarkedTypesText = ReportTypes:Text(', ')
|
||||||
local MarkedLaserCodesText = ReportLaserCodes:Text(', ')
|
--local MarkedLaserCodesText = ReportLaserCodes:Text(', ')
|
||||||
self.CC:GetPositionable():MessageToSetGroup( "Marking " .. MarkingCount .. " x " .. MarkedTypesText .. ", code " .. MarkedLaserCodesText .. ".", 5, self.AttackSet, self.DesignateName )
|
--self.CC:GetPositionable():MessageToSetGroup( "Marking " .. MarkingCount .. " x " .. MarkedTypesText .. ", code " .. MarkedLaserCodesText .. ".", 5, self.AttackSet, self.DesignateName )
|
||||||
|
|
||||||
self:__Lasing( -self.LaseDuration, Index, Duration, LaserCodeRequested )
|
self:__Lasing( -self.LaseDuration, Index, Duration, LaserCodeRequested )
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -792,7 +792,7 @@ function FOX:onafterMissileLaunch(From, Event, To, missile)
|
|||||||
local text=string.format("Missile launch detected! Distance %.1f NM, bearing %03d°.", UTILS.MetersToNM(distance), bearing)
|
local text=string.format("Missile launch detected! Distance %.1f NM, bearing %03d°.", UTILS.MetersToNM(distance), bearing)
|
||||||
|
|
||||||
-- Say notching headings.
|
-- Say notching headings.
|
||||||
BASE:ScheduleOnce(5, FOX._SayNotchingHeadings, self, player, missile.weapon)
|
self:ScheduleOnce(5, FOX._SayNotchingHeadings, self, player, missile.weapon)
|
||||||
|
|
||||||
--TODO: ALERT or INFO depending on whether this is a direct target.
|
--TODO: ALERT or INFO depending on whether this is a direct target.
|
||||||
--TODO: lauchalertall option.
|
--TODO: lauchalertall option.
|
||||||
@@ -1114,6 +1114,13 @@ end
|
|||||||
-- Event Functions
|
-- Event Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- FOX event handler for event birth.
|
||||||
|
-- @param #FOX self
|
||||||
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
|
function FOX:OnEventPlayerEnterAircraft(EventData)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- FOX event handler for event birth.
|
--- FOX event handler for event birth.
|
||||||
-- @param #FOX self
|
-- @param #FOX self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
@@ -1155,7 +1162,7 @@ function FOX:OnEventBirth(EventData)
|
|||||||
|
|
||||||
-- Add F10 radio menu for player.
|
-- Add F10 radio menu for player.
|
||||||
if not self.menudisabled then
|
if not self.menudisabled then
|
||||||
SCHEDULER:New(nil, self._AddF10Commands, {self,_unitName}, 0.1)
|
self:ScheduleOnce(0.1, FOX._AddF10Commands, self, _unitname)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Player data.
|
-- Player data.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
|||||||
-- ## Features:
|
-- ## Features:
|
||||||
--
|
--
|
||||||
-- * Track the missiles fired at you and other players, providing bearing and range information of the missiles towards the airplanes.
|
-- * Track the missiles fired at you and other players, providing bearing and range information of the missiles towards the airplanes.
|
||||||
-- * Provide alerts of missile launches, including detailed information of the units launching, including bearing, range °
|
-- * Provide alerts of missile launches, including detailed information of the units launching, including bearing, range
|
||||||
-- * Provide alerts when a missile would have killed your aircraft.
|
-- * Provide alerts when a missile would have killed your aircraft.
|
||||||
-- * Provide alerts when the missile self destructs.
|
-- * Provide alerts when the missile self destructs.
|
||||||
-- * Enable / Disable and Configure the Missile Trainer using the various menu options.
|
-- * Enable / Disable and Configure the Missile Trainer using the various menu options.
|
||||||
|
|||||||
@@ -949,11 +949,14 @@ function PSEUDOATC:LocalAirports(GID, UID)
|
|||||||
for _,airbase in pairs(airports) do
|
for _,airbase in pairs(airports) do
|
||||||
|
|
||||||
local name=airbase:getName()
|
local name=airbase:getName()
|
||||||
local q=AIRBASE:FindByName(name):GetCoordinate()
|
local a=AIRBASE:FindByName(name)
|
||||||
local d=q:Get2DDistance(pos)
|
if a then
|
||||||
|
local q=a:GetCoordinate()
|
||||||
|
local d=q:Get2DDistance(pos)
|
||||||
|
|
||||||
-- Add to table.
|
-- Add to table.
|
||||||
table.insert(self.group[GID].player[UID].airports, {distance=d, name=name})
|
table.insert(self.group[GID].player[UID].airports, {distance=d, name=name})
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1041,6 +1044,3 @@ function PSEUDOATC:_myname(unitname)
|
|||||||
|
|
||||||
return string.format("%s (%s)", csign, pname)
|
return string.format("%s (%s)", csign, pname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
-- @field #string category Category of aircarft: "plane" or "heli".
|
-- @field #string category Category of aircarft: "plane" or "heli".
|
||||||
-- @field #number groupsize Number of aircraft in group.
|
-- @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 #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 #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 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.
|
-- @field #number Vclimb Default climb rate in ft/min.
|
||||||
@@ -348,7 +348,7 @@ RAT={
|
|||||||
category = nil, -- Category of aircarft: "plane" or "heli".
|
category = nil, -- Category of aircarft: "plane" or "heli".
|
||||||
groupsize=nil, -- Number of aircraft in the group.
|
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.
|
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, ...).
|
aircraft = {}, -- Table which holds the basic aircraft properties (speed, range, ...).
|
||||||
Vcruisemax=nil, -- Max cruise speed in set by user.
|
Vcruisemax=nil, -- Max cruise speed in set by user.
|
||||||
Vclimb=1500, -- Default climb rate in ft/min.
|
Vclimb=1500, -- Default climb rate in ft/min.
|
||||||
@@ -657,7 +657,7 @@ end
|
|||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param #number naircraft (Optional) Number of aircraft to spawn. Default is one aircraft.
|
-- @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.
|
-- @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)
|
function RAT:Spawn(naircraft)
|
||||||
|
|
||||||
-- Make sure that this function is only been called once per RAT object.
|
-- Make sure that this function is only been called once per RAT object.
|
||||||
@@ -1289,7 +1289,7 @@ end
|
|||||||
|
|
||||||
--- Include all airports which lie in a zone as possible destinations.
|
--- Include all airports which lie in a zone as possible destinations.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param Core.Zone#ZONE zone Zone in which the departure airports lie. Has to be a MOOSE zone.
|
-- @param Core.Zone#ZONE zone Zone in which the destination airports lie. Has to be a MOOSE zone.
|
||||||
-- @return #RAT RAT self object.
|
-- @return #RAT RAT self object.
|
||||||
function RAT:SetDestinationsFromZone(zone)
|
function RAT:SetDestinationsFromZone(zone)
|
||||||
self:F2(zone)
|
self:F2(zone)
|
||||||
@@ -1305,7 +1305,7 @@ end
|
|||||||
|
|
||||||
--- Include all airports which lie in a zone as possible destinations.
|
--- Include all airports which lie in a zone as possible destinations.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param Core.Zone#ZONE zone Zone in which the destination airports lie. Has to be a MOOSE zone.
|
-- @param Core.Zone#ZONE zone Zone in which the departure airports lie. Has to be a MOOSE zone.
|
||||||
-- @return #RAT RAT self object.
|
-- @return #RAT RAT self object.
|
||||||
function RAT:SetDeparturesFromZone(zone)
|
function RAT:SetDeparturesFromZone(zone)
|
||||||
self:F2(zone)
|
self:F2(zone)
|
||||||
@@ -2049,9 +2049,15 @@ function RAT:_InitAircraft(DCSgroup)
|
|||||||
--self.aircraft.descriptors=DCSdesc
|
--self.aircraft.descriptors=DCSdesc
|
||||||
|
|
||||||
-- aircraft dimensions
|
-- aircraft dimensions
|
||||||
self.aircraft.length=DCSdesc.box.max.x
|
if DCSdesc.box then
|
||||||
self.aircraft.height=DCSdesc.box.max.y
|
self.aircraft.length=DCSdesc.box.max.x
|
||||||
self.aircraft.width=DCSdesc.box.max.z
|
self.aircraft.height=DCSdesc.box.max.y
|
||||||
|
self.aircraft.width=DCSdesc.box.max.z
|
||||||
|
elseif DCStype == "Mirage-F1CE" then
|
||||||
|
self.aircraft.length=16
|
||||||
|
self.aircraft.height=5
|
||||||
|
self.aircraft.width=9
|
||||||
|
end
|
||||||
self.aircraft.box=math.max(self.aircraft.length,self.aircraft.width)
|
self.aircraft.box=math.max(self.aircraft.length,self.aircraft.width)
|
||||||
|
|
||||||
-- info message
|
-- info message
|
||||||
@@ -5371,7 +5377,7 @@ function RAT:_ModifySpawnTemplate(waypoints, livery, spawnplace, departure, take
|
|||||||
|
|
||||||
if spawnonground then
|
if spawnonground then
|
||||||
|
|
||||||
-- Sh°ps and FARPS seem to have a build in queue.
|
-- Ships and FARPS seem to have a build in queue.
|
||||||
if spawnonship or spawnonfarp or spawnonrunway or automatic then
|
if spawnonship or spawnonfarp or spawnonrunway or automatic then
|
||||||
self:T(RAT.id..string.format("RAT group %s spawning at farp, ship or runway %s.", self.alias, departure:GetName()))
|
self:T(RAT.id..string.format("RAT group %s spawning at farp, ship or runway %s.", self.alias, departure:GetName()))
|
||||||
|
|
||||||
@@ -6145,4 +6151,3 @@ function RATMANAGER:_RollDice(nrat,ntot,min,alive)
|
|||||||
-- Return number of groups to be spawned.
|
-- Return number of groups to be spawned.
|
||||||
return N
|
return N
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -67,7 +67,7 @@
|
|||||||
--
|
--
|
||||||
-- * Upload scoring to a database or a BI tool to publish the scoring results to the player community.
|
-- * Upload scoring to a database or a BI tool to publish the scoring results to the player community.
|
||||||
-- * Upload scoring in an (online) Excel like tool, using pivot tables and pivot charts to show mission results.
|
-- * Upload scoring in an (online) Excel like tool, using pivot tables and pivot charts to show mission results.
|
||||||
-- * Share scoring amoung players after the mission to discuss mission results.
|
-- * Share scoring among players after the mission to discuss mission results.
|
||||||
--
|
--
|
||||||
-- Scores can be **reported**. **Menu options** are automatically added to **each player group** when a player joins a client slot or a CA unit.
|
-- Scores can be **reported**. **Menu options** are automatically added to **each player group** when a player joins a client slot or a CA unit.
|
||||||
-- Use the radio menu F10 to consult the scores while running the mission.
|
-- Use the radio menu F10 to consult the scores while running the mission.
|
||||||
@@ -88,7 +88,6 @@
|
|||||||
-- @module Functional.Scoring
|
-- @module Functional.Scoring
|
||||||
-- @image Scoring.JPG
|
-- @image Scoring.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type SCORING
|
--- @type SCORING
|
||||||
-- @field Players A collection of the current players that have joined the game.
|
-- @field Players A collection of the current players that have joined the game.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
@@ -99,7 +98,6 @@
|
|||||||
--
|
--
|
||||||
-- local Scoring = SCORING:New( "Scoring File" )
|
-- local Scoring = SCORING:New( "Scoring File" )
|
||||||
--
|
--
|
||||||
--
|
|
||||||
-- # Set the destroy score or penalty scale:
|
-- # Set the destroy score or penalty scale:
|
||||||
--
|
--
|
||||||
-- Score scales can be set for scores granted when enemies or friendlies are destroyed.
|
-- Score scales can be set for scores granted when enemies or friendlies are destroyed.
|
||||||
@@ -147,11 +145,11 @@
|
|||||||
--
|
--
|
||||||
-- # (Decommissioned) Configure fratricide level.
|
-- # (Decommissioned) Configure fratricide level.
|
||||||
--
|
--
|
||||||
-- **This functionality is decomissioned until the DCS bug concerning Unit:destroy() not being functional in multi player for player units has been fixed by ED**.
|
-- **This functionality is decommissioned until the DCS bug concerning Unit:destroy() not being functional in multi player for player units has been fixed by ED**.
|
||||||
--
|
--
|
||||||
-- When a player commits too much damage to friendlies, his penalty score will reach a certain level.
|
-- When a player commits too much damage to friendlies, his penalty score will reach a certain level.
|
||||||
-- Use the method @{#SCORING.SetFratricide}() to define the level when a player gets kicked.
|
-- Use the method @{#SCORING.SetFratricide}() to define the level when a player gets kicked.
|
||||||
-- By default, the fratricide level is the default penalty mutiplier * 2 for the penalty score.
|
-- By default, the fratricide level is the default penalty multiplier * 2 for the penalty score.
|
||||||
--
|
--
|
||||||
-- # Penalty score when a player changes the coalition.
|
-- # Penalty score when a player changes the coalition.
|
||||||
--
|
--
|
||||||
@@ -190,8 +188,8 @@
|
|||||||
--
|
--
|
||||||
-- --Sanitize Mission Scripting environment
|
-- --Sanitize Mission Scripting environment
|
||||||
-- --This makes unavailable some unsecure functions.
|
-- --This makes unavailable some unsecure functions.
|
||||||
-- --Mission downloaded from server to client may contain potentialy harmful lua code that may use these functions.
|
-- --Mission downloaded from server to client may contain potentially harmful lua code that may use these functions.
|
||||||
-- --You can remove the code below and make availble these functions at your own risk.
|
-- --You can remove the code below and make available these functions at your own risk.
|
||||||
--
|
--
|
||||||
-- The MOOSE designer cannot take any responsibility of any damage inflicted as a result of the de-sanitization.
|
-- The MOOSE designer cannot take any responsibility of any damage inflicted as a result of the de-sanitization.
|
||||||
-- That being said, I hope that the SCORING class provides you with a great add-on to score your squad mates achievements.
|
-- That being said, I hope that the SCORING class provides you with a great add-on to score your squad mates achievements.
|
||||||
@@ -229,20 +227,18 @@ SCORING = {
|
|||||||
Players = {},
|
Players = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
local _SCORINGCoalition =
|
local _SCORINGCoalition = {
|
||||||
{
|
[1] = "Red",
|
||||||
[1] = "Red",
|
[2] = "Blue",
|
||||||
[2] = "Blue",
|
}
|
||||||
}
|
|
||||||
|
|
||||||
local _SCORINGCategory =
|
local _SCORINGCategory = {
|
||||||
{
|
[Unit.Category.AIRPLANE] = "Plane",
|
||||||
[Unit.Category.AIRPLANE] = "Plane",
|
[Unit.Category.HELICOPTER] = "Helicopter",
|
||||||
[Unit.Category.HELICOPTER] = "Helicopter",
|
[Unit.Category.GROUND_UNIT] = "Vehicle",
|
||||||
[Unit.Category.GROUND_UNIT] = "Vehicle",
|
[Unit.Category.SHIP] = "Ship",
|
||||||
[Unit.Category.SHIP] = "Ship",
|
[Unit.Category.STRUCTURE] = "Structure",
|
||||||
[Unit.Category.STRUCTURE] = "Structure",
|
}
|
||||||
}
|
|
||||||
|
|
||||||
--- Creates a new SCORING object to administer the scoring achieved by players.
|
--- Creates a new SCORING object to administer the scoring achieved by players.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
@@ -250,8 +246,8 @@ local _SCORINGCategory =
|
|||||||
-- @return #SCORING self
|
-- @return #SCORING self
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Define a new scoring object for the mission Gori Valley.
|
-- -- Define a new scoring object for the mission Gori Valley.
|
||||||
-- ScoringObject = SCORING:New( "Gori Valley" )
|
-- ScoringObject = SCORING:New( "Gori Valley" )
|
||||||
--
|
--
|
||||||
function SCORING:New( GameName )
|
function SCORING:New( GameName )
|
||||||
|
|
||||||
@@ -264,7 +260,6 @@ function SCORING:New( GameName )
|
|||||||
error( "A game name must be given to register the scoring results" )
|
error( "A game name must be given to register the scoring results" )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Additional Object scores
|
-- Additional Object scores
|
||||||
self.ScoringObjects = {}
|
self.ScoringObjects = {}
|
||||||
|
|
||||||
@@ -284,9 +279,11 @@ function SCORING:New( GameName )
|
|||||||
|
|
||||||
-- Default fratricide penalty level (maximum penalty that can be assigned to a player before he gets kicked).
|
-- Default fratricide penalty level (maximum penalty that can be assigned to a player before he gets kicked).
|
||||||
self:SetFratricide( self.ScaleDestroyPenalty * 3 )
|
self:SetFratricide( self.ScaleDestroyPenalty * 3 )
|
||||||
|
self.penaltyonfratricide = true
|
||||||
|
|
||||||
-- Default penalty when a player changes coalition.
|
-- Default penalty when a player changes coalition.
|
||||||
self:SetCoalitionChangePenalty( self.ScaleDestroyPenalty )
|
self:SetCoalitionChangePenalty( self.ScaleDestroyPenalty )
|
||||||
|
self.penaltyoncoalitionchange = true
|
||||||
|
|
||||||
self:SetDisplayMessagePrefix()
|
self:SetDisplayMessagePrefix()
|
||||||
|
|
||||||
@@ -295,21 +292,18 @@ function SCORING:New( GameName )
|
|||||||
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
|
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
|
||||||
self:HandleEvent( EVENTS.Hit, self._EventOnHit )
|
self:HandleEvent( EVENTS.Hit, self._EventOnHit )
|
||||||
self:HandleEvent( EVENTS.Birth )
|
self:HandleEvent( EVENTS.Birth )
|
||||||
--self:HandleEvent( EVENTS.PlayerEnterUnit )
|
-- self:HandleEvent( EVENTS.PlayerEnterUnit )
|
||||||
self:HandleEvent( EVENTS.PlayerLeaveUnit )
|
self:HandleEvent( EVENTS.PlayerLeaveUnit )
|
||||||
|
|
||||||
-- During mission startup, especially for single player,
|
-- During mission startup, especially for single player,
|
||||||
-- iterate the database for the player that has joined, and add him to the scoring, and set the menu.
|
-- iterate the database for the player that has joined, and add him to the scoring, and set the menu.
|
||||||
-- But this can only be started one second after the mission has started, so i need to schedule this ...
|
-- But this can only be started one second after the mission has started, so i need to schedule this ...
|
||||||
self.ScoringPlayerScan = BASE:ScheduleOnce( 1,
|
self.ScoringPlayerScan = BASE:ScheduleOnce( 1, function()
|
||||||
function()
|
for PlayerName, PlayerUnit in pairs( _DATABASE:GetPlayerUnits() ) do
|
||||||
for PlayerName, PlayerUnit in pairs( _DATABASE:GetPlayerUnits() ) do
|
self:_AddPlayerFromUnit( PlayerUnit )
|
||||||
self:_AddPlayerFromUnit( PlayerUnit )
|
self:SetScoringMenu( PlayerUnit:GetGroup() )
|
||||||
self:SetScoringMenu( PlayerUnit:GetGroup() )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
)
|
end )
|
||||||
|
|
||||||
|
|
||||||
-- Create the CSV file.
|
-- Create the CSV file.
|
||||||
self:OpenCSV( GameName )
|
self:OpenCSV( GameName )
|
||||||
@@ -327,7 +321,6 @@ function SCORING:SetDisplayMessagePrefix( DisplayMessagePrefix )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the scale for scoring valid destroys (enemy destroys).
|
--- Set the scale for scoring valid destroys (enemy destroys).
|
||||||
-- A default calculated score is a value between 1 and 10.
|
-- A default calculated score is a value between 1 and 10.
|
||||||
-- The scale magnifies the scores given to the players.
|
-- The scale magnifies the scores given to the players.
|
||||||
@@ -409,7 +402,6 @@ function SCORING:RemoveStaticScore( ScoreStatic )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Specify a special additional score for a @{Wrapper.Group}.
|
--- Specify a special additional score for a @{Wrapper.Group}.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param Wrapper.Group#GROUP ScoreGroup The @{Wrapper.Group} for which each @{Wrapper.Unit} a Score is given.
|
-- @param Wrapper.Group#GROUP ScoreGroup The @{Wrapper.Group} for which each @{Wrapper.Unit} a Score is given.
|
||||||
@@ -462,7 +454,6 @@ function SCORING:RemoveZoneScore( ScoreZone )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Configure to send messages after a target has been hit.
|
--- Configure to send messages after a target has been hit.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param #boolean OnOff If true is given, the messages are sent.
|
-- @param #boolean OnOff If true is given, the messages are sent.
|
||||||
@@ -569,10 +560,9 @@ function SCORING:IfMessagesToCoalition()
|
|||||||
return self.MessagesAudience == 2
|
return self.MessagesAudience == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- When a player commits too much damage to friendlies, his penalty score will reach a certain level.
|
--- When a player commits too much damage to friendlies, his penalty score will reach a certain level.
|
||||||
-- Use this method to define the level when a player gets kicked.
|
-- Use this method to define the level when a player gets kicked.
|
||||||
-- By default, the fratricide level is the default penalty mutiplier * 2 for the penalty score.
|
-- By default, the fratricide level is the default penalty multiplier * 2 for the penalty score.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param #number Fratricide The amount of maximum penalty that may be inflicted by a friendly player before he gets kicked.
|
-- @param #number Fratricide The amount of maximum penalty that may be inflicted by a friendly player before he gets kicked.
|
||||||
-- @return #SCORING
|
-- @return #SCORING
|
||||||
@@ -582,6 +572,23 @@ function SCORING:SetFratricide( Fratricide )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Decide if fratricide is leading to penalties (true) or not (false)
|
||||||
|
-- @param #SCORING self
|
||||||
|
-- @param #boolean OnOff Switch for Fratricide
|
||||||
|
-- @return #SCORING
|
||||||
|
function SCORING:SwitchFratricide( OnOff )
|
||||||
|
self.penaltyonfratricide = OnOff
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Decide if a change of coalition is leading to penalties (true) or not (false)
|
||||||
|
-- @param #SCORING self
|
||||||
|
-- @param #boolean OnOff Switch for Coalition Changes.
|
||||||
|
-- @return #SCORING
|
||||||
|
function SCORING:SwitchTreason( OnOff )
|
||||||
|
self.penaltyoncoalitionchange = OnOff
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- When a player changes the coalition, he can receive a penalty score.
|
--- When a player changes the coalition, he can receive a penalty score.
|
||||||
-- Use the method @{#SCORING.SetCoalitionChangePenalty}() to define the penalty when a player changes coalition.
|
-- Use the method @{#SCORING.SetCoalitionChangePenalty}() to define the penalty when a player changes coalition.
|
||||||
@@ -595,20 +602,18 @@ function SCORING:SetCoalitionChangePenalty( CoalitionChangePenalty )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Sets the scoring menu.
|
--- Sets the scoring menu.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @return #SCORING
|
-- @return #SCORING
|
||||||
function SCORING:SetScoringMenu( ScoringGroup )
|
function SCORING:SetScoringMenu( ScoringGroup )
|
||||||
local Menu = MENU_GROUP:New( ScoringGroup, 'Scoring and Statistics' )
|
local Menu = MENU_GROUP:New( ScoringGroup, 'Scoring and Statistics' )
|
||||||
local ReportGroupSummary = MENU_GROUP_COMMAND:New( ScoringGroup, 'Summary report players in group', Menu, SCORING.ReportScoreGroupSummary, self, ScoringGroup )
|
local ReportGroupSummary = MENU_GROUP_COMMAND:New( ScoringGroup, 'Summary report players in group', Menu, SCORING.ReportScoreGroupSummary, self, ScoringGroup )
|
||||||
local ReportGroupDetailed = MENU_GROUP_COMMAND:New( ScoringGroup, 'Detailed report players in group', Menu, SCORING.ReportScoreGroupDetailed, self, ScoringGroup )
|
local ReportGroupDetailed = MENU_GROUP_COMMAND:New( ScoringGroup, 'Detailed report players in group', Menu, SCORING.ReportScoreGroupDetailed, self, ScoringGroup )
|
||||||
local ReportToAllSummary = MENU_GROUP_COMMAND:New( ScoringGroup, 'Summary report all players', Menu, SCORING.ReportScoreAllSummary, self, ScoringGroup )
|
local ReportToAllSummary = MENU_GROUP_COMMAND:New( ScoringGroup, 'Summary report all players', Menu, SCORING.ReportScoreAllSummary, self, ScoringGroup )
|
||||||
self:SetState( ScoringGroup, "ScoringMenu", Menu )
|
self:SetState( ScoringGroup, "ScoringMenu", Menu )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Add a new player entering a Unit.
|
--- Add a new player entering a Unit.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param Wrapper.Unit#UNIT UnitData
|
-- @param Wrapper.Unit#UNIT UnitData
|
||||||
@@ -647,14 +652,15 @@ function SCORING:_AddPlayerFromUnit( UnitData )
|
|||||||
if not self.Players[PlayerName].UnitCoalition then
|
if not self.Players[PlayerName].UnitCoalition then
|
||||||
self.Players[PlayerName].UnitCoalition = UnitCoalition
|
self.Players[PlayerName].UnitCoalition = UnitCoalition
|
||||||
else
|
else
|
||||||
if self.Players[PlayerName].UnitCoalition ~= UnitCoalition then
|
-- TODO: switch for coalition changes, make penalty alterable
|
||||||
self.Players[PlayerName].Penalty = self.Players[PlayerName].Penalty + 50
|
if self.Players[PlayerName].UnitCoalition ~= UnitCoalition and self.penaltyoncoalitionchange then
|
||||||
|
self.Players[PlayerName].Penalty = self.Players[PlayerName].Penalty + self.CoalitionChangePenalty or 50
|
||||||
self.Players[PlayerName].PenaltyCoalition = self.Players[PlayerName].PenaltyCoalition + 1
|
self.Players[PlayerName].PenaltyCoalition = self.Players[PlayerName].PenaltyCoalition + 1
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' changed coalition from " .. _SCORINGCoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. _SCORINGCoalition[UnitCoalition] ..
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' changed coalition from " .. _SCORINGCoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. _SCORINGCoalition[UnitCoalition] ..
|
||||||
"(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.",
|
"(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). ".. self.CoalitionChangePenalty .."Penalty points added.",
|
||||||
MESSAGE.Type.Information
|
MESSAGE.Type.Information
|
||||||
):ToAll()
|
):ToAll()
|
||||||
self:ScoreCSV( PlayerName, "", "COALITION_PENALTY", 1, -50, self.Players[PlayerName].UnitName, _SCORINGCoalition[self.Players[PlayerName].UnitCoalition], _SCORINGCategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType,
|
self:ScoreCSV( PlayerName, "", "COALITION_PENALTY", 1, -1*self.CoalitionChangePenalty, self.Players[PlayerName].UnitName, _SCORINGCoalition[self.Players[PlayerName].UnitCoalition], _SCORINGCategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType,
|
||||||
UnitName, _SCORINGCoalition[UnitCoalition], _SCORINGCategory[UnitCategory], UnitData:GetTypeName() )
|
UnitName, _SCORINGCoalition[UnitCoalition], _SCORINGCategory[UnitCategory], UnitData:GetTypeName() )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -667,29 +673,25 @@ function SCORING:_AddPlayerFromUnit( UnitData )
|
|||||||
self.Players[PlayerName].ThreatLevel = UnitThreatLevel
|
self.Players[PlayerName].ThreatLevel = UnitThreatLevel
|
||||||
self.Players[PlayerName].ThreatType = UnitThreatType
|
self.Players[PlayerName].ThreatType = UnitThreatType
|
||||||
|
|
||||||
-- TODO: DCS bug concerning Units with skill level client don't get destroyed in multi player. This logic is deactivated until this bug gets fixed.
|
-- TODO: make fratricide switchable
|
||||||
--[[
|
if self.Players[PlayerName].Penalty > self.Fratricide * 0.50 and self.penaltyonfratricide then
|
||||||
if self.Players[PlayerName].Penalty > self.Fratricide * 0.50 then
|
|
||||||
if self.Players[PlayerName].PenaltyWarning < 1 then
|
if self.Players[PlayerName].PenaltyWarning < 1 then
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "': WARNING! If you continue to commit FRATRICIDE and have a PENALTY score higher than " .. self.Fratricide .. ", you will be COURT MARTIALED and DISMISSED from this mission! \nYour total penalty is: " .. self.Players[PlayerName].Penalty,
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "': WARNING! If you continue to commit FRATRICIDE and have a PENALTY score higher than " .. self.Fratricide .. ", you will be COURT MARTIALED and DISMISSED from this mission! \nYour total penalty is: " .. self.Players[PlayerName].Penalty,
|
||||||
MESSAGE.Type.Information
|
MESSAGE.Type.Information )
|
||||||
):ToAll()
|
:ToAll()
|
||||||
self.Players[PlayerName].PenaltyWarning = self.Players[PlayerName].PenaltyWarning + 1
|
self.Players[PlayerName].PenaltyWarning = self.Players[PlayerName].PenaltyWarning + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Players[PlayerName].Penalty > self.Fratricide then
|
if self.Players[PlayerName].Penalty > self.Fratricide and self.penaltyonfratricide then
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' committed FRATRICIDE, he will be COURT MARTIALED and is DISMISSED from this mission!",
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' committed FRATRICIDE, he will be COURT MARTIALED and is DISMISSED from this mission!",
|
||||||
MESSAGE.Type.Information
|
MESSAGE.Type.Information )
|
||||||
):ToAll()
|
:ToAll()
|
||||||
UnitData:GetGroup():Destroy()
|
UnitData:GetGroup():Destroy()
|
||||||
end
|
end
|
||||||
--]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Add a goal score for a player.
|
--- Add a goal score for a player.
|
||||||
-- The method takes the Player name for which the Goal score needs to be set.
|
-- The method takes the Player name for which the Goal score needs to be set.
|
||||||
-- The GoalTag is a string or identifier that is taken into the CSV file scoring log to identify the goal.
|
-- The GoalTag is a string or identifier that is taken into the CSV file scoring log to identify the goal.
|
||||||
@@ -712,14 +714,14 @@ function SCORING:AddGoalScorePlayer( PlayerName, GoalTag, Text, Score )
|
|||||||
PlayerData.Goals[GoalTag].Score = PlayerData.Goals[GoalTag].Score + Score
|
PlayerData.Goals[GoalTag].Score = PlayerData.Goals[GoalTag].Score + Score
|
||||||
PlayerData.Score = PlayerData.Score + Score
|
PlayerData.Score = PlayerData.Score + Score
|
||||||
|
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Text, MESSAGE.Type.Information ):ToAll()
|
MESSAGE:NewType( self.DisplayMessagePrefix .. Text,
|
||||||
|
MESSAGE.Type.Information )
|
||||||
|
:ToAll()
|
||||||
|
|
||||||
self:ScoreCSV( PlayerName, "", "GOAL_" .. string.upper( GoalTag ), 1, Score, nil )
|
self:ScoreCSV( PlayerName, "", "GOAL_" .. string.upper( GoalTag ), 1, Score, nil )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Add a goal score for a player.
|
--- Add a goal score for a player.
|
||||||
-- The method takes the PlayerUnit for which the Goal score needs to be set.
|
-- The method takes the PlayerUnit for which the Goal score needs to be set.
|
||||||
-- The GoalTag is a string or identifier that is taken into the CSV file scoring log to identify the goal.
|
-- The GoalTag is a string or identifier that is taken into the CSV file scoring log to identify the goal.
|
||||||
@@ -744,13 +746,14 @@ function SCORING:AddGoalScore( PlayerUnit, GoalTag, Text, Score )
|
|||||||
PlayerData.Goals[GoalTag].Score = PlayerData.Goals[GoalTag].Score + Score
|
PlayerData.Goals[GoalTag].Score = PlayerData.Goals[GoalTag].Score + Score
|
||||||
PlayerData.Score = PlayerData.Score + Score
|
PlayerData.Score = PlayerData.Score + Score
|
||||||
|
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Text, MESSAGE.Type.Information ):ToAll()
|
MESSAGE:NewType( self.DisplayMessagePrefix .. Text,
|
||||||
|
MESSAGE.Type.Information )
|
||||||
|
:ToAll()
|
||||||
|
|
||||||
self:ScoreCSV( PlayerName, "", "GOAL_" .. string.upper( GoalTag ), 1, Score, PlayerUnit:GetName() )
|
self:ScoreCSV( PlayerName, "", "GOAL_" .. string.upper( GoalTag ), 1, Score, PlayerUnit:GetName() )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Registers Scores the players completing a Mission Task.
|
--- Registers Scores the players completing a Mission Task.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param Tasking.Mission#MISSION Mission
|
-- @param Tasking.Mission#MISSION Mission
|
||||||
@@ -780,7 +783,9 @@ function SCORING:_AddMissionTaskScore( Mission, PlayerUnit, Text, Score )
|
|||||||
PlayerData.Score = self.Players[PlayerName].Score + Score
|
PlayerData.Score = self.Players[PlayerName].Score + Score
|
||||||
PlayerData.Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score
|
PlayerData.Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score
|
||||||
|
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Mission:GetText() .. " : " .. Text .. " Score: " .. Score, MESSAGE.Type.Information ):ToAll()
|
MESSAGE:NewType( self.DisplayMessagePrefix .. Mission:GetText() .. " : " .. Text .. " Score: " .. Score,
|
||||||
|
MESSAGE.Type.Information )
|
||||||
|
:ToAll()
|
||||||
|
|
||||||
self:ScoreCSV( PlayerName, "", "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score, PlayerUnit:GetName() )
|
self:ScoreCSV( PlayerName, "", "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score, PlayerUnit:GetName() )
|
||||||
end
|
end
|
||||||
@@ -841,26 +846,24 @@ function SCORING:_AddMissionScore( Mission, Text, Score )
|
|||||||
PlayerData.Score = PlayerData.Score + Score
|
PlayerData.Score = PlayerData.Score + Score
|
||||||
PlayerData.Mission[MissionName].ScoreMission = PlayerData.Mission[MissionName].ScoreMission + Score
|
PlayerData.Mission[MissionName].ScoreMission = PlayerData.Mission[MissionName].ScoreMission + Score
|
||||||
|
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' has " .. Text .. " in " .. Mission:GetText() .. ". " ..
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' has " .. Text .. " in " .. Mission:GetText() .. ". " .. Score .. " mission score!",
|
||||||
Score .. " mission score!",
|
MESSAGE.Type.Information )
|
||||||
MESSAGE.Type.Information ):ToAll()
|
:ToAll()
|
||||||
|
|
||||||
self:ScoreCSV( PlayerName, "", "MISSION_" .. MissionName:gsub( ' ', '_' ), 1, Score )
|
self:ScoreCSV( PlayerName, "", "MISSION_" .. MissionName:gsub( ' ', '_' ), 1, Score )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Handles the OnPlayerEnterUnit event for the scoring.
|
--- Handles the OnPlayerEnterUnit event for the scoring.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param Core.Event#EVENTDATA Event
|
-- @param Core.Event#EVENTDATA Event
|
||||||
--function SCORING:OnEventPlayerEnterUnit( Event )
|
-- function SCORING:OnEventPlayerEnterUnit( Event )
|
||||||
-- if Event.IniUnit then
|
-- if Event.IniUnit then
|
||||||
-- self:_AddPlayerFromUnit( Event.IniUnit )
|
-- self:_AddPlayerFromUnit( Event.IniUnit )
|
||||||
-- self:SetScoringMenu( Event.IniGroup )
|
-- self:SetScoringMenu( Event.IniGroup )
|
||||||
-- end
|
-- end
|
||||||
--end
|
-- end
|
||||||
|
|
||||||
--- Handles the OnBirth event for the scoring.
|
--- Handles the OnBirth event for the scoring.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
@@ -886,12 +889,11 @@ function SCORING:OnEventPlayerLeaveUnit( Event )
|
|||||||
local Menu = self:GetState( Event.IniUnit:GetGroup(), "ScoringMenu" ) -- Core.Menu#MENU_GROUP
|
local Menu = self:GetState( Event.IniUnit:GetGroup(), "ScoringMenu" ) -- Core.Menu#MENU_GROUP
|
||||||
if Menu then
|
if Menu then
|
||||||
-- TODO: Check if this fixes #281.
|
-- TODO: Check if this fixes #281.
|
||||||
--Menu:Remove()
|
-- Menu:Remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Handles the OnHit event for the scoring.
|
--- Handles the OnHit event for the scoring.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param Core.Event#EVENTDATA Event
|
-- @param Core.Event#EVENTDATA Event
|
||||||
@@ -936,9 +938,9 @@ function SCORING:_EventOnHit( Event )
|
|||||||
InitPlayerName = Event.IniPlayerName
|
InitPlayerName = Event.IniPlayerName
|
||||||
|
|
||||||
InitCoalition = Event.IniCoalition
|
InitCoalition = Event.IniCoalition
|
||||||
--TODO: Workaround Client DCS Bug
|
-- TODO: Workaround Client DCS Bug
|
||||||
--InitCategory = InitUnit:getCategory()
|
-- InitCategory = InitUnit:getCategory()
|
||||||
--InitCategory = InitUnit:getDesc().category
|
-- InitCategory = InitUnit:getDesc().category
|
||||||
InitCategory = Event.IniCategory
|
InitCategory = Event.IniCategory
|
||||||
InitType = Event.IniTypeName
|
InitType = Event.IniTypeName
|
||||||
|
|
||||||
@@ -946,10 +948,9 @@ function SCORING:_EventOnHit( Event )
|
|||||||
InitUnitCategory = _SCORINGCategory[InitCategory]
|
InitUnitCategory = _SCORINGCategory[InitCategory]
|
||||||
InitUnitType = InitType
|
InitUnitType = InitType
|
||||||
|
|
||||||
self:T( { InitUnitName, InitGroupName, InitPlayerName, InitCoalition, InitCategory, InitType , InitUnitCoalition, InitUnitCategory, InitUnitType } )
|
self:T( { InitUnitName, InitGroupName, InitPlayerName, InitCoalition, InitCategory, InitType, InitUnitCoalition, InitUnitCategory, InitUnitType } )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if Event.TgtDCSUnit then
|
if Event.TgtDCSUnit then
|
||||||
|
|
||||||
TargetUnit = Event.TgtDCSUnit
|
TargetUnit = Event.TgtDCSUnit
|
||||||
@@ -960,9 +961,9 @@ function SCORING:_EventOnHit( Event )
|
|||||||
TargetPlayerName = Event.TgtPlayerName
|
TargetPlayerName = Event.TgtPlayerName
|
||||||
|
|
||||||
TargetCoalition = Event.TgtCoalition
|
TargetCoalition = Event.TgtCoalition
|
||||||
--TODO: Workaround Client DCS Bug
|
-- TODO: Workaround Client DCS Bug
|
||||||
--TargetCategory = TargetUnit:getCategory()
|
-- TargetCategory = TargetUnit:getCategory()
|
||||||
--TargetCategory = TargetUnit:getDesc().category
|
-- TargetCategory = TargetUnit:getDesc().category
|
||||||
TargetCategory = Event.TgtCategory
|
TargetCategory = Event.TgtCategory
|
||||||
TargetType = Event.TgtTypeName
|
TargetType = Event.TgtTypeName
|
||||||
|
|
||||||
@@ -1023,23 +1024,17 @@ function SCORING:_EventOnHit( Event )
|
|||||||
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit + 1
|
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit + 1
|
||||||
|
|
||||||
if TargetPlayerName ~= nil then -- It is a player hitting another player ...
|
if TargetPlayerName ~= nil then -- It is a player hitting another player ...
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit friendly player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.PenaltyHit .. " times. " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit friendly player '" .. TargetPlayerName .. "' " ..
|
"Penalty: -" .. PlayerHit.Penalty .. ". Score Total:" .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.PenaltyHit .. " times. " ..
|
MESSAGE.Type.Update )
|
||||||
"Penalty: -" .. PlayerHit.Penalty .. ". Score Total:" .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Update
|
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
|
||||||
else
|
else
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit friendly target " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.PenaltyHit .. " times. " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit friendly target " ..
|
"Penalty: -" .. PlayerHit.Penalty .. ". Score Total:" .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.PenaltyHit .. " times. " ..
|
MESSAGE.Type.Update )
|
||||||
"Penalty: -" .. PlayerHit.Penalty .. ". Score Total:" .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Update
|
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
|
||||||
end
|
end
|
||||||
self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
else
|
else
|
||||||
@@ -1047,33 +1042,26 @@ function SCORING:_EventOnHit( Event )
|
|||||||
PlayerHit.Score = PlayerHit.Score + 1
|
PlayerHit.Score = PlayerHit.Score + 1
|
||||||
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
||||||
if TargetPlayerName ~= nil then -- It is a player hitting another player ...
|
if TargetPlayerName ~= nil then -- It is a player hitting another player ...
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit enemy player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit enemy player '" .. TargetPlayerName .. "' " ..
|
"Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " ..
|
MESSAGE.Type.Update )
|
||||||
"Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Update
|
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
|
||||||
else
|
else
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit enemy target " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit enemy target " ..
|
"Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " ..
|
MESSAGE.Type.Update )
|
||||||
"Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Update
|
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
|
||||||
end
|
end
|
||||||
self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_SCORE", 1, 1, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_SCORE", 1, 1, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
end
|
end
|
||||||
else -- A scenery object was hit.
|
else -- A scenery object was hit.
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit scenery object.",
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit scenery object.",
|
MESSAGE.Type.Update )
|
||||||
MESSAGE.Type.Update
|
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
||||||
)
|
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
||||||
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
|
||||||
self:ScoreCSV( InitPlayerName, "", "HIT_SCORE", 1, 0, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType )
|
self:ScoreCSV( InitPlayerName, "", "HIT_SCORE", 1, 0, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1125,9 +1113,9 @@ function SCORING:_EventOnHit( Event )
|
|||||||
if InitCoalition then -- A coalition object was hit, probably a static.
|
if InitCoalition then -- A coalition object was hit, probably a static.
|
||||||
if InitCoalition == TargetCoalition then
|
if InitCoalition == TargetCoalition then
|
||||||
-- TODO: Penalty according scale
|
-- TODO: Penalty according scale
|
||||||
Player.Penalty = Player.Penalty + 10
|
Player.Penalty = Player.Penalty + 10 --* self.ScaleDestroyPenalty
|
||||||
PlayerHit.Penalty = PlayerHit.Penalty + 10
|
PlayerHit.Penalty = PlayerHit.Penalty + 10 --* self.ScaleDestroyPenalty
|
||||||
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit + 1
|
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit + 1 * self.ScaleDestroyPenalty
|
||||||
|
|
||||||
MESSAGE
|
MESSAGE
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit friendly target " ..
|
:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit friendly target " ..
|
||||||
@@ -1142,23 +1130,20 @@ function SCORING:_EventOnHit( Event )
|
|||||||
Player.Score = Player.Score + 1
|
Player.Score = Player.Score + 1
|
||||||
PlayerHit.Score = PlayerHit.Score + 1
|
PlayerHit.Score = PlayerHit.Score + 1
|
||||||
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit enemy target " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit enemy target " ..
|
"Score: +" .. PlayerHit.Score .. " = " .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. TargetType .. " ) " ..
|
MESSAGE.Type.Update )
|
||||||
"Score: +" .. PlayerHit.Score .. " = " .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Update
|
:ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
|
||||||
self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_SCORE", 1, 1, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_SCORE", 1, 1, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
end
|
end
|
||||||
else -- A scenery object was hit.
|
else -- A scenery object was hit.
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit scenery object.",
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit scenery object.",
|
MESSAGE.Type.Update )
|
||||||
MESSAGE.Type.Update
|
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
||||||
)
|
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
||||||
:ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
|
||||||
self:ScoreCSV( Event.WeaponPlayerName, "", "HIT_SCORE", 1, 0, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, "", "Scenery", TargetUnitType )
|
self:ScoreCSV( Event.WeaponPlayerName, "", "HIT_SCORE", 1, 0, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, "", "Scenery", TargetUnitType )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1194,8 +1179,8 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
|||||||
TargetPlayerName = Event.IniPlayerName
|
TargetPlayerName = Event.IniPlayerName
|
||||||
|
|
||||||
TargetCoalition = Event.IniCoalition
|
TargetCoalition = Event.IniCoalition
|
||||||
--TargetCategory = TargetUnit:getCategory()
|
-- TargetCategory = TargetUnit:getCategory()
|
||||||
--TargetCategory = TargetUnit:getDesc().category -- Workaround
|
-- TargetCategory = TargetUnit:getDesc().category -- Workaround
|
||||||
TargetCategory = Event.IniCategory
|
TargetCategory = Event.IniCategory
|
||||||
TargetType = Event.IniTypeName
|
TargetType = Event.IniTypeName
|
||||||
|
|
||||||
@@ -1236,7 +1221,7 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
|||||||
local TargetDestroy = Player.Destroy[TargetCategory][TargetType]
|
local TargetDestroy = Player.Destroy[TargetCategory][TargetType]
|
||||||
TargetDestroy.Score = TargetDestroy.Score or 0
|
TargetDestroy.Score = TargetDestroy.Score or 0
|
||||||
TargetDestroy.ScoreDestroy = TargetDestroy.ScoreDestroy or 0
|
TargetDestroy.ScoreDestroy = TargetDestroy.ScoreDestroy or 0
|
||||||
TargetDestroy.Penalty = TargetDestroy.Penalty or 0
|
TargetDestroy.Penalty = TargetDestroy.Penalty or 0
|
||||||
TargetDestroy.PenaltyDestroy = TargetDestroy.PenaltyDestroy or 0
|
TargetDestroy.PenaltyDestroy = TargetDestroy.PenaltyDestroy or 0
|
||||||
|
|
||||||
if TargetCoalition then
|
if TargetCoalition then
|
||||||
@@ -1244,81 +1229,69 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
|||||||
local ThreatLevelTarget = TargetThreatLevel
|
local ThreatLevelTarget = TargetThreatLevel
|
||||||
local ThreatTypeTarget = TargetThreatType
|
local ThreatTypeTarget = TargetThreatType
|
||||||
local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1
|
local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1
|
||||||
local ThreatPenalty = math.ceil( ( ThreatLevelTarget / ThreatLevelPlayer ) * self.ScaleDestroyPenalty / 10 )
|
local ThreatPenalty = math.ceil( (ThreatLevelTarget / ThreatLevelPlayer) * self.ScaleDestroyPenalty / 10 )
|
||||||
self:F( { ThreatLevel = ThreatPenalty, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } )
|
self:F( { ThreatLevel = ThreatPenalty, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } )
|
||||||
|
|
||||||
Player.Penalty = Player.Penalty + ThreatPenalty
|
Player.Penalty = Player.Penalty + ThreatPenalty
|
||||||
TargetDestroy.Penalty = TargetDestroy.Penalty + ThreatPenalty
|
TargetDestroy.Penalty = TargetDestroy.Penalty + ThreatPenalty
|
||||||
TargetDestroy.PenaltyDestroy = TargetDestroy.PenaltyDestroy + 1
|
TargetDestroy.PenaltyDestroy = TargetDestroy.PenaltyDestroy + 1
|
||||||
|
|
||||||
if Player.HitPlayers[TargetPlayerName] then -- A player destroyed another player
|
if Player.HitPlayers[TargetPlayerName] then -- A player destroyed another player
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly player '" .. TargetPlayerName .. "' " ..
|
"Penalty: -" .. TargetDestroy.Penalty .. " = " .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
MESSAGE.Type.Information )
|
||||||
"Penalty: -" .. TargetDestroy.Penalty .. " = " .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Information
|
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
|
||||||
else
|
else
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly target " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly target " ..
|
"Penalty: -" .. TargetDestroy.Penalty .. " = " .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
MESSAGE.Type.Information )
|
||||||
"Penalty: -" .. TargetDestroy.Penalty .. " = " .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Information
|
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Destroyed = true
|
|
||||||
self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_PENALTY", 1, ThreatPenalty, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_PENALTY", 1, ThreatPenalty, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
|
Destroyed = true
|
||||||
else
|
else
|
||||||
|
|
||||||
local ThreatLevelTarget = TargetThreatLevel
|
local ThreatLevelTarget = TargetThreatLevel
|
||||||
local ThreatTypeTarget = TargetThreatType
|
local ThreatTypeTarget = TargetThreatType
|
||||||
local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1
|
local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1
|
||||||
local ThreatScore = math.ceil( ( ThreatLevelTarget / ThreatLevelPlayer ) * self.ScaleDestroyScore / 10 )
|
local ThreatScore = math.ceil( (ThreatLevelTarget / ThreatLevelPlayer) * self.ScaleDestroyScore / 10 )
|
||||||
|
|
||||||
self:F( { ThreatLevel = ThreatScore, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } )
|
self:F( { ThreatLevel = ThreatScore, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } )
|
||||||
|
|
||||||
Player.Score = Player.Score + ThreatScore
|
Player.Score = Player.Score + ThreatScore
|
||||||
TargetDestroy.Score = TargetDestroy.Score + ThreatScore
|
TargetDestroy.Score = TargetDestroy.Score + ThreatScore
|
||||||
TargetDestroy.ScoreDestroy = TargetDestroy.ScoreDestroy + 1
|
TargetDestroy.ScoreDestroy = TargetDestroy.ScoreDestroy + 1
|
||||||
if Player.HitPlayers[TargetPlayerName] then -- A player destroyed another player
|
if Player.HitPlayers[TargetPlayerName] then -- A player destroyed another player
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy player '" .. TargetPlayerName .. "' " ..
|
"Score: +" .. TargetDestroy.Score .. " = " .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
MESSAGE.Type.Information )
|
||||||
"Score: +" .. TargetDestroy.Score .. " = " .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Information
|
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
|
||||||
else
|
else
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy " ..
|
"Score: +" .. TargetDestroy.Score .. " = " .. Player.Score - Player.Penalty,
|
||||||
TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
MESSAGE.Type.Information )
|
||||||
"Score: +" .. TargetDestroy.Score .. " = " .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Information
|
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
|
||||||
end
|
end
|
||||||
Destroyed = true
|
|
||||||
self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, ThreatScore, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, ThreatScore, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
|
Destroyed = true
|
||||||
|
|
||||||
local UnitName = TargetUnit:GetName()
|
local UnitName = TargetUnit:GetName()
|
||||||
local Score = self.ScoringObjects[UnitName]
|
local Score = self.ScoringObjects[UnitName]
|
||||||
if Score then
|
if Score then
|
||||||
Player.Score = Player.Score + Score
|
Player.Score = Player.Score + Score
|
||||||
TargetDestroy.Score = TargetDestroy.Score + Score
|
TargetDestroy.Score = TargetDestroy.Score + Score
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Special target '" .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " .. " destroyed! " ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Special target '" .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " .. " destroyed! " ..
|
"Player '" .. PlayerName .. "' receives an extra " .. Score .. " points! Total: " .. Player.Score - Player.Penalty,
|
||||||
"Player '" .. PlayerName .. "' receives an extra " .. Score .. " points! Total: " .. Player.Score - Player.Penalty,
|
MESSAGE.Type.Information )
|
||||||
MESSAGE.Type.Information
|
:ToAllIf( self:IfMessagesScore() and self:IfMessagesToAll() )
|
||||||
)
|
:ToCoalitionIf( InitCoalition, self:IfMessagesScore() and self:IfMessagesToCoalition() )
|
||||||
:ToAllIf( self:IfMessagesScore() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesScore() and self:IfMessagesToCoalition() )
|
|
||||||
self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
Destroyed = true
|
Destroyed = true
|
||||||
end
|
end
|
||||||
@@ -1331,13 +1304,12 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
|||||||
if ScoreZone:IsVec2InZone( TargetUnit:GetVec2() ) then
|
if ScoreZone:IsVec2InZone( TargetUnit:GetVec2() ) then
|
||||||
Player.Score = Player.Score + Score
|
Player.Score = Player.Score + Score
|
||||||
TargetDestroy.Score = TargetDestroy.Score + Score
|
TargetDestroy.Score = TargetDestroy.Score + Score
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Target destroyed in zone '" .. ScoreZone:GetName() .. "'." ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Target destroyed in zone '" .. ScoreZone:GetName() .. "'." ..
|
"Player '" .. PlayerName .. "' receives an extra " .. Score .. " points! " .. "Total: " .. Player.Score - Player.Penalty,
|
||||||
"Player '" .. PlayerName .. "' receives an extra " .. Score .. " points! " ..
|
MESSAGE.Type.Information )
|
||||||
"Total: " .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Information )
|
:ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() )
|
||||||
:ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() )
|
|
||||||
self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
Destroyed = true
|
Destroyed = true
|
||||||
end
|
end
|
||||||
@@ -1347,22 +1319,20 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
|||||||
else
|
else
|
||||||
-- Check if there are Zones where the destruction happened.
|
-- Check if there are Zones where the destruction happened.
|
||||||
for ZoneName, ScoreZoneData in pairs( self.ScoringZones ) do
|
for ZoneName, ScoreZoneData in pairs( self.ScoringZones ) do
|
||||||
self:F( { ScoringZone = ScoreZoneData } )
|
self:F( { ScoringZone = ScoreZoneData } )
|
||||||
local ScoreZone = ScoreZoneData.ScoreZone -- Core.Zone#ZONE_BASE
|
local ScoreZone = ScoreZoneData.ScoreZone -- Core.Zone#ZONE_BASE
|
||||||
local Score = ScoreZoneData.Score
|
local Score = ScoreZoneData.Score
|
||||||
if ScoreZone:IsVec2InZone( TargetUnit:GetVec2() ) then
|
if ScoreZone:IsVec2InZone( TargetUnit:GetVec2() ) then
|
||||||
Player.Score = Player.Score + Score
|
Player.Score = Player.Score + Score
|
||||||
TargetDestroy.Score = TargetDestroy.Score + Score
|
TargetDestroy.Score = TargetDestroy.Score + Score
|
||||||
MESSAGE
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Scenery destroyed in zone '" .. ScoreZone:GetName() .. "'." ..
|
||||||
:NewType( self.DisplayMessagePrefix .. "Scenery destroyed in zone '" .. ScoreZone:GetName() .. "'." ..
|
"Player '" .. PlayerName .. "' receives an extra " .. Score .. " points! " .. "Total: " .. Player.Score - Player.Penalty,
|
||||||
"Player '" .. PlayerName .. "' receives an extra " .. Score .. " points! " ..
|
MESSAGE.Type.Information )
|
||||||
"Total: " .. Player.Score - Player.Penalty,
|
:ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() )
|
||||||
MESSAGE.Type.Information
|
:ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() )
|
||||||
)
|
|
||||||
:ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() )
|
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() )
|
|
||||||
Destroyed = true
|
|
||||||
self:ScoreCSV( PlayerName, "", "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType )
|
self:ScoreCSV( PlayerName, "", "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType )
|
||||||
|
Destroyed = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1378,7 +1348,6 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Produce detailed report of player hit scores.
|
--- Produce detailed report of player hit scores.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param #string PlayerName The name of the player.
|
-- @param #string PlayerName The name of the player.
|
||||||
@@ -1420,7 +1389,7 @@ function SCORING:ReportDetailedPlayerHits( PlayerName )
|
|||||||
PlayerScore = PlayerScore + Score
|
PlayerScore = PlayerScore + Score
|
||||||
PlayerPenalty = PlayerPenalty + Penalty
|
PlayerPenalty = PlayerPenalty + Penalty
|
||||||
else
|
else
|
||||||
--ScoreMessageHits = ScoreMessageHits .. string.format( "%s:%d ", string.format(CategoryName, 1, 1), 0 )
|
-- ScoreMessageHits = ScoreMessageHits .. string.format( "%s:%d ", string.format(CategoryName, 1, 1), 0 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ScoreMessageHits ~= "" then
|
if ScoreMessageHits ~= "" then
|
||||||
@@ -1431,7 +1400,6 @@ function SCORING:ReportDetailedPlayerHits( PlayerName )
|
|||||||
return ScoreMessage, PlayerScore, PlayerPenalty
|
return ScoreMessage, PlayerScore, PlayerPenalty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Produce detailed report of player destroy scores.
|
--- Produce detailed report of player destroy scores.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param #string PlayerName The name of the player.
|
-- @param #string PlayerName The name of the player.
|
||||||
@@ -1478,7 +1446,7 @@ function SCORING:ReportDetailedPlayerDestroys( PlayerName )
|
|||||||
PlayerScore = PlayerScore + Score
|
PlayerScore = PlayerScore + Score
|
||||||
PlayerPenalty = PlayerPenalty + Penalty
|
PlayerPenalty = PlayerPenalty + Penalty
|
||||||
else
|
else
|
||||||
--ScoreMessageDestroys = ScoreMessageDestroys .. string.format( "%s:%d ", string.format(CategoryName, 1, 1), 0 )
|
-- ScoreMessageDestroys = ScoreMessageDestroys .. string.format( "%s:%d ", string.format(CategoryName, 1, 1), 0 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ScoreMessageDestroys ~= "" then
|
if ScoreMessageDestroys ~= "" then
|
||||||
@@ -1597,7 +1565,6 @@ function SCORING:ReportDetailedPlayerMissions( PlayerName )
|
|||||||
return ScoreMessage, PlayerScore, PlayerPenalty
|
return ScoreMessage, PlayerScore, PlayerPenalty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Report Group Score Summary
|
--- Report Group Score Summary
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param Wrapper.Group#GROUP PlayerGroup The player group.
|
-- @param Wrapper.Group#GROUP PlayerGroup The player group.
|
||||||
@@ -1637,13 +1604,12 @@ function SCORING:ReportScoreGroupSummary( PlayerGroup )
|
|||||||
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
|
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
|
||||||
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + PenaltyGoals + PenaltyMissions
|
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + PenaltyGoals + PenaltyMissions
|
||||||
|
|
||||||
PlayerMessage =
|
PlayerMessage = string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )",
|
||||||
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )",
|
PlayerName,
|
||||||
PlayerName,
|
PlayerScore - PlayerPenalty,
|
||||||
PlayerScore - PlayerPenalty,
|
PlayerScore,
|
||||||
PlayerScore,
|
PlayerPenalty
|
||||||
PlayerPenalty
|
)
|
||||||
)
|
|
||||||
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup )
|
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1687,7 +1653,7 @@ function SCORING:ReportScoreGroupDetailed( PlayerGroup )
|
|||||||
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
|
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
|
||||||
|
|
||||||
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
|
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
|
||||||
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions
|
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + PenaltyGoals + PenaltyMissions
|
||||||
|
|
||||||
PlayerMessage =
|
PlayerMessage =
|
||||||
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )%s%s%s%s%s",
|
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )%s%s%s%s%s",
|
||||||
@@ -1743,7 +1709,7 @@ function SCORING:ReportScoreAllSummary( PlayerGroup )
|
|||||||
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
|
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
|
||||||
|
|
||||||
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
|
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
|
||||||
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions
|
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + PenaltyGoals + PenaltyMissions
|
||||||
|
|
||||||
PlayerMessage =
|
PlayerMessage =
|
||||||
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )",
|
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )",
|
||||||
@@ -1758,17 +1724,16 @@ function SCORING:ReportScoreAllSummary( PlayerGroup )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function SCORING:SecondsToClock( sSeconds )
|
||||||
function SCORING:SecondsToClock(sSeconds)
|
|
||||||
local nSeconds = sSeconds
|
local nSeconds = sSeconds
|
||||||
if nSeconds == 0 then
|
if nSeconds == 0 then
|
||||||
--return nil;
|
-- return nil;
|
||||||
return "00:00:00";
|
return "00:00:00";
|
||||||
else
|
else
|
||||||
nHours = string.format("%02.f", math.floor(nSeconds/3600));
|
nHours = string.format( "%02.f", math.floor( nSeconds / 3600 ) );
|
||||||
nMins = string.format("%02.f", math.floor(nSeconds/60 - (nHours*60)));
|
nMins = string.format( "%02.f", math.floor( nSeconds / 60 - (nHours * 60) ) );
|
||||||
nSecs = string.format("%02.f", math.floor(nSeconds - nHours*3600 - nMins *60));
|
nSecs = string.format( "%02.f", math.floor( nSeconds - nHours * 3600 - nMins * 60 ) );
|
||||||
return nHours..":"..nMins..":"..nSecs
|
return nHours .. ":" .. nMins .. ":" .. nSecs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1793,9 +1758,9 @@ function SCORING:OpenCSV( ScoringCSV )
|
|||||||
error( "Error: Cannot open CSV file in " .. lfs.writedir() )
|
error( "Error: Cannot open CSV file in " .. lfs.writedir() )
|
||||||
end
|
end
|
||||||
|
|
||||||
self.CSVFile:write( '"GameName","RunTime","Time","PlayerName","TargetPlayerName","ScoreType","PlayerUnitCoaltion","PlayerUnitCategory","PlayerUnitType","PlayerUnitName","TargetUnitCoalition","TargetUnitCategory","TargetUnitType","TargetUnitName","Times","Score"\n' )
|
self.CSVFile:write( '"GameName","RunTime","Time","PlayerName","TargetPlayerName","ScoreType","PlayerUnitCoalition","PlayerUnitCategory","PlayerUnitType","PlayerUnitName","TargetUnitCoalition","TargetUnitCategory","TargetUnitType","TargetUnitName","Times","Score"\n' )
|
||||||
|
|
||||||
self.RunTime = os.date("%y-%m-%d_%H-%M-%S")
|
self.RunTime = os.date( "%y-%m-%d_%H-%M-%S" )
|
||||||
else
|
else
|
||||||
error( "A string containing the CSV file name must be given." )
|
error( "A string containing the CSV file name must be given." )
|
||||||
end
|
end
|
||||||
@@ -1805,7 +1770,6 @@ function SCORING:OpenCSV( ScoringCSV )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Registers a score for a player.
|
--- Registers a score for a player.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param #string PlayerName The name of the player.
|
-- @param #string PlayerName The name of the player.
|
||||||
@@ -1823,7 +1787,7 @@ end
|
|||||||
-- @param #string TargetUnitType The type of the target unit.
|
-- @param #string TargetUnitType The type of the target unit.
|
||||||
-- @return #SCORING self
|
-- @return #SCORING self
|
||||||
function SCORING:ScoreCSV( PlayerName, TargetPlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
function SCORING:ScoreCSV( PlayerName, TargetPlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
--write statistic information to file
|
-- write statistic information to file
|
||||||
local ScoreTime = self:SecondsToClock( timer.getTime() )
|
local ScoreTime = self:SecondsToClock( timer.getTime() )
|
||||||
PlayerName = PlayerName:gsub( '"', '_' )
|
PlayerName = PlayerName:gsub( '"', '_' )
|
||||||
|
|
||||||
@@ -1835,7 +1799,7 @@ function SCORING:ScoreCSV( PlayerName, TargetPlayerName, ScoreType, ScoreTimes,
|
|||||||
|
|
||||||
if PlayerUnit then
|
if PlayerUnit then
|
||||||
if not PlayerUnitCategory then
|
if not PlayerUnitCategory then
|
||||||
--PlayerUnitCategory = SCORINGCategory[PlayerUnit:getCategory()]
|
-- PlayerUnitCategory = SCORINGCategory[PlayerUnit:getCategory()]
|
||||||
PlayerUnitCategory = _SCORINGCategory[PlayerUnit:getDesc().category]
|
PlayerUnitCategory = _SCORINGCategory[PlayerUnit:getDesc().category]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1888,7 +1852,6 @@ function SCORING:ScoreCSV( PlayerName, TargetPlayerName, ScoreType, ScoreTimes,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function SCORING:CloseCSV()
|
function SCORING:CloseCSV()
|
||||||
if lfs and io and os then
|
if lfs and io and os then
|
||||||
self.CSVFile:close()
|
self.CSVFile:close()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Authors: **FlightControl**, **applevangelist**
|
-- ### Authors: **FlightControl**, **applevangelist**
|
||||||
--
|
--
|
||||||
-- Last Update: Nov 2021
|
-- Last Update: Feb 2022
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -59,6 +59,7 @@ SEAD = {
|
|||||||
Padding = 10,
|
Padding = 10,
|
||||||
CallBack = nil,
|
CallBack = nil,
|
||||||
UseCallBack = false,
|
UseCallBack = false,
|
||||||
|
debug = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Missile enumerators
|
--- Missile enumerators
|
||||||
@@ -76,6 +77,9 @@ SEAD = {
|
|||||||
["X_25"] = "X_25",
|
["X_25"] = "X_25",
|
||||||
["X_31"] = "X_31",
|
["X_31"] = "X_31",
|
||||||
["Kh25"] = "Kh25",
|
["Kh25"] = "Kh25",
|
||||||
|
["BGM_109"] = "BGM_109",
|
||||||
|
["AGM_154"] = "AGM_154",
|
||||||
|
["HY-2"] = "HY-2",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Missile enumerators - from DCS ME and Wikipedia
|
--- Missile enumerators - from DCS ME and Wikipedia
|
||||||
@@ -85,7 +89,7 @@ SEAD = {
|
|||||||
["AGM_88"] = { 150, 3},
|
["AGM_88"] = { 150, 3},
|
||||||
["AGM_45"] = { 12, 2},
|
["AGM_45"] = { 12, 2},
|
||||||
["AGM_122"] = { 16.5, 2.3},
|
["AGM_122"] = { 16.5, 2.3},
|
||||||
["AGM_84"] = { 280, 0.85},
|
["AGM_84"] = { 280, 0.8},
|
||||||
["ALARM"] = { 45, 2},
|
["ALARM"] = { 45, 2},
|
||||||
["LD-10"] = { 60, 4},
|
["LD-10"] = { 60, 4},
|
||||||
["X_58"] = { 70, 4},
|
["X_58"] = { 70, 4},
|
||||||
@@ -93,6 +97,9 @@ SEAD = {
|
|||||||
["X_25"] = { 25, 0.76},
|
["X_25"] = { 25, 0.76},
|
||||||
["X_31"] = {150, 3},
|
["X_31"] = {150, 3},
|
||||||
["Kh25"] = {25, 0.8},
|
["Kh25"] = {25, 0.8},
|
||||||
|
["BGM_109"] = {460, 0.705}, --in-game ~465kn
|
||||||
|
["AGM_154"] = {130, 0.61},
|
||||||
|
["HY-2"] = {90,1},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Creates the main object which is handling defensive actions for SA sites or moving SA vehicles.
|
--- Creates the main object which is handling defensive actions for SA sites or moving SA vehicles.
|
||||||
@@ -108,8 +115,8 @@ SEAD = {
|
|||||||
-- SEAD_RU_SAM_Defenses = SEAD:New( { 'RU SA-6 Kub', 'RU SA-6 Defenses', 'RU MI-26 Troops', 'RU Attack Gori' } )
|
-- SEAD_RU_SAM_Defenses = SEAD:New( { 'RU SA-6 Kub', 'RU SA-6 Defenses', 'RU MI-26 Troops', 'RU Attack Gori' } )
|
||||||
function SEAD:New( SEADGroupPrefixes, Padding )
|
function SEAD:New( SEADGroupPrefixes, Padding )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, FSM:New() )
|
||||||
self:F( SEADGroupPrefixes )
|
self:T( SEADGroupPrefixes )
|
||||||
|
|
||||||
if type( SEADGroupPrefixes ) == 'table' then
|
if type( SEADGroupPrefixes ) == 'table' then
|
||||||
for SEADGroupPrefixID, SEADGroupPrefix in pairs( SEADGroupPrefixes ) do
|
for SEADGroupPrefixID, SEADGroupPrefix in pairs( SEADGroupPrefixes ) do
|
||||||
@@ -122,14 +129,21 @@ function SEAD:New( SEADGroupPrefixes, Padding )
|
|||||||
local padding = Padding or 10
|
local padding = Padding or 10
|
||||||
if padding < 10 then padding = 10 end
|
if padding < 10 then padding = 10 end
|
||||||
self.Padding = padding
|
self.Padding = padding
|
||||||
self.UseEmissionsOnOff = false
|
self.UseEmissionsOnOff = true
|
||||||
|
|
||||||
|
self.debug = false
|
||||||
|
|
||||||
self.CallBack = nil
|
self.CallBack = nil
|
||||||
self.UseCallBack = false
|
self.UseCallBack = false
|
||||||
|
|
||||||
self:HandleEvent( EVENTS.Shot, self.HandleEventShot )
|
self:HandleEvent( EVENTS.Shot, self.HandleEventShot )
|
||||||
|
|
||||||
self:I("*** SEAD - Started Version 0.3.3")
|
-- Start State.
|
||||||
|
self:SetStartState("Running")
|
||||||
|
self:AddTransition("*", "ManageEvasion", "*")
|
||||||
|
self:AddTransition("*", "CalculateHitZone", "*")
|
||||||
|
|
||||||
|
self:I("*** SEAD - Started Version 0.4.3")
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -213,7 +227,7 @@ function SEAD:_CheckHarms(WeaponName)
|
|||||||
local hit = false
|
local hit = false
|
||||||
local name = ""
|
local name = ""
|
||||||
for _,_name in pairs (SEAD.Harms) do
|
for _,_name in pairs (SEAD.Harms) do
|
||||||
if string.find(WeaponName,_name,1) then
|
if string.find(WeaponName,_name,1,true) then
|
||||||
hit = true
|
hit = true
|
||||||
name = _name
|
name = _name
|
||||||
break
|
break
|
||||||
@@ -249,6 +263,186 @@ function SEAD:_GetDistance(_point1, _point2)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (Internal) Calculate hit zone of an AGM-88
|
||||||
|
-- @param #SEAD self
|
||||||
|
-- @param #table SEADWeapon DCS.Weapon object
|
||||||
|
-- @param Core.Point#COORDINATE pos0 Position of the plane when it fired
|
||||||
|
-- @param #number height Height when the missile was fired
|
||||||
|
-- @param Wrapper.Group#GROUP SEADGroup Attacker group
|
||||||
|
-- @param #string SEADWeaponName Weapon Name
|
||||||
|
-- @return #SEAD self
|
||||||
|
function SEAD:onafterCalculateHitZone(From,Event,To,SEADWeapon,pos0,height,SEADGroup,SEADWeaponName)
|
||||||
|
self:T("**** Calculating hit zone for " .. (SEADWeaponName or "None"))
|
||||||
|
if SEADWeapon and SEADWeapon:isExist() then
|
||||||
|
--local pos = SEADWeapon:getPoint()
|
||||||
|
|
||||||
|
-- postion and height
|
||||||
|
local position = SEADWeapon:getPosition()
|
||||||
|
local mheight = height
|
||||||
|
-- heading
|
||||||
|
local wph = math.atan2(position.x.z, position.x.x)
|
||||||
|
if wph < 0 then
|
||||||
|
wph=wph+2*math.pi
|
||||||
|
end
|
||||||
|
wph=math.deg(wph)
|
||||||
|
|
||||||
|
-- velocity
|
||||||
|
local wpndata = SEAD.HarmData["AGM_88"]
|
||||||
|
if string.find(SEADWeaponName,"154",1) then
|
||||||
|
wpndata = SEAD.HarmData["AGM_154"]
|
||||||
|
end
|
||||||
|
local mveloc = math.floor(wpndata[2] * 340.29)
|
||||||
|
local c1 = (2*mheight*9.81)/(mveloc^2)
|
||||||
|
local c2 = (mveloc^2) / 9.81
|
||||||
|
local Ropt = c2 * math.sqrt(c1+1)
|
||||||
|
if height <= 5000 then
|
||||||
|
Ropt = Ropt * 0.72
|
||||||
|
elseif height <= 7500 then
|
||||||
|
Ropt = Ropt * 0.82
|
||||||
|
elseif height <= 10000 then
|
||||||
|
Ropt = Ropt * 0.87
|
||||||
|
elseif height <= 12500 then
|
||||||
|
Ropt = Ropt * 0.98
|
||||||
|
end
|
||||||
|
|
||||||
|
-- look at a couple of zones across the trajectory
|
||||||
|
for n=1,3 do
|
||||||
|
local dist = Ropt - ((n-1)*20000)
|
||||||
|
local predpos= pos0:Translate(dist,wph)
|
||||||
|
if predpos then
|
||||||
|
|
||||||
|
local targetzone = ZONE_RADIUS:New("Target Zone",predpos:GetVec2(),20000)
|
||||||
|
|
||||||
|
if self.debug then
|
||||||
|
predpos:MarkToAll(string.format("height=%dm | heading=%d | velocity=%ddeg | Ropt=%dm",mheight,wph,mveloc,Ropt),false)
|
||||||
|
targetzone:DrawZone(coalition.side.BLUE,{0,0,1},0.2,nil,nil,3,true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local seadset = SET_GROUP:New():FilterPrefixes(self.SEADGroupPrefixes):FilterZones({targetzone}):FilterOnce()
|
||||||
|
local tgtcoord = targetzone:GetRandomPointVec2()
|
||||||
|
--if tgtcoord and tgtcoord.ClassName == "COORDINATE" then
|
||||||
|
--local tgtgrp = seadset:FindNearestGroupFromPointVec2(tgtcoord)
|
||||||
|
local tgtgrp = seadset:GetRandom()
|
||||||
|
local _targetgroup = nil
|
||||||
|
local _targetgroupname = "none"
|
||||||
|
local _targetskill = "Random"
|
||||||
|
if tgtgrp and tgtgrp:IsAlive() then
|
||||||
|
_targetgroup = tgtgrp
|
||||||
|
_targetgroupname = tgtgrp:GetName() -- group name
|
||||||
|
_targetskill = tgtgrp:GetUnit(1):GetSkill()
|
||||||
|
self:T("*** Found Target = ".. _targetgroupname)
|
||||||
|
self:ManageEvasion(_targetskill,_targetgroup,pos0,"AGM_88",SEADGroup, 20)
|
||||||
|
end
|
||||||
|
--end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (Internal) Handle Evasion
|
||||||
|
-- @param #SEAD self
|
||||||
|
-- @param #string _targetskill
|
||||||
|
-- @param Wrapper.Group#GROUP _targetgroup
|
||||||
|
-- @param Core.Point#COORDINATE SEADPlanePos
|
||||||
|
-- @param #string SEADWeaponName
|
||||||
|
-- @param Wrapper.Group#GROUP SEADGroup Attacker Group
|
||||||
|
-- @param #number timeoffset Offset for tti calc
|
||||||
|
-- @return #SEAD self
|
||||||
|
function SEAD:onafterManageEvasion(From,Event,To,_targetskill,_targetgroup,SEADPlanePos,SEADWeaponName,SEADGroup,timeoffset)
|
||||||
|
local timeoffset = timeoffset or 0
|
||||||
|
if _targetskill == "Random" then -- when skill is random, choose a skill
|
||||||
|
local Skills = { "Average", "Good", "High", "Excellent" }
|
||||||
|
_targetskill = Skills[ math.random(1,4) ]
|
||||||
|
end
|
||||||
|
--self:T( _targetskill )
|
||||||
|
if self.TargetSkill[_targetskill] then
|
||||||
|
local _evade = math.random (1,100) -- random number for chance of evading action
|
||||||
|
if (_evade > self.TargetSkill[_targetskill].Evade) then
|
||||||
|
self:T("*** SEAD - Evading")
|
||||||
|
-- calculate distance of attacker
|
||||||
|
local _targetpos = _targetgroup:GetCoordinate()
|
||||||
|
local _distance = self:_GetDistance(SEADPlanePos, _targetpos)
|
||||||
|
-- weapon speed
|
||||||
|
local hit, data = self:_CheckHarms(SEADWeaponName)
|
||||||
|
local wpnspeed = 666 -- ;)
|
||||||
|
local reach = 10
|
||||||
|
if hit then
|
||||||
|
local wpndata = SEAD.HarmData[data]
|
||||||
|
reach = wpndata[1] * 1,1
|
||||||
|
local mach = wpndata[2]
|
||||||
|
wpnspeed = math.floor(mach * 340.29)
|
||||||
|
end
|
||||||
|
-- time to impact
|
||||||
|
local _tti = math.floor(_distance / wpnspeed) - timeoffset -- estimated impact time
|
||||||
|
if _distance > 0 then
|
||||||
|
_distance = math.floor(_distance / 1000) -- km
|
||||||
|
else
|
||||||
|
_distance = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
self:T( string.format("*** SEAD - target skill %s, distance %dkm, reach %dkm, tti %dsec", _targetskill, _distance,reach,_tti ))
|
||||||
|
|
||||||
|
if reach >= _distance then
|
||||||
|
self:T("*** SEAD - Shot in Reach")
|
||||||
|
|
||||||
|
local function SuppressionStart(args)
|
||||||
|
self:T(string.format("*** SEAD - %s Radar Off & Relocating",args[2]))
|
||||||
|
local grp = args[1] -- Wrapper.Group#GROUP
|
||||||
|
local name = args[2] -- #string Group Name
|
||||||
|
local attacker = args[3] -- Wrapper.Group#GROUP
|
||||||
|
if self.UseEmissionsOnOff then
|
||||||
|
grp:EnableEmission(false)
|
||||||
|
end
|
||||||
|
grp:OptionAlarmStateGreen() -- needed else we cannot move around
|
||||||
|
grp:RelocateGroundRandomInRadius(20,300,false,false,"Diamond")
|
||||||
|
if self.UseCallBack then
|
||||||
|
local object = self.CallBack
|
||||||
|
object:SeadSuppressionStart(grp,name,attacker)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function SuppressionStop(args)
|
||||||
|
self:T(string.format("*** SEAD - %s Radar On",args[2]))
|
||||||
|
local grp = args[1] -- Wrapper.Group#GROUP
|
||||||
|
local name = args[2] -- #string Group Nam
|
||||||
|
if self.UseEmissionsOnOff then
|
||||||
|
grp:EnableEmission(true)
|
||||||
|
end
|
||||||
|
grp:OptionAlarmStateRed()
|
||||||
|
grp:OptionEngageRange(self.EngagementRange)
|
||||||
|
self.SuppressedGroups[name] = false
|
||||||
|
if self.UseCallBack then
|
||||||
|
local object = self.CallBack
|
||||||
|
object:SeadSuppressionEnd(grp,name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- randomize switch-on time
|
||||||
|
local delay = math.random(self.TargetSkill[_targetskill].DelayOn[1], self.TargetSkill[_targetskill].DelayOn[2])
|
||||||
|
if delay > _tti then delay = delay / 2 end -- speed up
|
||||||
|
if _tti > 600 then delay = _tti - 90 end -- shot from afar, 600 is default shorad ontime
|
||||||
|
|
||||||
|
local SuppressionStartTime = timer.getTime() + delay
|
||||||
|
local SuppressionEndTime = timer.getTime() + _tti + self.Padding
|
||||||
|
local _targetgroupname = _targetgroup:GetName()
|
||||||
|
if not self.SuppressedGroups[_targetgroupname] then
|
||||||
|
self:T(string.format("*** SEAD - %s | Parameters TTI %ds | Switch-Off in %ds",_targetgroupname,_tti,delay))
|
||||||
|
timer.scheduleFunction(SuppressionStart,{_targetgroup,_targetgroupname, SEADGroup},SuppressionStartTime)
|
||||||
|
timer.scheduleFunction(SuppressionStop,{_targetgroup,_targetgroupname},SuppressionEndTime)
|
||||||
|
self.SuppressedGroups[_targetgroupname] = true
|
||||||
|
if self.UseCallBack then
|
||||||
|
local object = self.CallBack
|
||||||
|
object:SeadSuppressionPlanned(_targetgroup,_targetgroupname,SuppressionStartTime,SuppressionEndTime, SEADGroup)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- (Internal) Detects if an SAM site was shot with an anti radiation missile. In this case, take evasive actions based on the skill level set within the ME.
|
--- (Internal) Detects if an SAM site was shot with an anti radiation missile. In this case, take evasive actions based on the skill level set within the ME.
|
||||||
-- @param #SEAD self
|
-- @param #SEAD self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
@@ -256,6 +450,7 @@ end
|
|||||||
function SEAD:HandleEventShot( EventData )
|
function SEAD:HandleEventShot( EventData )
|
||||||
self:T( { EventData.id } )
|
self:T( { EventData.id } )
|
||||||
local SEADPlane = EventData.IniUnit -- Wrapper.Unit#UNIT
|
local SEADPlane = EventData.IniUnit -- Wrapper.Unit#UNIT
|
||||||
|
local SEADGroup = EventData.IniGroup -- Wrapper.Group#GROUP
|
||||||
local SEADPlanePos = SEADPlane:GetCoordinate() -- Core.Point#COORDINATE
|
local SEADPlanePos = SEADPlane:GetCoordinate() -- Core.Point#COORDINATE
|
||||||
local SEADUnit = EventData.IniDCSUnit
|
local SEADUnit = EventData.IniDCSUnit
|
||||||
local SEADUnitName = EventData.IniDCSUnitName
|
local SEADUnitName = EventData.IniDCSUnitName
|
||||||
@@ -270,114 +465,55 @@ function SEAD:HandleEventShot( EventData )
|
|||||||
local _targetskill = "Random"
|
local _targetskill = "Random"
|
||||||
local _targetgroupname = "none"
|
local _targetgroupname = "none"
|
||||||
local _target = EventData.Weapon:getTarget() -- Identify target
|
local _target = EventData.Weapon:getTarget() -- Identify target
|
||||||
local _targetUnit = UNIT:Find(_target) -- Wrapper.Unit#UNIT
|
if not _target or self.debug then -- AGM-88 or 154 w/o target data
|
||||||
|
self:E("***** SEAD - No target data for " .. (SEADWeaponName or "None"))
|
||||||
|
if string.find(SEADWeaponName,"AGM_88",1,true) or string.find(SEADWeaponName,"AGM_154",1,true) then
|
||||||
|
self:I("**** Tracking AGM-88/154 with no target data.")
|
||||||
|
local pos0 = SEADPlane:GetCoordinate()
|
||||||
|
local fheight = SEADPlane:GetHeight()
|
||||||
|
self:__CalculateHitZone(20,SEADWeapon,pos0,fheight,SEADGroup,SEADWeaponName)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
local targetcat = _target:getCategory() -- Identify category
|
||||||
|
local _targetUnit = nil -- Wrapper.Unit#UNIT
|
||||||
local _targetgroup = nil -- Wrapper.Group#GROUP
|
local _targetgroup = nil -- Wrapper.Group#GROUP
|
||||||
if _targetUnit and _targetUnit:IsAlive() then
|
self:T(string.format("*** Targetcat = %d",targetcat))
|
||||||
_targetgroup = _targetUnit:GetGroup()
|
if targetcat == Object.Category.UNIT then -- UNIT
|
||||||
_targetgroupname = _targetgroup:GetName() -- group name
|
self:T("*** Target Category UNIT")
|
||||||
local _targetUnitName = _targetUnit:GetName()
|
_targetUnit = UNIT:Find(_target) -- Wrapper.Unit#UNIT
|
||||||
_targetUnit:GetSkill()
|
if _targetUnit and _targetUnit:IsAlive() then
|
||||||
_targetskill = _targetUnit:GetSkill()
|
_targetgroup = _targetUnit:GetGroup()
|
||||||
|
_targetgroupname = _targetgroup:GetName() -- group name
|
||||||
|
local _targetUnitName = _targetUnit:GetName()
|
||||||
|
_targetUnit:GetSkill()
|
||||||
|
_targetskill = _targetUnit:GetSkill()
|
||||||
|
end
|
||||||
|
elseif targetcat == Object.Category.STATIC then
|
||||||
|
self:T("*** Target Category STATIC")
|
||||||
|
local seadset = SET_GROUP:New():FilterPrefixes(self.SEADGroupPrefixes):FilterOnce()
|
||||||
|
local targetpoint = _target:getPoint() or {x=0,y=0,z=0}
|
||||||
|
local tgtcoord = COORDINATE:NewFromVec3(targetpoint)
|
||||||
|
local tgtgrp = seadset:FindNearestGroupFromPointVec2(tgtcoord)
|
||||||
|
if tgtgrp and tgtgrp:IsAlive() then
|
||||||
|
_targetgroup = tgtgrp
|
||||||
|
_targetgroupname = tgtgrp:GetName() -- group name
|
||||||
|
_targetskill = tgtgrp:GetUnit(1):GetSkill()
|
||||||
|
self:T("*** Found Target = ".. _targetgroupname)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- see if we are shot at
|
-- see if we are shot at
|
||||||
local SEADGroupFound = false
|
local SEADGroupFound = false
|
||||||
for SEADGroupPrefixID, SEADGroupPrefix in pairs( self.SEADGroupPrefixes ) do
|
for SEADGroupPrefixID, SEADGroupPrefix in pairs( self.SEADGroupPrefixes ) do
|
||||||
self:T( _targetgroupname, SEADGroupPrefix )
|
self:T("Target = ".. _targetgroupname .. " | Prefix = " .. SEADGroupPrefix )
|
||||||
if string.find( _targetgroupname, SEADGroupPrefix, 1, true ) then
|
if string.find( _targetgroupname, SEADGroupPrefix,1,true ) then
|
||||||
SEADGroupFound = true
|
SEADGroupFound = true
|
||||||
self:T( '*** SEAD - Group Match Found' )
|
self:T( '*** SEAD - Group Match Found' )
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if SEADGroupFound == true then -- yes we are being attacked
|
if SEADGroupFound == true then -- yes we are being attacked
|
||||||
if _targetskill == "Random" then -- when skill is random, choose a skill
|
self:ManageEvasion(_targetskill,_targetgroup,SEADPlanePos,SEADWeaponName,SEADGroup)
|
||||||
local Skills = { "Average", "Good", "High", "Excellent" }
|
|
||||||
_targetskill = Skills[ math.random(1,4) ]
|
|
||||||
end
|
|
||||||
--self:T( _targetskill )
|
|
||||||
if self.TargetSkill[_targetskill] then
|
|
||||||
local _evade = math.random (1,100) -- random number for chance of evading action
|
|
||||||
if (_evade > self.TargetSkill[_targetskill].Evade) then
|
|
||||||
self:T("*** SEAD - Evading")
|
|
||||||
-- calculate distance of attacker
|
|
||||||
local _targetpos = _targetgroup:GetCoordinate()
|
|
||||||
local _distance = self:_GetDistance(SEADPlanePos, _targetpos)
|
|
||||||
-- weapon speed
|
|
||||||
local hit, data = self:_CheckHarms(SEADWeaponName)
|
|
||||||
local wpnspeed = 666 -- ;)
|
|
||||||
local reach = 10
|
|
||||||
if hit then
|
|
||||||
local wpndata = SEAD.HarmData[data]
|
|
||||||
reach = wpndata[1] * 1,1
|
|
||||||
local mach = wpndata[2]
|
|
||||||
wpnspeed = math.floor(mach * 340.29)
|
|
||||||
end
|
|
||||||
-- time to impact
|
|
||||||
local _tti = math.floor(_distance / wpnspeed) -- estimated impact time
|
|
||||||
if _distance > 0 then
|
|
||||||
_distance = math.floor(_distance / 1000) -- km
|
|
||||||
else
|
|
||||||
_distance = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
self:T( string.format("*** SEAD - target skill %s, distance %dkm, reach %dkm, tti %dsec", _targetskill, _distance,reach,_tti ))
|
|
||||||
|
|
||||||
if reach >= _distance then
|
|
||||||
self:T("*** SEAD - Shot in Reach")
|
|
||||||
|
|
||||||
local function SuppressionStart(args)
|
|
||||||
self:T(string.format("*** SEAD - %s Radar Off & Relocating",args[2]))
|
|
||||||
local grp = args[1] -- Wrapper.Group#GROUP
|
|
||||||
local name = args[2] -- #string Group Name
|
|
||||||
if self.UseEmissionsOnOff then
|
|
||||||
grp:EnableEmission(false)
|
|
||||||
end
|
|
||||||
grp:OptionAlarmStateGreen() -- needed else we cannot move around
|
|
||||||
grp:RelocateGroundRandomInRadius(20,300,false,false,"Diamond")
|
|
||||||
if self.UseCallBack then
|
|
||||||
local object = self.CallBack
|
|
||||||
object:SeadSuppressionStart(grp,name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function SuppressionStop(args)
|
|
||||||
self:T(string.format("*** SEAD - %s Radar On",args[2]))
|
|
||||||
local grp = args[1] -- Wrapper.Group#GROUP
|
|
||||||
local name = args[2] -- #string Group Nam
|
|
||||||
if self.UseEmissionsOnOff then
|
|
||||||
grp:EnableEmission(true)
|
|
||||||
end
|
|
||||||
grp:OptionAlarmStateAuto()
|
|
||||||
grp:OptionEngageRange(self.EngagementRange)
|
|
||||||
self.SuppressedGroups[name] = false
|
|
||||||
if self.UseCallBack then
|
|
||||||
local object = self.CallBack
|
|
||||||
object:SeadSuppressionEnd(grp,name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- randomize switch-on time
|
|
||||||
local delay = math.random(self.TargetSkill[_targetskill].DelayOn[1], self.TargetSkill[_targetskill].DelayOn[2])
|
|
||||||
if delay > _tti then delay = delay / 2 end -- speed up
|
|
||||||
if _tti > (3*delay) then delay = (_tti / 2) * 0.9 end -- shot from afar
|
|
||||||
|
|
||||||
local SuppressionStartTime = timer.getTime() + delay
|
|
||||||
local SuppressionEndTime = timer.getTime() + _tti + self.Padding
|
|
||||||
|
|
||||||
if not self.SuppressedGroups[_targetgroupname] then
|
|
||||||
self:T(string.format("*** SEAD - %s | Parameters TTI %ds | Switch-Off in %ds",_targetgroupname,_tti,delay))
|
|
||||||
timer.scheduleFunction(SuppressionStart,{_targetgroup,_targetgroupname},SuppressionStartTime)
|
|
||||||
timer.scheduleFunction(SuppressionStop,{_targetgroup,_targetgroupname},SuppressionEndTime)
|
|
||||||
self.SuppressedGroups[_targetgroupname] = true
|
|
||||||
if self.UseCallBack then
|
|
||||||
local object = self.CallBack
|
|
||||||
object:SeadSuppressionPlanned(_targetgroup,_targetgroupname,SuppressionStartTime,SuppressionEndTime)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
-- @module Functional.Shorad
|
-- @module Functional.Shorad
|
||||||
-- @image Functional.Shorad.jpg
|
-- @image Functional.Shorad.jpg
|
||||||
--
|
--
|
||||||
-- Date: July 2021
|
-- Date: Nov 2021
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **SHORAD** class, extends Core.Base#BASE
|
--- **SHORAD** class, extends Core.Base#BASE
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
-- @field #boolean UseEmOnOff Decide if we are using Emission on/off (default) or AlarmState red/green.
|
-- @field #boolean UseEmOnOff Decide if we are using Emission on/off (default) or AlarmState red/green.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
--- *Good friends are worth defending.* Mr Tushman, Wonder (the Movie)
|
--- *Good friends are worth defending.* Mr Tushman, Wonder (the Movie)
|
||||||
--
|
--
|
||||||
-- Simple Class for a more intelligent Short Range Air Defense System
|
-- Simple Class for a more intelligent Short Range Air Defense System
|
||||||
@@ -131,6 +132,7 @@ do
|
|||||||
["Kh29"] = "Kh29",
|
["Kh29"] = "Kh29",
|
||||||
["Kh31"] = "Kh31",
|
["Kh31"] = "Kh31",
|
||||||
["Kh66"] = "Kh66",
|
["Kh66"] = "Kh66",
|
||||||
|
--["BGM_109"] = "BGM_109",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Instantiates a new SHORAD object
|
--- Instantiates a new SHORAD object
|
||||||
@@ -138,13 +140,13 @@ do
|
|||||||
-- @param #string Name Name of this SHORAD
|
-- @param #string Name Name of this SHORAD
|
||||||
-- @param #string ShoradPrefix Filter for the Shorad #SET_GROUP
|
-- @param #string ShoradPrefix Filter for the Shorad #SET_GROUP
|
||||||
-- @param Core.Set#SET_GROUP Samset The #SET_GROUP of SAM sites to defend
|
-- @param Core.Set#SET_GROUP Samset The #SET_GROUP of SAM sites to defend
|
||||||
-- @param #number Radius Defense radius in meters, used to switch on groups
|
-- @param #number Radius Defense radius in meters, used to switch on SHORAD groups **within** this radius
|
||||||
-- @param #number ActiveTimer Determines how many seconds the systems stay on red alert after wake-up call
|
-- @param #number ActiveTimer Determines how many seconds the systems stay on red alert after wake-up call
|
||||||
-- @param #string Coalition Coalition, i.e. "blue", "red", or "neutral"
|
-- @param #string Coalition Coalition, i.e. "blue", "red", or "neutral"
|
||||||
-- @param #boolean UseEmOnOff Use Emissions On/Off rather than Alarm State Red/Green (default: use Emissions switch)
|
-- @param #boolean UseEmOnOff Use Emissions On/Off rather than Alarm State Red/Green (default: use Emissions switch)
|
||||||
-- @retunr #SHORAD self
|
-- @retunr #SHORAD self
|
||||||
function SHORAD:New(Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition, UseEmOnOff)
|
function SHORAD:New(Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition, UseEmOnOff)
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, FSM:New() )
|
||||||
self:T({Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition})
|
self:T({Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition})
|
||||||
|
|
||||||
local GroupSet = SET_GROUP:New():FilterPrefixes(ShoradPrefix):FilterCoalitions(Coalition):FilterCategoryGround():FilterStart()
|
local GroupSet = SET_GROUP:New():FilterPrefixes(ShoradPrefix):FilterCoalitions(Coalition):FilterCategoryGround():FilterStart()
|
||||||
@@ -162,11 +164,17 @@ do
|
|||||||
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
|
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
|
||||||
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
||||||
self.UseEmOnOff = UseEmOnOff or false -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
self.UseEmOnOff = UseEmOnOff or false -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
||||||
self:I("*** SHORAD - Started Version 0.2.8")
|
self:I("*** SHORAD - Started Version 0.3.1")
|
||||||
-- Set the string id for output to DCS.log file.
|
-- Set the string id for output to DCS.log file.
|
||||||
self.lid=string.format("SHORAD %s | ", self.name)
|
self.lid=string.format("SHORAD %s | ", self.name)
|
||||||
self:_InitState()
|
self:_InitState()
|
||||||
self:HandleEvent(EVENTS.Shot, self.HandleEventShot)
|
self:HandleEvent(EVENTS.Shot, self.HandleEventShot)
|
||||||
|
|
||||||
|
-- Start State.
|
||||||
|
self:SetStartState("Running")
|
||||||
|
self:AddTransition("*", "WakeUpShorad", "*")
|
||||||
|
self:AddTransition("*", "CalculateHitZone", "*")
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -310,7 +318,7 @@ do
|
|||||||
local hit = false
|
local hit = false
|
||||||
if self.DefendHarms then
|
if self.DefendHarms then
|
||||||
for _,_name in pairs (SHORAD.Harms) do
|
for _,_name in pairs (SHORAD.Harms) do
|
||||||
if string.find(WeaponName,_name,1) then hit = true end
|
if string.find(WeaponName,_name,1,true) then hit = true end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return hit
|
return hit
|
||||||
@@ -326,7 +334,7 @@ do
|
|||||||
local hit = false
|
local hit = false
|
||||||
if self.DefendMavs then
|
if self.DefendMavs then
|
||||||
for _,_name in pairs (SHORAD.Mavs) do
|
for _,_name in pairs (SHORAD.Mavs) do
|
||||||
if string.find(WeaponName,_name,1) then hit = true end
|
if string.find(WeaponName,_name,1,true) then hit = true end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return hit
|
return hit
|
||||||
@@ -367,7 +375,7 @@ do
|
|||||||
local returnname = false
|
local returnname = false
|
||||||
for _,_groups in pairs (shoradset) do
|
for _,_groups in pairs (shoradset) do
|
||||||
local groupname = _groups:GetName()
|
local groupname = _groups:GetName()
|
||||||
if string.find(groupname, tgtgrp, 1) then
|
if string.find(groupname, tgtgrp, 1, true) then
|
||||||
returnname = true
|
returnname = true
|
||||||
--_groups:RelocateGroundRandomInRadius(7,100,false,false) -- be a bit evasive
|
--_groups:RelocateGroundRandomInRadius(7,100,false,false) -- be a bit evasive
|
||||||
end
|
end
|
||||||
@@ -388,7 +396,7 @@ do
|
|||||||
local returnname = false
|
local returnname = false
|
||||||
for _,_groups in pairs (shoradset) do
|
for _,_groups in pairs (shoradset) do
|
||||||
local groupname = _groups:GetName()
|
local groupname = _groups:GetName()
|
||||||
if string.find(groupname, tgtgrp, 1) then
|
if string.find(groupname, tgtgrp, 1, true) then
|
||||||
returnname = true
|
returnname = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -400,6 +408,7 @@ do
|
|||||||
-- @return #boolean Returns true for a detection, else false
|
-- @return #boolean Returns true for a detection, else false
|
||||||
function SHORAD:_ShotIsDetected()
|
function SHORAD:_ShotIsDetected()
|
||||||
self:T(self.lid .. " _ShotIsDetected")
|
self:T(self.lid .. " _ShotIsDetected")
|
||||||
|
if self.debug then return true end
|
||||||
local IsDetected = false
|
local IsDetected = false
|
||||||
local DetectionProb = math.random(self.DefenseLowProb, self.DefenseHighProb) -- reference value
|
local DetectionProb = math.random(self.DefenseLowProb, self.DefenseHighProb) -- reference value
|
||||||
local ActualDetection = math.random(1,100) -- value for this shot
|
local ActualDetection = math.random(1,100) -- value for this shot
|
||||||
@@ -423,7 +432,7 @@ do
|
|||||||
-- mymantis = MANTIS:New("BlueMantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")
|
-- mymantis = MANTIS:New("BlueMantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")
|
||||||
-- mymantis:AddShorad(myshorad,720)
|
-- mymantis:AddShorad(myshorad,720)
|
||||||
-- mymantis:Start()
|
-- mymantis:Start()
|
||||||
function SHORAD:WakeUpShorad(TargetGroup, Radius, ActiveTimer, TargetCat)
|
function SHORAD:onafterWakeUpShorad(From, Event, To, TargetGroup, Radius, ActiveTimer, TargetCat)
|
||||||
self:T(self.lid .. " WakeUpShorad")
|
self:T(self.lid .. " WakeUpShorad")
|
||||||
self:T({TargetGroup, Radius, ActiveTimer, TargetCat})
|
self:T({TargetGroup, Radius, ActiveTimer, TargetCat})
|
||||||
local targetcat = TargetCat or Object.Category.UNIT
|
local targetcat = TargetCat or Object.Category.UNIT
|
||||||
@@ -477,6 +486,76 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (Internal) Calculate hit zone of an AGM-88
|
||||||
|
-- @param #SHORAD self
|
||||||
|
-- @param #table SEADWeapon DCS.Weapon object
|
||||||
|
-- @param Core.Point#COORDINATE pos0 Position of the plane when it fired
|
||||||
|
-- @param #number height Height when the missile was fired
|
||||||
|
-- @param Wrapper.Group#GROUP SEADGroup Attacker group
|
||||||
|
-- @return #SHORAD self
|
||||||
|
function SHORAD:onafterCalculateHitZone(From,Event,To,SEADWeapon,pos0,height,SEADGroup)
|
||||||
|
self:T("**** Calculating hit zone")
|
||||||
|
if SEADWeapon and SEADWeapon:isExist() then
|
||||||
|
--local pos = SEADWeapon:getPoint()
|
||||||
|
|
||||||
|
-- postion and height
|
||||||
|
local position = SEADWeapon:getPosition()
|
||||||
|
local mheight = height
|
||||||
|
-- heading
|
||||||
|
local wph = math.atan2(position.x.z, position.x.x)
|
||||||
|
if wph < 0 then
|
||||||
|
wph=wph+2*math.pi
|
||||||
|
end
|
||||||
|
wph=math.deg(wph)
|
||||||
|
|
||||||
|
-- velocity
|
||||||
|
local wpndata = SEAD.HarmData["AGM_88"]
|
||||||
|
local mveloc = math.floor(wpndata[2] * 340.29)
|
||||||
|
local c1 = (2*mheight*9.81)/(mveloc^2)
|
||||||
|
local c2 = (mveloc^2) / 9.81
|
||||||
|
local Ropt = c2 * math.sqrt(c1+1)
|
||||||
|
if height <= 5000 then
|
||||||
|
Ropt = Ropt * 0.72
|
||||||
|
elseif height <= 7500 then
|
||||||
|
Ropt = Ropt * 0.82
|
||||||
|
elseif height <= 10000 then
|
||||||
|
Ropt = Ropt * 0.87
|
||||||
|
elseif height <= 12500 then
|
||||||
|
Ropt = Ropt * 0.98
|
||||||
|
end
|
||||||
|
|
||||||
|
-- look at a couple of zones across the trajectory
|
||||||
|
for n=1,3 do
|
||||||
|
local dist = Ropt - ((n-1)*20000)
|
||||||
|
local predpos= pos0:Translate(dist,wph)
|
||||||
|
if predpos then
|
||||||
|
|
||||||
|
local targetzone = ZONE_RADIUS:New("Target Zone",predpos:GetVec2(),20000)
|
||||||
|
|
||||||
|
if self.debug then
|
||||||
|
predpos:MarkToAll(string.format("height=%dm | heading=%d | velocity=%ddeg | Ropt=%dm",mheight,wph,mveloc,Ropt),false)
|
||||||
|
targetzone:DrawZone(coalition.side.BLUE,{0,0,1},0.2,nil,nil,3,true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local seadset = self.Groupset
|
||||||
|
local tgtcoord = targetzone:GetRandomPointVec2()
|
||||||
|
local tgtgrp = seadset:FindNearestGroupFromPointVec2(tgtcoord)
|
||||||
|
local _targetgroup = nil
|
||||||
|
local _targetgroupname = "none"
|
||||||
|
local _targetskill = "Random"
|
||||||
|
if tgtgrp and tgtgrp:IsAlive() then
|
||||||
|
_targetgroup = tgtgrp
|
||||||
|
_targetgroupname = tgtgrp:GetName() -- group name
|
||||||
|
_targetskill = tgtgrp:GetUnit(1):GetSkill()
|
||||||
|
self:T("*** Found Target = ".. _targetgroupname)
|
||||||
|
self:WakeUpShorad(_targetgroupname, self.Radius, self.ActiveTimer, Object.Category.UNIT)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Main function - work on the EventData
|
--- Main function - work on the EventData
|
||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param Core.Event#EVENTDATA EventData The event details table data set
|
-- @param Core.Event#EVENTDATA EventData The event details table data set
|
||||||
@@ -504,13 +583,48 @@ do
|
|||||||
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then
|
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then
|
||||||
-- get target data
|
-- get target data
|
||||||
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
||||||
|
-- Is there target data?
|
||||||
|
if not targetdata or self.debug then
|
||||||
|
if string.find(ShootingWeaponName,"AGM_88",1,true) then
|
||||||
|
self:I("**** Tracking AGM-88 with no target data.")
|
||||||
|
local pos0 = EventData.IniUnit:GetCoordinate()
|
||||||
|
local fheight = EventData.IniUnit:GetHeight()
|
||||||
|
self:__CalculateHitZone(20,ShootingWeapon,pos0,fheight,EventData.IniGroup)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
local targetcat = targetdata:getCategory() -- Identify category
|
local targetcat = targetdata:getCategory() -- Identify category
|
||||||
self:T(string.format("Target Category (3=STATIC, 1=UNIT)= %s",tostring(targetcat)))
|
self:T(string.format("Target Category (3=STATIC, 1=UNIT)= %s",tostring(targetcat)))
|
||||||
|
self:T({targetdata})
|
||||||
local targetunit = nil
|
local targetunit = nil
|
||||||
if targetcat == Object.Category.UNIT then -- UNIT
|
if targetcat == Object.Category.UNIT then -- UNIT
|
||||||
targetunit = UNIT:Find(targetdata)
|
targetunit = UNIT:Find(targetdata)
|
||||||
elseif targetcat == Object.Category.STATIC then -- STATIC
|
elseif targetcat == Object.Category.STATIC then -- STATIC
|
||||||
targetunit = STATIC:Find(targetdata)
|
--self:T("Static Target Data")
|
||||||
|
--self:T({targetdata:isExist()})
|
||||||
|
--self:T({targetdata:getPoint()})
|
||||||
|
local tgtcoord = COORDINATE:NewFromVec3(targetdata:getPoint())
|
||||||
|
--tgtcoord:MarkToAll("Missile Target",true)
|
||||||
|
|
||||||
|
local tgtgrp1 = self.Samset:FindNearestGroupFromPointVec2(tgtcoord)
|
||||||
|
local tgtcoord1 = tgtgrp1:GetCoordinate()
|
||||||
|
--tgtcoord1:MarkToAll("Close target SAM",true)
|
||||||
|
|
||||||
|
local tgtgrp2 = self.Groupset:FindNearestGroupFromPointVec2(tgtcoord)
|
||||||
|
local tgtcoord2 = tgtgrp2:GetCoordinate()
|
||||||
|
--tgtcoord2:MarkToAll("Close target SHORAD",true)
|
||||||
|
|
||||||
|
local dist1 = tgtcoord:Get2DDistance(tgtcoord1)
|
||||||
|
local dist2 = tgtcoord:Get2DDistance(tgtcoord2)
|
||||||
|
|
||||||
|
if dist1 < dist2 then
|
||||||
|
targetunit = tgtgrp1
|
||||||
|
targetcat = Object.Category.UNIT
|
||||||
|
else
|
||||||
|
targetunit = tgtgrp2
|
||||||
|
targetcat = Object.Category.UNIT
|
||||||
|
end
|
||||||
end
|
end
|
||||||
--local targetunitname = Unit.getName(targetdata) -- Unit name
|
--local targetunitname = Unit.getName(targetdata) -- Unit name
|
||||||
if targetunit and targetunit:IsAlive() then
|
if targetunit and targetunit:IsAlive() then
|
||||||
@@ -519,7 +633,11 @@ do
|
|||||||
local targetgroup = nil
|
local targetgroup = nil
|
||||||
local targetgroupname = "none"
|
local targetgroupname = "none"
|
||||||
if targetcat == Object.Category.UNIT then
|
if targetcat == Object.Category.UNIT then
|
||||||
targetgroup = targetunit:GetGroup()
|
if targetunit.ClassName == "UNIT" then
|
||||||
|
targetgroup = targetunit:GetGroup()
|
||||||
|
elseif targetunit.ClassName == "GROUP" then
|
||||||
|
targetgroup = targetunit
|
||||||
|
end
|
||||||
targetgroupname = targetgroup:GetName() -- group name
|
targetgroupname = targetgroup:GetName() -- group name
|
||||||
elseif targetcat == Object.Category.STATIC then
|
elseif targetcat == Object.Category.STATIC then
|
||||||
targetgroup = targetunit
|
targetgroup = targetunit
|
||||||
@@ -540,6 +658,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
--
|
--
|
||||||
end
|
end
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -804,7 +804,7 @@ do -- ZONE_CAPTURE_COALITION
|
|||||||
return IsEmpty
|
return IsEmpty
|
||||||
end
|
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
|
-- @param #ZONE_CAPTURE_COALITION self
|
||||||
-- @return #boolean self:IsAllInZoneOfCoalition( self.Coalition )
|
-- @return #boolean self:IsAllInZoneOfCoalition( self.Coalition )
|
||||||
function ZONE_CAPTURE_COALITION:IsGuarded()
|
function ZONE_CAPTURE_COALITION:IsGuarded()
|
||||||
@@ -826,7 +826,7 @@ do -- ZONE_CAPTURE_COALITION
|
|||||||
return IsCaptured
|
return IsCaptured
|
||||||
end
|
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
|
-- @param #ZONE_CAPTURE_COALITION self
|
||||||
-- @return #boolean self:IsSomeInZoneOfCoalition( self.Coalition )
|
-- @return #boolean self:IsSomeInZoneOfCoalition( self.Coalition )
|
||||||
function ZONE_CAPTURE_COALITION:IsAttacked()
|
function ZONE_CAPTURE_COALITION:IsAttacked()
|
||||||
@@ -906,7 +906,6 @@ do -- ZONE_CAPTURE_COALITION
|
|||||||
-- Misc Functions
|
-- Misc Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
--- Update Mark on F10 map.
|
--- Update Mark on F10 map.
|
||||||
-- @param #ZONE_CAPTURE_COALITION self
|
-- @param #ZONE_CAPTURE_COALITION self
|
||||||
function ZONE_CAPTURE_COALITION:Mark()
|
function ZONE_CAPTURE_COALITION:Mark()
|
||||||
@@ -925,7 +924,7 @@ do -- ZONE_CAPTURE_COALITION
|
|||||||
Coord:RemoveMark(self.MarkBlue)
|
Coord:RemoveMark(self.MarkBlue)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create new marks for each coaliton.
|
-- Create new marks for each coalition.
|
||||||
if self.Coalition == coalition.side.BLUE then
|
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 )
|
self.MarkRed = Coord:MarkToCoalitionRed( "Coalition: Blue\nCapture Zone: " .. ZoneName .. "\nStatus: " .. State )
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ do -- ZoneGoal
|
|||||||
-- @field #table ObjectCategories Table of object categories that are able to hold a zone. Default is UNITS and STATICS.
|
-- @field #table ObjectCategories Table of object categories that are able to hold a zone. Default is UNITS and STATICS.
|
||||||
-- @extends Functional.ZoneGoal#ZONE_GOAL
|
-- @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.
|
-- Derived classes implement the ways how the achievements can be realized.
|
||||||
--
|
--
|
||||||
@@ -42,10 +41,10 @@ do -- ZoneGoal
|
|||||||
--
|
--
|
||||||
-- @field #ZONE_GOAL_COALITION
|
-- @field #ZONE_GOAL_COALITION
|
||||||
ZONE_GOAL_COALITION = {
|
ZONE_GOAL_COALITION = {
|
||||||
ClassName = "ZONE_GOAL_COALITION",
|
ClassName = "ZONE_GOAL_COALITION",
|
||||||
Coalition = nil,
|
Coalition = nil,
|
||||||
PreviousCoaliton = nil,
|
PreviousCoalition = nil,
|
||||||
UnitCategories = nil,
|
UnitCategories = nil,
|
||||||
ObjectCategories = nil,
|
ObjectCategories = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,31 +60,30 @@ do -- ZoneGoal
|
|||||||
function ZONE_GOAL_COALITION:New( Zone, Coalition, UnitCategories )
|
function ZONE_GOAL_COALITION:New( Zone, Coalition, UnitCategories )
|
||||||
|
|
||||||
if not Zone then
|
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
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Inherit ZONE_GOAL.
|
-- Inherit ZONE_GOAL.
|
||||||
local self = BASE:Inherit( self, ZONE_GOAL:New( Zone ) ) -- #ZONE_GOAL_COALITION
|
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.
|
-- 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.
|
-- Set default unit and object categories for the zone scan.
|
||||||
self:SetUnitCategories(UnitCategories)
|
self:SetUnitCategories( UnitCategories )
|
||||||
self:SetObjectCategories()
|
self:SetObjectCategories()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the owning coalition of the zone.
|
--- Set the owning coalition of the zone.
|
||||||
-- @param #ZONE_GOAL_COALITION self
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
-- @param DCSCoalition.DCSCoalition#coalition Coalition The coalition ID, e.g. *coalition.side.RED*.
|
-- @param DCSCoalition.DCSCoalition#coalition Coalition The coalition ID, e.g. *coalition.side.RED*.
|
||||||
-- @return #ZONE_GOAL_COALITION
|
-- @return #ZONE_GOAL_COALITION
|
||||||
function ZONE_GOAL_COALITION:SetCoalition( Coalition )
|
function ZONE_GOAL_COALITION:SetCoalition( Coalition )
|
||||||
self.PreviousCoalition=self.Coalition or Coalition
|
self.PreviousCoalition = self.Coalition or Coalition
|
||||||
self.Coalition = Coalition
|
self.Coalition = Coalition
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -96,11 +94,11 @@ do -- ZoneGoal
|
|||||||
-- @return #ZONE_GOAL_COALITION
|
-- @return #ZONE_GOAL_COALITION
|
||||||
function ZONE_GOAL_COALITION:SetUnitCategories( UnitCategories )
|
function ZONE_GOAL_COALITION:SetUnitCategories( UnitCategories )
|
||||||
|
|
||||||
if UnitCategories and type(UnitCategories)~="table" then
|
if UnitCategories and type( UnitCategories ) ~= "table" then
|
||||||
UnitCategories={UnitCategories}
|
UnitCategories = { UnitCategories }
|
||||||
end
|
end
|
||||||
|
|
||||||
self.UnitCategories=UnitCategories or {Unit.Category.GROUND_UNIT}
|
self.UnitCategories = UnitCategories or { Unit.Category.GROUND_UNIT }
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -111,11 +109,11 @@ do -- ZoneGoal
|
|||||||
-- @return #ZONE_GOAL_COALITION
|
-- @return #ZONE_GOAL_COALITION
|
||||||
function ZONE_GOAL_COALITION:SetObjectCategories( ObjectCategories )
|
function ZONE_GOAL_COALITION:SetObjectCategories( ObjectCategories )
|
||||||
|
|
||||||
if ObjectCategories and type(ObjectCategories)~="table" then
|
if ObjectCategories and type( ObjectCategories ) ~= "table" then
|
||||||
ObjectCategories={ObjectCategories}
|
ObjectCategories = { ObjectCategories }
|
||||||
end
|
end
|
||||||
|
|
||||||
self.ObjectCategories=ObjectCategories or {Object.Category.UNIT, Object.Category.STATIC}
|
self.ObjectCategories = ObjectCategories or { Object.Category.UNIT, Object.Category.STATIC }
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -127,22 +125,20 @@ do -- ZoneGoal
|
|||||||
return self.Coalition
|
return self.Coalition
|
||||||
end
|
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
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
-- @return DCSCoalition.DCSCoalition#coalition Coalition.
|
-- @return DCSCoalition.DCSCoalition#coalition Coalition.
|
||||||
function ZONE_GOAL_COALITION:GetPreviousCoalition()
|
function ZONE_GOAL_COALITION:GetPreviousCoalition()
|
||||||
return self.PreviousCoalition
|
return self.PreviousCoalition
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the owning coalition name of the zone.
|
--- Get the owning coalition name of the zone.
|
||||||
-- @param #ZONE_GOAL_COALITION self
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
-- @return #string Coalition name.
|
-- @return #string Coalition name.
|
||||||
function ZONE_GOAL_COALITION:GetCoalitionName()
|
function ZONE_GOAL_COALITION:GetCoalitionName()
|
||||||
return UTILS.GetCoalitionName(self.Coalition)
|
return UTILS.GetCoalitionName( self.Coalition )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check status Coalition ownership.
|
--- Check status Coalition ownership.
|
||||||
-- @param #ZONE_GOAL_COALITION self
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
-- @return #ZONE_GOAL_COALITION
|
-- @return #ZONE_GOAL_COALITION
|
||||||
@@ -152,8 +148,8 @@ do -- ZoneGoal
|
|||||||
local State = self:GetState()
|
local State = self:GetState()
|
||||||
|
|
||||||
-- Debug text.
|
-- Debug text.
|
||||||
local text=string.format("Zone state=%s, Owner=%s, Scanning...", State, self:GetCoalitionName())
|
local text = string.format( "Zone state=%s, Owner=%s, Scanning...", State, self:GetCoalitionName() )
|
||||||
self:F(text)
|
self:F( text )
|
||||||
|
|
||||||
-- Scan zone.
|
-- Scan zone.
|
||||||
self:Scan( self.ObjectCategories, self.UnitCategories )
|
self:Scan( self.ObjectCategories, self.UnitCategories )
|
||||||
|
|||||||
@@ -4,9 +4,13 @@ __Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' )
|
|||||||
__Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Templates.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/Templates.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/STTS.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/STTS.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Utilities/FiFo.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Utilities/Socket.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Base.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Base.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Core/Astar.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Beacon.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Beacon.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Core/Condition.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/UserFlag.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/UserFlag.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Report.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Report.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Scheduler.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Scheduler.lua' )
|
||||||
@@ -27,6 +31,8 @@ __Moose.Include( 'Scripts/Moose/Core/SpawnStatic.lua' )
|
|||||||
__Moose.Include( 'Scripts/Moose/Core/Timer.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Timer.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Goal.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Goal.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Spot.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Spot.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Core/MarkerOps_Base.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Core/TextAndSound.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Object.lua' )
|
__Moose.Include( 'Scripts/Moose/Wrapper/Object.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Identifiable.lua' )
|
__Moose.Include( 'Scripts/Moose/Wrapper/Identifiable.lua' )
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
--- ATIS class.
|
--- ATIS class.
|
||||||
-- @type ATIS
|
-- @type ATIS
|
||||||
-- @field #string ClassName Name of the class.
|
-- @field #string ClassName Name of the class.
|
||||||
-- @field #boolean Debug Debug mode. Messages to all about status.
|
|
||||||
-- @field #string lid Class id string for output to DCS log file.
|
-- @field #string lid Class id string for output to DCS log file.
|
||||||
-- @field #string theatre DCS map name.
|
-- @field #string theatre DCS map name.
|
||||||
-- @field #string airbasename The name of the airbase.
|
-- @field #string airbasename The name of the airbase.
|
||||||
@@ -309,7 +308,6 @@
|
|||||||
-- @field #ATIS
|
-- @field #ATIS
|
||||||
ATIS = {
|
ATIS = {
|
||||||
ClassName = "ATIS",
|
ClassName = "ATIS",
|
||||||
Debug = false,
|
|
||||||
lid = nil,
|
lid = nil,
|
||||||
theatre = nil,
|
theatre = nil,
|
||||||
airbasename = nil,
|
airbasename = nil,
|
||||||
@@ -588,7 +586,7 @@ _ATIS = {}
|
|||||||
|
|
||||||
--- ATIS class version.
|
--- ATIS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
ATIS.version = "0.9.6"
|
ATIS.version = "0.9.8"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -613,26 +611,26 @@ ATIS.version = "0.9.6"
|
|||||||
|
|
||||||
--- Create a new ATIS class object for a specific aircraft carrier unit.
|
--- Create a new ATIS class object for a specific aircraft carrier unit.
|
||||||
-- @param #ATIS self
|
-- @param #ATIS self
|
||||||
-- @param #string airbasename Name of the airbase.
|
-- @param #string AirbaseName Name of the airbase.
|
||||||
-- @param #number frequency Radio frequency in MHz. Default 143.00 MHz.
|
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz.
|
||||||
-- @param #number modulation Radio modulation: 0=AM, 1=FM. Default 0=AM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators
|
-- @param #number Modulation Radio modulation: 0=AM, 1=FM. Default 0=AM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators.
|
||||||
-- @return #ATIS self
|
-- @return #ATIS self
|
||||||
function ATIS:New( airbasename, frequency, modulation )
|
function ATIS:New(AirbaseName, Frequency, Modulation)
|
||||||
|
|
||||||
-- Inherit everything from FSM class.
|
-- Inherit everything from FSM class.
|
||||||
local self = BASE:Inherit( self, FSM:New() ) -- #ATIS
|
local self = BASE:Inherit( self, FSM:New() ) -- #ATIS
|
||||||
|
|
||||||
self.airbasename = airbasename
|
self.airbasename=AirbaseName
|
||||||
self.airbase = AIRBASE:FindByName( airbasename )
|
self.airbase=AIRBASE:FindByName(AirbaseName)
|
||||||
|
|
||||||
if self.airbase == nil then
|
if self.airbase==nil then
|
||||||
self:E( "ERROR: Airbase %s for ATIS could not be found!", tostring( airbasename ) )
|
self:E("ERROR: Airbase %s for ATIS could not be found!", tostring(AirbaseName))
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Default freq and modulation.
|
-- Default freq and modulation.
|
||||||
self.frequency = frequency or 143.00
|
self.frequency=Frequency or 143.00
|
||||||
self.modulation = modulation or 0
|
self.modulation=Modulation or 0
|
||||||
|
|
||||||
-- Get map.
|
-- Get map.
|
||||||
self.theatre = env.mission.theatre
|
self.theatre = env.mission.theatre
|
||||||
@@ -734,14 +732,6 @@ function ATIS:New( airbasename, frequency, modulation )
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #string Text Report text.
|
-- @param #string Text Report text.
|
||||||
|
|
||||||
-- Debug trace.
|
|
||||||
if false then
|
|
||||||
self.Debug = true
|
|
||||||
BASE:TraceOnOff( true )
|
|
||||||
BASE:TraceClass( self.ClassName )
|
|
||||||
BASE:TraceLevel( 1 )
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -755,7 +745,7 @@ end
|
|||||||
-- @return #ATIS self
|
-- @return #ATIS self
|
||||||
function ATIS:SetSoundfilesPath( path )
|
function ATIS:SetSoundfilesPath( path )
|
||||||
self.soundpath = tostring( path or "ATIS Soundfiles/" )
|
self.soundpath = tostring( path or "ATIS Soundfiles/" )
|
||||||
self:I( self.lid .. string.format( "Setting sound files path to %s", self.soundpath ) )
|
self:T( self.lid .. string.format( "Setting sound files path to %s", self.soundpath ) )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -766,7 +756,7 @@ end
|
|||||||
-- @return #ATIS self
|
-- @return #ATIS self
|
||||||
function ATIS:SetRadioRelayUnitName( unitname )
|
function ATIS:SetRadioRelayUnitName( unitname )
|
||||||
self.relayunitname = unitname
|
self.relayunitname = unitname
|
||||||
self:I( self.lid .. string.format( "Setting radio relay unit to %s", self.relayunitname ) )
|
self:T( self.lid .. string.format( "Setting radio relay unit to %s", self.relayunitname ) )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -802,6 +792,15 @@ function ATIS:SetRunwayLength()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Give information on runway length.
|
||||||
|
-- @param #ATIS self
|
||||||
|
-- @return #ATIS self
|
||||||
|
function ATIS:SetRunwayLength()
|
||||||
|
self.rwylength=true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Give information on airfield elevation
|
--- Give information on airfield elevation
|
||||||
-- @param #ATIS self
|
-- @param #ATIS self
|
||||||
-- @return #ATIS self
|
-- @return #ATIS self
|
||||||
@@ -852,7 +851,7 @@ function ATIS:SetRunwayHeadingsMagnetic( headings )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Add runway heading to table.
|
-- Add runway heading to table.
|
||||||
self:I( self.lid .. string.format( "Adding user specified magnetic runway heading %s", heading ) )
|
self:T( self.lid .. string.format( "Adding user specified magnetic runway heading %s", heading ) )
|
||||||
table.insert( self.runwaymag, heading )
|
table.insert( self.runwaymag, heading )
|
||||||
|
|
||||||
local h = self:GetRunwayWithoutLR( heading )
|
local h = self:GetRunwayWithoutLR( heading )
|
||||||
@@ -874,7 +873,7 @@ function ATIS:SetRunwayHeadingsMagnetic( headings )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Add inverse runway heading to table.
|
-- Add inverse runway heading to table.
|
||||||
self:I( self.lid .. string.format( "Adding user specified magnetic runway heading %s (inverse)", head2 ) )
|
self:T( self.lid .. string.format( "Adding user specified magnetic runway heading %s (inverse)", head2 ) )
|
||||||
table.insert( self.runwaymag, head2 )
|
table.insert( self.runwaymag, head2 )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1128,16 +1127,22 @@ end
|
|||||||
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`.
|
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`.
|
||||||
-- @param #number Port SRS port. Default 5002.
|
-- @param #number Port SRS port. Default 5002.
|
||||||
-- @return #ATIS self
|
-- @return #ATIS self
|
||||||
function ATIS:SetSRS( PathToSRS, Gender, Culture, Voice, Port )
|
function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port)
|
||||||
self.useSRS = true
|
if PathToSRS then
|
||||||
self.msrs = MSRS:New( PathToSRS, self.frequency, self.modulation )
|
self.useSRS=true
|
||||||
self.msrs:SetGender( Gender )
|
self.msrs=MSRS:New(PathToSRS, self.frequency, self.modulation)
|
||||||
self.msrs:SetCulture( Culture )
|
self.msrs:SetGender(Gender)
|
||||||
self.msrs:SetVoice( Voice )
|
self.msrs:SetCulture(Culture)
|
||||||
self.msrs:SetPort( Port )
|
self.msrs:SetVoice(Voice)
|
||||||
self.msrs:SetCoalition( self:GetCoalition() )
|
self.msrs:SetPort(Port)
|
||||||
if self.dTQueueCheck <= 10 then
|
self.msrs:SetCoalition(self:GetCoalition())
|
||||||
self:SetQueueUpdateTime( 90 )
|
self.msrs:SetLabel("ATIS")
|
||||||
|
self.msrsQ = MSRSQUEUE:New("ATIS")
|
||||||
|
if self.dTQueueCheck<=10 then
|
||||||
|
self:SetQueueUpdateTime(90)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self:E(self.lid..string.format("ERROR: No SRS path specified!"))
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -1179,31 +1184,33 @@ function ATIS:onafterStart( From, Event, To )
|
|||||||
self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation ) )
|
self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation ) )
|
||||||
|
|
||||||
-- Start radio queue.
|
-- Start radio queue.
|
||||||
self.radioqueue = RADIOQUEUE:New( self.frequency, self.modulation, string.format( "ATIS %s", self.airbasename ) )
|
if not self.useSRS then
|
||||||
|
self.radioqueue = RADIOQUEUE:New( self.frequency, self.modulation, string.format( "ATIS %s", self.airbasename ) )
|
||||||
|
|
||||||
-- Send coordinate is airbase coord.
|
-- Send coordinate is airbase coord.
|
||||||
self.radioqueue:SetSenderCoordinate( self.airbase:GetCoordinate() )
|
self.radioqueue:SetSenderCoordinate( self.airbase:GetCoordinate() )
|
||||||
|
|
||||||
-- Set relay unit if we have one.
|
-- Set relay unit if we have one.
|
||||||
self.radioqueue:SetSenderUnitName( self.relayunitname )
|
self.radioqueue:SetSenderUnitName( self.relayunitname )
|
||||||
|
|
||||||
-- Set radio power.
|
-- Set radio power.
|
||||||
self.radioqueue:SetRadioPower( self.power )
|
self.radioqueue:SetRadioPower( self.power )
|
||||||
|
|
||||||
-- Init numbers.
|
-- Init numbers.
|
||||||
self.radioqueue:SetDigit( 0, ATIS.Sound.N0.filename, ATIS.Sound.N0.duration, self.soundpath )
|
self.radioqueue:SetDigit( 0, ATIS.Sound.N0.filename, ATIS.Sound.N0.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 1, ATIS.Sound.N1.filename, ATIS.Sound.N1.duration, self.soundpath )
|
self.radioqueue:SetDigit( 1, ATIS.Sound.N1.filename, ATIS.Sound.N1.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 2, ATIS.Sound.N2.filename, ATIS.Sound.N2.duration, self.soundpath )
|
self.radioqueue:SetDigit( 2, ATIS.Sound.N2.filename, ATIS.Sound.N2.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 3, ATIS.Sound.N3.filename, ATIS.Sound.N3.duration, self.soundpath )
|
self.radioqueue:SetDigit( 3, ATIS.Sound.N3.filename, ATIS.Sound.N3.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 4, ATIS.Sound.N4.filename, ATIS.Sound.N4.duration, self.soundpath )
|
self.radioqueue:SetDigit( 4, ATIS.Sound.N4.filename, ATIS.Sound.N4.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 5, ATIS.Sound.N5.filename, ATIS.Sound.N5.duration, self.soundpath )
|
self.radioqueue:SetDigit( 5, ATIS.Sound.N5.filename, ATIS.Sound.N5.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 6, ATIS.Sound.N6.filename, ATIS.Sound.N6.duration, self.soundpath )
|
self.radioqueue:SetDigit( 6, ATIS.Sound.N6.filename, ATIS.Sound.N6.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 7, ATIS.Sound.N7.filename, ATIS.Sound.N7.duration, self.soundpath )
|
self.radioqueue:SetDigit( 7, ATIS.Sound.N7.filename, ATIS.Sound.N7.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 8, ATIS.Sound.N8.filename, ATIS.Sound.N8.duration, self.soundpath )
|
self.radioqueue:SetDigit( 8, ATIS.Sound.N8.filename, ATIS.Sound.N8.duration, self.soundpath )
|
||||||
self.radioqueue:SetDigit( 9, ATIS.Sound.N9.filename, ATIS.Sound.N9.duration, self.soundpath )
|
self.radioqueue:SetDigit( 9, ATIS.Sound.N9.filename, ATIS.Sound.N9.duration, self.soundpath )
|
||||||
|
|
||||||
-- Start radio queue.
|
-- Start radio queue.
|
||||||
self.radioqueue:Start( 1, 0.1 )
|
self.radioqueue:Start( 1, 0.1 )
|
||||||
|
end
|
||||||
|
|
||||||
-- Handle airbase capture
|
-- Handle airbase capture
|
||||||
-- Handle events.
|
-- Handle events.
|
||||||
@@ -1239,7 +1246,7 @@ function ATIS:onafterStatus( From, Event, To )
|
|||||||
else
|
else
|
||||||
text = text .. string.format( ", Relay unit=%s (alive=%s)", tostring( self.relayunitname ), relayunitstatus )
|
text = text .. string.format( ", Relay unit=%s (alive=%s)", tostring( self.relayunitname ), relayunitstatus )
|
||||||
end
|
end
|
||||||
self:I( self.lid .. text )
|
self:T( self.lid .. text )
|
||||||
|
|
||||||
self:__Status( -60 )
|
self:__Status( -60 )
|
||||||
end
|
end
|
||||||
@@ -1378,7 +1385,8 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
--- Runway ---
|
--- Runway ---
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
local runway, rwyLeft = self:GetActiveRunway()
|
local runwayLanding, rwyLandingLeft=self:GetActiveRunway()
|
||||||
|
local runwayTakeoff, rwyTakeoffLeft=self:GetActiveRunway(true)
|
||||||
|
|
||||||
------------
|
------------
|
||||||
--- Time ---
|
--- Time ---
|
||||||
@@ -1444,8 +1452,8 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
|
|
||||||
-- Convert to °F.
|
-- Convert to °F.
|
||||||
if self.TDegF then
|
if self.TDegF then
|
||||||
temperature = UTILS.CelsiusToFahrenheit( temperature )
|
temperature=UTILS.CelsiusToFahrenheit(temperature)
|
||||||
dewpoint = UTILS.CelsiusToFahrenheit( dewpoint )
|
dewpoint=UTILS.CelsiusToFahrenheit(dewpoint)
|
||||||
end
|
end
|
||||||
|
|
||||||
local TEMPERATURE = string.format( "%d", math.abs( temperature ) )
|
local TEMPERATURE = string.format( "%d", math.abs( temperature ) )
|
||||||
@@ -1740,6 +1748,10 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Wind
|
-- Wind
|
||||||
|
-- Adding a space after each digit of WINDFROM to convert this to aviation-speak for TTS via SRS
|
||||||
|
if self.useSRS then
|
||||||
|
WINDFROM = string.gsub(WINDFROM,".", "%1 ")
|
||||||
|
end
|
||||||
if self.metric then
|
if self.metric then
|
||||||
subtitle = string.format( "Wind from %s at %s m/s", WINDFROM, WINDSPEED )
|
subtitle = string.format( "Wind from %s at %s m/s", WINDFROM, WINDSPEED )
|
||||||
else
|
else
|
||||||
@@ -1998,20 +2010,20 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
alltext = alltext .. ";\n" .. subtitle
|
alltext = alltext .. ";\n" .. subtitle
|
||||||
|
|
||||||
-- Active runway.
|
-- Active runway.
|
||||||
local subtitle = string.format( "Active runway %s", runway )
|
local subtitle=string.format("Active runway %s", runwayLanding)
|
||||||
if rwyLeft == true then
|
if rwyLandingLeft==true then
|
||||||
subtitle = subtitle .. " Left"
|
subtitle=subtitle.." Left"
|
||||||
elseif rwyLeft == false then
|
elseif rwyLandingLeft==false then
|
||||||
subtitle = subtitle .. " Right"
|
subtitle=subtitle.." Right"
|
||||||
end
|
end
|
||||||
local _RUNACT = subtitle
|
local _RUNACT = subtitle
|
||||||
if not self.useSRS then
|
if not self.useSRS then
|
||||||
self:Transmission( ATIS.Sound.ActiveRunway, 1.0, subtitle )
|
self:Transmission(ATIS.Sound.ActiveRunway, 1.0, subtitle)
|
||||||
self.radioqueue:Number2Transmission( runway )
|
self.radioqueue:Number2Transmission(runwayLanding)
|
||||||
if rwyLeft == true then
|
if rwyLandingLeft==true then
|
||||||
self:Transmission( ATIS.Sound.Left, 0.2 )
|
self:Transmission(ATIS.Sound.Left, 0.2)
|
||||||
elseif rwyLeft == false then
|
elseif rwyLandingLeft==false then
|
||||||
self:Transmission( ATIS.Sound.Right, 0.2 )
|
self:Transmission(ATIS.Sound.Right, 0.2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
alltext = alltext .. ";\n" .. subtitle
|
alltext = alltext .. ";\n" .. subtitle
|
||||||
@@ -2122,7 +2134,7 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ILS
|
-- ILS
|
||||||
local ils = self:GetNavPoint( self.ils, runway, rwyLeft )
|
local ils=self:GetNavPoint(self.ils, runwayLanding, rwyLandingLeft)
|
||||||
if ils then
|
if ils then
|
||||||
subtitle = string.format( "ILS frequency %.2f MHz", ils.frequency )
|
subtitle = string.format( "ILS frequency %.2f MHz", ils.frequency )
|
||||||
if not self.useSRS then
|
if not self.useSRS then
|
||||||
@@ -2140,7 +2152,7 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Outer NDB
|
-- Outer NDB
|
||||||
local ndb = self:GetNavPoint( self.ndbouter, runway, rwyLeft )
|
local ndb=self:GetNavPoint(self.ndbouter, runwayLanding, rwyLandingLeft)
|
||||||
if ndb then
|
if ndb then
|
||||||
subtitle = string.format( "Outer NDB frequency %.2f MHz", ndb.frequency )
|
subtitle = string.format( "Outer NDB frequency %.2f MHz", ndb.frequency )
|
||||||
if not self.useSRS then
|
if not self.useSRS then
|
||||||
@@ -2158,7 +2170,7 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Inner NDB
|
-- Inner NDB
|
||||||
local ndb = self:GetNavPoint( self.ndbinner, runway, rwyLeft )
|
local ndb=self:GetNavPoint(self.ndbinner, runwayLanding, rwyLandingLeft)
|
||||||
if ndb then
|
if ndb then
|
||||||
subtitle = string.format( "Inner NDB frequency %.2f MHz", ndb.frequency )
|
subtitle = string.format( "Inner NDB frequency %.2f MHz", ndb.frequency )
|
||||||
if not self.useSRS then
|
if not self.useSRS then
|
||||||
@@ -2197,7 +2209,7 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
|
|
||||||
-- TACAN
|
-- TACAN
|
||||||
if self.tacan then
|
if self.tacan then
|
||||||
subtitle = string.format( "TACAN channel %dX", self.tacan )
|
subtitle=string.format("TACAN channel %dX Ray", self.tacan)
|
||||||
if not self.useSRS then
|
if not self.useSRS then
|
||||||
self:Transmission( ATIS.Sound.TACANChannel, 1.0, subtitle )
|
self:Transmission( ATIS.Sound.TACANChannel, 1.0, subtitle )
|
||||||
self.radioqueue:Number2Transmission( tostring( self.tacan ), nil, 0.2 )
|
self.radioqueue:Number2Transmission( tostring( self.tacan ), nil, 0.2 )
|
||||||
@@ -2217,7 +2229,7 @@ function ATIS:onafterBroadcast( From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- PRMG
|
-- PRMG
|
||||||
local ndb = self:GetNavPoint( self.prmg, runway, rwyLeft )
|
local ndb=self:GetNavPoint(self.prmg, runwayLanding, rwyLandingLeft)
|
||||||
if ndb then
|
if ndb then
|
||||||
subtitle = string.format( "PRMG channel %d", ndb.frequency )
|
subtitle = string.format( "PRMG channel %d", ndb.frequency )
|
||||||
if not self.useSRS then
|
if not self.useSRS then
|
||||||
@@ -2275,7 +2287,9 @@ function ATIS:onafterReport( From, Event, To, Text )
|
|||||||
self:T( "SRS TTS: " .. text )
|
self:T( "SRS TTS: " .. text )
|
||||||
|
|
||||||
-- Play text-to-speech report.
|
-- Play text-to-speech report.
|
||||||
self.msrs:PlayText( text )
|
local duration = STTS.getSpeechTime(text,0.95)
|
||||||
|
self.msrsQ:NewTransmission(text,duration,self.msrs,nil,2)
|
||||||
|
--self.msrs:PlayText( text )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2344,39 +2358,19 @@ end
|
|||||||
|
|
||||||
--- Get active runway runway.
|
--- Get active runway runway.
|
||||||
-- @param #ATIS self
|
-- @param #ATIS self
|
||||||
|
-- @param #boolean Takeoff If `true`, get runway for takeoff. Default is for landing.
|
||||||
-- @return #string Active runway, e.g. "31" for 310 deg.
|
-- @return #string Active runway, e.g. "31" for 310 deg.
|
||||||
-- @return #boolean Use Left=true, Right=false, or nil.
|
-- @return #boolean Use Left=true, Right=false, or nil.
|
||||||
function ATIS:GetActiveRunway()
|
function ATIS:GetActiveRunway(Takeoff)
|
||||||
|
|
||||||
local coord = self.airbase:GetCoordinate()
|
local runway=nil --Wrapper.Airbase#AIRBASE.Runway
|
||||||
local height = coord:GetLandHeight()
|
if Takeoff then
|
||||||
|
runway=self.airbase:GetActiveRunwayTakeoff()
|
||||||
-- Get wind direction and speed in m/s.
|
else
|
||||||
local windFrom, windSpeed = coord:GetWind( height + 10 )
|
runway=self.airbase:GetActiveRunwayLanding()
|
||||||
|
|
||||||
-- Get active runway data based on wind direction.
|
|
||||||
local runact = self.airbase:GetActiveRunway( self.runwaym2t )
|
|
||||||
|
|
||||||
-- Active runway "31".
|
|
||||||
local runway = self:GetMagneticRunway( windFrom ) or runact.idx
|
|
||||||
|
|
||||||
-- Left or right in case there are two runways with the same heading.
|
|
||||||
local rwyLeft = nil
|
|
||||||
|
|
||||||
-- Check if user explicitly specified a runway.
|
|
||||||
if self.activerunway then
|
|
||||||
|
|
||||||
-- Get explicit runway heading if specified.
|
|
||||||
local runwayno = self:GetRunwayWithoutLR( self.activerunway )
|
|
||||||
if runwayno ~= "" then
|
|
||||||
runway = runwayno
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Was "L"eft or "R"ight given?
|
|
||||||
rwyLeft = self:GetRunwayLR( self.activerunway )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return runway, rwyLeft
|
return runway.name, runway.isLeft
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get runway from user supplied magnetic heading.
|
--- Get runway from user supplied magnetic heading.
|
||||||
@@ -2442,7 +2436,7 @@ end
|
|||||||
-- @return #string Runway heading without left or right, *e.g.* "31".
|
-- @return #string Runway heading without left or right, *e.g.* "31".
|
||||||
function ATIS:GetRunwayWithoutLR( runway )
|
function ATIS:GetRunwayWithoutLR( runway )
|
||||||
local rwywo = runway:gsub( "%D+", "" )
|
local rwywo = runway:gsub( "%D+", "" )
|
||||||
-- self:I(string.format("FF runway=%s ==> rwywo=%s", runway, rwywo))
|
-- self:T(string.format("FF runway=%s ==> rwywo=%s", runway, rwywo))
|
||||||
return rwywo
|
return rwywo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,12 @@
|
|||||||
-- * [USS George Washington](https://en.wikipedia.org/wiki/USS_George_Washington_(CVN-73)) (CVN-73) [Super Carrier Module]
|
-- * [USS George Washington](https://en.wikipedia.org/wiki/USS_George_Washington_(CVN-73)) (CVN-73) [Super Carrier Module]
|
||||||
-- * [USS Harry S. Truman](https://en.wikipedia.org/wiki/USS_Harry_S._Truman) (CVN-75) [Super Carrier Module]
|
-- * [USS Harry S. Truman](https://en.wikipedia.org/wiki/USS_Harry_S._Truman) (CVN-75) [Super Carrier Module]
|
||||||
-- * [USS Forrestal](https://en.wikipedia.org/wiki/USS_Forrestal_(CV-59)) (CV-59) [Heatblur Carrier Module]
|
-- * [USS Forrestal](https://en.wikipedia.org/wiki/USS_Forrestal_(CV-59)) (CV-59) [Heatblur Carrier Module]
|
||||||
|
-- * [HMS Hermes](https://en.wikipedia.org/wiki/HMS_Hermes_(R12)) (R12) [**WIP**]
|
||||||
|
-- * [HMS Invincible](https://en.wikipedia.org/wiki/HMS_Invincible_(R05) (R05) [**WIP**]
|
||||||
-- * [USS Tarawa](https://en.wikipedia.org/wiki/USS_Tarawa_(LHA-1)) (LHA-1) [**WIP**]
|
-- * [USS Tarawa](https://en.wikipedia.org/wiki/USS_Tarawa_(LHA-1)) (LHA-1) [**WIP**]
|
||||||
-- * [USS America](https://en.wikipedia.org/wiki/USS_America_(LHA-6)) (LHA-6) [**WIP**]
|
-- * [USS America](https://en.wikipedia.org/wiki/USS_America_(LHA-6)) (LHA-6) [**WIP**]
|
||||||
-- * [Juan Carlos I](https://en.wikipedia.org/wiki/Spanish_amphibious_assault_ship_Juan_Carlos_I) (L61) [**WIP**]
|
-- * [Juan Carlos I](https://en.wikipedia.org/wiki/Spanish_amphibious_assault_ship_Juan_Carlos_I) (L61) [**WIP**]
|
||||||
|
-- * [HMAS Canberra](https://en.wikipedia.org/wiki/HMAS_Canberra_(L02)) (L02) [**WIP**]
|
||||||
--
|
--
|
||||||
-- **Supported Aircraft:**
|
-- **Supported Aircraft:**
|
||||||
--
|
--
|
||||||
@@ -51,9 +54,9 @@
|
|||||||
--
|
--
|
||||||
-- At the moment, optimized parameters are available for the F/A-18C Hornet (Lot 20) and A-4E community mod as aircraft and the USS John C. Stennis as carrier.
|
-- At the moment, optimized parameters are available for the F/A-18C Hornet (Lot 20) and A-4E community mod as aircraft and the USS John C. Stennis as carrier.
|
||||||
--
|
--
|
||||||
-- The AV-8B Harrier, the USS Tarawa, USS America, HMAS Canberra and Juan Carlos I are WIP. The AV-8B harrier and the LHA's and LHD can only be used together, i.e. these ships are the only carriers the harrier is supposed to land on and
|
-- The AV-8B Harrier, HMS Hermes, HMS Invincible, the USS Tarawa, USS America, HMAS Canberra, and Juan Carlos I are WIP. The AV-8B harrier and the LHA's and LHD can only be used together, i.e. these ships are the only carriers the harrier is supposed to land on and
|
||||||
-- no other fixed wing aircraft (human or AI controlled) are supposed to land on these ships. Currently only Case I is supported. Case II/III take slightly different steps from the CVN carrier.
|
-- no other fixed wing aircraft (human or AI controlled) are supposed to land on these ships. Currently only Case I is supported. Case II/III take slightly different steps from the CVN carrier.
|
||||||
-- However, the two Case II/III pattern are very similar so this is not a big drawback.
|
-- However, if no offset is used for the holding radial this provides a very close representation of the V/STOL Case III, allowing for an approach to over the deck and a vertical landing.
|
||||||
--
|
--
|
||||||
-- Heatblur's mighty F-14B Tomcat has been added (March 13th 2019) as well. Same goes for the A version.
|
-- Heatblur's mighty F-14B Tomcat has been added (March 13th 2019) as well. Same goes for the A version.
|
||||||
--
|
--
|
||||||
@@ -113,10 +116,11 @@
|
|||||||
-- * [Harrier Ship Landing Mission with Auto LSO!](https://www.youtube.com/watch?v=lqmVvpunk2c)
|
-- * [Harrier Ship Landing Mission with Auto LSO!](https://www.youtube.com/watch?v=lqmVvpunk2c)
|
||||||
-- * [Updated Airboss V/STOL Features USS Tarawa](https://youtu.be/K7I4pU6j718)
|
-- * [Updated Airboss V/STOL Features USS Tarawa](https://youtu.be/K7I4pU6j718)
|
||||||
-- * [Harrier Practice pattern USS America](https://youtu.be/99NigITYmcI)
|
-- * [Harrier Practice pattern USS America](https://youtu.be/99NigITYmcI)
|
||||||
|
-- * [Harrier CASE III TACAN Approach USS Tarawa](https://www.youtube.com/watch?v=bTgJXZ9Mhdc&t=1s)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### Author: **funkyfranky**
|
-- ### Author: **funkyfranky** LHA and LHD V/STOL additions by **Pene**
|
||||||
-- ### Special Thanks To **Bankler**
|
-- ### Special Thanks To **Bankler**
|
||||||
-- For his great [Recovery Trainer](https://forums.eagle.ru/showthread.php?t=221412) mission and script!
|
-- For his great [Recovery Trainer](https://forums.eagle.ru/showthread.php?t=221412) mission and script!
|
||||||
-- His work was the initial inspiration for this class. Also note that this implementation uses some routines for determining the player position in Case I recoveries he developed.
|
-- His work was the initial inspiration for this class. Also note that this implementation uses some routines for determining the player position in Case I recoveries he developed.
|
||||||
@@ -1260,7 +1264,7 @@ AIRBOSS = {
|
|||||||
|
|
||||||
--- Aircraft types capable of landing on carrier (human+AI).
|
--- Aircraft types capable of landing on carrier (human+AI).
|
||||||
-- @type AIRBOSS.AircraftCarrier
|
-- @type AIRBOSS.AircraftCarrier
|
||||||
-- @field #string AV8B AV-8B Night Harrier. Works only with the USS Tarawa, USS America and Juan Carlos I.
|
-- @field #string AV8B AV-8B Night Harrier. Works only with the HMS Hermes, HMS Invincible, USS Tarawa, USS America, and Juan Carlos I.
|
||||||
-- @field #string A4EC A-4E Community mod.
|
-- @field #string A4EC A-4E Community mod.
|
||||||
-- @field #string HORNET F/A-18C Lot 20 Hornet by Eagle Dynamics.
|
-- @field #string HORNET F/A-18C Lot 20 Hornet by Eagle Dynamics.
|
||||||
-- @field #string F14A F-14A by Heatblur.
|
-- @field #string F14A F-14A by Heatblur.
|
||||||
@@ -1296,6 +1300,8 @@ AIRBOSS.AircraftCarrier={
|
|||||||
-- @field #string TRUMAN USS Harry S. Truman (CVN-75) [Super Carrier Module]
|
-- @field #string TRUMAN USS Harry S. Truman (CVN-75) [Super Carrier Module]
|
||||||
-- @field #string FORRESTAL USS Forrestal (CV-59) [Heatblur Carrier Module]
|
-- @field #string FORRESTAL USS Forrestal (CV-59) [Heatblur Carrier Module]
|
||||||
-- @field #string VINSON USS Carl Vinson (CVN-70) [Obsolete]
|
-- @field #string VINSON USS Carl Vinson (CVN-70) [Obsolete]
|
||||||
|
-- @field #string HERMES HMS Hermes (R12) [V/STOL Carrier]
|
||||||
|
-- @field #string INVINCIBLE HMS Invincible (R05) [V/STOL Carrier]
|
||||||
-- @field #string TARAWA USS Tarawa (LHA-1) [V/STOL Carrier]
|
-- @field #string TARAWA USS Tarawa (LHA-1) [V/STOL Carrier]
|
||||||
-- @field #string AMERICA USS America (LHA-6) [V/STOL Carrier]
|
-- @field #string AMERICA USS America (LHA-6) [V/STOL Carrier]
|
||||||
-- @field #string JCARLOS Juan Carlos I (L61) [V/STOL Carrier]
|
-- @field #string JCARLOS Juan Carlos I (L61) [V/STOL Carrier]
|
||||||
@@ -1309,6 +1315,8 @@ AIRBOSS.CarrierType = {
|
|||||||
STENNIS = "Stennis",
|
STENNIS = "Stennis",
|
||||||
FORRESTAL = "Forrestal",
|
FORRESTAL = "Forrestal",
|
||||||
VINSON = "VINSON",
|
VINSON = "VINSON",
|
||||||
|
HERMES = "HERMES81",
|
||||||
|
INVINCIBLE = "hms_invincible",
|
||||||
TARAWA = "LHA_Tarawa",
|
TARAWA = "LHA_Tarawa",
|
||||||
AMERICA = "USS America LHA-6",
|
AMERICA = "USS America LHA-6",
|
||||||
JCARLOS = "L61",
|
JCARLOS = "L61",
|
||||||
@@ -1980,6 +1988,12 @@ function AIRBOSS:New( carriername, alias )
|
|||||||
elseif self.carriertype == AIRBOSS.CarrierType.VINSON then
|
elseif self.carriertype == AIRBOSS.CarrierType.VINSON then
|
||||||
-- TODO: Carl Vinson parameters.
|
-- TODO: Carl Vinson parameters.
|
||||||
self:_InitStennis()
|
self:_InitStennis()
|
||||||
|
elseif self.carriertype == AIRBOSS.CarrierType.HERMES then
|
||||||
|
-- Hermes parameters.
|
||||||
|
self:_InitHermes()
|
||||||
|
elseif self.carriertype == AIRBOSS.CarrierType.INVINCIBLE then
|
||||||
|
-- Invincible parameters.
|
||||||
|
self:_InitInvincible()
|
||||||
elseif self.carriertype == AIRBOSS.CarrierType.TARAWA then
|
elseif self.carriertype == AIRBOSS.CarrierType.TARAWA then
|
||||||
-- Tarawa parameters.
|
-- Tarawa parameters.
|
||||||
self:_InitTarawa()
|
self:_InitTarawa()
|
||||||
@@ -2082,7 +2096,7 @@ function AIRBOSS:New( carriername, alias )
|
|||||||
-- cL:FlareYellow()
|
-- cL:FlareYellow()
|
||||||
|
|
||||||
-- Carrier specific.
|
-- Carrier specific.
|
||||||
if self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.TARAWA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.AMERICA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.JCARLOS or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.CANBERRA then
|
if self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.INVINCIBLE or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.HERMES or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.TARAWA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.AMERICA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.JCARLOS or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.CANBERRA then
|
||||||
|
|
||||||
-- Flare wires.
|
-- Flare wires.
|
||||||
local w1 = stern:Translate( self.carrierparam.wire1, FB, true )
|
local w1 = stern:Translate( self.carrierparam.wire1, FB, true )
|
||||||
@@ -2811,13 +2825,29 @@ end
|
|||||||
-- @param #number Low
|
-- @param #number Low
|
||||||
-- @param #number LOW
|
-- @param #number LOW
|
||||||
-- @return #AIRBOSS self
|
-- @return #AIRBOSS self
|
||||||
function AIRBOSS:SetGlideslopeErrorThresholds( _max, _min, High, HIGH, Low, LOW )
|
|
||||||
self.gle._max = _max or 0.4
|
function AIRBOSS:SetGlideslopeErrorThresholds(_max,_min, High, HIGH, Low, LOW)
|
||||||
self.gle.High = High or 0.8
|
|
||||||
self.gle.HIGH = HIGH or 1.5
|
--Check if V/STOL Carrier
|
||||||
self.gle._min = _min or -0.3
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
self.gle.Low = Low or -0.6
|
|
||||||
self.gle.LOW = LOW or -0.9
|
-- allow a larger GSE for V/STOL operations --Pene Testing
|
||||||
|
self.gle._max=_max or 0.7
|
||||||
|
self.gle.High=High or 1.4
|
||||||
|
self.gle.HIGH=HIGH or 1.9
|
||||||
|
self.gle._min=_min or -0.5
|
||||||
|
self.gle.Low=Low or -1.2
|
||||||
|
self.gle.LOW=LOW or -1.5
|
||||||
|
-- CVN values
|
||||||
|
else
|
||||||
|
self.gle._max=_max or 0.4
|
||||||
|
self.gle.High=High or 0.8
|
||||||
|
self.gle.HIGH=HIGH or 1.5
|
||||||
|
self.gle._min=_min or -0.3
|
||||||
|
self.gle.Low=Low or -0.6
|
||||||
|
self.gle.LOW=LOW or -0.9
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2832,15 +2862,33 @@ end
|
|||||||
-- @param #number RightMed
|
-- @param #number RightMed
|
||||||
-- @param #number RIGHT
|
-- @param #number RIGHT
|
||||||
-- @return #AIRBOSS self
|
-- @return #AIRBOSS self
|
||||||
function AIRBOSS:SetLineupErrorThresholds( _max, _min, Left, LeftMed, LEFT, Right, RightMed, RIGHT )
|
|
||||||
self.lue._max = _max or 0.5
|
function AIRBOSS:SetLineupErrorThresholds(_max,_min, Left, LeftMed, LEFT, Right, RightMed, RIGHT)
|
||||||
self.lue._min = _min or -0.5
|
|
||||||
self.lue.Left = Left or -1.0
|
--Check if V/STOL Carrier -- Pene testing
|
||||||
self.lue.LeftMed = LeftMed or -2.0
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
self.lue.LEFT = LEFT or -3.0
|
|
||||||
self.lue.Right = Right or 1.0
|
-- V/STOL Values -- allow a larger LUE for V/STOL operations
|
||||||
self.lue.RightMed = RightMed or 2.0
|
self.lue._max=_max or 1.8
|
||||||
self.lue.RIGHT = RIGHT or 3.0
|
self.lue._min=_min or -1.8
|
||||||
|
self.lue.Left=Left or -2.8
|
||||||
|
self.lue.LeftMed=LeftMed or -3.8
|
||||||
|
self.lue.LEFT=LEFT or -4.5
|
||||||
|
self.lue.Right=Right or 2.8
|
||||||
|
self.lue.RightMed=RightMed or 3.8
|
||||||
|
self.lue.RIGHT=RIGHT or 4.5
|
||||||
|
-- CVN Values
|
||||||
|
else
|
||||||
|
self.lue._max=_max or 0.5
|
||||||
|
self.lue._min=_min or -0.5
|
||||||
|
self.lue.Left=Left or -1.0
|
||||||
|
self.lue.LeftMed=LeftMed or -2.0
|
||||||
|
self.lue.LEFT=LEFT or -3.0
|
||||||
|
self.lue.Right=Right or 1.0
|
||||||
|
self.lue.RightMed=RightMed or 2.0
|
||||||
|
self.lue.RIGHT=RIGHT or 3.0
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4384,6 +4432,86 @@ function AIRBOSS:_InitForrestal()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Init parameters for R12 HMS Hermes carrier.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
function AIRBOSS:_InitHermes()
|
||||||
|
|
||||||
|
-- Init Stennis as default.
|
||||||
|
self:_InitStennis()
|
||||||
|
|
||||||
|
-- Carrier Parameters.
|
||||||
|
self.carrierparam.sterndist = -105
|
||||||
|
self.carrierparam.deckheight = 12 -- From model viewer WL0.
|
||||||
|
|
||||||
|
-- Total size of the carrier (approx as rectangle).
|
||||||
|
self.carrierparam.totlength = 228.19
|
||||||
|
self.carrierparam.totwidthport = 20.5
|
||||||
|
self.carrierparam.totwidthstarboard = 24.5
|
||||||
|
|
||||||
|
-- Landing runway.
|
||||||
|
self.carrierparam.rwyangle = 0
|
||||||
|
self.carrierparam.rwylength = 215
|
||||||
|
self.carrierparam.rwywidth = 13
|
||||||
|
|
||||||
|
-- Wires.
|
||||||
|
self.carrierparam.wire1 = nil
|
||||||
|
self.carrierparam.wire2 = nil
|
||||||
|
self.carrierparam.wire3 = nil
|
||||||
|
self.carrierparam.wire4 = nil
|
||||||
|
|
||||||
|
-- Late break.
|
||||||
|
self.BreakLate.name = "Late Break"
|
||||||
|
self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0.
|
||||||
|
self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks?
|
||||||
|
self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port.
|
||||||
|
self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard.
|
||||||
|
self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat.
|
||||||
|
self.BreakLate.LimitXmax = nil
|
||||||
|
self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2
|
||||||
|
self.BreakLate.LimitZmax = nil
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Init parameters for R05 HMS Invincible carrier.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
function AIRBOSS:_InitInvincible()
|
||||||
|
|
||||||
|
-- Init Stennis as default.
|
||||||
|
self:_InitStennis()
|
||||||
|
|
||||||
|
-- Carrier Parameters.
|
||||||
|
self.carrierparam.sterndist = -105
|
||||||
|
self.carrierparam.deckheight = 12 -- From model viewer WL0.
|
||||||
|
|
||||||
|
-- Total size of the carrier (approx as rectangle).
|
||||||
|
self.carrierparam.totlength = 228.19
|
||||||
|
self.carrierparam.totwidthport = 20.5
|
||||||
|
self.carrierparam.totwidthstarboard = 24.5
|
||||||
|
|
||||||
|
-- Landing runway.
|
||||||
|
self.carrierparam.rwyangle = 0
|
||||||
|
self.carrierparam.rwylength = 215
|
||||||
|
self.carrierparam.rwywidth = 13
|
||||||
|
|
||||||
|
-- Wires.
|
||||||
|
self.carrierparam.wire1 = nil
|
||||||
|
self.carrierparam.wire2 = nil
|
||||||
|
self.carrierparam.wire3 = nil
|
||||||
|
self.carrierparam.wire4 = nil
|
||||||
|
|
||||||
|
-- Late break.
|
||||||
|
self.BreakLate.name = "Late Break"
|
||||||
|
self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0.
|
||||||
|
self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks?
|
||||||
|
self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port.
|
||||||
|
self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard.
|
||||||
|
self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat.
|
||||||
|
self.BreakLate.LimitXmax = nil
|
||||||
|
self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2
|
||||||
|
self.BreakLate.LimitZmax = nil
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- Init parameters for LHA-1 Tarawa carrier.
|
--- Init parameters for LHA-1 Tarawa carrier.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
function AIRBOSS:_InitTarawa()
|
function AIRBOSS:_InitTarawa()
|
||||||
@@ -5007,14 +5135,16 @@ function AIRBOSS:_GetAircraftAoA( playerData )
|
|||||||
aoa.Fast = 8.25 -- =17.5/2
|
aoa.Fast = 8.25 -- =17.5/2
|
||||||
aoa.FAST = 8.00 -- =16.5/2
|
aoa.FAST = 8.00 -- =16.5/2
|
||||||
elseif harrier then
|
elseif harrier then
|
||||||
-- AV-8B Harrier parameters. Tuning done on the Fast AoA to allow for abeam and ninety at Nozzles 60 - 73.
|
|
||||||
aoa.SLOW = 14.0
|
-- AV-8B Harrier parameters. Tuning done on the Fast AoA to allow for abeam and ninety at Nozzles 55. Pene testing
|
||||||
aoa.Slow = 13.0
|
aoa.SLOW = 16.0
|
||||||
aoa.OnSpeedMax = 12.0
|
aoa.Slow = 13.5
|
||||||
aoa.OnSpeed = 11.0
|
aoa.OnSpeedMax = 12.5
|
||||||
aoa.OnSpeedMin = 10.0
|
aoa.OnSpeed = 10.0
|
||||||
aoa.Fast = 8.0
|
aoa.OnSpeedMin = 9.5
|
||||||
aoa.FAST = 7.5
|
aoa.Fast = 8.0
|
||||||
|
aoa.FAST = 7.5
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return aoa
|
return aoa
|
||||||
@@ -5273,8 +5403,8 @@ function AIRBOSS:_GetAircraftParameters( playerData, step )
|
|||||||
elseif skyhawk then
|
elseif skyhawk then
|
||||||
alt = UTILS.FeetToMeters( 300 ) -- ?
|
alt = UTILS.FeetToMeters( 300 ) -- ?
|
||||||
elseif harrier then
|
elseif harrier then
|
||||||
-- 300-325 ft
|
alt=UTILS.FeetToMeters(312)-- 300-325 ft
|
||||||
alt = UTILS.FeetToMeters( 300 ) -- Need to verify
|
|
||||||
end
|
end
|
||||||
|
|
||||||
aoa = aoaac.OnSpeed
|
aoa = aoaac.OnSpeed
|
||||||
@@ -6058,7 +6188,7 @@ function AIRBOSS:_RefuelAI( flight )
|
|||||||
-- Guide AI to divert field --
|
-- 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() )
|
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.
|
-- Handle case where there is no divert field of the own coalition and try neutral instead.
|
||||||
@@ -6209,7 +6339,7 @@ function AIRBOSS:_GetMarshalAltitude( stack, case )
|
|||||||
p2 = Carrier:Translate( UTILS.NMToMeters( 1.5 ), hdg )
|
p2 = Carrier:Translate( UTILS.NMToMeters( 1.5 ), hdg )
|
||||||
|
|
||||||
-- Tarawa,LHA,LHD Delta patterns.
|
-- Tarawa,LHA,LHD Delta patterns.
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
|
|
||||||
-- Pattern is directly overhead the carrier.
|
-- Pattern is directly overhead the carrier.
|
||||||
p1 = Carrier:Translate( UTILS.NMToMeters( 1.0 ), hdg + 90 )
|
p1 = Carrier:Translate( UTILS.NMToMeters( 1.0 ), hdg + 90 )
|
||||||
@@ -8048,7 +8178,7 @@ function AIRBOSS:OnEventLand( EventData )
|
|||||||
self:T( self.lid .. text )
|
self:T( self.lid .. text )
|
||||||
|
|
||||||
-- Check carrier type.
|
-- Check carrier type.
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
|
|
||||||
-- Power "Idle".
|
-- Power "Idle".
|
||||||
self:RadioTransmission( self.LSORadio, self.LSOCall.IDLE, false, 1, nil, true )
|
self:RadioTransmission( self.LSORadio, self.LSOCall.IDLE, false, 1, nil, true )
|
||||||
@@ -8083,7 +8213,7 @@ function AIRBOSS:OnEventLand( EventData )
|
|||||||
-- AI unit landed --
|
-- AI unit landed --
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
if self.carriertype ~= AIRBOSS.CarrierType.TARAWA or self.carriertype ~= AIRBOSS.CarrierType.AMERICA or self.carriertype ~= AIRBOSS.CarrierType.JCARLOS or self.carriertype ~= AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype ~= AIRBOSS.CarrierType.INVINCIBLE or self.carriertype ~= AIRBOSS.CarrierType.HERMES or self.carriertype ~= AIRBOSS.CarrierType.TARAWA or self.carriertype ~= AIRBOSS.CarrierType.AMERICA or self.carriertype ~= AIRBOSS.CarrierType.JCARLOS or self.carriertype ~= AIRBOSS.CarrierType.CANBERRA then
|
||||||
|
|
||||||
-- Coordinate at landing event
|
-- Coordinate at landing event
|
||||||
local coord = EventData.IniUnit:GetCoordinate()
|
local coord = EventData.IniUnit:GetCoordinate()
|
||||||
@@ -9121,7 +9251,7 @@ function AIRBOSS:_CheckForLongDownwind( playerData )
|
|||||||
local limit = UTILS.NMToMeters( -1.6 )
|
local limit = UTILS.NMToMeters( -1.6 )
|
||||||
|
|
||||||
-- For the tarawa, other LHA and LHD we give a bit more space.
|
-- For the tarawa, other LHA and LHD we give a bit more space.
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
limit = UTILS.NMToMeters( -2.0 )
|
limit = UTILS.NMToMeters( -2.0 )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -9208,7 +9338,7 @@ function AIRBOSS:_Ninety( playerData )
|
|||||||
self:_PlayerHint( playerData )
|
self:_PlayerHint( playerData )
|
||||||
|
|
||||||
-- Next step: wake.
|
-- Next step: wake.
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
-- Harrier has no wake stop. It stays port of the boat.
|
-- Harrier has no wake stop. It stays port of the boat.
|
||||||
self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.FINAL )
|
self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.FINAL )
|
||||||
else
|
else
|
||||||
@@ -9464,8 +9594,9 @@ function AIRBOSS:_Groove( playerData )
|
|||||||
-- Speed difference.
|
-- Speed difference.
|
||||||
local dv = math.abs( vplayer - vcarrier )
|
local dv = math.abs( vplayer - vcarrier )
|
||||||
|
|
||||||
-- Stable when speed difference < 20 km/h.
|
|
||||||
local stable = dv < 20
|
-- Stable when speed difference < 30 km/h.(16 Kts)Pene Testing
|
||||||
|
local stable=dv<30
|
||||||
|
|
||||||
-- Check if player is inside the zone.
|
-- Check if player is inside the zone.
|
||||||
if playerData.unit:IsInZone( ZoneALS ) and stable then
|
if playerData.unit:IsInZone( ZoneALS ) and stable then
|
||||||
@@ -9497,8 +9628,8 @@ function AIRBOSS:_Groove( playerData )
|
|||||||
-- Speed difference.
|
-- Speed difference.
|
||||||
local dv = math.abs( vplayer - vcarrier )
|
local dv = math.abs( vplayer - vcarrier )
|
||||||
|
|
||||||
-- Stable when v<10 km/h.
|
-- Stable when v<15 km/h.
|
||||||
local stable = dv < 10
|
local stable=dv<15
|
||||||
|
|
||||||
-- Radio Transmission "Stabilized" once the aircraft has been cleared to cross and is over the Landing Spot and stable.
|
-- Radio Transmission "Stabilized" once the aircraft has been cleared to cross and is over the Landing Spot and stable.
|
||||||
if playerData.unit:IsInZone( ZoneLS ) and stable and playerData.stable == true then
|
if playerData.unit:IsInZone( ZoneLS ) and stable and playerData.stable == true then
|
||||||
@@ -9537,25 +9668,26 @@ function AIRBOSS:_Groove( playerData )
|
|||||||
-- Nothing else necessary.
|
-- Nothing else necessary.
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Long V/STOL groove time Wave Off over 75 seconds to IC - TOPGUN level Only. --pene testing (WIP)
|
end
|
||||||
|
|
||||||
-- if rho>=RAR and rho<=RIC and not playerData.waveoff and playerData.difficulty==AIRBOSS.Difficulty.HARD and playerData.actype== AIRBOSS.AircraftCarrier.AV8B then
|
-- Long V/STOL groove time Wave Off over 75 seconds to IC - TOPGUN level Only. --pene testing (WIP)--- Need to think more about this.
|
||||||
-- Get groove time
|
|
||||||
-- local vSlow=groovedata.time
|
|
||||||
-- If too slow wave off.
|
|
||||||
-- if vSlow >75 then
|
|
||||||
|
|
||||||
-- LSO Wave off!
|
--if rho>=RAR and rho<=RIC and not playerData.waveoff and playerData.difficulty==AIRBOSS.Difficulty.HARD and playerData.actype== AIRBOSS.AircraftCarrier.AV8B then
|
||||||
-- self:RadioTransmission(self.LSORadio, self.LSOCall.WAVEOFF, nil, nil, nil, true)
|
-- Get groove time
|
||||||
-- playerData.Tlso=timer.getTime()
|
--local vSlow=groovedata.time
|
||||||
|
-- If too slow wave off.
|
||||||
|
--if vSlow >75 then
|
||||||
|
|
||||||
-- Player was waved Off
|
-- LSO Wave off!
|
||||||
-- playerData.waveoff=true
|
--self:RadioTransmission(self.LSORadio, self.LSOCall.WAVEOFF, nil, nil, nil, true)
|
||||||
-- return
|
--playerData.Tlso=timer.getTime()
|
||||||
-- end
|
|
||||||
-- end
|
-- Player was waved Off
|
||||||
|
--playerData.waveoff=true
|
||||||
|
--return
|
||||||
|
--end
|
||||||
|
--end
|
||||||
|
|
||||||
-- Groovedata step.
|
-- Groovedata step.
|
||||||
groovedata.Step = playerData.step
|
groovedata.Step = playerData.step
|
||||||
@@ -9726,8 +9858,8 @@ function AIRBOSS:_CheckWaveOff( glideslopeError, lineupError, AoA, playerData )
|
|||||||
-- For the harrier, we allow a bit more room.
|
-- For the harrier, we allow a bit more room.
|
||||||
if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then
|
if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then
|
||||||
glMax = 2.6
|
glMax = 2.6
|
||||||
glMin = -2.0
|
glMin = -2.2 -- Testing, @Engines may be just dragging it in on Hermes, or the carrier parameters need adjusting.
|
||||||
luAbs = 4.1 -- Testing Pene (WIP) needs feedback to tighten up tolerences.
|
luAbs = 4.1 -- Testing Pene.
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -9893,17 +10025,23 @@ function AIRBOSS:_GetSternCoord()
|
|||||||
local hdg = self.carrier:GetHeading()
|
local hdg = self.carrier:GetHeading()
|
||||||
|
|
||||||
-- Final bearing (true).
|
-- Final bearing (true).
|
||||||
local FB = self:GetFinalBearing()
|
local FB=self:GetFinalBearing()
|
||||||
|
local case=self.case
|
||||||
|
|
||||||
-- Stern coordinate (sterndist<0). Also translate 10 meters starboard wrt Final bearing.
|
-- Stern coordinate (sterndist<0). Also translate 10 meters starboard wrt Final bearing.
|
||||||
self.sterncoord:UpdateFromCoordinate( self:GetCoordinate() )
|
self.sterncoord:UpdateFromCoordinate( self:GetCoordinate() )
|
||||||
-- local stern=self:GetCoordinate()
|
-- local stern=self:GetCoordinate()
|
||||||
|
|
||||||
-- Stern coordinate (sterndist<0).
|
-- Stern coordinate (sterndist<0). --Pene testing Case III
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then
|
||||||
-- Tarawa: Translate 8 meters port.
|
if case==3 then
|
||||||
self.sterncoord:Translate( self.carrierparam.sterndist, hdg, true, true ):Translate( 8, FB - 90, true, true )
|
-- CASE III V/STOL translation Due over deck approach if needed.
|
||||||
elseif self.carriertype == AIRBOSS.CarrierType.STENNIS then
|
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true)
|
||||||
|
elseif case==2 or case==1 then
|
||||||
|
-- V/Stol: Translate 8 meters port.
|
||||||
|
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true)
|
||||||
|
end
|
||||||
|
elseif self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
||||||
-- Stennis: translate 7 meters starboard wrt Final bearing.
|
-- Stennis: translate 7 meters starboard wrt Final bearing.
|
||||||
self.sterncoord:Translate( self.carrierparam.sterndist, hdg, true, true ):Translate( 7, FB + 90, true, true )
|
self.sterncoord:Translate( self.carrierparam.sterndist, hdg, true, true ):Translate( 7, FB + 90, true, true )
|
||||||
elseif self.carriertype == AIRBOSS.CarrierType.FORRESTAL then
|
elseif self.carriertype == AIRBOSS.CarrierType.FORRESTAL then
|
||||||
@@ -10536,7 +10674,8 @@ function AIRBOSS:_GetZoneRunwayBox()
|
|||||||
return self.zoneRunwaybox
|
return self.zoneRunwaybox
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get zone of primary abeam landing position of USS Tarawa, USS America and Juan Carlos. Box length 50 meters and width 30 meters.
|
--- Get zone of primary abeam landing position of HMS Hermes, HMS Invincible, USS Tarawa, USS America and Juan Carlos. Box length 50 meters and width 30 meters.
|
||||||
|
|
||||||
--- Allow for Clear to land call from LSO approaching abeam the landing spot if stable as per NATOPS 00-80T
|
--- Allow for Clear to land call from LSO approaching abeam the landing spot if stable as per NATOPS 00-80T
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @return Core.Zone#ZONE_POLYGON Zone surrounding landing runway.
|
-- @return Core.Zone#ZONE_POLYGON Zone surrounding landing runway.
|
||||||
@@ -10548,8 +10687,8 @@ function AIRBOSS:_GetZoneAbeamLandingSpot()
|
|||||||
-- Current carrier heading.
|
-- Current carrier heading.
|
||||||
local FB = self:GetFinalBearing( false )
|
local FB = self:GetFinalBearing( false )
|
||||||
|
|
||||||
-- Coordinate array.
|
-- Coordinate array. Pene Testing extended Abeam landing spot V/STOL.
|
||||||
local p = {}
|
local p={}
|
||||||
|
|
||||||
-- Points.
|
-- Points.
|
||||||
p[1] = S:Translate( 15, FB ):Translate( 15, FB + 90 ) -- Top-Right
|
p[1] = S:Translate( 15, FB ):Translate( 15, FB + 90 ) -- Top-Right
|
||||||
@@ -10640,7 +10779,7 @@ function AIRBOSS:_GetZoneHolding( case, stack )
|
|||||||
self.zoneHolding = ZONE_RADIUS:New( "CASE I Holding Zone", Post:GetVec2(), self.marshalradius )
|
self.zoneHolding = ZONE_RADIUS:New( "CASE I Holding Zone", Post:GetVec2(), self.marshalradius )
|
||||||
|
|
||||||
-- Delta pattern.
|
-- Delta pattern.
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
self.zoneHolding = ZONE_RADIUS:New( "CASE I Holding Zone", self.carrier:GetVec2(), UTILS.NMToMeters( 5 ) )
|
self.zoneHolding = ZONE_RADIUS:New( "CASE I Holding Zone", self.carrier:GetVec2(), UTILS.NMToMeters( 5 ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -10692,7 +10831,7 @@ function AIRBOSS:_GetZoneCommence( case, stack )
|
|||||||
-- Three position
|
-- Three position
|
||||||
local Three = self:GetCoordinate():Translate( D, hdg + 275 )
|
local Three = self:GetCoordinate():Translate( D, hdg + 275 )
|
||||||
|
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
|
|
||||||
local Dx = UTILS.NMToMeters( 2.25 )
|
local Dx = UTILS.NMToMeters( 2.25 )
|
||||||
|
|
||||||
@@ -10983,7 +11122,7 @@ function AIRBOSS:_GetAltCarrier( unit )
|
|||||||
return h
|
return h
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get optimal landing position of the aircraft. Usually between second and third wire. In case of Tarawa and America we take the abeam landing spot 120 ft abeam the 7.5 position, for the Juan Carlos I it is 120 ft and abeam the 5 position.
|
--- Get optimal landing position of the aircraft. Usually between second and third wire. In case of Tarawa, Canberrra, Juan Carlos and America we take the abeam landing spot 120 ft above and 21 ft abeam the 7.5 position, for the Juan Carlos I, HMS Invincible, and HMS Hermes and Invincible it is 120 ft above and 21 ft abeam the 5 position. For CASE III it is 120ft directly above the landing spot.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @return Core.Point#COORDINATE Optimal landing coordinate.
|
-- @return Core.Point#COORDINATE Optimal landing coordinate.
|
||||||
function AIRBOSS:_GetOptLandingCoordinate()
|
function AIRBOSS:_GetOptLandingCoordinate()
|
||||||
@@ -10993,44 +11132,27 @@ function AIRBOSS:_GetOptLandingCoordinate()
|
|||||||
|
|
||||||
-- Stern coordinate.
|
-- Stern coordinate.
|
||||||
-- local stern=self:_GetSternCoord()
|
-- local stern=self:_GetSternCoord()
|
||||||
|
|
||||||
-- Final bearing.
|
-- Final bearing.
|
||||||
local FB = self:GetFinalBearing( false )
|
|
||||||
|
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA then
|
local FB=self:GetFinalBearing(false)
|
||||||
|
local case=self.case
|
||||||
|
-- set Case III V/STOL abeam landing spot over deck -- Pene Testing
|
||||||
|
if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then
|
||||||
|
|
||||||
|
if case==3 then
|
||||||
|
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate())
|
||||||
|
-- Altitude 120ft -- is this corect for Case III?
|
||||||
|
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
|
||||||
|
|
||||||
|
elseif case==2 or case==1 then
|
||||||
|
|
||||||
-- Landing 100 ft abeam, 120 ft alt.
|
-- Landing 100 ft abeam, 120 ft alt.
|
||||||
self.landingcoord:UpdateFromCoordinate( self:_GetLandingSpotCoordinate() ):Translate( 35, FB - 90, true, true )
|
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()):Translate(35, FB-90, true, true)
|
||||||
-- stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
--stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
||||||
|
|
||||||
-- Alitude 120 ft.
|
-- Atlitude 120 ft.
|
||||||
self.landingcoord:SetAltitude( UTILS.FeetToMeters( 120 ) )
|
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
|
||||||
elseif self.carriertype == AIRBOSS.CarrierType.AMERICA then
|
end
|
||||||
|
|
||||||
-- Landing 100 ft abeam, 120 ft alt. To allow adjustments to match different deck configurations.
|
|
||||||
self.landingcoord:UpdateFromCoordinate( self:_GetLandingSpotCoordinate() ):Translate( 35, FB - 90, true, true )
|
|
||||||
-- stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
|
||||||
|
|
||||||
-- Alitude 120 ft.
|
|
||||||
self.landingcoord:SetAltitude( UTILS.FeetToMeters( 120 ) )
|
|
||||||
|
|
||||||
elseif self.carriertype == AIRBOSS.CarrierType.JCARLOS then
|
|
||||||
|
|
||||||
-- Landing 100 ft abeam, 120 ft alt.
|
|
||||||
self.landingcoord:UpdateFromCoordinate( self:_GetLandingSpotCoordinate() ):Translate( 35, FB - 90, true, true )
|
|
||||||
-- stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
|
||||||
|
|
||||||
-- Alitude 120 ft.
|
|
||||||
self.landingcoord:SetAltitude( UTILS.FeetToMeters( 120 ) )
|
|
||||||
|
|
||||||
elseif self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
|
||||||
|
|
||||||
-- Landing 100 ft abeam, 120 ft alt.
|
|
||||||
self.landingcoord:UpdateFromCoordinate( self:_GetLandingSpotCoordinate() ):Translate( 35, FB - 90, true, true )
|
|
||||||
-- stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
|
||||||
|
|
||||||
-- Alitude 120 ft.
|
|
||||||
self.landingcoord:SetAltitude( UTILS.FeetToMeters( 120 ) )
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@@ -11059,7 +11181,21 @@ function AIRBOSS:_GetLandingSpotCoordinate()
|
|||||||
-- Stern coordinate.
|
-- Stern coordinate.
|
||||||
-- local stern=self:_GetSternCoord()
|
-- local stern=self:_GetSternCoord()
|
||||||
|
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA then
|
if self.carriertype==AIRBOSS.CarrierType.HERMES then
|
||||||
|
|
||||||
|
-- Landing 100 ft abeam, 100 alt.
|
||||||
|
local hdg = self:GetHeading()
|
||||||
|
|
||||||
|
-- Primary landing spot 5
|
||||||
|
self.landingspotcoord:Translate( 69, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
|
||||||
|
elseif self.carriertype == AIRBOSS.CarrierType.INVINCIBLE then
|
||||||
|
|
||||||
|
-- Using spot 3 as the default
|
||||||
|
local hdg = self:GetHeading()
|
||||||
|
|
||||||
|
self.landingspotcoord:Translate( 69, hdg, true, true ):SetAltitude( self.carrierparam.deckheight )
|
||||||
|
-- This location looks good.
|
||||||
|
elseif self.carriertype == AIRBOSS.CarrierType.TARAWA then
|
||||||
|
|
||||||
-- Landing 100 ft abeam, 120 alt.
|
-- Landing 100 ft abeam, 120 alt.
|
||||||
local hdg = self:GetHeading()
|
local hdg = self:GetHeading()
|
||||||
@@ -11127,7 +11263,7 @@ end
|
|||||||
|
|
||||||
--- Get wind direction and speed at carrier position.
|
--- Get wind direction and speed at carrier position.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @param #number alt Altitude ASL in meters. Default 50 m.
|
-- @param #number alt Altitude ASL in meters. Default 15 m.
|
||||||
-- @param #boolean magnetic Direction including magnetic declination.
|
-- @param #boolean magnetic Direction including magnetic declination.
|
||||||
-- @param Core.Point#COORDINATE coord (Optional) Coordinate at which to get the wind. Default is current carrier position.
|
-- @param Core.Point#COORDINATE coord (Optional) Coordinate at which to get the wind. Default is current carrier position.
|
||||||
-- @return #number Direction the wind is blowing **from** in degrees.
|
-- @return #number Direction the wind is blowing **from** in degrees.
|
||||||
@@ -11137,8 +11273,8 @@ function AIRBOSS:GetWind( alt, magnetic, coord )
|
|||||||
-- Current position of the carrier or input.
|
-- Current position of the carrier or input.
|
||||||
local cv = coord or self:GetCoordinate()
|
local cv = coord or self:GetCoordinate()
|
||||||
|
|
||||||
-- Wind direction and speed. By default at 50 meters ASL.
|
-- Wind direction and speed. By default at 15 meters ASL.
|
||||||
local Wdir, Wspeed = cv:GetWind( alt or 50 )
|
local Wdir, Wspeed = cv:GetWind( alt or 15 )
|
||||||
|
|
||||||
-- Include magnetic declination.
|
-- Include magnetic declination.
|
||||||
if magnetic then
|
if magnetic then
|
||||||
@@ -11649,15 +11785,17 @@ function AIRBOSS:_LSOgrade( playerData )
|
|||||||
local G = GXX .. " " .. GIM .. " " .. " " .. GIC .. " " .. GAR
|
local G = GXX .. " " .. GIM .. " " .. " " .. GIC .. " " .. GAR
|
||||||
|
|
||||||
-- Count number of minor, normal and major deviations.
|
-- Count number of minor, normal and major deviations.
|
||||||
local N = nXX + nIM + nIC + nAR
|
local N=nXX+nIM+nIC+nAR
|
||||||
local nL = count( G, '_' ) / 2
|
local Nv=nXX+nIM
|
||||||
local nS = count( G, '%(' )
|
local nL=count(G, '_')/2
|
||||||
local nN = N - nS - nL
|
local nS=count(G, '%(')
|
||||||
|
local nN=N-nS-nL
|
||||||
|
local nNv=Nv-nS-nL
|
||||||
|
|
||||||
-- Groove time 15-18.99 sec for a unicorn. Or 65-70 for V/STOL unicorn.
|
-- Groove time 15-18.99 sec for a unicorn. Or 60-65 for V/STOL unicorn.
|
||||||
local Tgroove = playerData.Tgroove
|
local Tgroove=playerData.Tgroove
|
||||||
local TgrooveUnicorn = Tgroove and (Tgroove >= 15.0 and Tgroove <= 18.99) or false
|
local TgrooveUnicorn=Tgroove and (Tgroove>=15.0 and Tgroove<=18.99) or false
|
||||||
local TgrooveVstolUnicorn = Tgroove and (Tgroove >= 60.0 and Tgroove <= 65.0) and playerData.actype == AIRBOSS.AircraftCarrier.AV8B or false
|
local TgrooveVstolUnicorn=Tgroove and (Tgroove>=60.0 and Tgroove<=65.0)and playerData.actype==AIRBOSS.AircraftCarrier.AV8B or false
|
||||||
|
|
||||||
local grade
|
local grade
|
||||||
local points
|
local points
|
||||||
@@ -11668,29 +11806,33 @@ function AIRBOSS:_LSOgrade( playerData )
|
|||||||
G = "Unicorn"
|
G = "Unicorn"
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Add AV-8B Harrier devation allowances due to lower groundspeed and 3x conventional groove time, this allows to maintain LSO tolerances while respecting the deviations are not unsafe. (WIP requires feedback)
|
-- Add AV-8B Harrier devation allowances due to lower groundspeed and 3x conventional groove time, this allows to maintain LSO tolerances while respecting the deviations are not unsafe.--Pene testing
|
||||||
-- Large devaitions still result in a No Grade, A Unicorn still requires a clean pass with no deviation.
|
-- Large devaitions still result in a No Grade, A Unicorn still requires a clean pass with no deviation.
|
||||||
if nL > 3 and playerData.actype == AIRBOSS.AircraftCarrier.AV8B then
|
if nL > 1 and playerData.actype==AIRBOSS.AircraftCarrier.AV8B then
|
||||||
-- Larger deviations ==> "No grade" 2.0 points.
|
-- Larger deviations ==> "No grade" 2.0 points.
|
||||||
grade = "--"
|
grade="--"
|
||||||
points = 2.0
|
points=2.0
|
||||||
elseif nN > 2 and playerData.actype == AIRBOSS.AircraftCarrier.AV8B then
|
elseif nNv >= 1 and playerData.actype==AIRBOSS.AircraftCarrier.AV8B then
|
||||||
-- Only average deviations ==> "Fair Pass" Pass with average deviations and corrections.
|
-- Only average deviations ==> "Fair Pass" Pass with average deviations and corrections.
|
||||||
grade = "(OK)"
|
grade="(OK)"
|
||||||
points = 3.0
|
points=3.0
|
||||||
elseif nL > 0 then
|
elseif nNv < 1 and playerData.actype==AIRBOSS.AircraftCarrier.AV8B then
|
||||||
|
-- Only minor average deviations ==> "OK" Pass with minor deviations and corrections. (test nNv<=1 and)
|
||||||
|
grade="OK"
|
||||||
|
points=4.0
|
||||||
|
elseif nL > 0 then
|
||||||
-- Larger deviations ==> "No grade" 2.0 points.
|
-- Larger deviations ==> "No grade" 2.0 points.
|
||||||
grade = "--"
|
grade="--"
|
||||||
points = 2.0
|
points=2.0
|
||||||
elseif nN > 0 then
|
elseif nN> 0 then
|
||||||
-- No larger but average deviations ==> "Fair Pass" Pass with average deviations and corrections.
|
-- No larger but average deviations ==> "Fair Pass" Pass with average deviations and corrections.
|
||||||
grade = "(OK)"
|
grade="(OK)"
|
||||||
points = 3.0
|
points=3.0
|
||||||
else
|
else
|
||||||
-- Only minor corrections
|
-- Only minor corrections
|
||||||
grade = "OK"
|
grade="OK"
|
||||||
points = 4.0
|
points=4.0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -11994,7 +12136,7 @@ function AIRBOSS:_GS( step, n )
|
|||||||
if n == -1 then
|
if n == -1 then
|
||||||
gp = AIRBOSS.GroovePos.IC
|
gp = AIRBOSS.GroovePos.IC
|
||||||
elseif n == 1 then
|
elseif n == 1 then
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
gp = AIRBOSS.GroovePos.AL
|
gp = AIRBOSS.GroovePos.AL
|
||||||
else
|
else
|
||||||
gp = AIRBOSS.GroovePos.IW
|
gp = AIRBOSS.GroovePos.IW
|
||||||
@@ -13873,7 +14015,7 @@ function AIRBOSS:_IsCarrierAircraft( unit )
|
|||||||
|
|
||||||
-- Special case for Harrier which can only land on Tarawa, LHA and LHD.
|
-- Special case for Harrier which can only land on Tarawa, LHA and LHD.
|
||||||
if aircrafttype == AIRBOSS.AircraftCarrier.AV8B then
|
if aircrafttype == AIRBOSS.AircraftCarrier.AV8B then
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
@@ -13881,7 +14023,7 @@ function AIRBOSS:_IsCarrierAircraft( unit )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Also only Harriers can land on the Tarawa, LHA and LHD.
|
-- Also only Harriers can land on the Tarawa, LHA and LHD.
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
if aircrafttype ~= AIRBOSS.AircraftCarrier.AV8B then
|
if aircrafttype ~= AIRBOSS.AircraftCarrier.AV8B then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@@ -17238,7 +17380,7 @@ function AIRBOSS:_MarkCaseZones( _unitName, flare )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Tarawa, LHA and LHD landing spots.
|
-- Tarawa, LHA and LHD landing spots.
|
||||||
if self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then
|
||||||
text = text .. "\n* abeam landing stop with RED flares"
|
text = text .. "\n* abeam landing stop with RED flares"
|
||||||
-- Abeam landing spot zone.
|
-- Abeam landing spot zone.
|
||||||
local ALSPT = self:_GetZoneAbeamLandingSpot()
|
local ALSPT = self:_GetZoneAbeamLandingSpot()
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+3997
-3077
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@
|
|||||||
-- @field #string tankergroupname Name of the late activated tanker template group.
|
-- @field #string tankergroupname Name of the late activated tanker template group.
|
||||||
-- @field Wrapper.Group#GROUP tanker Tanker group.
|
-- @field Wrapper.Group#GROUP tanker Tanker group.
|
||||||
-- @field Wrapper.Airbase#AIRBASE airbase The home airbase object of the tanker. Normally the aircraft carrier.
|
-- @field Wrapper.Airbase#AIRBASE airbase The home airbase object of the tanker. Normally the aircraft carrier.
|
||||||
-- @field Core.Radio#BEACON beacon Tanker TACAN beacon.
|
-- @field Core.Beacon#BEACON beacon Tanker TACAN beacon.
|
||||||
-- @field #number TACANchannel TACAN channel. Default 1.
|
-- @field #number TACANchannel TACAN channel. Default 1.
|
||||||
-- @field #string TACANmode TACAN mode, i.e. "X" or "Y". Default "Y". Use only "Y" for AA TACAN stations!
|
-- @field #string TACANmode TACAN mode, i.e. "X" or "Y". Default "Y". Use only "Y" for AA TACAN stations!
|
||||||
-- @field #string TACANmorse TACAN morse code. Three letters identifying the TACAN station. Default "TKR".
|
-- @field #string TACANmorse TACAN morse code. Three letters identifying the TACAN station. Default "TKR".
|
||||||
@@ -784,10 +784,11 @@ end
|
|||||||
-- @param #RECOVERYTANKER self
|
-- @param #RECOVERYTANKER self
|
||||||
-- @param #number channel TACAN channel. Default 1.
|
-- @param #number channel TACAN channel. Default 1.
|
||||||
-- @param #string morse TACAN morse code identifier. Three letters. Default "TKR".
|
-- @param #string morse TACAN morse code identifier. Three letters. Default "TKR".
|
||||||
|
-- @param #string mode TACAN mode, which can be either "Y" (default) or "X".
|
||||||
-- @return #RECOVERYTANKER self
|
-- @return #RECOVERYTANKER self
|
||||||
function RECOVERYTANKER:SetTACAN(channel, morse)
|
function RECOVERYTANKER:SetTACAN(channel, morse, mode)
|
||||||
self.TACANchannel=channel or 1
|
self.TACANchannel=channel or 1
|
||||||
self.TACANmode="Y"
|
self.TACANmode=mode or "Y"
|
||||||
self.TACANmorse=morse or "TKR"
|
self.TACANmorse=morse or "TKR"
|
||||||
self.TACANon=true
|
self.TACANon=true
|
||||||
return self
|
return self
|
||||||
@@ -1625,7 +1626,6 @@ function RECOVERYTANKER:_ActivateTACAN(delay)
|
|||||||
if delay and delay>0 then
|
if delay and delay>0 then
|
||||||
|
|
||||||
-- Schedule TACAN activation.
|
-- Schedule TACAN activation.
|
||||||
--SCHEDULER:New(nil, self._ActivateTACAN, {self}, delay)
|
|
||||||
self:ScheduleOnce(delay, RECOVERYTANKER._ActivateTACAN, self)
|
self:ScheduleOnce(delay, RECOVERYTANKER._ActivateTACAN, self)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ function RADIO:SetFrequency(Frequency)
|
|||||||
if type(Frequency) == "number" then
|
if type(Frequency) == "number" then
|
||||||
|
|
||||||
-- If frequency is in range
|
-- If frequency is in range
|
||||||
-- if (Frequency >= 30 and Frequency <= 87.995) or (Frequency >= 108 and Frequency <= 173.995) or (Frequency >= 225 and Frequency <= 399.975) then
|
--if (Frequency >= 30 and Frequency <= 87.995) or (Frequency >= 108 and Frequency <= 173.995) or (Frequency >= 225 and Frequency <= 399.975) then
|
||||||
|
|
||||||
-- Convert frequency from MHz to Hz
|
-- Convert frequency from MHz to Hz
|
||||||
self.Frequency = Frequency * 1000000
|
self.Frequency = Frequency * 1000000
|
||||||
@@ -186,7 +186,7 @@ function RADIO:SetFrequency(Frequency)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
-- end
|
--end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:E({"Frequency is not a number. Frequency unchanged.", Frequency})
|
self:E({"Frequency is not a number. Frequency unchanged.", Frequency})
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ RADIOSPEECH.Vocabulary.RU = {
|
|||||||
["br"] = { "br", 1.1 },
|
["br"] = { "br", 1.1 },
|
||||||
["bra"] = { "bra", 0.3 },
|
["bra"] = { "bra", 0.3 },
|
||||||
|
|
||||||
|
|
||||||
["возвращение на базу"] = { "returning_to_base", 1.40 },
|
["возвращение на базу"] = { "returning_to_base", 1.40 },
|
||||||
["на пути к наземной цели"] = { "on_route_to_ground_target", 1.45 },
|
["на пути к наземной цели"] = { "on_route_to_ground_target", 1.45 },
|
||||||
["перехват боги"] = { "intercepting_bogeys", 1.22 },
|
["перехват боги"] = { "intercepting_bogeys", 1.22 },
|
||||||
|
|||||||
@@ -45,14 +45,13 @@
|
|||||||
-- @field Core.Point#COORDINATE coordinate Coordinate from where the transmission is send.
|
-- @field Core.Point#COORDINATE coordinate Coordinate from where the transmission is send.
|
||||||
-- @field #string path Path to the SRS exe. This includes the final slash "/".
|
-- @field #string path Path to the SRS exe. This includes the final slash "/".
|
||||||
-- @field #string google Full path google credentials JSON file, e.g. "C:\Users\username\Downloads\service-account-file.json".
|
-- @field #string google Full path google credentials JSON file, e.g. "C:\Users\username\Downloads\service-account-file.json".
|
||||||
|
-- @field #string Label Label showing up on the SRS radio overlay. Default is "ROBOT". No spaces allowed.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- *It is a very sad thing that nowadays there is so little useless information.* - Oscar Wilde
|
--- *It is a very sad thing that nowadays there is so little useless information.* - Oscar Wilde
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- 
|
|
||||||
--
|
|
||||||
-- # The MSRS Concept
|
-- # The MSRS Concept
|
||||||
--
|
--
|
||||||
-- This class allows to broadcast sound files or text via Simple Radio Standalone (SRS).
|
-- This class allows to broadcast sound files or text via Simple Radio Standalone (SRS).
|
||||||
@@ -95,6 +94,14 @@
|
|||||||
-- For more information on setting up a cloud account, visit: https://cloud.google.com/text-to-speech
|
-- For more information on setting up a cloud account, visit: https://cloud.google.com/text-to-speech
|
||||||
-- Google's supported SSML reference: https://cloud.google.com/text-to-speech/docs/ssml
|
-- Google's supported SSML reference: https://cloud.google.com/text-to-speech/docs/ssml
|
||||||
--
|
--
|
||||||
|
-- **NOTE on using GOOGLE TTS with SRS:** You need to have the C# library installed in your SRS folder for Google to work.
|
||||||
|
-- You can obtain it e.g. here: [NuGet](https://www.nuget.org/packages/Grpc.Core)
|
||||||
|
--
|
||||||
|
-- **Pro-Tipp** - use the command line with power shell to call DCS-SR-ExternalAudio.exe - it will tell you what is missing.
|
||||||
|
-- and also the Google Console error, in case you have missed a step in setting up your Google TTS.
|
||||||
|
-- E.g. `.\DCS-SR-ExternalAudio.exe -t "Text Message" -f 255 -m AM -c 2 -s 2 -z -G "Path_To_You_Google.Json"`
|
||||||
|
-- Plays a message on 255AM for the blue coalition in-game.
|
||||||
|
--
|
||||||
-- ## Set Voice
|
-- ## Set Voice
|
||||||
--
|
--
|
||||||
-- Use a specifc voice with the @{#MSRS.SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
-- Use a specifc voice with the @{#MSRS.SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||||
@@ -106,6 +113,14 @@
|
|||||||
--
|
--
|
||||||
-- Use @{#MSRS.SetCoordinate} to define the origin from where the transmission is broadcasted.
|
-- Use @{#MSRS.SetCoordinate} to define the origin from where the transmission is broadcasted.
|
||||||
--
|
--
|
||||||
|
-- ## Set SRS Port
|
||||||
|
--
|
||||||
|
-- Use @{#MSRS.SetPort} to define the SRS port. Defaults to 5002.
|
||||||
|
--
|
||||||
|
-- ## Set SRS Volume
|
||||||
|
--
|
||||||
|
-- Use @{#MSRS.SetVolume} to define the SRS volume. Defaults to 1.0. Allowed values are between 0.0 and 1.0, from silent to loudest.
|
||||||
|
--
|
||||||
-- @field #MSRS
|
-- @field #MSRS
|
||||||
MSRS = {
|
MSRS = {
|
||||||
ClassName = "MSRS",
|
ClassName = "MSRS",
|
||||||
@@ -121,11 +136,113 @@ MSRS = {
|
|||||||
volume = 1,
|
volume = 1,
|
||||||
speed = 1,
|
speed = 1,
|
||||||
coordinate = nil,
|
coordinate = nil,
|
||||||
|
Label = "ROBOT",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MSRS class version.
|
--- MSRS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
MSRS.version="0.0.3"
|
MSRS.version="0.1.0"
|
||||||
|
|
||||||
|
--- Voices
|
||||||
|
-- @type Voices
|
||||||
|
MSRS.Voices = {
|
||||||
|
Microsoft = {
|
||||||
|
["Hedda"] = "Microsoft Hedda Desktop", -- de-DE
|
||||||
|
["Hazel"] = "Microsoft Hazel Desktop", -- en-GB
|
||||||
|
["David"] = "Microsoft David Desktop", -- en-US
|
||||||
|
["Zira"] = "Microsoft Zira Desktop", -- en-US
|
||||||
|
["Hortense"] = "Microsoft Hortense Desktop", --fr-FR
|
||||||
|
},
|
||||||
|
Google = {
|
||||||
|
Standard = {
|
||||||
|
["en-AU-Standard-A"] = 'en-AU-Standard-A', -- [1] FEMALE
|
||||||
|
["en-AU-Standard-B"] = 'en-AU-Standard-B', -- [2] MALE
|
||||||
|
["en-AU-Standard-C"] = 'en-AU-Standard-C', -- [3] FEMALE
|
||||||
|
["en-AU-Standard-D"] = 'en-AU-Standard-D', -- [4] MALE
|
||||||
|
["en-IN-Standard-A"] = 'en-IN-Standard-A', -- [5] FEMALE
|
||||||
|
["en-IN-Standard-B"] = 'en-IN-Standard-B', -- [6] MALE
|
||||||
|
["en-IN-Standard-C"] = 'en-IN-Standard-C', -- [7] MALE
|
||||||
|
["en-IN-Standard-D"] = 'en-IN-Standard-D', -- [8] FEMALE
|
||||||
|
["en-GB-Standard-A"] = 'en-GB-Standard-A', -- [9] FEMALE
|
||||||
|
["en-GB-Standard-B"] = 'en-GB-Standard-B', -- [10] MALE
|
||||||
|
["en-GB-Standard-C"] = 'en-GB-Standard-C', -- [11] FEMALE
|
||||||
|
["en-GB-Standard-D"] = 'en-GB-Standard-D', -- [12] MALE
|
||||||
|
["en-GB-Standard-F"] = 'en-GB-Standard-F', -- [13] FEMALE
|
||||||
|
["en-US-Standard-A"] = 'en-US-Standard-A', -- [14] MALE
|
||||||
|
["en-US-Standard-B"] = 'en-US-Standard-B', -- [15] MALE
|
||||||
|
["en-US-Standard-C"] = 'en-US-Standard-C', -- [16] FEMALE
|
||||||
|
["en-US-Standard-D"] = 'en-US-Standard-D', -- [17] MALE
|
||||||
|
["en-US-Standard-E"] = 'en-US-Standard-E', -- [18] FEMALE
|
||||||
|
["en-US-Standard-F"] = 'en-US-Standard-F', -- [19] FEMALE
|
||||||
|
["en-US-Standard-G"] = 'en-US-Standard-G', -- [20] FEMALE
|
||||||
|
["en-US-Standard-H"] = 'en-US-Standard-H', -- [21] FEMALE
|
||||||
|
["en-US-Standard-I"] = 'en-US-Standard-I', -- [22] MALE
|
||||||
|
["en-US-Standard-J"] = 'en-US-Standard-J', -- [23] MALE
|
||||||
|
["fr-FR-Standard-A"] = "fr-FR-Standard-A", -- Female
|
||||||
|
["fr-FR-Standard-B"] = "fr-FR-Standard-B", -- Male
|
||||||
|
["fr-FR-Standard-C"] = "fr-FR-Standard-C", -- Female
|
||||||
|
["fr-FR-Standard-D"] = "fr-FR-Standard-D", -- Male
|
||||||
|
["fr-FR-Standard-E"] = "fr-FR-Standard-E", -- Female
|
||||||
|
["de-DE-Standard-A"] = "de-DE-Standard-A", -- Female
|
||||||
|
["de-DE-Standard-B"] = "de-DE-Standard-B", -- Male
|
||||||
|
["de-DE-Standard-C"] = "de-DE-Standard-C", -- Female
|
||||||
|
["de-DE-Standard-D"] = "de-DE-Standard-D", -- Male
|
||||||
|
["de-DE-Standard-E"] = "de-DE-Standard-E", -- Male
|
||||||
|
["de-DE-Standard-F"] = "de-DE-Standard-F", -- Female
|
||||||
|
["es-ES-Standard-A"] = "es-ES-Standard-A", -- Female
|
||||||
|
["es-ES-Standard-B"] = "es-ES-Standard-B", -- Male
|
||||||
|
["es-ES-Standard-C"] = "es-ES-Standard-C", -- Female
|
||||||
|
["es-ES-Standard-D"] = "es-ES-Standard-D", -- Female
|
||||||
|
["it-IT-Standard-A"] = "it-IT-Standard-A", -- Female
|
||||||
|
["it-IT-Standard-B"] = "it-IT-Standard-B", -- Female
|
||||||
|
["it-IT-Standard-C"] = "it-IT-Standard-C", -- Male
|
||||||
|
["it-IT-Standard-D"] = "it-IT-Standard-D", -- Male
|
||||||
|
},
|
||||||
|
Wavenet = {
|
||||||
|
["en-AU-Wavenet-A"] = 'en-AU-Wavenet-A', -- [1] FEMALE
|
||||||
|
["en-AU-Wavenet-B"] = 'en-AU-Wavenet-B', -- [2] MALE
|
||||||
|
["en-AU-Wavenet-C"] = 'en-AU-Wavenet-C', -- [3] FEMALE
|
||||||
|
["en-AU-Wavenet-D"] = 'en-AU-Wavenet-D', -- [4] MALE
|
||||||
|
["en-IN-Wavenet-A"] = 'en-IN-Wavenet-A', -- [5] FEMALE
|
||||||
|
["en-IN-Wavenet-B"] = 'en-IN-Wavenet-B', -- [6] MALE
|
||||||
|
["en-IN-Wavenet-C"] = 'en-IN-Wavenet-C', -- [7] MALE
|
||||||
|
["en-IN-Wavenet-D"] = 'en-IN-Wavenet-D', -- [8] FEMALE
|
||||||
|
["en-GB-Wavenet-A"] = 'en-GB-Wavenet-A', -- [9] FEMALE
|
||||||
|
["en-GB-Wavenet-B"] = 'en-GB-Wavenet-B', -- [10] MALE
|
||||||
|
["en-GB-Wavenet-C"] = 'en-GB-Wavenet-C', -- [11] FEMALE
|
||||||
|
["en-GB-Wavenet-D"] = 'en-GB-Wavenet-D', -- [12] MALE
|
||||||
|
["en-GB-Wavenet-F"] = 'en-GB-Wavenet-F', -- [13] FEMALE
|
||||||
|
["en-US-Wavenet-A"] = 'en-US-Wavenet-A', -- [14] MALE
|
||||||
|
["en-US-Wavenet-B"] = 'en-US-Wavenet-B', -- [15] MALE
|
||||||
|
["en-US-Wavenet-C"] = 'en-US-Wavenet-C', -- [16] FEMALE
|
||||||
|
["en-US-Wavenet-D"] = 'en-US-Wavenet-D', -- [17] MALE
|
||||||
|
["en-US-Wavenet-E"] = 'en-US-Wavenet-E', -- [18] FEMALE
|
||||||
|
["en-US-Wavenet-F"] = 'en-US-Wavenet-F', -- [19] FEMALE
|
||||||
|
["en-US-Wavenet-G"] = 'en-US-Wavenet-G', -- [20] FEMALE
|
||||||
|
["en-US-Wavenet-H"] = 'en-US-Wavenet-H', -- [21] FEMALE
|
||||||
|
["en-US-Wavenet-I"] = 'en-US-Wavenet-I', -- [22] MALE
|
||||||
|
["en-US-Wavenet-J"] = 'en-US-Wavenet-J', -- [23] MALE
|
||||||
|
["fr-FR-Wavenet-A"] = "fr-FR-Wavenet-A", -- Female
|
||||||
|
["fr-FR-Wavenet-B"] = "fr-FR-Wavenet-B", -- Male
|
||||||
|
["fr-FR-Wavenet-C"] = "fr-FR-Wavenet-C", -- Female
|
||||||
|
["fr-FR-Wavenet-D"] = "fr-FR-Wavenet-D", -- Male
|
||||||
|
["fr-FR-Wavenet-E"] = "fr-FR-Wavenet-E", -- Female
|
||||||
|
["de-DE-Wavenet-A"] = "de-DE-Wavenet-A", -- Female
|
||||||
|
["de-DE-Wavenet-B"] = "de-DE-Wavenet-B", -- Male
|
||||||
|
["de-DE-Wavenet-C"] = "de-DE-Wavenet-C", -- Female
|
||||||
|
["de-DE-Wavenet-D"] = "de-DE-Wavenet-D", -- Male
|
||||||
|
["de-DE-Wavenet-E"] = "de-DE-Wavenet-E", -- Male
|
||||||
|
["de-DE-Wavenet-F"] = "de-DE-Wavenet-F", -- Female
|
||||||
|
["es-ES-Wavenet-B"] = "es-ES-Wavenet-B", -- Male
|
||||||
|
["es-ES-Wavenet-C"] = "es-ES-Wavenet-C", -- Female
|
||||||
|
["es-ES-Wavenet-D"] = "es-ES-Wavenet-D", -- Female
|
||||||
|
["it-IT-Wavenet-A"] = "it-IT-Wavenet-A", -- Female
|
||||||
|
["it-IT-Wavenet-B"] = "it-IT-Wavenet-B", -- Female
|
||||||
|
["it-IT-Wavenet-C"] = "it-IT-Wavenet-C", -- Male
|
||||||
|
["it-IT-Wavenet-D"] = "it-IT-Wavenet-D", -- Male
|
||||||
|
} ,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -144,8 +261,9 @@ MSRS.version="0.0.3"
|
|||||||
-- @param #string PathToSRS Path to the directory, where SRS is located.
|
-- @param #string PathToSRS Path to the directory, where SRS is located.
|
||||||
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz. Can also be given as a #table of multiple frequencies.
|
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz. Can also be given as a #table of multiple frequencies.
|
||||||
-- @param #number Modulation Radio modulation: 0=AM (default), 1=FM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators. Can also be given as a #table of multiple modulations.
|
-- @param #number Modulation Radio modulation: 0=AM (default), 1=FM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators. Can also be given as a #table of multiple modulations.
|
||||||
|
-- @param #number Volume Volume - 1.0 is max, 0.0 is silence
|
||||||
-- @return #MSRS self
|
-- @return #MSRS self
|
||||||
function MSRS:New(PathToSRS, Frequency, Modulation)
|
function MSRS:New(PathToSRS, Frequency, Modulation, Volume)
|
||||||
|
|
||||||
-- Defaults.
|
-- Defaults.
|
||||||
Frequency =Frequency or 143
|
Frequency =Frequency or 143
|
||||||
@@ -160,6 +278,13 @@ function MSRS:New(PathToSRS, Frequency, Modulation)
|
|||||||
self:SetModulations(Modulation)
|
self:SetModulations(Modulation)
|
||||||
self:SetGender()
|
self:SetGender()
|
||||||
self:SetCoalition()
|
self:SetCoalition()
|
||||||
|
self:SetLabel()
|
||||||
|
self:SetVolume()
|
||||||
|
self.lid = string.format("%s-%s | ", self.name, self.version)
|
||||||
|
|
||||||
|
if not io or not os then
|
||||||
|
self:E(self.lid.."***** ERROR - io or os NOT desanitized! MSRS will not work!")
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -202,12 +327,47 @@ function MSRS:GetPath()
|
|||||||
return self.path
|
return self.path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set SRS volume.
|
||||||
|
-- @param #MSRS self
|
||||||
|
-- @param #number Volume Volume - 1.0 is max, 0.0 is silence
|
||||||
|
-- @return #MSRS self
|
||||||
|
function MSRS:SetVolume(Volume)
|
||||||
|
local volume = Volume or 1
|
||||||
|
if volume > 1 then volume = 1 elseif volume < 0 then volume = 0 end
|
||||||
|
self.volume = volume
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get SRS volume.
|
||||||
|
-- @param #MSRS self
|
||||||
|
-- @return #number Volume Volume - 1.0 is max, 0.0 is silence
|
||||||
|
function MSRS:GetVolume()
|
||||||
|
return self.volume
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set label.
|
||||||
|
-- @param #MSRS self
|
||||||
|
-- @param #number Label. Default "ROBOT"
|
||||||
|
-- @return #MSRS self
|
||||||
|
function MSRS:SetLabel(Label)
|
||||||
|
self.Label=Label or "ROBOT"
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get label.
|
||||||
|
-- @param #MSRS self
|
||||||
|
-- @return #number Label.
|
||||||
|
function MSRS:GetLabel()
|
||||||
|
return self.Label
|
||||||
|
end
|
||||||
|
|
||||||
--- Set port.
|
--- Set port.
|
||||||
-- @param #MSRS self
|
-- @param #MSRS self
|
||||||
-- @param #number Port Port. Default 5002.
|
-- @param #number Port Port. Default 5002.
|
||||||
-- @return #MSRS self
|
-- @return #MSRS self
|
||||||
function MSRS:SetPort(Port)
|
function MSRS:SetPort(Port)
|
||||||
self.port=Port or 5002
|
self.port=Port or 5002
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get port.
|
--- Get port.
|
||||||
@@ -223,6 +383,7 @@ end
|
|||||||
-- @return #MSRS self
|
-- @return #MSRS self
|
||||||
function MSRS:SetCoalition(Coalition)
|
function MSRS:SetCoalition(Coalition)
|
||||||
self.coalition=Coalition or 0
|
self.coalition=Coalition or 0
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get coalition.
|
--- Get coalition.
|
||||||
@@ -391,22 +552,11 @@ function MSRS:PlaySoundFile(Soundfile, Delay)
|
|||||||
local command=self:_GetCommand()
|
local command=self:_GetCommand()
|
||||||
|
|
||||||
-- Append file.
|
-- Append file.
|
||||||
command=command.." --file="..tostring(soundfile)
|
command=command..' --file="'..tostring(soundfile)..'"'
|
||||||
|
|
||||||
|
-- Execute command.
|
||||||
self:_ExecCommand(command)
|
self:_ExecCommand(command)
|
||||||
|
|
||||||
--[[
|
|
||||||
|
|
||||||
command=command.." > bla.txt"
|
|
||||||
|
|
||||||
-- Debug output.
|
|
||||||
self:I(string.format("MSRS PlaySoundfile command=%s", command))
|
|
||||||
|
|
||||||
-- Execute SRS command.
|
|
||||||
local x=os.execute(command)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -432,16 +582,6 @@ function MSRS:PlaySoundText(SoundText, Delay)
|
|||||||
-- Execute command.
|
-- Execute command.
|
||||||
self:_ExecCommand(command)
|
self:_ExecCommand(command)
|
||||||
|
|
||||||
--[[
|
|
||||||
command=command.." > bla.txt"
|
|
||||||
|
|
||||||
-- Debug putput.
|
|
||||||
self:I(string.format("MSRS PlaySoundfile command=%s", command))
|
|
||||||
|
|
||||||
-- Execute SRS command.
|
|
||||||
local x=os.execute(command)
|
|
||||||
]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -467,37 +607,48 @@ function MSRS:PlayText(Text, Delay)
|
|||||||
-- Execute command.
|
-- Execute command.
|
||||||
self:_ExecCommand(command)
|
self:_ExecCommand(command)
|
||||||
|
|
||||||
--[[
|
end
|
||||||
|
|
||||||
-- Check that length of command is max 255 chars or os.execute() will not work!
|
return self
|
||||||
if string.len(command)>255 then
|
end
|
||||||
|
|
||||||
-- Create a tmp file.
|
--- Play text message via STTS with explicitly specified options.
|
||||||
local filename = os.getenv('TMP') .. "\\MSRS-"..STTS.uuid()..".bat"
|
-- @param #MSRS self
|
||||||
|
-- @param #string Text Text message.
|
||||||
|
-- @param #number Delay Delay in seconds, before the message is played.
|
||||||
|
-- @param #table Frequencies Radio frequencies.
|
||||||
|
-- @param #table Modulations Radio modulations.
|
||||||
|
-- @param #string Gender Gender.
|
||||||
|
-- @param #string Culture Culture.
|
||||||
|
-- @param #string Voice Voice.
|
||||||
|
-- @param #number Volume Volume.
|
||||||
|
-- @param #string Label Label.
|
||||||
|
-- @return #MSRS self
|
||||||
|
function MSRS:PlayTextExt(Text, Delay, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label)
|
||||||
|
|
||||||
local script = io.open(filename, "w+")
|
if Delay and Delay>0 then
|
||||||
script:write(command.." && exit")
|
self:ScheduleOnce(Delay, MSRS.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label)
|
||||||
script:close()
|
else
|
||||||
|
|
||||||
-- Play command.
|
|
||||||
command=string.format("\"%s\"", filename)
|
|
||||||
|
|
||||||
-- Play file in 0.05 seconds
|
|
||||||
timer.scheduleFunction(os.execute, command, timer.getTime()+0.05)
|
|
||||||
|
|
||||||
-- Remove file in 1 second.
|
|
||||||
timer.scheduleFunction(os.remove, filename, timer.getTime()+1)
|
|
||||||
else
|
|
||||||
|
|
||||||
-- Debug output.
|
|
||||||
self:I(string.format("MSRS Text command=%s", command))
|
|
||||||
|
|
||||||
-- Execute SRS command.
|
|
||||||
local x=os.execute(command)
|
|
||||||
|
|
||||||
|
-- Ensure table.
|
||||||
|
if Frequencies and type(Frequencies)~="table" then
|
||||||
|
Frequencies={Frequencies}
|
||||||
end
|
end
|
||||||
|
|
||||||
]]
|
-- Ensure table.
|
||||||
|
if Modulations and type(Modulations)~="table" then
|
||||||
|
Modulations={Modulations}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get command line.
|
||||||
|
local command=self:_GetCommand(Frequencies, Modulations, nil, Gender, Voice, Culture, Volume, nil, nil, Label)
|
||||||
|
|
||||||
|
-- Append text.
|
||||||
|
command=command..string.format(" --text=\"%s\"", tostring(Text))
|
||||||
|
|
||||||
|
-- Execute command.
|
||||||
|
self:_ExecCommand(command)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -634,8 +785,9 @@ end
|
|||||||
-- @param #number volume Volume.
|
-- @param #number volume Volume.
|
||||||
-- @param #number speed Speed.
|
-- @param #number speed Speed.
|
||||||
-- @param #number port Port.
|
-- @param #number port Port.
|
||||||
|
-- @param #string label Label, defaults to "ROBOT" (displayed sender name in the radio overlay of SRS) - No spaces allowed!
|
||||||
-- @return #string Command.
|
-- @return #string Command.
|
||||||
function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, speed, port)
|
function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, speed, port,label)
|
||||||
|
|
||||||
local path=self:GetPath() or STTS.DIRECTORY
|
local path=self:GetPath() or STTS.DIRECTORY
|
||||||
local exe=STTS.EXECUTABLE or "DCS-SR-ExternalAudio.exe"
|
local exe=STTS.EXECUTABLE or "DCS-SR-ExternalAudio.exe"
|
||||||
@@ -648,6 +800,7 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp
|
|||||||
volume=volume or self.volume
|
volume=volume or self.volume
|
||||||
speed=speed or self.speed
|
speed=speed or self.speed
|
||||||
port=port or self.port
|
port=port or self.port
|
||||||
|
label=label or self.Label
|
||||||
|
|
||||||
-- Replace modulation
|
-- Replace modulation
|
||||||
modus=modus:gsub("0", "AM")
|
modus=modus:gsub("0", "AM")
|
||||||
@@ -657,12 +810,12 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp
|
|||||||
--local command=string.format("%s --freqs=%s --modulations=%s --coalition=%d --port=%d --volume=%.2f --speed=%d", exe, freqs, modus, coal, port, volume, speed)
|
--local command=string.format("%s --freqs=%s --modulations=%s --coalition=%d --port=%d --volume=%.2f --speed=%d", exe, freqs, modus, coal, port, volume, speed)
|
||||||
|
|
||||||
-- Command from orig STTS script. Works better for some unknown reason!
|
-- Command from orig STTS script. Works better for some unknown reason!
|
||||||
local command=string.format("start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -h", path, exe, freqs, modus, coal, port, "ROBOT")
|
--local command=string.format("start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -h", path, exe, freqs, modus, coal, port, "ROBOT")
|
||||||
|
|
||||||
--local command=string.format('start /b "" /d "%s" "%s" -f %s -m %s -c %s -p %s -n "%s" > bla.txt', path, exe, freqs, modus, coal, port, "ROBOT")
|
--local command=string.format('start /b "" /d "%s" "%s" -f %s -m %s -c %s -p %s -n "%s" > bla.txt', path, exe, freqs, modus, coal, port, "ROBOT")
|
||||||
|
|
||||||
-- Command.
|
-- Command.
|
||||||
local command=string.format('%s/%s -f %s -m %s -c %s -p %s -n "%s"', path, exe, freqs, modus, coal, port, "ROBOT")
|
local command=string.format('"%s\\%s" -f %s -m %s -c %s -p %s -n "%s" -v "%.1f"', path, exe, freqs, modus, coal, port, label,volume)
|
||||||
|
|
||||||
-- Set voice or gender/culture.
|
-- Set voice or gender/culture.
|
||||||
if voice then
|
if voice then
|
||||||
@@ -671,7 +824,7 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp
|
|||||||
else
|
else
|
||||||
-- Add gender.
|
-- Add gender.
|
||||||
if gender and gender~="female" then
|
if gender and gender~="female" then
|
||||||
command=command..string.format(" --gender=%s", tostring(gender))
|
command=command..string.format(" -g %s", tostring(gender))
|
||||||
end
|
end
|
||||||
-- Add culture.
|
-- Add culture.
|
||||||
if culture and culture~="en-GB" then
|
if culture and culture~="en-GB" then
|
||||||
@@ -696,6 +849,353 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp
|
|||||||
return command
|
return command
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Manages radio transmissions.
|
||||||
|
--
|
||||||
|
-- The purpose of the MSRSQUEUE class is to manage SRS text-to-speech (TTS) messages using the MSRS class.
|
||||||
|
-- This can be used to submit multiple TTS messages and the class takes care that they are transmitted one after the other (and not overlapping).
|
||||||
|
--
|
||||||
|
-- @type MSRSQUEUE
|
||||||
|
-- @field #string ClassName Name of the class "MSRSQUEUE".
|
||||||
|
-- @field #string lid ID for dcs.log.
|
||||||
|
-- @field #table queue The queue of transmissions.
|
||||||
|
-- @field #string alias Name of the radio queue.
|
||||||
|
-- @field #number dt Time interval in seconds for checking the radio queue.
|
||||||
|
-- @field #number Tlast Time (abs) when the last transmission finished.
|
||||||
|
-- @field #boolean checking If `true`, the queue update function is scheduled to be called again.
|
||||||
|
-- @extends Core.Base#BASE
|
||||||
|
MSRSQUEUE = {
|
||||||
|
ClassName = "MSRSQUEUE",
|
||||||
|
Debugmode = nil,
|
||||||
|
lid = nil,
|
||||||
|
queue = {},
|
||||||
|
alias = nil,
|
||||||
|
dt = nil,
|
||||||
|
Tlast = nil,
|
||||||
|
checking = nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Radio queue transmission data.
|
||||||
|
-- @type MSRSQUEUE.Transmission
|
||||||
|
-- @field #string text Text to be transmitted.
|
||||||
|
-- @field Sound.SRS#MSRS msrs MOOSE SRS object.
|
||||||
|
-- @field #number duration Duration in seconds.
|
||||||
|
-- @field #table subgroups Groups to send subtitle to.
|
||||||
|
-- @field #string subtitle Subtitle of the transmission.
|
||||||
|
-- @field #number subduration Duration of the subtitle being displayed.
|
||||||
|
-- @field #number frequency Frequency.
|
||||||
|
-- @field #number modulation Modulation.
|
||||||
|
-- @field #number Tstarted Mission time (abs) in seconds when the transmission started.
|
||||||
|
-- @field #boolean isplaying If true, transmission is currently playing.
|
||||||
|
-- @field #number Tplay Mission time (abs) in seconds when the transmission should be played.
|
||||||
|
-- @field #number interval Interval in seconds before next transmission.
|
||||||
|
|
||||||
|
--- Create a new MSRSQUEUE object for a given radio frequency/modulation.
|
||||||
|
-- @param #MSRSQUEUE self
|
||||||
|
-- @param #string alias (Optional) Name of the radio queue.
|
||||||
|
-- @return #MSRSQUEUE self The MSRSQUEUE object.
|
||||||
|
function MSRSQUEUE:New(alias)
|
||||||
|
|
||||||
|
-- Inherit base
|
||||||
|
local self=BASE:Inherit(self, BASE:New()) --#MSRSQUEUE
|
||||||
|
|
||||||
|
self.alias=alias or "My Radio"
|
||||||
|
|
||||||
|
self.dt=1.0
|
||||||
|
|
||||||
|
self.lid=string.format("MSRSQUEUE %s | ", self.alias)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Clear the radio queue.
|
||||||
|
-- @param #MSRSQUEUE self
|
||||||
|
-- @return #MSRSQUEUE self The MSRSQUEUE object.
|
||||||
|
function MSRSQUEUE:Clear()
|
||||||
|
self:I(self.lid.."Clearning MSRSQUEUE")
|
||||||
|
self.queue={}
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Add a transmission to the radio queue.
|
||||||
|
-- @param #MSRSQUEUE self
|
||||||
|
-- @param #MSRSQUEUE.Transmission transmission The transmission data table.
|
||||||
|
-- @return #MSRSQUEUE self
|
||||||
|
function MSRSQUEUE:AddTransmission(transmission)
|
||||||
|
|
||||||
|
-- Init.
|
||||||
|
transmission.isplaying=false
|
||||||
|
transmission.Tstarted=nil
|
||||||
|
|
||||||
|
-- Add to queue.
|
||||||
|
table.insert(self.queue, transmission)
|
||||||
|
|
||||||
|
-- Start checking.
|
||||||
|
if not self.checking then
|
||||||
|
self:_CheckRadioQueue()
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Create a new transmission and add it to the radio queue.
|
||||||
|
-- @param #MSRSQUEUE self
|
||||||
|
-- @param #string text Text to play.
|
||||||
|
-- @param #number duration Duration in seconds the file lasts. Default is determined by number of characters of the text message.
|
||||||
|
-- @param Sound.SRS#MSRS msrs MOOSE SRS object.
|
||||||
|
-- @param #number tstart Start time (abs) seconds. Default now.
|
||||||
|
-- @param #number interval Interval in seconds after the last transmission finished.
|
||||||
|
-- @param #table subgroups Groups that should receive the subtiltle.
|
||||||
|
-- @param #string subtitle Subtitle displayed when the message is played.
|
||||||
|
-- @param #number subduration Duration [sec] of the subtitle being displayed. Default 5 sec.
|
||||||
|
-- @param #number frequency Radio frequency if other than MSRS default.
|
||||||
|
-- @param #number modulation Radio modulation if other then MSRS default.
|
||||||
|
-- @return #MSRSQUEUE.Transmission Radio transmission table.
|
||||||
|
function MSRSQUEUE:NewTransmission(text, duration, msrs, tstart, interval, subgroups, subtitle, subduration, frequency, modulation)
|
||||||
|
|
||||||
|
-- Sanity checks.
|
||||||
|
if not text then
|
||||||
|
self:E(self.lid.."ERROR: No text specified.")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
if type(text)~="string" then
|
||||||
|
self:E(self.lid.."ERROR: Text specified is NOT a string.")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Create a new transmission object.
|
||||||
|
local transmission={} --#MSRSQUEUE.Transmission
|
||||||
|
transmission.text=text
|
||||||
|
transmission.duration=duration or STTS.getSpeechTime(text)
|
||||||
|
transmission.msrs=msrs
|
||||||
|
transmission.Tplay=tstart or timer.getAbsTime()
|
||||||
|
transmission.subtitle=subtitle
|
||||||
|
transmission.interval=interval or 0
|
||||||
|
transmission.frequency=frequency
|
||||||
|
transmission.modulation=modulation
|
||||||
|
transmission.subgroups=subgroups
|
||||||
|
if transmission.subtitle then
|
||||||
|
transmission.subduration=subduration or transmission.duration
|
||||||
|
else
|
||||||
|
transmission.subduration=0 --nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add transmission to queue.
|
||||||
|
self:AddTransmission(transmission)
|
||||||
|
|
||||||
|
return transmission
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Broadcast radio message.
|
||||||
|
-- @param #MSRSQUEUE self
|
||||||
|
-- @param #MSRSQUEUE.Transmission transmission The transmission.
|
||||||
|
function MSRSQUEUE:Broadcast(transmission)
|
||||||
|
|
||||||
|
if transmission.frequency then
|
||||||
|
transmission.msrs:PlayTextExt(transmission.text, nil, transmission.frequency, transmission.modulation, Gender, Culture, Voice, Volume, Label)
|
||||||
|
else
|
||||||
|
transmission.msrs:PlayText(transmission.text)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function texttogroup(gid)
|
||||||
|
-- Text to group.
|
||||||
|
trigger.action.outTextForGroup(gid, transmission.subtitle, transmission.subduration, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if transmission.subgroups and #transmission.subgroups>0 then
|
||||||
|
|
||||||
|
for _,_group in pairs(transmission.subgroups) do
|
||||||
|
local group=_group --Wrapper.Group#GROUP
|
||||||
|
|
||||||
|
if group and group:IsAlive() then
|
||||||
|
local gid=group:GetID()
|
||||||
|
|
||||||
|
self:ScheduleOnce(4, texttogroup, gid)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculate total transmission duration of all transmission in the queue.
|
||||||
|
-- @param #MSRSQUEUE self
|
||||||
|
-- @return #number Total transmission duration.
|
||||||
|
function MSRSQUEUE:CalcTransmisstionDuration()
|
||||||
|
|
||||||
|
local Tnow=timer.getAbsTime()
|
||||||
|
|
||||||
|
local T=0
|
||||||
|
for _,_transmission in pairs(self.queue) do
|
||||||
|
local transmission=_transmission --#MSRSQUEUE.Transmission
|
||||||
|
|
||||||
|
if transmission.isplaying then
|
||||||
|
|
||||||
|
-- Playing for dt seconds.
|
||||||
|
local dt=Tnow-transmission.Tstarted
|
||||||
|
|
||||||
|
T=T+transmission.duration-dt
|
||||||
|
|
||||||
|
else
|
||||||
|
T=T+transmission.duration
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return T
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check radio queue for transmissions to be broadcasted.
|
||||||
|
-- @param #MSRSQUEUE self
|
||||||
|
-- @param #number delay Delay in seconds before checking.
|
||||||
|
function MSRSQUEUE:_CheckRadioQueue(delay)
|
||||||
|
|
||||||
|
-- Transmissions in queue.
|
||||||
|
local N=#self.queue
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T2(self.lid..string.format("Check radio queue %s: delay=%.3f sec, N=%d, checking=%s", self.alias, delay or 0, N, tostring(self.checking)))
|
||||||
|
|
||||||
|
if delay and delay>0 then
|
||||||
|
|
||||||
|
-- Delayed call.
|
||||||
|
self:ScheduleOnce(delay, MSRSQUEUE._CheckRadioQueue, self)
|
||||||
|
|
||||||
|
-- Checking on.
|
||||||
|
self.checking=true
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Check if queue is empty.
|
||||||
|
if N==0 then
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Check radio queue %s empty ==> disable checking", self.alias))
|
||||||
|
|
||||||
|
-- Queue is now empty. Nothing to else to do. We start checking again, if a transmission is added.
|
||||||
|
self.checking=false
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get current abs time.
|
||||||
|
local time=timer.getAbsTime()
|
||||||
|
|
||||||
|
-- Checking on.
|
||||||
|
self.checking=true
|
||||||
|
|
||||||
|
-- Set dt.
|
||||||
|
local dt=self.dt
|
||||||
|
|
||||||
|
|
||||||
|
local playing=false
|
||||||
|
local next=nil --#MSRSQUEUE.Transmission
|
||||||
|
local remove=nil
|
||||||
|
for i,_transmission in ipairs(self.queue) do
|
||||||
|
local transmission=_transmission --#MSRSQUEUE.Transmission
|
||||||
|
|
||||||
|
-- Check if transmission time has passed.
|
||||||
|
if time>=transmission.Tplay then
|
||||||
|
|
||||||
|
-- Check if transmission is currently playing.
|
||||||
|
if transmission.isplaying then
|
||||||
|
|
||||||
|
-- Check if transmission is finished.
|
||||||
|
if time>=transmission.Tstarted+transmission.duration then
|
||||||
|
|
||||||
|
-- Transmission over.
|
||||||
|
transmission.isplaying=false
|
||||||
|
|
||||||
|
-- Remove ith element in queue.
|
||||||
|
remove=i
|
||||||
|
|
||||||
|
-- Store time last transmission finished.
|
||||||
|
self.Tlast=time
|
||||||
|
|
||||||
|
else -- still playing
|
||||||
|
|
||||||
|
-- Transmission is still playing.
|
||||||
|
playing=true
|
||||||
|
|
||||||
|
dt=transmission.duration-(time-transmission.Tstarted)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
else -- not playing yet
|
||||||
|
|
||||||
|
local Tlast=self.Tlast
|
||||||
|
|
||||||
|
if transmission.interval==nil then
|
||||||
|
|
||||||
|
-- Not playing ==> this will be next.
|
||||||
|
if next==nil then
|
||||||
|
next=transmission
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
if Tlast==nil or time-Tlast>=transmission.interval then
|
||||||
|
next=transmission
|
||||||
|
else
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- We got a transmission or one with an interval that is not due yet. No need for anything else.
|
||||||
|
if next or Tlast then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Transmission not due yet.
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Found a new transmission.
|
||||||
|
if next~=nil and not playing then
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Broadcasting text=\"%s\" at T=%.3f", next.text, time))
|
||||||
|
|
||||||
|
-- Call SRS.
|
||||||
|
self:Broadcast(next)
|
||||||
|
|
||||||
|
next.isplaying=true
|
||||||
|
next.Tstarted=time
|
||||||
|
dt=next.duration
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Remove completed call from queue.
|
||||||
|
if remove then
|
||||||
|
-- Remove from queue.
|
||||||
|
table.remove(self.queue, remove)
|
||||||
|
N=N-1
|
||||||
|
|
||||||
|
-- Check if queue is empty.
|
||||||
|
if #self.queue==0 then
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Check radio queue %s empty ==> disable checking", self.alias))
|
||||||
|
|
||||||
|
self.checking=false
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check queue.
|
||||||
|
self:_CheckRadioQueue(dt)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -183,13 +183,17 @@ do -- Sound File
|
|||||||
|
|
||||||
--- Set path, where the sound file is located.
|
--- Set path, where the sound file is located.
|
||||||
-- @param #SOUNDFILE self
|
-- @param #SOUNDFILE self
|
||||||
-- @param #string Path Path to the directory, where the sound file is located.
|
-- @param #string Path Path to the directory, where the sound file is located. In case this is nil, it defaults to the DCS mission temp directory.
|
||||||
-- @return #SOUNDFILE self
|
-- @return #SOUNDFILE self
|
||||||
function SOUNDFILE:SetPath(Path)
|
function SOUNDFILE:SetPath(Path)
|
||||||
|
|
||||||
-- Init path.
|
-- Init path.
|
||||||
self.path=Path or "l10n/DEFAULT/"
|
self.path=Path or "l10n/DEFAULT/"
|
||||||
|
|
||||||
|
if not Path and self.useSRS then -- use path to mission temp dir
|
||||||
|
self.path = os.getenv('TMP') .. "\\DCS\\Mission\\l10n\\DEFAULT"
|
||||||
|
end
|
||||||
|
|
||||||
-- Remove (back)slashes.
|
-- Remove (back)slashes.
|
||||||
local nmax=1000 ; local n=1
|
local nmax=1000 ; local n=1
|
||||||
while (self.path:sub(-1)=="/" or self.path:sub(-1)==[[\]]) and n<=nmax do
|
while (self.path:sub(-1)=="/" or self.path:sub(-1)==[[\]]) and n<=nmax do
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ do -- UserSound
|
|||||||
-- @param #USERSOUND self
|
-- @param #USERSOUND self
|
||||||
-- @param #string UserSoundFileName The filename of the usersound.
|
-- @param #string UserSoundFileName The filename of the usersound.
|
||||||
-- @return #USERSOUND
|
-- @return #USERSOUND
|
||||||
function USERSOUND:New( UserSoundFileName ) --R2.3
|
function USERSOUND:New( UserSoundFileName )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, BASE:New() ) -- #USERSOUND
|
local self = BASE:Inherit( self, BASE:New() ) -- #USERSOUND
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ do -- UserSound
|
|||||||
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||||
-- BlueVictory:SetFileName( "BlueVictoryLoud.ogg" ) -- Set the BlueVictory to change the file name to play a louder sound.
|
-- BlueVictory:SetFileName( "BlueVictoryLoud.ogg" ) -- Set the BlueVictory to change the file name to play a louder sound.
|
||||||
--
|
--
|
||||||
function USERSOUND:SetFileName( UserSoundFileName ) --R2.3
|
function USERSOUND:SetFileName( UserSoundFileName )
|
||||||
|
|
||||||
self.UserSoundFileName = UserSoundFileName
|
self.UserSoundFileName = UserSoundFileName
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ do -- UserSound
|
|||||||
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||||
-- BlueVictory:ToAll() -- Play the sound that Blue has won.
|
-- BlueVictory:ToAll() -- Play the sound that Blue has won.
|
||||||
--
|
--
|
||||||
function USERSOUND:ToAll() --R2.3
|
function USERSOUND:ToAll()
|
||||||
|
|
||||||
trigger.action.outSound( self.UserSoundFileName )
|
trigger.action.outSound( self.UserSoundFileName )
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ do -- UserSound
|
|||||||
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||||
-- BlueVictory:ToCoalition( coalition.side.BLUE ) -- Play the sound that Blue has won to the blue coalition.
|
-- BlueVictory:ToCoalition( coalition.side.BLUE ) -- Play the sound that Blue has won to the blue coalition.
|
||||||
--
|
--
|
||||||
function USERSOUND:ToCoalition( Coalition ) --R2.3
|
function USERSOUND:ToCoalition( Coalition )
|
||||||
|
|
||||||
trigger.action.outSoundForCoalition(Coalition, self.UserSoundFileName )
|
trigger.action.outSoundForCoalition(Coalition, self.UserSoundFileName )
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ do -- UserSound
|
|||||||
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||||
-- BlueVictory:ToCountry( country.id.USA ) -- Play the sound that Blue has won to the USA country.
|
-- BlueVictory:ToCountry( country.id.USA ) -- Play the sound that Blue has won to the USA country.
|
||||||
--
|
--
|
||||||
function USERSOUND:ToCountry( Country ) --R2.3
|
function USERSOUND:ToCountry( Country )
|
||||||
|
|
||||||
trigger.action.outSoundForCountry( Country, self.UserSoundFileName )
|
trigger.action.outSoundForCountry( Country, self.UserSoundFileName )
|
||||||
|
|
||||||
@@ -123,9 +123,9 @@ do -- UserSound
|
|||||||
-- @usage
|
-- @usage
|
||||||
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||||
-- local PlayerGroup = GROUP:FindByName( "PlayerGroup" ) -- Search for the active group named "PlayerGroup", that contains a human player.
|
-- local PlayerGroup = GROUP:FindByName( "PlayerGroup" ) -- Search for the active group named "PlayerGroup", that contains a human player.
|
||||||
-- BlueVictory:ToGroup( PlayerGroup ) -- Play the sound that Blue has won to the player group.
|
-- BlueVictory:ToGroup( PlayerGroup ) -- Play the victory sound to the player group.
|
||||||
--
|
--
|
||||||
function USERSOUND:ToGroup( Group, Delay ) --R2.3
|
function USERSOUND:ToGroup( Group, Delay )
|
||||||
|
|
||||||
Delay=Delay or 0
|
Delay=Delay or 0
|
||||||
if Delay>0 then
|
if Delay>0 then
|
||||||
@@ -137,4 +137,26 @@ do -- UserSound
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Play the usersound to the given @{Wrapper.Unit}.
|
||||||
|
-- @param #USERSOUND self
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit The @{Wrapper.Unit} to play the usersound to.
|
||||||
|
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
|
||||||
|
-- @return #USERSOUND The usersound instance.
|
||||||
|
-- @usage
|
||||||
|
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||||
|
-- local PlayerUnit = UNIT:FindByName( "PlayerUnit" ) -- Search for the active unit named "PlayerUnit", a human player.
|
||||||
|
-- BlueVictory:ToUnit( PlayerUnit ) -- Play the victory sound to the player unit.
|
||||||
|
--
|
||||||
|
function USERSOUND:ToUnit( Unit, Delay )
|
||||||
|
|
||||||
|
Delay=Delay or 0
|
||||||
|
if Delay>0 then
|
||||||
|
SCHEDULER:New(nil, USERSOUND.ToUnit,{self, Unit}, Delay)
|
||||||
|
else
|
||||||
|
trigger.action.outSoundForUnit( Unit:GetID(), self.UserSoundFileName )
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -216,7 +216,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
|
|||||||
local MenuReporting = MENU_GROUP:New( EventGroup, "Missions Reports", CommandCenterMenu )
|
local MenuReporting = MENU_GROUP:New( EventGroup, "Missions Reports", CommandCenterMenu )
|
||||||
local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Status Report", MenuReporting, self.ReportSummary, self, EventGroup )
|
local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Status Report", MenuReporting, self.ReportSummary, self, EventGroup )
|
||||||
local MenuMissionsDetails = MENU_GROUP_COMMAND:New( EventGroup, "Missions Players Report", MenuReporting, self.ReportMissionsPlayers, self, EventGroup )
|
local MenuMissionsDetails = MENU_GROUP_COMMAND:New( EventGroup, "Missions Players Report", MenuReporting, self.ReportMissionsPlayers, self, EventGroup )
|
||||||
self:ReportSummary( EventGroup )
|
--self:ReportSummary( EventGroup )
|
||||||
local PlayerUnit = EventData.IniUnit
|
local PlayerUnit = EventData.IniUnit
|
||||||
for MissionID, Mission in pairs( self:GetMissions() ) do
|
for MissionID, Mission in pairs( self:GetMissions() ) do
|
||||||
local Mission = Mission -- Tasking.Mission#MISSION
|
local Mission = Mission -- Tasking.Mission#MISSION
|
||||||
@@ -560,9 +560,11 @@ function COMMANDCENTER:SetAutoAssignTasks( AutoAssign )
|
|||||||
self.AutoAssignTasks = AutoAssign or false
|
self.AutoAssignTasks = AutoAssign or false
|
||||||
|
|
||||||
if self.AutoAssignTasks == true then
|
if self.AutoAssignTasks == true then
|
||||||
self:ScheduleRepeat( 10, 30, 0, nil, self.AssignTasks, self )
|
self.autoAssignTasksScheduleID=self:ScheduleRepeat( 10, 30, 0, nil, self.AssignTasks, self )
|
||||||
else
|
else
|
||||||
self:ScheduleStop( self.AssignTasks )
|
self:ScheduleStop()
|
||||||
|
-- FF this is not the schedule ID
|
||||||
|
--self:ScheduleStop( self.AssignTasks )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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 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 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 #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
|
-- @return #MISSION self
|
||||||
function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition )
|
function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition )
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- 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.
|
-- ## 1.3) Join a Task.
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -683,6 +683,7 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
-- If no TaskPrefix is given, then "Transport" will be used as the prefix.
|
-- If no TaskPrefix is given, then "Transport" will be used as the prefix.
|
||||||
-- @param Core.SetCargo#SET_CARGO SetCargo The SetCargo to be transported.
|
-- @param Core.SetCargo#SET_CARGO SetCargo The SetCargo to be transported.
|
||||||
-- @param #string Briefing The briefing of the task transport to be shown to the player.
|
-- @param #string Briefing The briefing of the task transport to be shown to the player.
|
||||||
|
-- @param #boolean Silent If true don't send a message that a new task is available.
|
||||||
-- @return Tasking.Task_Cargo_Transport#TASK_CARGO_TRANSPORT
|
-- @return Tasking.Task_Cargo_Transport#TASK_CARGO_TRANSPORT
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
@@ -705,10 +706,12 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
-- -- Here we set a TransportDeployZone. We use the WorkplaceTask as the reference, and provide a ZONE object.
|
-- -- Here we set a TransportDeployZone. We use the WorkplaceTask as the reference, and provide a ZONE object.
|
||||||
-- TaskDispatcher:SetTransportDeployZone( WorkplaceTask, ZONE:New( "Workplace" ) )
|
-- TaskDispatcher:SetTransportDeployZone( WorkplaceTask, ZONE:New( "Workplace" ) )
|
||||||
--
|
--
|
||||||
function TASK_CARGO_DISPATCHER:AddTransportTask( TaskPrefix, SetCargo, Briefing )
|
function TASK_CARGO_DISPATCHER:AddTransportTask( TaskPrefix, SetCargo, Briefing, Silent )
|
||||||
|
|
||||||
self.TransportCount = self.TransportCount + 1
|
self.TransportCount = self.TransportCount + 1
|
||||||
|
|
||||||
|
local verbose = Silent or false
|
||||||
|
|
||||||
local TaskName = string.format( ( TaskPrefix or "Transport" ) .. ".%03d", self.TransportCount )
|
local TaskName = string.format( ( TaskPrefix or "Transport" ) .. ".%03d", self.TransportCount )
|
||||||
|
|
||||||
self.Transport[TaskName] = {}
|
self.Transport[TaskName] = {}
|
||||||
@@ -717,7 +720,7 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
self.Transport[TaskName].Task = nil
|
self.Transport[TaskName].Task = nil
|
||||||
self.Transport[TaskName].TaskPrefix = TaskPrefix
|
self.Transport[TaskName].TaskPrefix = TaskPrefix
|
||||||
|
|
||||||
self:ManageTasks()
|
self:ManageTasks(verbose)
|
||||||
|
|
||||||
return self.Transport[TaskName] and self.Transport[TaskName].Task
|
return self.Transport[TaskName] and self.Transport[TaskName].Task
|
||||||
end
|
end
|
||||||
@@ -785,10 +788,11 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
|
|
||||||
--- Assigns tasks to the @{Core.Set#SET_GROUP}.
|
--- Assigns tasks to the @{Core.Set#SET_GROUP}.
|
||||||
-- @param #TASK_CARGO_DISPATCHER self
|
-- @param #TASK_CARGO_DISPATCHER self
|
||||||
|
-- @param #boolean Silent Announce new task (nil/false) or not (true).
|
||||||
-- @return #boolean Return true if you want the task assigning to continue... false will cancel the loop.
|
-- @return #boolean Return true if you want the task assigning to continue... false will cancel the loop.
|
||||||
function TASK_CARGO_DISPATCHER:ManageTasks()
|
function TASK_CARGO_DISPATCHER:ManageTasks(Silent)
|
||||||
self:F()
|
self:F()
|
||||||
|
local verbose = Silent and true
|
||||||
local AreaMsg = {}
|
local AreaMsg = {}
|
||||||
local TaskMsg = {}
|
local TaskMsg = {}
|
||||||
local ChangeMsg = {}
|
local ChangeMsg = {}
|
||||||
@@ -897,7 +901,7 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
local TaskText = TaskReport:Text(", ")
|
local TaskText = TaskReport:Text(", ")
|
||||||
|
|
||||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||||
if ( not Mission:IsGroupAssigned(TaskGroup) ) and TaskText ~= "" then
|
if ( not Mission:IsGroupAssigned(TaskGroup) ) and TaskText ~= "" and not verbose then
|
||||||
Mission:GetCommandCenter():MessageToGroup( string.format( "%s has tasks %s. Subscribe to a task using the radio menu.", Mission:GetShortText(), TaskText ), TaskGroup )
|
Mission:GetCommandCenter():MessageToGroup( string.format( "%s has tasks %s. Subscribe to a task using the radio menu.", Mission:GetShortText(), TaskText ), TaskGroup )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
--
|
--
|
||||||
-- **Specific features:**
|
-- **Specific features:**
|
||||||
--
|
--
|
||||||
-- * Creates a task to transport @{Cargo.Cargo} to and between deployment zones.
|
-- * Creates a task to transport #Cargo.Cargo to and between deployment zones.
|
||||||
-- * Derived from the TASK_CARGO class, which is derived from the TASK class.
|
-- * Derived from the TASK_CARGO class, which is derived from the TASK class.
|
||||||
-- * Orchestrate the task flow, so go from Planned to Assigned to Success, Failed or Cancelled.
|
-- * Orchestrate the task flow, so go from Planned to Assigned to Success, Failed or Cancelled.
|
||||||
-- * Co-operation tasking, so a player joins a group of players executing the same task.
|
-- * Co-operation tasking, so a player joins a group of players executing the same task.
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- Please read through the @{Tasking.Task_Cargo} process to understand the mechanisms of tasking and cargo tasking and handling.
|
-- Please read through the #Tasking.Task_Cargo process to understand the mechanisms of tasking and cargo tasking and handling.
|
||||||
--
|
--
|
||||||
-- Enjoy!
|
-- Enjoy!
|
||||||
-- FC
|
-- FC
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
do -- TASK_CARGO_TRANSPORT
|
do -- TASK_CARGO_TRANSPORT
|
||||||
|
|
||||||
--- @type TASK_CARGO_TRANSPORT
|
-- @type TASK_CARGO_TRANSPORT
|
||||||
-- @extends Tasking.Task_CARGO#TASK_CARGO
|
-- @extends Tasking.Task_CARGO#TASK_CARGO
|
||||||
|
|
||||||
--- Orchestrates the task for players to transport cargo to or between deployment zones.
|
--- Orchestrates the task for players to transport cargo to or between deployment zones.
|
||||||
@@ -76,7 +76,7 @@ do -- TASK_CARGO_TRANSPORT
|
|||||||
--
|
--
|
||||||
-- ## 1.1) Create a command center.
|
-- ## 1.1) Create a command center.
|
||||||
--
|
--
|
||||||
-- First you need to create a command center using the @{Tasking.CommandCenter#COMMANDCENTER.New}() constructor.
|
-- First you need to create a command center using the Tasking.CommandCenter#COMMANDCENTER.New constructor.
|
||||||
--
|
--
|
||||||
-- local CommandCenter = COMMANDCENTER
|
-- local CommandCenter = COMMANDCENTER
|
||||||
-- :New( HQ, "Lima" ) -- Create the CommandCenter.
|
-- :New( HQ, "Lima" ) -- Create the CommandCenter.
|
||||||
@@ -85,7 +85,7 @@ do -- TASK_CARGO_TRANSPORT
|
|||||||
--
|
--
|
||||||
-- Tasks work in a mission, which groups these tasks to achieve a joint mission goal.
|
-- Tasks work in a mission, which groups these tasks to achieve a joint mission goal.
|
||||||
-- A command center can govern multiple missions.
|
-- A command center can govern multiple missions.
|
||||||
-- Create a new mission, using the @{Tasking.Mission#MISSION.New}() constructor.
|
-- Create a new mission, using the Tasking.Mission#MISSION.New constructor.
|
||||||
--
|
--
|
||||||
-- -- Declare the Mission for the Command Center.
|
-- -- Declare the Mission for the Command Center.
|
||||||
-- local Mission = MISSION
|
-- local Mission = MISSION
|
||||||
@@ -99,7 +99,7 @@ do -- TASK_CARGO_TRANSPORT
|
|||||||
-- ## 1.3) Create the transport cargo task.
|
-- ## 1.3) Create the transport cargo task.
|
||||||
--
|
--
|
||||||
-- So, now that we have a command center and a mission, we now create the transport task.
|
-- So, now that we have a command center and a mission, we now create the transport task.
|
||||||
-- We create the transport task using the @{#TASK_CARGO_TRANSPORT.New}() constructor.
|
-- We create the transport task using the #TASK_CARGO_TRANSPORT.New constructor.
|
||||||
--
|
--
|
||||||
-- Because a transport task will not generate the cargo itself, you'll need to create it first.
|
-- Because a transport task will not generate the cargo itself, you'll need to create it first.
|
||||||
-- The cargo in this case will be the downed pilot!
|
-- The cargo in this case will be the downed pilot!
|
||||||
@@ -118,7 +118,7 @@ do -- TASK_CARGO_TRANSPORT
|
|||||||
-- -- The cargoset "CargoSet" will embed all defined cargo of type "Pilots" (prefix) into its set.
|
-- -- The cargoset "CargoSet" will embed all defined cargo of type "Pilots" (prefix) into its set.
|
||||||
-- local CargoGroup = CARGO_GROUP:New( PilotGroup, "Cargo", "Engineer Team 1", 500 )
|
-- local CargoGroup = CARGO_GROUP:New( PilotGroup, "Cargo", "Engineer Team 1", 500 )
|
||||||
--
|
--
|
||||||
-- What is also needed, is to have a set of @{Core.Group}s defined that contains the clients of the players.
|
-- What is also needed, is to have a set of Core.Groups defined that contains the clients of the players.
|
||||||
--
|
--
|
||||||
-- -- Allocate the Transport, which are the helicopter to retrieve the pilot, that can be manned by players.
|
-- -- Allocate the Transport, which are the helicopter to retrieve the pilot, that can be manned by players.
|
||||||
-- local GroupSet = SET_GROUP:New():FilterPrefixes( "Transport" ):FilterStart()
|
-- local GroupSet = SET_GROUP:New():FilterPrefixes( "Transport" ):FilterStart()
|
||||||
@@ -139,48 +139,48 @@ do -- TASK_CARGO_TRANSPORT
|
|||||||
-- By doing this, cargo transport tasking will become a dynamic experience.
|
-- By doing this, cargo transport tasking will become a dynamic experience.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- # 2) Create a task using the @{Tasking.Task_Cargo_Dispatcher} module.
|
-- # 2) Create a task using the Tasking.Task_Cargo_Dispatcher module.
|
||||||
--
|
--
|
||||||
-- Actually, it is better to **GENERATE** these tasks using the @{Tasking.Task_Cargo_Dispatcher} module.
|
-- Actually, it is better to **GENERATE** these tasks using the Tasking.Task_Cargo_Dispatcher module.
|
||||||
-- Using the dispatcher module, transport tasks can be created much more easy.
|
-- Using the dispatcher module, transport tasks can be created easier.
|
||||||
--
|
--
|
||||||
-- Find below an example how to use the TASK_CARGO_DISPATCHER class:
|
-- Find below an example how to use the TASK_CARGO_DISPATCHER class:
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- -- Find the HQ group.
|
-- -- Find the HQ group.
|
||||||
-- HQ = GROUP:FindByName( "HQ", "Bravo" )
|
-- HQ = GROUP:FindByName( "HQ", "Bravo" )
|
||||||
--
|
--
|
||||||
-- -- Create the command center with the name "Lima".
|
-- -- Create the command center with the name "Lima".
|
||||||
-- CommandCenter = COMMANDCENTER
|
-- CommandCenter = COMMANDCENTER
|
||||||
-- :New( HQ, "Lima" )
|
-- :New( HQ, "Lima" )
|
||||||
--
|
--
|
||||||
-- -- Create the mission, for the command center, with the name "Operation Cargo Fun", a "Tactical" mission, with the mission briefing "Transport Cargo", for the BLUE coalition.
|
-- -- Create the mission, for the command center, with the name "Operation Cargo Fun", a "Tactical" mission, with the mission briefing "Transport Cargo", for the BLUE coalition.
|
||||||
-- Mission = MISSION
|
-- Mission = MISSION
|
||||||
-- :New( CommandCenter, "Operation Cargo Fun", "Tactical", "Transport Cargo", coalition.side.BLUE )
|
-- :New( CommandCenter, "Operation Cargo Fun", "Tactical", "Transport Cargo", coalition.side.BLUE )
|
||||||
--
|
--
|
||||||
-- -- Create the SET of GROUPs containing clients (players) that will transport the cargo.
|
-- -- Create the SET of GROUPs containing clients (players) that will transport the cargo.
|
||||||
-- -- These are have a name that start with "Transport" and are of the "blue" coalition.
|
-- -- These are have a name that start with "Transport" and are of the "blue" coalition.
|
||||||
-- TransportGroups = SET_GROUP:New():FilterCoalitions( "blue" ):FilterPrefixes( "Transport" ):FilterStart()
|
-- TransportGroups = SET_GROUP:New():FilterCoalitions( "blue" ):FilterPrefixes( "Transport" ):FilterStart()
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- -- Here we create the TASK_CARGO_DISPATCHER object! This is where we assign the dispatcher to generate tasks in the Mission for the TransportGroups.
|
-- -- Here we create the TASK_CARGO_DISPATCHER object! This is where we assign the dispatcher to generate tasks in the Mission for the TransportGroups.
|
||||||
-- TaskDispatcher = TASK_CARGO_DISPATCHER:New( Mission, TransportGroups )
|
-- TaskDispatcher = TASK_CARGO_DISPATCHER:New( Mission, TransportGroups )
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- -- Here we declare the SET of CARGOs called "Workmaterials".
|
-- -- Here we declare the SET of CARGOs called "Workmaterials".
|
||||||
-- local CargoSetWorkmaterials = SET_CARGO:New():FilterTypes( "Workmaterials" ):FilterStart()
|
-- local CargoSetWorkmaterials = SET_CARGO:New():FilterTypes( "Workmaterials" ):FilterStart()
|
||||||
--
|
--
|
||||||
-- -- Here we declare (add) CARGO_GROUP objects of various types, that are filtered and added in the CargoSetworkmaterials cargo set.
|
-- -- Here we declare (add) CARGO_GROUP objects of various types, that are filtered and added in the CargoSetworkmaterials cargo set.
|
||||||
-- -- These cargo objects have the type "Workmaterials" which is exactly the type of cargo the CargoSetworkmaterials is filtering on.
|
-- -- These cargo objects have the type "Workmaterials" which is exactly the type of cargo the CargoSetworkmaterials is filtering on.
|
||||||
-- local EngineerCargoGroup = CARGO_GROUP:New( GROUP:FindByName( "Engineers" ), "Workmaterials", "Engineers", 250 )
|
-- local EngineerCargoGroup = CARGO_GROUP:New( GROUP:FindByName( "Engineers" ), "Workmaterials", "Engineers", 250 )
|
||||||
-- local ConcreteCargo = CARGO_SLINGLOAD:New( STATIC:FindByName( "Concrete" ), "Workmaterials", "Concrete", 150, 50 )
|
-- local ConcreteCargo = CARGO_SLINGLOAD:New( STATIC:FindByName( "Concrete" ), "Workmaterials", "Concrete", 150, 50 )
|
||||||
-- local CrateCargo = CARGO_CRATE:New( STATIC:FindByName( "Crate" ), "Workmaterials", "Crate", 150, 50 )
|
-- local CrateCargo = CARGO_CRATE:New( STATIC:FindByName( "Crate" ), "Workmaterials", "Crate", 150, 50 )
|
||||||
-- local EnginesCargo = CARGO_CRATE:New( STATIC:FindByName( "Engines" ), "Workmaterials", "Engines", 150, 50 )
|
-- local EnginesCargo = CARGO_CRATE:New( STATIC:FindByName( "Engines" ), "Workmaterials", "Engines", 150, 50 )
|
||||||
-- local MetalCargo = CARGO_CRATE:New( STATIC:FindByName( "Metal" ), "Workmaterials", "Metal", 150, 50 )
|
-- local MetalCargo = CARGO_CRATE:New( STATIC:FindByName( "Metal" ), "Workmaterials", "Metal", 150, 50 )
|
||||||
--
|
--
|
||||||
-- -- And here we create a new WorkplaceTask, using the :AddTransportTask method of the TaskDispatcher.
|
-- -- And here we create a new WorkplaceTask, using the :AddTransportTask method of the TaskDispatcher.
|
||||||
-- local WorkplaceTask = TaskDispatcher:AddTransportTask( "Build a Workplace", CargoSetWorkmaterials, "Transport the workers, engineers and the equipment near the Workplace." )
|
-- local WorkplaceTask = TaskDispatcher:AddTransportTask( "Build a Workplace", CargoSetWorkmaterials, "Transport the workers, engineers and the equipment near the Workplace." )
|
||||||
-- TaskDispatcher:SetTransportDeployZone( WorkplaceTask, ZONE:New( "Workplace" ) )
|
-- TaskDispatcher:SetTransportDeployZone( WorkplaceTask, ZONE:New( "Workplace" ) )
|
||||||
--
|
--
|
||||||
-- # 3) Handle cargo task events.
|
-- # 3) Handle cargo task events.
|
||||||
--
|
--
|
||||||
@@ -189,7 +189,7 @@ do -- TASK_CARGO_TRANSPORT
|
|||||||
-- In order to properly capture the events and avoid mistakes using the documentation, it is advised that you execute the following actions:
|
-- In order to properly capture the events and avoid mistakes using the documentation, it is advised that you execute the following actions:
|
||||||
--
|
--
|
||||||
-- * **Copy / Paste** the code section into your script.
|
-- * **Copy / Paste** the code section into your script.
|
||||||
-- * **Change** the CLASS literal to the task object name you have in your script.
|
-- * **Change** the "myclass" literal to the task object name you have in your script.
|
||||||
-- * Within the function, you can now **write your own code**!
|
-- * Within the function, you can now **write your own code**!
|
||||||
-- * **IntelliSense** will recognize the type of the variables provided by the function. Note: the From, Event and To variables can be safely ignored,
|
-- * **IntelliSense** will recognize the type of the variables provided by the function. Note: the From, Event and To variables can be safely ignored,
|
||||||
-- but you need to declare them as they are automatically provided by the event handling system of MOOSE.
|
-- but you need to declare them as they are automatically provided by the event handling system of MOOSE.
|
||||||
@@ -210,14 +210,13 @@ do -- TASK_CARGO_TRANSPORT
|
|||||||
-- If you want to code your own event handler, use this code fragment to tailor the event when a player carrier has picked up a cargo object in the CarrierGroup.
|
-- If you want to code your own event handler, use this code fragment to tailor the event when a player carrier has picked up a cargo object in the CarrierGroup.
|
||||||
-- You can use this event handler to post messages to players, or provide status updates etc.
|
-- You can use this event handler to post messages to players, or provide status updates etc.
|
||||||
--
|
--
|
||||||
-- --- CargoPickedUp event handler OnAfter for CLASS.
|
-- --- CargoPickedUp event handler OnAfter for "myclass".
|
||||||
-- -- @param #CLASS self
|
|
||||||
-- -- @param #string From A string that contains the "*from state name*" when the event was triggered.
|
-- -- @param #string From A string that contains the "*from state name*" when the event was triggered.
|
||||||
-- -- @param #string Event A string that contains the "*event name*" when the event was triggered.
|
-- -- @param #string Event A string that contains the "*event name*" when the event was triggered.
|
||||||
-- -- @param #string To A string that contains the "*to state name*" when the event was triggered.
|
-- -- @param #string To A string that contains the "*to state name*" when the event was triggered.
|
||||||
-- -- @param Wrapper.Unit#UNIT TaskUnit The unit (client) of the player that has picked up the cargo.
|
-- -- @param Wrapper.Unit#UNIT TaskUnit The unit (client) of the player that has picked up the cargo.
|
||||||
-- -- @param Cargo.Cargo#CARGO Cargo The cargo object that has been picked up. Note that this can be a CARGO_GROUP, CARGO_CRATE or CARGO_SLINGLOAD object!
|
-- -- @param Cargo.Cargo#CARGO Cargo The cargo object that has been picked up. Note that this can be a CARGO_GROUP, CARGO_CRATE or CARGO_SLINGLOAD object!
|
||||||
-- function CLASS:OnAfterCargoPickedUp( From, Event, To, TaskUnit, Cargo )
|
-- function myclass:OnAfterCargoPickedUp( From, Event, To, TaskUnit, Cargo )
|
||||||
--
|
--
|
||||||
-- -- Write here your own code.
|
-- -- Write here your own code.
|
||||||
--
|
--
|
||||||
@@ -240,15 +239,14 @@ do -- TASK_CARGO_TRANSPORT
|
|||||||
-- You can use this event handler to post messages to players, or provide status updates etc.
|
-- You can use this event handler to post messages to players, or provide status updates etc.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- --- CargoDeployed event handler OnAfter for CLASS.
|
-- --- CargoDeployed event handler OnAfter foR "myclass".
|
||||||
-- -- @param #CLASS self
|
|
||||||
-- -- @param #string From A string that contains the "*from state name*" when the event was triggered.
|
-- -- @param #string From A string that contains the "*from state name*" when the event was triggered.
|
||||||
-- -- @param #string Event A string that contains the "*event name*" when the event was triggered.
|
-- -- @param #string Event A string that contains the "*event name*" when the event was triggered.
|
||||||
-- -- @param #string To A string that contains the "*to state name*" when the event was triggered.
|
-- -- @param #string To A string that contains the "*to state name*" when the event was triggered.
|
||||||
-- -- @param Wrapper.Unit#UNIT TaskUnit The unit (client) of the player that has deployed the cargo.
|
-- -- @param Wrapper.Unit#UNIT TaskUnit The unit (client) of the player that has deployed the cargo.
|
||||||
-- -- @param Cargo.Cargo#CARGO Cargo The cargo object that has been deployed. Note that this can be a CARGO_GROUP, CARGO_CRATE or CARGO_SLINGLOAD object!
|
-- -- @param Cargo.Cargo#CARGO Cargo The cargo object that has been deployed. Note that this can be a CARGO_GROUP, CARGO_CRATE or CARGO_SLINGLOAD object!
|
||||||
-- -- @param Core.Zone#ZONE DeployZone The zone wherein the cargo is deployed. This can be any zone type, like a ZONE, ZONE_GROUP, ZONE_AIRBASE.
|
-- -- @param Core.Zone#ZONE DeployZone The zone wherein the cargo is deployed. This can be any zone type, like a ZONE, ZONE_GROUP, ZONE_AIRBASE.
|
||||||
-- function CLASS:OnAfterCargoDeployed( From, Event, To, TaskUnit, Cargo, DeployZone )
|
-- function myclass:OnAfterCargoDeployed( From, Event, To, TaskUnit, Cargo, DeployZone )
|
||||||
--
|
--
|
||||||
-- -- Write here your own code.
|
-- -- Write here your own code.
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -30,16 +30,16 @@ ENUMS = {}
|
|||||||
-- @type ENUMS.ROE
|
-- @type ENUMS.ROE
|
||||||
-- @field #number WeaponFree AI will engage any enemy group it detects. Target prioritization is based based on the threat of the target.
|
-- @field #number WeaponFree AI will engage any enemy group it detects. Target prioritization is based based on the threat of the target.
|
||||||
-- @field #number OpenFireWeaponFree AI will engage any enemy group it detects, but will prioritize targets specified in the groups tasking.
|
-- @field #number OpenFireWeaponFree AI will engage any enemy group it detects, but will prioritize targets specified in the groups tasking.
|
||||||
-- @field #number OpenFire AI will engage only targets specified in its tasking.
|
-- @field #number OpenFire AI will engage only targets specified in its taskings.
|
||||||
-- @field #number ReturnFire AI will only engage threats that shoot first.
|
-- @field #number ReturnFire AI will only engage threats that shoot first.
|
||||||
-- @field #number WeaponHold AI will hold fire under all circumstances.
|
-- @field #number WeaponHold AI will hold fire under all circumstances.
|
||||||
ENUMS.ROE = {
|
ENUMS.ROE = {
|
||||||
WeaponFree = 0,
|
WeaponFree=0,
|
||||||
OpenFireWeaponFree = 1,
|
OpenFireWeaponFree=1,
|
||||||
OpenFire = 2,
|
OpenFire=2,
|
||||||
ReturnFire = 3,
|
ReturnFire=3,
|
||||||
WeaponHold = 4,
|
WeaponHold=4,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Reaction On Threat.
|
--- Reaction On Threat.
|
||||||
-- @type ENUMS.ROT
|
-- @type ENUMS.ROT
|
||||||
@@ -49,11 +49,11 @@ ENUMS.ROE = {
|
|||||||
-- @field #number BypassAndEscape AI will attempt to avoid enemy threat zones all together. This includes attempting to fly above or around threats.
|
-- @field #number BypassAndEscape AI will attempt to avoid enemy threat zones all together. This includes attempting to fly above or around threats.
|
||||||
-- @field #number AllowAbortMission If a threat is deemed severe enough the AI will abort its mission and return to base.
|
-- @field #number AllowAbortMission If a threat is deemed severe enough the AI will abort its mission and return to base.
|
||||||
ENUMS.ROT = {
|
ENUMS.ROT = {
|
||||||
NoReaction = 0,
|
NoReaction=0,
|
||||||
PassiveDefense = 1,
|
PassiveDefense=1,
|
||||||
EvadeFire = 2,
|
EvadeFire=2,
|
||||||
BypassAndEscape = 3,
|
BypassAndEscape=3,
|
||||||
AllowAbortMission = 4,
|
AllowAbortMission=4,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Alarm state.
|
--- Alarm state.
|
||||||
@@ -62,12 +62,12 @@ ENUMS.ROT = {
|
|||||||
-- @field #number Green Group is not combat ready. Sensors are stowed if possible.
|
-- @field #number Green Group is not combat ready. Sensors are stowed if possible.
|
||||||
-- @field #number Red Group is combat ready and actively searching for targets. Some groups like infantry will not move in this state.
|
-- @field #number Red Group is combat ready and actively searching for targets. Some groups like infantry will not move in this state.
|
||||||
ENUMS.AlarmState = {
|
ENUMS.AlarmState = {
|
||||||
Auto = 0,
|
Auto=0,
|
||||||
Green = 1,
|
Green=1,
|
||||||
Red = 2,
|
Red=2,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Weapon types. See the [Weapon Flag](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) enumerator on Hoggit wiki.
|
--- Weapon types. See the [Weapon Flag](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) enumerotor on hoggit wiki.
|
||||||
-- @type ENUMS.WeaponFlag
|
-- @type ENUMS.WeaponFlag
|
||||||
ENUMS.WeaponFlag={
|
ENUMS.WeaponFlag={
|
||||||
-- Bombs
|
-- Bombs
|
||||||
@@ -111,7 +111,7 @@ ENUMS.WeaponFlag={
|
|||||||
--
|
--
|
||||||
-- Bombs
|
-- Bombs
|
||||||
GuidedBomb = 14, -- (LGB + TvGB + SNSGB)
|
GuidedBomb = 14, -- (LGB + TvGB + SNSGB)
|
||||||
AnyUnguidedBomb = 2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispenser + CandleBomb + ParachuteBomb)
|
AnyUnguidedBomb = 2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb)
|
||||||
AnyBomb = 2147485694, -- (GuidedBomb + AnyUnguidedBomb)
|
AnyBomb = 2147485694, -- (GuidedBomb + AnyUnguidedBomb)
|
||||||
--- Rockets
|
--- Rockets
|
||||||
AnyRocket = 30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket
|
AnyRocket = 30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket
|
||||||
@@ -126,6 +126,8 @@ ENUMS.WeaponFlag={
|
|||||||
AnyMissile = 268402688, -- AnyASM + AnyAAM
|
AnyMissile = 268402688, -- AnyASM + AnyAAM
|
||||||
--- Guns
|
--- Guns
|
||||||
Cannons = 805306368, -- GUN_POD + BuiltInCannon
|
Cannons = 805306368, -- GUN_POD + BuiltInCannon
|
||||||
|
--- Torpedo
|
||||||
|
Torpedo = 4294967296,
|
||||||
---
|
---
|
||||||
-- Even More Genral
|
-- Even More Genral
|
||||||
Auto = 3221225470, -- Any Weapon (AnyBomb + AnyRocket + AnyMissile + Cannons)
|
Auto = 3221225470, -- Any Weapon (AnyBomb + AnyRocket + AnyMissile + Cannons)
|
||||||
@@ -136,6 +138,93 @@ ENUMS.WeaponFlag={
|
|||||||
AnyGuided = 268402702, -- Any Guided Weapon
|
AnyGuided = 268402702, -- Any Guided Weapon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Weapon types by category. See the [Weapon Flag](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) enumerator on hoggit wiki.
|
||||||
|
-- @type ENUMS.WeaponType
|
||||||
|
-- @field #table Bomb Bombs.
|
||||||
|
-- @field #table Rocket Rocket.
|
||||||
|
-- @field #table Gun Guns.
|
||||||
|
-- @field #table Missile Missiles.
|
||||||
|
-- @field #table AAM Air-to-Air missiles.
|
||||||
|
-- @field #table Torpedo Torpedos.
|
||||||
|
-- @field #table Any Combinations.
|
||||||
|
ENUMS.WeaponType={}
|
||||||
|
ENUMS.WeaponType.Bomb={
|
||||||
|
-- Bombs
|
||||||
|
LGB = 2,
|
||||||
|
TvGB = 4,
|
||||||
|
SNSGB = 8,
|
||||||
|
HEBomb = 16,
|
||||||
|
Penetrator = 32,
|
||||||
|
NapalmBomb = 64,
|
||||||
|
FAEBomb = 128,
|
||||||
|
ClusterBomb = 256,
|
||||||
|
Dispencer = 512,
|
||||||
|
CandleBomb = 1024,
|
||||||
|
ParachuteBomb = 2147483648,
|
||||||
|
-- Combinations
|
||||||
|
GuidedBomb = 14, -- (LGB + TvGB + SNSGB)
|
||||||
|
AnyUnguidedBomb = 2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb)
|
||||||
|
AnyBomb = 2147485694, -- (GuidedBomb + AnyUnguidedBomb)
|
||||||
|
}
|
||||||
|
ENUMS.WeaponType.Rocket={
|
||||||
|
-- Rockets
|
||||||
|
LightRocket = 2048,
|
||||||
|
MarkerRocket = 4096,
|
||||||
|
CandleRocket = 8192,
|
||||||
|
HeavyRocket = 16384,
|
||||||
|
-- Combinations
|
||||||
|
AnyRocket = 30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket
|
||||||
|
}
|
||||||
|
ENUMS.WeaponType.Gun={
|
||||||
|
-- Guns
|
||||||
|
GunPod = 268435456,
|
||||||
|
BuiltInCannon = 536870912,
|
||||||
|
-- Combinations
|
||||||
|
Cannons = 805306368, -- GUN_POD + BuiltInCannon
|
||||||
|
}
|
||||||
|
ENUMS.WeaponType.Missile={
|
||||||
|
-- Missiles
|
||||||
|
AntiRadarMissile = 32768,
|
||||||
|
AntiShipMissile = 65536,
|
||||||
|
AntiTankMissile = 131072,
|
||||||
|
FireAndForgetASM = 262144,
|
||||||
|
LaserASM = 524288,
|
||||||
|
TeleASM = 1048576,
|
||||||
|
CruiseMissile = 2097152,
|
||||||
|
AntiRadarMissile2 = 1073741824,
|
||||||
|
-- Combinations
|
||||||
|
GuidedASM = 1572864, -- (LaserASM + TeleASM)
|
||||||
|
TacticalASM = 1835008, -- (GuidedASM + FireAndForgetASM)
|
||||||
|
AnyASM = 4161536, -- (AntiRadarMissile + AntiShipMissile + AntiTankMissile + FireAndForgetASM + GuidedASM + CruiseMissile)
|
||||||
|
AnyASM2 = 1077903360, -- 4161536+1073741824,
|
||||||
|
AnyAutonomousMissile = 36012032, -- IR_AAM + AntiRadarMissile + AntiShipMissile + FireAndForgetASM + CruiseMissile
|
||||||
|
AnyMissile = 268402688, -- AnyASM + AnyAAM
|
||||||
|
}
|
||||||
|
ENUMS.WeaponType.AAM={
|
||||||
|
-- Air-To-Air Missiles
|
||||||
|
SRAM = 4194304,
|
||||||
|
MRAAM = 8388608,
|
||||||
|
LRAAM = 16777216,
|
||||||
|
IR_AAM = 33554432,
|
||||||
|
SAR_AAM = 67108864,
|
||||||
|
AR_AAM = 134217728,
|
||||||
|
-- Combinations
|
||||||
|
AnyAAM = 264241152, -- IR_AAM + SAR_AAM + AR_AAM + SRAAM + MRAAM + LRAAM
|
||||||
|
}
|
||||||
|
ENUMS.WeaponType.Torpedo={
|
||||||
|
-- Torpedo
|
||||||
|
Torpedo = 4294967296,
|
||||||
|
}
|
||||||
|
ENUMS.WeaponType.Any={
|
||||||
|
-- General combinations
|
||||||
|
Weapon = 3221225470, -- Any Weapon (AnyBomb + AnyRocket + AnyMissile + Cannons)
|
||||||
|
AG = 2956984318, -- Any Air-To-Ground Weapon
|
||||||
|
AA = 264241152, -- Any Air-To-Air Weapon
|
||||||
|
Unguided = 2952822768, -- Any Unguided Weapon
|
||||||
|
Guided = 268402702, -- Any Guided Weapon
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Mission tasks.
|
--- Mission tasks.
|
||||||
-- @type ENUMS.MissionTask
|
-- @type ENUMS.MissionTask
|
||||||
-- @field #string NOTHING No special task. Group can perform the minimal tasks: Orbit, Refuelling, Follow and Aerobatics.
|
-- @field #string NOTHING No special task. Group can perform the minimal tasks: Orbit, Refuelling, Follow and Aerobatics.
|
||||||
@@ -173,7 +262,7 @@ ENUMS.MissionTask={
|
|||||||
TRANSPORT="Transport",
|
TRANSPORT="Transport",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Formations (new). See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on Hoggit wiki.
|
--- Formations (new). See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki.
|
||||||
-- @type ENUMS.Formation
|
-- @type ENUMS.Formation
|
||||||
ENUMS.Formation={}
|
ENUMS.Formation={}
|
||||||
ENUMS.Formation.FixedWing={}
|
ENUMS.Formation.FixedWing={}
|
||||||
@@ -216,23 +305,23 @@ ENUMS.Formation.FixedWing.FighterVic.Close = 917505
|
|||||||
ENUMS.Formation.FixedWing.FighterVic.Open = 917506
|
ENUMS.Formation.FixedWing.FighterVic.Open = 917506
|
||||||
ENUMS.Formation.RotaryWing={}
|
ENUMS.Formation.RotaryWing={}
|
||||||
ENUMS.Formation.RotaryWing.Column={}
|
ENUMS.Formation.RotaryWing.Column={}
|
||||||
ENUMS.Formation.RotaryWing.Column.D70 = 720896
|
ENUMS.Formation.RotaryWing.Column.D70=720896
|
||||||
ENUMS.Formation.RotaryWing.Wedge={}
|
ENUMS.Formation.RotaryWing.Wedge={}
|
||||||
ENUMS.Formation.RotaryWing.Wedge.D70 = 8
|
ENUMS.Formation.RotaryWing.Wedge.D70=8
|
||||||
ENUMS.Formation.RotaryWing.FrontRight={}
|
ENUMS.Formation.RotaryWing.FrontRight={}
|
||||||
ENUMS.Formation.RotaryWing.FrontRight.D300 = 655361
|
ENUMS.Formation.RotaryWing.FrontRight.D300=655361
|
||||||
ENUMS.Formation.RotaryWing.FrontRight.D600 = 655362
|
ENUMS.Formation.RotaryWing.FrontRight.D600=655362
|
||||||
ENUMS.Formation.RotaryWing.FrontLeft={}
|
ENUMS.Formation.RotaryWing.FrontLeft={}
|
||||||
ENUMS.Formation.RotaryWing.FrontLeft.D300 = 655617
|
ENUMS.Formation.RotaryWing.FrontLeft.D300=655617
|
||||||
ENUMS.Formation.RotaryWing.FrontLeft.D600 = 655618
|
ENUMS.Formation.RotaryWing.FrontLeft.D600=655618
|
||||||
ENUMS.Formation.RotaryWing.EchelonRight={}
|
ENUMS.Formation.RotaryWing.EchelonRight={}
|
||||||
ENUMS.Formation.RotaryWing.EchelonRight.D70 = 589825
|
ENUMS.Formation.RotaryWing.EchelonRight.D70 =589825
|
||||||
ENUMS.Formation.RotaryWing.EchelonRight.D300 = 589826
|
ENUMS.Formation.RotaryWing.EchelonRight.D300=589826
|
||||||
ENUMS.Formation.RotaryWing.EchelonRight.D600 = 589827
|
ENUMS.Formation.RotaryWing.EchelonRight.D600=589827
|
||||||
ENUMS.Formation.RotaryWing.EchelonLeft={}
|
ENUMS.Formation.RotaryWing.EchelonLeft={}
|
||||||
ENUMS.Formation.RotaryWing.EchelonLeft.D70 = 590081
|
ENUMS.Formation.RotaryWing.EchelonLeft.D70 =590081
|
||||||
ENUMS.Formation.RotaryWing.EchelonLeft.D300 = 590082
|
ENUMS.Formation.RotaryWing.EchelonLeft.D300=590082
|
||||||
ENUMS.Formation.RotaryWing.EchelonLeft.D600 = 590083
|
ENUMS.Formation.RotaryWing.EchelonLeft.D600=590083
|
||||||
ENUMS.Formation.Vehicle={}
|
ENUMS.Formation.Vehicle={}
|
||||||
ENUMS.Formation.Vehicle.Vee="Vee"
|
ENUMS.Formation.Vehicle.Vee="Vee"
|
||||||
ENUMS.Formation.Vehicle.EchelonRight="EchelonR"
|
ENUMS.Formation.Vehicle.EchelonRight="EchelonR"
|
||||||
@@ -244,25 +333,25 @@ ENUMS.Formation.Vehicle.Cone="Cone"
|
|||||||
ENUMS.Formation.Vehicle.Diamond="Diamond"
|
ENUMS.Formation.Vehicle.Diamond="Diamond"
|
||||||
|
|
||||||
--- Formations (old). The old format is a simplified version of the new formation enums, which allow more sophisticated settings.
|
--- Formations (old). The old format is a simplified version of the new formation enums, which allow more sophisticated settings.
|
||||||
-- See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on Hoggit wiki.
|
-- See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki.
|
||||||
-- @type ENUMS.FormationOld
|
-- @type ENUMS.FormationOld
|
||||||
ENUMS.FormationOld={}
|
ENUMS.FormationOld={}
|
||||||
ENUMS.FormationOld.FixedWing={}
|
ENUMS.FormationOld.FixedWing={}
|
||||||
ENUMS.FormationOld.FixedWing.LineAbreast = 1
|
ENUMS.FormationOld.FixedWing.LineAbreast=1
|
||||||
ENUMS.FormationOld.FixedWing.Trail = 2
|
ENUMS.FormationOld.FixedWing.Trail=2
|
||||||
ENUMS.FormationOld.FixedWing.Wedge = 3
|
ENUMS.FormationOld.FixedWing.Wedge=3
|
||||||
ENUMS.FormationOld.FixedWing.EchelonRight = 4
|
ENUMS.FormationOld.FixedWing.EchelonRight=4
|
||||||
ENUMS.FormationOld.FixedWing.EchelonLeft = 5
|
ENUMS.FormationOld.FixedWing.EchelonLeft=5
|
||||||
ENUMS.FormationOld.FixedWing.FingerFour = 6
|
ENUMS.FormationOld.FixedWing.FingerFour=6
|
||||||
ENUMS.FormationOld.FixedWing.SpreadFour = 7
|
ENUMS.FormationOld.FixedWing.SpreadFour=7
|
||||||
ENUMS.FormationOld.FixedWing.BomberElement = 12
|
ENUMS.FormationOld.FixedWing.BomberElement=12
|
||||||
ENUMS.FormationOld.FixedWing.BomberElementHeight = 13
|
ENUMS.FormationOld.FixedWing.BomberElementHeight=13
|
||||||
ENUMS.FormationOld.FixedWing.FighterVic = 14
|
ENUMS.FormationOld.FixedWing.FighterVic=14
|
||||||
ENUMS.FormationOld.RotaryWing={}
|
ENUMS.FormationOld.RotaryWing={}
|
||||||
ENUMS.FormationOld.RotaryWing.Wedge = 8
|
ENUMS.FormationOld.RotaryWing.Wedge=8
|
||||||
ENUMS.FormationOld.RotaryWing.Echelon = 9
|
ENUMS.FormationOld.RotaryWing.Echelon=9
|
||||||
ENUMS.FormationOld.RotaryWing.Front = 10
|
ENUMS.FormationOld.RotaryWing.Front=10
|
||||||
ENUMS.FormationOld.RotaryWing.Column = 11
|
ENUMS.FormationOld.RotaryWing.Column=11
|
||||||
|
|
||||||
|
|
||||||
--- Morse Code. See the [Wikipedia](https://en.wikipedia.org/wiki/Morse_code).
|
--- Morse Code. See the [Wikipedia](https://en.wikipedia.org/wiki/Morse_code).
|
||||||
@@ -360,3 +449,113 @@ ENUMS.Phonetic =
|
|||||||
Y = 'Yankee',
|
Y = 'Yankee',
|
||||||
Z = 'Zulu',
|
Z = 'Zulu',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Reporting Names (NATO). See the [Wikipedia](https://en.wikipedia.org/wiki/List_of_NATO_reporting_names_for_fighter_aircraft).
|
||||||
|
-- DCS known aircraft types
|
||||||
|
--
|
||||||
|
-- @type ENUMS.ReportingName
|
||||||
|
ENUMS.ReportingName =
|
||||||
|
{
|
||||||
|
NATO = {
|
||||||
|
-- Fighters
|
||||||
|
Dragon = "JF-17", -- China, correctly Fierce Dragon, Thunder for PAC
|
||||||
|
Fagot = "MiG-15",
|
||||||
|
Farmer = "MiG-19", -- Shenyang J-6 and Mikoyan-Gurevich MiG-19
|
||||||
|
Felon = "Su-57",
|
||||||
|
Fencer = "Su-24",
|
||||||
|
Fishbed = "MiG-21",
|
||||||
|
Fitter = "Su-17", -- Sukhoi Su-7 and Su-17/Su-20/Su-22
|
||||||
|
Flogger = "MiG-23", --and MiG-27
|
||||||
|
Flogger_D = "MiG-27", --and MiG-23
|
||||||
|
Flagon = "Su-15",
|
||||||
|
Foxbat = "MiG-25",
|
||||||
|
Fulcrum = "MiG-29",
|
||||||
|
Foxhound = "MiG-31",
|
||||||
|
Flanker = "Su-27", -- Sukhoi Su-27/Su-30/Su-33/Su-35/Su-37 and Shenyang J-11/J-15/J-16
|
||||||
|
Flanker_C = "Su-30",
|
||||||
|
Flanker_E = "Su-35",
|
||||||
|
Flanker_F = "Su-37",
|
||||||
|
Flanker_L = "J-11A",
|
||||||
|
Firebird = "J-10",
|
||||||
|
Sea_Flanker = "Su-33",
|
||||||
|
Fullback = "Su-34", -- also Su-32
|
||||||
|
Frogfoot = "Su-25",
|
||||||
|
Tomcat = "F-14", -- Iran
|
||||||
|
Mirage = "Mirage", -- various non-NATO
|
||||||
|
Codling = "Yak-40",
|
||||||
|
Maya = "L-39",
|
||||||
|
-- Fighters US/NATO
|
||||||
|
Warthog = "A-10",
|
||||||
|
--Mosquito = "A-20",
|
||||||
|
Skyhawk = "A-4E",
|
||||||
|
Viggen = "AJS37",
|
||||||
|
Harrier = "AV-8B",
|
||||||
|
Spirit = "B-2",
|
||||||
|
Aviojet = "C-101",
|
||||||
|
Nighthawk = "F-117A",
|
||||||
|
Eagle = "F-15C",
|
||||||
|
Mudhen = "F-15E",
|
||||||
|
Viper = "F-16",
|
||||||
|
Phantom = "F-4E",
|
||||||
|
Tiger = "F-5", -- was thinkg to name this MiG-25 ;)
|
||||||
|
Sabre = "F-86",
|
||||||
|
Hornet = "A-18", -- avoiding the slash
|
||||||
|
Hawk = "Hawk",
|
||||||
|
Albatros = "L-39",
|
||||||
|
Goshawk = "T-45",
|
||||||
|
Starfighter = "F-104",
|
||||||
|
Tornado = "Tornado",
|
||||||
|
-- Transport / Bomber / Others
|
||||||
|
Atlas = "A400",
|
||||||
|
Lancer = "B1-B",
|
||||||
|
Stratofortress = "B-52H",
|
||||||
|
Hercules = "C-130",
|
||||||
|
Super_Hercules = "Hercules",
|
||||||
|
Globemaster = "C-17",
|
||||||
|
Greyhound = "C-2A",
|
||||||
|
Galaxy = "C-5",
|
||||||
|
Hawkeye = "E-2D",
|
||||||
|
Sentry = "E-3A",
|
||||||
|
Stratotanker = "KC-135",
|
||||||
|
Extender = "KC-10",
|
||||||
|
Orion = "P-3C",
|
||||||
|
Viking = "S-3B",
|
||||||
|
Osprey = "V-22",
|
||||||
|
-- Bomber Rus
|
||||||
|
Badger = "H6-J",
|
||||||
|
Bear_J = "Tu-142", -- also Tu-95
|
||||||
|
Bear = "Tu-95", -- also Tu-142
|
||||||
|
Blinder = "Tu-22",
|
||||||
|
Blackjack = "Tu-160",
|
||||||
|
-- AIC / Transport / Other
|
||||||
|
Clank = "An-30",
|
||||||
|
Curl = "An-26",
|
||||||
|
Candid = "IL-76",
|
||||||
|
Midas = "IL-78",
|
||||||
|
Mainstay = "A-50",
|
||||||
|
Mainring = "KJ-2000", -- A-50 China
|
||||||
|
Yak = "Yak-52",
|
||||||
|
-- Helos
|
||||||
|
Helix = "Ka-27",
|
||||||
|
Shark = "Ka-50",
|
||||||
|
Hind = "Mi-24",
|
||||||
|
Halo = "Mi-26",
|
||||||
|
Hip = "Mi-8",
|
||||||
|
Havoc = "Mi-28",
|
||||||
|
Gazelle = "SA342",
|
||||||
|
-- Helos US
|
||||||
|
Huey = "UH-1H",
|
||||||
|
Cobra = "AH-1",
|
||||||
|
Apache = "AH-64",
|
||||||
|
Chinook = "CH-47",
|
||||||
|
Sea_Stallion = "CH-53",
|
||||||
|
Kiowa = "OH-58",
|
||||||
|
Seahawk = "SH-60",
|
||||||
|
Blackhawk = "UH-60",
|
||||||
|
Sea_King = "S-61",
|
||||||
|
-- Drones
|
||||||
|
UCAV = "WingLoong",
|
||||||
|
Reaper = "MQ-9",
|
||||||
|
Predator = "MQ-1A",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,773 @@
|
|||||||
|
--- **UTILS** - ClassicFiFo Stack.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ## Main Features:
|
||||||
|
--
|
||||||
|
-- * Build a simple multi-purpose FiFo (First-In, First-Out) stack for generic data.
|
||||||
|
-- * [Wikipedia](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### Author: **applevangelist**
|
||||||
|
-- @module Utils.FiFo
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
-- Date: April 2022
|
||||||
|
|
||||||
|
do
|
||||||
|
--- FIFO class.
|
||||||
|
-- @type FIFO
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #string lid Class id string for output to DCS log file.
|
||||||
|
-- @field #string version Version of FiFo.
|
||||||
|
-- @field #number counter Counter.
|
||||||
|
-- @field #number pointer Pointer.
|
||||||
|
-- @field #table stackbypointer Stack by pointer.
|
||||||
|
-- @field #table stackbyid Stack by ID.
|
||||||
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type FIFO.IDEntry
|
||||||
|
-- @field #number pointer
|
||||||
|
-- @field #table data
|
||||||
|
-- @field #table uniqueID
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @field #FIFO
|
||||||
|
FIFO = {
|
||||||
|
ClassName = "FIFO",
|
||||||
|
lid = "",
|
||||||
|
version = "0.0.5",
|
||||||
|
counter = 0,
|
||||||
|
pointer = 0,
|
||||||
|
stackbypointer = {},
|
||||||
|
stackbyid = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Instantiate a new FIFO Stack.
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #FIFO self
|
||||||
|
function FIFO:New()
|
||||||
|
-- Inherit everything from BASE class.
|
||||||
|
local self=BASE:Inherit(self, BASE:New()) --#FIFO
|
||||||
|
self.pointer = 0
|
||||||
|
self.counter = 0
|
||||||
|
self.stackbypointer = {}
|
||||||
|
self.stackbyid = {}
|
||||||
|
self.uniquecounter = 0
|
||||||
|
-- Set some string id for output to DCS.log file.
|
||||||
|
self.lid=string.format("%s (%s) | ", "FiFo", self.version)
|
||||||
|
self:T(self.lid .."Created.")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Empty FIFO Stack.
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #FIFO self
|
||||||
|
function FIFO:Clear()
|
||||||
|
self:T(self.lid.."Clear")
|
||||||
|
self.pointer = 0
|
||||||
|
self.counter = 0
|
||||||
|
self.stackbypointer = nil
|
||||||
|
self.stackbyid = nil
|
||||||
|
self.stackbypointer = {}
|
||||||
|
self.stackbyid = {}
|
||||||
|
self.uniquecounter = 0
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Push Object to Stack.
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @param #table Object
|
||||||
|
-- @param #string UniqueID (optional) - will default to current pointer + 1. Note - if you intend to use `FIFO:GetIDStackSorted()` keep the UniqueID numerical!
|
||||||
|
-- @return #FIFO self
|
||||||
|
function FIFO:Push(Object,UniqueID)
|
||||||
|
self:T(self.lid.."Push")
|
||||||
|
self:T({Object,UniqueID})
|
||||||
|
self.pointer = self.pointer + 1
|
||||||
|
self.counter = self.counter + 1
|
||||||
|
local uniID = UniqueID
|
||||||
|
if not UniqueID then
|
||||||
|
self.uniquecounter = self.uniquecounter + 1
|
||||||
|
uniID = self.uniquecounter
|
||||||
|
end
|
||||||
|
self.stackbyid[uniID] = { pointer = self.pointer, data = Object, uniqueID = uniID }
|
||||||
|
self.stackbypointer[self.pointer] = { pointer = self.pointer, data = Object, uniqueID = uniID }
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Pull Object from Stack.
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #table Object or nil if stack is empty
|
||||||
|
function FIFO:Pull()
|
||||||
|
self:T(self.lid.."Pull")
|
||||||
|
if self.counter == 0 then return nil end
|
||||||
|
--local object = self.stackbypointer[self.pointer].data
|
||||||
|
--self.stackbypointer[self.pointer] = nil
|
||||||
|
local object = self.stackbypointer[1].data
|
||||||
|
self.stackbypointer[1] = nil
|
||||||
|
self.counter = self.counter - 1
|
||||||
|
--self.pointer = self.pointer - 1
|
||||||
|
self:Flatten()
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Pull Object from Stack by Pointer
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @param #number Pointer
|
||||||
|
-- @return #table Object or nil if stack is empty
|
||||||
|
function FIFO:PullByPointer(Pointer)
|
||||||
|
self:T(self.lid.."PullByPointer " .. tostring(Pointer))
|
||||||
|
if self.counter == 0 then return nil end
|
||||||
|
local object = self.stackbypointer[Pointer] -- #FIFO.IDEntry
|
||||||
|
self.stackbypointer[Pointer] = nil
|
||||||
|
if object then self.stackbyid[object.uniqueID] = nil end
|
||||||
|
self.counter = self.counter - 1
|
||||||
|
self:Flatten()
|
||||||
|
if object then
|
||||||
|
return object.data
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- FIFO Read, not Pull, Object from Stack by Pointer
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @param #number Pointer
|
||||||
|
-- @return #table Object or nil if stack is empty or pointer does not exist
|
||||||
|
function FIFO:ReadByPointer(Pointer)
|
||||||
|
self:T(self.lid.."ReadByPointer " .. tostring(Pointer))
|
||||||
|
if self.counter == 0 or not Pointer or not self.stackbypointer[Pointer] then return nil end
|
||||||
|
local object = self.stackbypointer[Pointer] -- #FIFO.IDEntry
|
||||||
|
if object then
|
||||||
|
return object.data
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Read, not Pull, Object from Stack by UniqueID
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @param #number UniqueID
|
||||||
|
-- @return #table Object data or nil if stack is empty or ID does not exist
|
||||||
|
function FIFO:ReadByID(UniqueID)
|
||||||
|
self:T(self.lid.."ReadByID " .. tostring(UniqueID))
|
||||||
|
if self.counter == 0 or not UniqueID or not self.stackbyid[UniqueID] then return nil end
|
||||||
|
local object = self.stackbyid[UniqueID] -- #FIFO.IDEntry
|
||||||
|
if object then
|
||||||
|
return object.data
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Pull Object from Stack by UniqueID
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @param #tableUniqueID
|
||||||
|
-- @return #table Object or nil if stack is empty
|
||||||
|
function FIFO:PullByID(UniqueID)
|
||||||
|
self:T(self.lid.."PullByID " .. tostring(UniqueID))
|
||||||
|
if self.counter == 0 then return nil end
|
||||||
|
local object = self.stackbyid[UniqueID] -- #FIFO.IDEntry
|
||||||
|
--self.stackbyid[UniqueID] = nil
|
||||||
|
if object then
|
||||||
|
return self:PullByPointer(object.pointer)
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Housekeeping
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #FIFO self
|
||||||
|
function FIFO:Flatten()
|
||||||
|
self:T(self.lid.."Flatten")
|
||||||
|
-- rebuild stacks
|
||||||
|
local pointerstack = {}
|
||||||
|
local idstack = {}
|
||||||
|
local counter = 0
|
||||||
|
for _ID,_entry in pairs(self.stackbypointer) do
|
||||||
|
counter = counter + 1
|
||||||
|
pointerstack[counter] = { pointer = counter, data = _entry.data, uniqueID = _entry.uniqueID}
|
||||||
|
end
|
||||||
|
for _ID,_entry in pairs(pointerstack) do
|
||||||
|
idstack[_entry.uniqueID] = { pointer = _entry.pointer , data = _entry.data, uniqueID = _entry.uniqueID}
|
||||||
|
end
|
||||||
|
self.stackbypointer = nil
|
||||||
|
self.stackbypointer = pointerstack
|
||||||
|
self.stackbyid = nil
|
||||||
|
self.stackbyid = idstack
|
||||||
|
self.counter = counter
|
||||||
|
self.pointer = counter
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Check Stack is empty
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #boolean empty
|
||||||
|
function FIFO:IsEmpty()
|
||||||
|
self:T(self.lid.."IsEmpty")
|
||||||
|
return self.counter == 0 and true or false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Get stack size
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #number size
|
||||||
|
function FIFO:GetSize()
|
||||||
|
self:T(self.lid.."GetSize")
|
||||||
|
return self.counter
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Get stack size
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #number size
|
||||||
|
function FIFO:Count()
|
||||||
|
self:T(self.lid.."Count")
|
||||||
|
return self.counter
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Check Stack is NOT empty
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #boolean notempty
|
||||||
|
function FIFO:IsNotEmpty()
|
||||||
|
self:T(self.lid.."IsNotEmpty")
|
||||||
|
return not self:IsEmpty()
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Get the data stack by pointer
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #table Table of #FIFO.IDEntry entries
|
||||||
|
function FIFO:GetPointerStack()
|
||||||
|
self:T(self.lid.."GetPointerStack")
|
||||||
|
return self.stackbypointer
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Check if a certain UniqeID exists
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #boolean exists
|
||||||
|
function FIFO:HasUniqueID(UniqueID)
|
||||||
|
self:T(self.lid.."HasUniqueID")
|
||||||
|
if self.stackbyid[UniqueID] ~= nil then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Get the data stack by UniqueID
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #table Table of #FIFO.IDEntry entries
|
||||||
|
function FIFO:GetIDStack()
|
||||||
|
self:T(self.lid.."GetIDStack")
|
||||||
|
return self.stackbyid
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Get table of UniqueIDs sorted smallest to largest
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #table Table with index [1] to [n] of UniqueID entries
|
||||||
|
function FIFO:GetIDStackSorted()
|
||||||
|
self:T(self.lid.."GetIDStackSorted")
|
||||||
|
|
||||||
|
local stack = self:GetIDStack()
|
||||||
|
local idstack = {}
|
||||||
|
for _id,_entry in pairs(stack) do
|
||||||
|
idstack[#idstack+1] = _id
|
||||||
|
|
||||||
|
self:T({"pre",_id})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function sortID(a, b)
|
||||||
|
return a < b
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(idstack)
|
||||||
|
|
||||||
|
return idstack
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Get table of data entries
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #table Raw table indexed [1] to [n] of object entries - might be empty!
|
||||||
|
function FIFO:GetDataTable()
|
||||||
|
self:T(self.lid.."GetDataTable")
|
||||||
|
local datatable = {}
|
||||||
|
for _,_entry in pairs(self.stackbypointer) do
|
||||||
|
datatable[#datatable+1] = _entry.data
|
||||||
|
end
|
||||||
|
return datatable
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Get sorted table of data entries by UniqueIDs (must be numerical UniqueIDs only!)
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #table Table indexed [1] to [n] of sorted object entries - might be empty!
|
||||||
|
function FIFO:GetSortedDataTable()
|
||||||
|
self:T(self.lid.."GetSortedDataTable")
|
||||||
|
local datatable = {}
|
||||||
|
local idtablesorted = self:GetIDStackSorted()
|
||||||
|
for _,_entry in pairs(idtablesorted) do
|
||||||
|
datatable[#datatable+1] = self:ReadByID(_entry)
|
||||||
|
end
|
||||||
|
return datatable
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Iterate the FIFO and call an iterator function for the given FIFO data, providing the object for each element of the stack and optional parameters.
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @param #function IteratorFunction The function that will be called.
|
||||||
|
-- @param #table Arg (Optional) Further Arguments of the IteratorFunction.
|
||||||
|
-- @param #function Function (Optional) A function returning a #boolean true/false. Only if true, the IteratorFunction is called.
|
||||||
|
-- @param #table FunctionArguments (Optional) Function arguments.
|
||||||
|
-- @return #FIFO self
|
||||||
|
function FIFO:ForEach( IteratorFunction, Arg, Function, FunctionArguments )
|
||||||
|
self:T(self.lid.."ForEach")
|
||||||
|
|
||||||
|
local Set = self:GetPointerStack() or {}
|
||||||
|
Arg = Arg or {}
|
||||||
|
|
||||||
|
local function CoRoutine()
|
||||||
|
local Count = 0
|
||||||
|
for ObjectID, ObjectData in pairs( Set ) do
|
||||||
|
local Object = ObjectData.data
|
||||||
|
self:T( {Object} )
|
||||||
|
if Function then
|
||||||
|
if Function( unpack( FunctionArguments or {} ), Object ) == true then
|
||||||
|
IteratorFunction( Object, unpack( Arg ) )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
IteratorFunction( Object, unpack( Arg ) )
|
||||||
|
end
|
||||||
|
Count = Count + 1
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local co = CoRoutine
|
||||||
|
|
||||||
|
local function Schedule()
|
||||||
|
|
||||||
|
local status, res = co()
|
||||||
|
self:T( { status, res } )
|
||||||
|
|
||||||
|
if status == false then
|
||||||
|
error( res )
|
||||||
|
end
|
||||||
|
if res == false then
|
||||||
|
return true -- resume next time the loop
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
Schedule()
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FIFO Print stacks to dcs.log
|
||||||
|
-- @param #FIFO self
|
||||||
|
-- @return #FIFO self
|
||||||
|
function FIFO:Flush()
|
||||||
|
self:T(self.lid.."FiFo Flush")
|
||||||
|
self:I("FIFO Flushing Stack by Pointer")
|
||||||
|
for _id,_data in pairs (self.stackbypointer) do
|
||||||
|
local data = _data -- #FIFO.IDEntry
|
||||||
|
self:I(string.format("Pointer: %s | Entry: Number = %s Data = %s UniqueID = %s",tostring(_id),tostring(data.pointer),tostring(data.data),tostring(data.uniqueID)))
|
||||||
|
end
|
||||||
|
self:I("FIFO Flushing Stack by ID")
|
||||||
|
for _id,_data in pairs (self.stackbyid) do
|
||||||
|
local data = _data -- #FIFO.IDEntry
|
||||||
|
self:I(string.format("ID: %s | Entry: Number = %s Data = %s UniqueID = %s",tostring(_id),tostring(data.pointer),tostring(data.data),tostring(data.uniqueID)))
|
||||||
|
end
|
||||||
|
self:I("Counter = " .. self.counter)
|
||||||
|
self:I("Pointer = ".. self.pointer)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- End FIFO
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- LIFO
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do
|
||||||
|
--- **UTILS** - LiFo Stack.
|
||||||
|
--
|
||||||
|
-- **Main Features:**
|
||||||
|
--
|
||||||
|
-- * Build a simple multi-purpose LiFo (Last-In, First-Out) stack for generic data.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### Author: **applevangelist**
|
||||||
|
|
||||||
|
--- LIFO class.
|
||||||
|
-- @type LIFO
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #string lid Class id string for output to DCS log file.
|
||||||
|
-- @field #string version Version of LiFo
|
||||||
|
-- @field #number counter
|
||||||
|
-- @field #number pointer
|
||||||
|
-- @field #table stackbypointer
|
||||||
|
-- @field #table stackbyid
|
||||||
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type LIFO.IDEntry
|
||||||
|
-- @field #number pointer
|
||||||
|
-- @field #table data
|
||||||
|
-- @field #table uniqueID
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @field #LIFO
|
||||||
|
LIFO = {
|
||||||
|
ClassName = "LIFO",
|
||||||
|
lid = "",
|
||||||
|
version = "0.0.5",
|
||||||
|
counter = 0,
|
||||||
|
pointer = 0,
|
||||||
|
stackbypointer = {},
|
||||||
|
stackbyid = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Instantiate a new LIFO Stack
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #LIFO self
|
||||||
|
function LIFO:New()
|
||||||
|
-- Inherit everything from BASE class.
|
||||||
|
local self=BASE:Inherit(self, BASE:New())
|
||||||
|
self.pointer = 0
|
||||||
|
self.counter = 0
|
||||||
|
self.uniquecounter = 0
|
||||||
|
self.stackbypointer = {}
|
||||||
|
self.stackbyid = {}
|
||||||
|
-- Set some string id for output to DCS.log file.
|
||||||
|
self.lid=string.format("%s (%s) | ", "LiFo", self.version)
|
||||||
|
self:T(self.lid .."Created.")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Empty LIFO Stack
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #LIFO self
|
||||||
|
function LIFO:Clear()
|
||||||
|
self:T(self.lid.."Clear")
|
||||||
|
self.pointer = 0
|
||||||
|
self.counter = 0
|
||||||
|
self.stackbypointer = nil
|
||||||
|
self.stackbyid = nil
|
||||||
|
self.stackbypointer = {}
|
||||||
|
self.stackbyid = {}
|
||||||
|
self.uniquecounter = 0
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Push Object to Stack
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @param #table Object
|
||||||
|
-- @param #string UniqueID (optional) - will default to current pointer + 1
|
||||||
|
-- @return #LIFO self
|
||||||
|
function LIFO:Push(Object,UniqueID)
|
||||||
|
self:T(self.lid.."Push")
|
||||||
|
self:T({Object,UniqueID})
|
||||||
|
self.pointer = self.pointer + 1
|
||||||
|
self.counter = self.counter + 1
|
||||||
|
local uniID = UniqueID
|
||||||
|
if not UniqueID then
|
||||||
|
self.uniquecounter = self.uniquecounter + 1
|
||||||
|
uniID = self.uniquecounter
|
||||||
|
end
|
||||||
|
self.stackbyid[uniID] = { pointer = self.pointer, data = Object, uniqueID = uniID }
|
||||||
|
self.stackbypointer[self.pointer] = { pointer = self.pointer, data = Object, uniqueID = uniID }
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Pull Object from Stack
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #table Object or nil if stack is empty
|
||||||
|
function LIFO:Pull()
|
||||||
|
self:T(self.lid.."Pull")
|
||||||
|
if self.counter == 0 then return nil end
|
||||||
|
local object = self.stackbypointer[self.pointer].data
|
||||||
|
self.stackbypointer[self.pointer] = nil
|
||||||
|
--local object = self.stackbypointer[1].data
|
||||||
|
--self.stackbypointer[1] = nil
|
||||||
|
self.counter = self.counter - 1
|
||||||
|
self.pointer = self.pointer - 1
|
||||||
|
self:Flatten()
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Pull Object from Stack by Pointer
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @param #number Pointer
|
||||||
|
-- @return #table Object or nil if stack is empty
|
||||||
|
function LIFO:PullByPointer(Pointer)
|
||||||
|
self:T(self.lid.."PullByPointer " .. tostring(Pointer))
|
||||||
|
if self.counter == 0 then return nil end
|
||||||
|
local object = self.stackbypointer[Pointer] -- #FIFO.IDEntry
|
||||||
|
self.stackbypointer[Pointer] = nil
|
||||||
|
if object then self.stackbyid[object.uniqueID] = nil end
|
||||||
|
self.counter = self.counter - 1
|
||||||
|
self:Flatten()
|
||||||
|
if object then
|
||||||
|
return object.data
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Read, not Pull, Object from Stack by Pointer
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @param #number Pointer
|
||||||
|
-- @return #table Object or nil if stack is empty or pointer does not exist
|
||||||
|
function LIFO:ReadByPointer(Pointer)
|
||||||
|
self:T(self.lid.."ReadByPointer " .. tostring(Pointer))
|
||||||
|
if self.counter == 0 or not Pointer or not self.stackbypointer[Pointer] then return nil end
|
||||||
|
local object = self.stackbypointer[Pointer] -- #LIFO.IDEntry
|
||||||
|
if object then
|
||||||
|
return object.data
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Read, not Pull, Object from Stack by UniqueID
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @param #number UniqueID
|
||||||
|
-- @return #table Object or nil if stack is empty or ID does not exist
|
||||||
|
function LIFO:ReadByID(UniqueID)
|
||||||
|
self:T(self.lid.."ReadByID " .. tostring(UniqueID))
|
||||||
|
if self.counter == 0 or not UniqueID or not self.stackbyid[UniqueID] then return nil end
|
||||||
|
local object = self.stackbyid[UniqueID] -- #LIFO.IDEntry
|
||||||
|
if object then
|
||||||
|
return object.data
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Pull Object from Stack by UniqueID
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @param #tableUniqueID
|
||||||
|
-- @return #table Object or nil if stack is empty
|
||||||
|
function LIFO:PullByID(UniqueID)
|
||||||
|
self:T(self.lid.."PullByID " .. tostring(UniqueID))
|
||||||
|
if self.counter == 0 then return nil end
|
||||||
|
local object = self.stackbyid[UniqueID] -- #LIFO.IDEntry
|
||||||
|
--self.stackbyid[UniqueID] = nil
|
||||||
|
if object then
|
||||||
|
return self:PullByPointer(object.pointer)
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Housekeeping
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #LIFO self
|
||||||
|
function LIFO:Flatten()
|
||||||
|
self:T(self.lid.."Flatten")
|
||||||
|
-- rebuild stacks
|
||||||
|
local pointerstack = {}
|
||||||
|
local idstack = {}
|
||||||
|
local counter = 0
|
||||||
|
for _ID,_entry in pairs(self.stackbypointer) do
|
||||||
|
counter = counter + 1
|
||||||
|
pointerstack[counter] = { pointer = counter, data = _entry.data, uniqueID = _entry.uniqueID}
|
||||||
|
end
|
||||||
|
for _ID,_entry in pairs(pointerstack) do
|
||||||
|
idstack[_entry.uniqueID] = { pointer = _entry.pointer , data = _entry.data, uniqueID = _entry.uniqueID}
|
||||||
|
end
|
||||||
|
self.stackbypointer = nil
|
||||||
|
self.stackbypointer = pointerstack
|
||||||
|
self.stackbyid = nil
|
||||||
|
self.stackbyid = idstack
|
||||||
|
self.counter = counter
|
||||||
|
self.pointer = counter
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Check Stack is empty
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #boolean empty
|
||||||
|
function LIFO:IsEmpty()
|
||||||
|
self:T(self.lid.."IsEmpty")
|
||||||
|
return self.counter == 0 and true or false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Get stack size
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #number size
|
||||||
|
function LIFO:GetSize()
|
||||||
|
self:T(self.lid.."GetSize")
|
||||||
|
return self.counter
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Get stack size
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #number size
|
||||||
|
function LIFO:Count()
|
||||||
|
self:T(self.lid.."Count")
|
||||||
|
return self.counter
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Check Stack is NOT empty
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #boolean notempty
|
||||||
|
function LIFO:IsNotEmpty()
|
||||||
|
self:T(self.lid.."IsNotEmpty")
|
||||||
|
return not self:IsEmpty()
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Get the data stack by pointer
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #table Table of #LIFO.IDEntry entries
|
||||||
|
function LIFO:GetPointerStack()
|
||||||
|
self:T(self.lid.."GetPointerStack")
|
||||||
|
return self.stackbypointer
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Get the data stack by UniqueID
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #table Table of #LIFO.IDEntry entries
|
||||||
|
function LIFO:GetIDStack()
|
||||||
|
self:T(self.lid.."GetIDStack")
|
||||||
|
return self.stackbyid
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Get table of UniqueIDs sorted smallest to largest
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #table Table of #LIFO.IDEntry entries
|
||||||
|
function LIFO:GetIDStackSorted()
|
||||||
|
self:T(self.lid.."GetIDStackSorted")
|
||||||
|
|
||||||
|
local stack = self:GetIDStack()
|
||||||
|
local idstack = {}
|
||||||
|
for _id,_entry in pairs(stack) do
|
||||||
|
idstack[#idstack+1] = _id
|
||||||
|
|
||||||
|
self:T({"pre",_id})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function sortID(a, b)
|
||||||
|
return a < b
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(idstack)
|
||||||
|
|
||||||
|
return idstack
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Check if a certain UniqeID exists
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #boolean exists
|
||||||
|
function LIFO:HasUniqueID(UniqueID)
|
||||||
|
self:T(self.lid.."HasUniqueID")
|
||||||
|
return self.stackbyid[UniqueID] and true or false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Print stacks to dcs.log
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #LIFO self
|
||||||
|
function LIFO:Flush()
|
||||||
|
self:T(self.lid.."FiFo Flush")
|
||||||
|
self:I("LIFO Flushing Stack by Pointer")
|
||||||
|
for _id,_data in pairs (self.stackbypointer) do
|
||||||
|
local data = _data -- #LIFO.IDEntry
|
||||||
|
self:I(string.format("Pointer: %s | Entry: Number = %s Data = %s UniqueID = %s",tostring(_id),tostring(data.pointer),tostring(data.data),tostring(data.uniqueID)))
|
||||||
|
end
|
||||||
|
self:I("LIFO Flushing Stack by ID")
|
||||||
|
for _id,_data in pairs (self.stackbyid) do
|
||||||
|
local data = _data -- #LIFO.IDEntry
|
||||||
|
self:I(string.format("ID: %s | Entry: Number = %s Data = %s UniqueID = %s",tostring(_id),tostring(data.pointer),tostring(data.data),tostring(data.uniqueID)))
|
||||||
|
end
|
||||||
|
self:I("Counter = " .. self.counter)
|
||||||
|
self:I("Pointer = ".. self.pointer)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Get table of data entries
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #table Raw table indexed [1] to [n] of object entries - might be empty!
|
||||||
|
function LIFO:GetDataTable()
|
||||||
|
self:T(self.lid.."GetDataTable")
|
||||||
|
local datatable = {}
|
||||||
|
for _,_entry in pairs(self.stackbypointer) do
|
||||||
|
datatable[#datatable+1] = _entry.data
|
||||||
|
end
|
||||||
|
return datatable
|
||||||
|
end
|
||||||
|
|
||||||
|
--- LIFO Get sorted table of data entries by UniqueIDs (must be numerical UniqueIDs only!)
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @return #table Table indexed [1] to [n] of sorted object entries - might be empty!
|
||||||
|
function LIFO:GetSortedDataTable()
|
||||||
|
self:T(self.lid.."GetSortedDataTable")
|
||||||
|
local datatable = {}
|
||||||
|
local idtablesorted = self:GetIDStackSorted()
|
||||||
|
for _,_entry in pairs(idtablesorted) do
|
||||||
|
datatable[#datatable+1] = self:ReadByID(_entry)
|
||||||
|
end
|
||||||
|
return datatable
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Iterate the LIFO and call an iterator function for the given LIFO data, providing the object for each element of the stack and optional parameters.
|
||||||
|
-- @param #LIFO self
|
||||||
|
-- @param #function IteratorFunction The function that will be called.
|
||||||
|
-- @param #table Arg (Optional) Further Arguments of the IteratorFunction.
|
||||||
|
-- @param #function Function (Optional) A function returning a #boolean true/false. Only if true, the IteratorFunction is called.
|
||||||
|
-- @param #table FunctionArguments (Optional) Function arguments.
|
||||||
|
-- @return #LIFO self
|
||||||
|
function LIFO:ForEach( IteratorFunction, Arg, Function, FunctionArguments )
|
||||||
|
self:T(self.lid.."ForEach")
|
||||||
|
|
||||||
|
local Set = self:GetPointerStack() or {}
|
||||||
|
Arg = Arg or {}
|
||||||
|
|
||||||
|
local function CoRoutine()
|
||||||
|
local Count = 0
|
||||||
|
for ObjectID, ObjectData in pairs( Set ) do
|
||||||
|
local Object = ObjectData.data
|
||||||
|
self:T( {Object} )
|
||||||
|
if Function then
|
||||||
|
if Function( unpack( FunctionArguments or {} ), Object ) == true then
|
||||||
|
IteratorFunction( Object, unpack( Arg ) )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
IteratorFunction( Object, unpack( Arg ) )
|
||||||
|
end
|
||||||
|
Count = Count + 1
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local co = CoRoutine
|
||||||
|
|
||||||
|
local function Schedule()
|
||||||
|
|
||||||
|
local status, res = co()
|
||||||
|
self:T( { status, res } )
|
||||||
|
|
||||||
|
if status == false then
|
||||||
|
error( res )
|
||||||
|
end
|
||||||
|
if res == false then
|
||||||
|
return true -- resume next time the loop
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
Schedule()
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- End LIFO
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
end
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
-- ### Author: **TAW CougarNL**, *funkyfranky*
|
-- ### Author: **TAW CougarNL**, *funkyfranky*
|
||||||
--
|
--
|
||||||
-- @module Utilities.PROFILER
|
-- @module Utilities.PROFILER
|
||||||
-- @image MOOSE.JPG
|
-- @image Utils_Profiler.jpg
|
||||||
|
|
||||||
--- PROFILER class.
|
--- PROFILER class.
|
||||||
-- @type PROFILER
|
-- @type PROFILER
|
||||||
@@ -24,7 +24,8 @@
|
|||||||
-- @field #number ThreshTtot Total time threshold. Only write output if total function CPU time is more than this value.
|
-- @field #number ThreshTtot Total time threshold. Only write output if total function CPU time is more than this value.
|
||||||
-- @field #string fileNamePrefix Output file name prefix, e.g. "MooseProfiler".
|
-- @field #string fileNamePrefix Output file name prefix, e.g. "MooseProfiler".
|
||||||
-- @field #string fileNameSuffix Output file name prefix, e.g. "txt"
|
-- @field #string fileNameSuffix Output file name prefix, e.g. "txt"
|
||||||
--- *The emperor counsels simplicity. First principles. Of each particular thing, ask: What is it in itself, in its own constitution? What is its causal nature? *
|
|
||||||
|
--- *The emperor counsels simplicity.* *First principles. Of each particular thing, ask: What is it in itself, in its own constitution? What is its causal nature?*
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -33,11 +34,24 @@
|
|||||||
-- # The PROFILER Concept
|
-- # The PROFILER Concept
|
||||||
--
|
--
|
||||||
-- Profile your lua code. This tells you, which functions are called very often and which consume most real time.
|
-- Profile your lua code. This tells you, which functions are called very often and which consume most real time.
|
||||||
-- With this information you can optimize the performance of your code.
|
-- With this information you can optimize the perfomance of your code.
|
||||||
--
|
--
|
||||||
-- # Prerequisites
|
-- # Prerequisites
|
||||||
--
|
--
|
||||||
-- The modules **os** and **lfs** need to be de-sanitized.
|
-- The modules **os**, **io** and **lfs** need to be desanizied. Comment out the lines
|
||||||
|
--
|
||||||
|
-- --sanitizeModule('os')
|
||||||
|
-- --sanitizeModule('io')
|
||||||
|
-- --sanitizeModule('lfs')
|
||||||
|
--
|
||||||
|
-- in your *"DCS World OpenBeta/Scripts/MissionScripting.lua"* file.
|
||||||
|
--
|
||||||
|
-- But be aware that these changes can make you system vulnerable to attacks.
|
||||||
|
--
|
||||||
|
-- # Disclaimer
|
||||||
|
--
|
||||||
|
-- **Profiling itself is CPU expensive!** Don't use this when you want to fly or host a mission.
|
||||||
|
--
|
||||||
--
|
--
|
||||||
-- # Start
|
-- # Start
|
||||||
--
|
--
|
||||||
@@ -123,12 +137,12 @@ function PROFILER.Start( Delay, Duration )
|
|||||||
go = false
|
go = false
|
||||||
end
|
end
|
||||||
if not io then
|
if not io then
|
||||||
env.error( "ERROR: Profiler needs io to be de-sanitized!" )
|
env.error("ERROR: Profiler needs io to be desanitized!")
|
||||||
go = false
|
go=false
|
||||||
end
|
end
|
||||||
if not lfs then
|
if not lfs then
|
||||||
env.error( "ERROR: Profiler needs lfs to be de-sanitized!" )
|
env.error("ERROR: Profiler needs lfs to be desanitized!")
|
||||||
go = false
|
go=false
|
||||||
end
|
end
|
||||||
if not go then
|
if not go then
|
||||||
return
|
return
|
||||||
@@ -139,11 +153,11 @@ function PROFILER.Start( Delay, Duration )
|
|||||||
else
|
else
|
||||||
|
|
||||||
-- Set start time.
|
-- Set start time.
|
||||||
PROFILER.TstartGame = timer.getTime()
|
PROFILER.TstartGame=timer.getTime()
|
||||||
PROFILER.TstartOS = os.clock()
|
PROFILER.TstartOS=os.clock()
|
||||||
|
|
||||||
-- Add event handler.
|
-- Add event handler.
|
||||||
world.addEventHandler( PROFILER.eventHandler )
|
world.addEventHandler(PROFILER.eventHandler)
|
||||||
|
|
||||||
-- Info in log.
|
-- Info in log.
|
||||||
env.info( '############################ Profiler Started ############################' )
|
env.info( '############################ Profiler Started ############################' )
|
||||||
@@ -152,18 +166,19 @@ function PROFILER.Start( Delay, Duration )
|
|||||||
else
|
else
|
||||||
env.info( string.format( "- Will be stopped when mission ends" ) )
|
env.info( string.format( "- Will be stopped when mission ends" ) )
|
||||||
end
|
end
|
||||||
env.info( string.format( "- Calls per second threshold %.3f/sec", PROFILER.ThreshCPS ) )
|
env.info(string.format("- Calls per second threshold %.3f/sec", PROFILER.ThreshCPS))
|
||||||
env.info( string.format( "- Total function time threshold %.3f sec", PROFILER.ThreshTtot ) )
|
env.info(string.format("- Total function time threshold %.3f sec", PROFILER.ThreshTtot))
|
||||||
env.info( string.format( "- Output file \"%s\" in your DCS log file folder", PROFILER.getfilename( PROFILER.fileNameSuffix ) ) )
|
env.info(string.format("- Output file \"%s\" in your DCS log file folder", PROFILER.getfilename(PROFILER.fileNameSuffix)))
|
||||||
env.info( string.format( "- Output file \"%s\" in CSV format", PROFILER.getfilename( "csv" ) ) )
|
env.info(string.format("- Output file \"%s\" in CSV format", PROFILER.getfilename("csv")))
|
||||||
env.info( '###############################################################################' )
|
env.info('###############################################################################')
|
||||||
|
|
||||||
|
|
||||||
-- Message on screen
|
-- Message on screen
|
||||||
local duration = Duration or 600
|
local duration=Duration or 600
|
||||||
trigger.action.outText( "### Profiler running ###", duration )
|
trigger.action.outText("### Profiler running ###", duration)
|
||||||
|
|
||||||
-- Set hook.
|
-- Set hook.
|
||||||
debug.sethook( PROFILER.hook, "cr" )
|
debug.sethook(PROFILER.hook, "cr")
|
||||||
|
|
||||||
-- Auto stop profiler.
|
-- Auto stop profiler.
|
||||||
if Duration then
|
if Duration then
|
||||||
@@ -181,20 +196,29 @@ function PROFILER.Stop( Delay )
|
|||||||
if Delay and Delay > 0 then
|
if Delay and Delay > 0 then
|
||||||
|
|
||||||
BASE:ScheduleOnce( Delay, PROFILER.Stop )
|
BASE:ScheduleOnce( Delay, PROFILER.Stop )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function PROFILER.Stop(Delay)
|
||||||
|
|
||||||
|
if Delay and Delay>0 then
|
||||||
|
|
||||||
|
BASE:ScheduleOnce(Delay, PROFILER.Stop)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Remove hook.
|
-- Remove hook.
|
||||||
debug.sethook()
|
debug.sethook()
|
||||||
|
|
||||||
|
|
||||||
-- Run time game.
|
-- Run time game.
|
||||||
local runTimeGame = timer.getTime() - PROFILER.TstartGame
|
local runTimeGame=timer.getTime()-PROFILER.TstartGame
|
||||||
|
|
||||||
-- Run time real OS.
|
-- Run time real OS.
|
||||||
local runTimeOS = os.clock() - PROFILER.TstartOS
|
local runTimeOS=os.clock()-PROFILER.TstartOS
|
||||||
|
|
||||||
-- Show info.
|
-- Show info.
|
||||||
PROFILER.showInfo( runTimeGame, runTimeOS )
|
PROFILER.showInfo(runTimeGame, runTimeOS)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -213,34 +237,34 @@ end
|
|||||||
|
|
||||||
--- Debug hook.
|
--- Debug hook.
|
||||||
-- @param #table event Event.
|
-- @param #table event Event.
|
||||||
function PROFILER.hook( event )
|
function PROFILER.hook(event)
|
||||||
|
|
||||||
local f = debug.getinfo( 2, "f" ).func
|
local f=debug.getinfo(2, "f").func
|
||||||
|
|
||||||
if event == 'call' then
|
if event=='call' then
|
||||||
|
|
||||||
if PROFILER.Counters[f] == nil then
|
if PROFILER.Counters[f]==nil then
|
||||||
|
|
||||||
PROFILER.Counters[f] = 1
|
PROFILER.Counters[f]=1
|
||||||
PROFILER.dInfo[f] = debug.getinfo( 2, "Sn" )
|
PROFILER.dInfo[f]=debug.getinfo(2,"Sn")
|
||||||
|
|
||||||
if PROFILER.fTimeTotal[f] == nil then
|
if PROFILER.fTimeTotal[f]==nil then
|
||||||
PROFILER.fTimeTotal[f] = 0
|
PROFILER.fTimeTotal[f]=0
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
PROFILER.Counters[f] = PROFILER.Counters[f] + 1
|
PROFILER.Counters[f] = PROFILER.Counters[f] + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if PROFILER.fTime[f] == nil then
|
if PROFILER.fTime[f]==nil then
|
||||||
PROFILER.fTime[f] = os.clock()
|
PROFILER.fTime[f]=os.clock()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif (event == 'return') then
|
elseif (event=='return') then
|
||||||
|
|
||||||
if PROFILER.fTime[f] ~= nil then
|
if PROFILER.fTime[f]~=nil then
|
||||||
PROFILER.fTimeTotal[f] = PROFILER.fTimeTotal[f] + (os.clock() - PROFILER.fTime[f])
|
PROFILER.fTimeTotal[f]=PROFILER.fTimeTotal[f]+(os.clock()-PROFILER.fTime[f])
|
||||||
PROFILER.fTime[f] = nil
|
PROFILER.fTime[f]=nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -259,9 +283,9 @@ end
|
|||||||
-- @return #number Function time in seconds.
|
-- @return #number Function time in seconds.
|
||||||
function PROFILER.getData( func )
|
function PROFILER.getData( func )
|
||||||
|
|
||||||
local n = PROFILER.dInfo[func]
|
local n=PROFILER.dInfo[func]
|
||||||
|
|
||||||
if n.what == "C" then
|
if n.what=="C" then
|
||||||
return n.name, "?", "?", PROFILER.fTimeTotal[func]
|
return n.name, "?", "?", PROFILER.fTimeTotal[func]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -282,20 +306,20 @@ end
|
|||||||
function PROFILER.showTable( data, f, runTimeGame )
|
function PROFILER.showTable( data, f, runTimeGame )
|
||||||
|
|
||||||
-- Loop over data.
|
-- Loop over data.
|
||||||
for i = 1, #data do
|
for i=1, #data do
|
||||||
local t = data[i] -- #PROFILER.Data
|
local t=data[i] --#PROFILER.Data
|
||||||
|
|
||||||
-- Calls per second.
|
-- Calls per second.
|
||||||
local cps = t.count / runTimeGame
|
local cps=t.count/runTimeGame
|
||||||
|
|
||||||
local threshCPS = cps >= PROFILER.ThreshCPS
|
local threshCPS=cps>=PROFILER.ThreshCPS
|
||||||
local threshTot = t.tm >= PROFILER.ThreshTtot
|
local threshTot=t.tm>=PROFILER.ThreshTtot
|
||||||
|
|
||||||
if threshCPS and threshTot then
|
if threshCPS and threshTot then
|
||||||
|
|
||||||
-- Output
|
-- Output
|
||||||
local text = string.format( "%30s: %8d calls %8.1f/sec - Time Total %8.3f sec (%.3f %%) %5.3f sec/call %s line %s", t.func, t.count, cps, t.tm, t.tm / runTimeGame * 100, t.tm / t.count, tostring( t.src ), tostring( t.line ) )
|
local text=string.format("%30s: %8d calls %8.1f/sec - Time Total %8.3f sec (%.3f %%) %5.3f sec/call %s line %s", t.func, t.count, cps, t.tm, t.tm/runTimeGame*100, t.tm/t.count, tostring(t.src), tostring(t.line))
|
||||||
PROFILER._flog( f, text )
|
PROFILER._flog(f, text)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -312,19 +336,19 @@ function PROFILER.printCSV( data, runTimeGame )
|
|||||||
local g = io.open( file, 'w' )
|
local g = io.open( file, 'w' )
|
||||||
|
|
||||||
-- Header.
|
-- Header.
|
||||||
local text = "Function,Total Calls,Calls per Sec,Total Time,Total in %,Sec per Call,Source File;Line Number,"
|
local text="Function,Total Calls,Calls per Sec,Total Time,Total in %,Sec per Call,Source File;Line Number,"
|
||||||
g:write( text .. "\r\n" )
|
g:write(text.."\r\n")
|
||||||
|
|
||||||
-- Loop over data.
|
-- Loop over data.
|
||||||
for i = 1, #data do
|
for i=1, #data do
|
||||||
local t = data[i] -- #PROFILER.Data
|
local t=data[i] --#PROFILER.Data
|
||||||
|
|
||||||
-- Calls per second.
|
-- Calls per second.
|
||||||
local cps = t.count / runTimeGame
|
local cps = t.count / runTimeGame
|
||||||
|
|
||||||
-- Output
|
-- Output
|
||||||
local txt = string.format( "%s,%d,%.1f,%.3f,%.3f,%.3f,%s,%s,", t.func, t.count, cps, t.tm, t.tm / runTimeGame * 100, t.tm / t.count, tostring( t.src ), tostring( t.line ) )
|
local txt=string.format("%s,%d,%.1f,%.3f,%.3f,%.3f,%s,%s,", t.func, t.count, cps, t.tm, t.tm/runTimeGame*100, t.tm/t.count, tostring(t.src), tostring(t.line))
|
||||||
g:write( txt .. "\r\n" )
|
g:write(txt.."\r\n")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -335,15 +359,15 @@ end
|
|||||||
--- Write info to output file.
|
--- Write info to output file.
|
||||||
-- @param #string ext Extension.
|
-- @param #string ext Extension.
|
||||||
-- @return #string File name.
|
-- @return #string File name.
|
||||||
function PROFILER.getfilename( ext )
|
function PROFILER.getfilename(ext)
|
||||||
|
|
||||||
local dir = lfs.writedir() .. [[Logs\]]
|
local dir=lfs.writedir()..[[Logs\]]
|
||||||
|
|
||||||
ext = ext or PROFILER.fileNameSuffix
|
ext=ext or PROFILER.fileNameSuffix
|
||||||
|
|
||||||
local file = dir .. PROFILER.fileNamePrefix .. "." .. ext
|
local file=dir..PROFILER.fileNamePrefix.."."..ext
|
||||||
|
|
||||||
if not UTILS.FileExists( file ) then
|
if not UTILS.FileExists(file) then
|
||||||
return file
|
return file
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -365,34 +389,39 @@ end
|
|||||||
function PROFILER.showInfo( runTimeGame, runTimeOS )
|
function PROFILER.showInfo( runTimeGame, runTimeOS )
|
||||||
|
|
||||||
-- Output file.
|
-- Output file.
|
||||||
local file = PROFILER.getfilename( PROFILER.fileNameSuffix )
|
local file=PROFILER.getfilename(PROFILER.fileNameSuffix)
|
||||||
local f = io.open( file, 'w' )
|
local f=io.open(file, 'w')
|
||||||
|
|
||||||
-- Gather data.
|
-- Gather data.
|
||||||
local Ttot = 0
|
local Ttot=0
|
||||||
local Calls = 0
|
local Calls=0
|
||||||
|
|
||||||
local t = {}
|
local t={}
|
||||||
|
|
||||||
local tcopy = nil -- #PROFILER.Data
|
local tcopy=nil --#PROFILER.Data
|
||||||
local tserialize = nil -- #PROFILER.Data
|
local tserialize=nil --#PROFILER.Data
|
||||||
local tforgen = nil -- #PROFILER.Data
|
local tforgen=nil --#PROFILER.Data
|
||||||
local tpairs = nil -- #PROFILER.Data
|
local tpairs=nil --#PROFILER.Data
|
||||||
|
|
||||||
for func, count in pairs( PROFILER.Counters ) do
|
|
||||||
|
|
||||||
local s, src, line, tm = PROFILER.getData( func )
|
for func, count in pairs(PROFILER.Counters) do
|
||||||
|
|
||||||
if PROFILER.logUnknown == true then
|
local s,src,line,tm=PROFILER.getData(func)
|
||||||
if s == nil then
|
|
||||||
s = "<Unknown>"
|
if PROFILER.logUnknown==true then
|
||||||
end
|
if s==nil then s="<Unknown>" end
|
||||||
end
|
end
|
||||||
|
|
||||||
if s ~= nil then
|
if s~=nil then
|
||||||
|
|
||||||
-- Profile data.
|
-- Profile data.
|
||||||
local T = { func = s, src = src, line = line, count = count, tm = tm } -- #PROFILER.Data
|
local T=
|
||||||
|
{ func=s,
|
||||||
|
src=src,
|
||||||
|
line=line,
|
||||||
|
count=count,
|
||||||
|
tm=tm,
|
||||||
|
} --#PROFILER.Data
|
||||||
|
|
||||||
-- Collect special cases. Somehow, e.g. "_copy" appears multiple times so we try to gather all data.
|
-- Collect special cases. Somehow, e.g. "_copy" appears multiple times so we try to gather all data.
|
||||||
if s == "_copy" then
|
if s == "_copy" then
|
||||||
@@ -406,32 +435,32 @@ function PROFILER.showInfo( runTimeGame, runTimeOS )
|
|||||||
if tserialize == nil then
|
if tserialize == nil then
|
||||||
tserialize = T
|
tserialize = T
|
||||||
else
|
else
|
||||||
tserialize.count = tserialize.count + T.count
|
tserialize.count=tserialize.count+T.count
|
||||||
tserialize.tm = tserialize.tm + T.tm
|
tserialize.tm=tserialize.tm+T.tm
|
||||||
end
|
end
|
||||||
elseif s == "(for generator)" then
|
elseif s=="(for generator)" then
|
||||||
if tforgen == nil then
|
if tforgen==nil then
|
||||||
tforgen = T
|
tforgen=T
|
||||||
else
|
else
|
||||||
tforgen.count = tforgen.count + T.count
|
tforgen.count=tforgen.count+T.count
|
||||||
tforgen.tm = tforgen.tm + T.tm
|
tforgen.tm=tforgen.tm+T.tm
|
||||||
end
|
end
|
||||||
elseif s == "pairs" then
|
elseif s=="pairs" then
|
||||||
if tpairs == nil then
|
if tpairs==nil then
|
||||||
tpairs = T
|
tpairs=T
|
||||||
else
|
else
|
||||||
tpairs.count = tpairs.count + T.count
|
tpairs.count=tpairs.count+T.count
|
||||||
tpairs.tm = tpairs.tm + T.tm
|
tpairs.tm=tpairs.tm+T.tm
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
table.insert( t, T )
|
table.insert( t, T )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Total function time.
|
-- Total function time.
|
||||||
Ttot = Ttot + tm
|
Ttot=Ttot+tm
|
||||||
|
|
||||||
-- Total number of calls.
|
-- Total number of calls.
|
||||||
Calls = Calls + count
|
Calls=Calls+count
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -442,83 +471,77 @@ function PROFILER.showInfo( runTimeGame, runTimeOS )
|
|||||||
table.insert( t, tcopy )
|
table.insert( t, tcopy )
|
||||||
end
|
end
|
||||||
if tserialize then
|
if tserialize then
|
||||||
table.insert( t, tserialize )
|
table.insert(t, tserialize)
|
||||||
end
|
end
|
||||||
if tforgen then
|
if tforgen then
|
||||||
table.insert( t, tforgen )
|
table.insert( t, tforgen )
|
||||||
end
|
end
|
||||||
if tpairs then
|
if tpairs then
|
||||||
table.insert( t, tpairs )
|
table.insert(t, tpairs)
|
||||||
end
|
end
|
||||||
|
|
||||||
env.info( '############################ Profiler Stopped ############################' )
|
env.info('############################ Profiler Stopped ############################')
|
||||||
env.info( string.format( "* Runtime Game : %s = %d sec", UTILS.SecondsToClock( runTimeGame, true ), runTimeGame ) )
|
env.info(string.format("* Runtime Game : %s = %d sec", UTILS.SecondsToClock(runTimeGame, true), runTimeGame))
|
||||||
env.info( string.format( "* Runtime Real : %s = %d sec", UTILS.SecondsToClock( runTimeOS, true ), runTimeOS ) )
|
env.info(string.format("* Runtime Real : %s = %d sec", UTILS.SecondsToClock(runTimeOS, true), runTimeOS))
|
||||||
env.info( string.format( "* Function time : %s = %.1f sec (%.1f percent of runtime game)", UTILS.SecondsToClock( Ttot, true ), Ttot, Ttot / runTimeGame * 100 ) )
|
env.info(string.format("* Function time : %s = %.1f sec (%.1f percent of runtime game)", UTILS.SecondsToClock(Ttot, true), Ttot, Ttot/runTimeGame*100))
|
||||||
env.info( string.format( "* Total functions : %d", #t ) )
|
env.info(string.format("* Total functions : %d", #t))
|
||||||
env.info( string.format( "* Total func calls : %d", Calls ) )
|
env.info(string.format("* Total func calls : %d", Calls))
|
||||||
env.info( string.format( "* Writing to file : \"%s\"", file ) )
|
env.info(string.format("* Writing to file : \"%s\"", file))
|
||||||
env.info( string.format( "* Writing to file : \"%s\"", PROFILER.getfilename( "csv" ) ) )
|
env.info(string.format("* Writing to file : \"%s\"", PROFILER.getfilename("csv")))
|
||||||
env.info( "##############################################################################" )
|
env.info("##############################################################################")
|
||||||
|
|
||||||
-- Sort by total time.
|
-- Sort by total time.
|
||||||
table.sort( t, function( a, b )
|
table.sort(t, function(a,b) return a.tm>b.tm end)
|
||||||
return a.tm > b.tm
|
|
||||||
end )
|
|
||||||
|
|
||||||
-- Write data.
|
-- Write data.
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, "************************************************************************************************************************" )
|
PROFILER._flog(f,"************************************************************************************************************************")
|
||||||
PROFILER._flog( f, "************************************************************************************************************************" )
|
PROFILER._flog(f,"************************************************************************************************************************")
|
||||||
PROFILER._flog( f, "************************************************************************************************************************" )
|
PROFILER._flog(f,"************************************************************************************************************************")
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, "-------------------------" )
|
PROFILER._flog(f,"-------------------------")
|
||||||
PROFILER._flog( f, "---- Profiler Report ----" )
|
PROFILER._flog(f,"---- Profiler Report ----")
|
||||||
PROFILER._flog( f, "-------------------------" )
|
PROFILER._flog(f,"-------------------------")
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, string.format( "* Runtime Game : %s = %.1f sec", UTILS.SecondsToClock( runTimeGame, true ), runTimeGame ) )
|
PROFILER._flog(f,string.format("* Runtime Game : %s = %.1f sec", UTILS.SecondsToClock(runTimeGame, true), runTimeGame))
|
||||||
PROFILER._flog( f, string.format( "* Runtime Real : %s = %.1f sec", UTILS.SecondsToClock( runTimeOS, true ), runTimeOS ) )
|
PROFILER._flog(f,string.format("* Runtime Real : %s = %.1f sec", UTILS.SecondsToClock(runTimeOS, true), runTimeOS))
|
||||||
PROFILER._flog( f, string.format( "* Function time : %s = %.1f sec (%.1f %% of runtime game)", UTILS.SecondsToClock( Ttot, true ), Ttot, Ttot / runTimeGame * 100 ) )
|
PROFILER._flog(f,string.format("* Function time : %s = %.1f sec (%.1f %% of runtime game)", UTILS.SecondsToClock(Ttot, true), Ttot, Ttot/runTimeGame*100))
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, string.format( "* Total functions = %d", #t ) )
|
PROFILER._flog(f,string.format("* Total functions = %d", #t))
|
||||||
PROFILER._flog( f, string.format( "* Total func calls = %d", Calls ) )
|
PROFILER._flog(f,string.format("* Total func calls = %d", Calls))
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, string.format( "* Calls per second threshold = %.3f/sec", PROFILER.ThreshCPS ) )
|
PROFILER._flog(f,string.format("* Calls per second threshold = %.3f/sec", PROFILER.ThreshCPS))
|
||||||
PROFILER._flog( f, string.format( "* Total func time threshold = %.3f sec", PROFILER.ThreshTtot ) )
|
PROFILER._flog(f,string.format("* Total func time threshold = %.3f sec", PROFILER.ThreshTtot))
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, "************************************************************************************************************************" )
|
PROFILER._flog(f,"************************************************************************************************************************")
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER.showTable( t, f, runTimeGame )
|
PROFILER.showTable(t, f, runTimeGame)
|
||||||
|
|
||||||
-- Sort by number of calls.
|
-- Sort by number of calls.
|
||||||
table.sort( t, function( a, b )
|
table.sort(t, function(a,b) return a.tm/a.count>b.tm/b.count end)
|
||||||
return a.tm / a.count > b.tm / b.count
|
|
||||||
end )
|
|
||||||
|
|
||||||
-- Detailed data.
|
-- Detailed data.
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, "************************************************************************************************************************" )
|
PROFILER._flog(f,"************************************************************************************************************************")
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, "--------------------------------------" )
|
PROFILER._flog(f,"--------------------------------------")
|
||||||
PROFILER._flog( f, "---- Data Sorted by Time per Call ----" )
|
PROFILER._flog(f,"---- Data Sorted by Time per Call ----")
|
||||||
PROFILER._flog( f, "--------------------------------------" )
|
PROFILER._flog(f,"--------------------------------------")
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER.showTable( t, f, runTimeGame )
|
PROFILER.showTable(t, f, runTimeGame)
|
||||||
|
|
||||||
-- Sort by number of calls.
|
-- Sort by number of calls.
|
||||||
table.sort( t, function( a, b )
|
table.sort(t, function(a,b) return a.count>b.count end)
|
||||||
return a.count > b.count
|
|
||||||
end )
|
|
||||||
|
|
||||||
-- Detailed data.
|
-- Detailed data.
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, "************************************************************************************************************************" )
|
PROFILER._flog(f,"************************************************************************************************************************")
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER._flog( f, "------------------------------------" )
|
PROFILER._flog(f,"------------------------------------")
|
||||||
PROFILER._flog( f, "---- Data Sorted by Total Calls ----" )
|
PROFILER._flog(f,"---- Data Sorted by Total Calls ----")
|
||||||
PROFILER._flog( f, "------------------------------------" )
|
PROFILER._flog(f,"------------------------------------")
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog(f,"")
|
||||||
PROFILER.showTable( t, f, runTimeGame )
|
PROFILER.showTable(t, f, runTimeGame)
|
||||||
|
|
||||||
-- Closing.
|
-- Closing.
|
||||||
PROFILER._flog( f, "" )
|
PROFILER._flog( f, "" )
|
||||||
|
|||||||
@@ -494,330 +494,343 @@ routines.ground = {}
|
|||||||
routines.fixedWing = {}
|
routines.fixedWing = {}
|
||||||
routines.heli = {}
|
routines.heli = {}
|
||||||
|
|
||||||
routines.ground.buildWP = function( point, overRideForm, overRideSpeed )
|
routines.ground.buildWP = function(point, overRideForm, overRideSpeed)
|
||||||
|
|
||||||
local wp = {}
|
local wp = {}
|
||||||
wp.x = point.x
|
wp.x = point.x
|
||||||
|
|
||||||
if point.z then
|
if point.z then
|
||||||
wp.y = point.z
|
wp.y = point.z
|
||||||
else
|
else
|
||||||
wp.y = point.y
|
wp.y = point.y
|
||||||
end
|
end
|
||||||
local form, speed
|
local form, speed
|
||||||
|
|
||||||
if point.speed and not overRideSpeed then
|
if point.speed and not overRideSpeed then
|
||||||
wp.speed = point.speed
|
wp.speed = point.speed
|
||||||
elseif type( overRideSpeed ) == 'number' then
|
elseif type(overRideSpeed) == 'number' then
|
||||||
wp.speed = overRideSpeed
|
wp.speed = overRideSpeed
|
||||||
else
|
else
|
||||||
wp.speed = routines.utils.kmphToMps( 20 )
|
wp.speed = routines.utils.kmphToMps(20)
|
||||||
end
|
end
|
||||||
|
|
||||||
if point.form and not overRideForm then
|
if point.form and not overRideForm then
|
||||||
form = point.form
|
form = point.form
|
||||||
else
|
else
|
||||||
form = overRideForm
|
form = overRideForm
|
||||||
end
|
end
|
||||||
|
|
||||||
if not form then
|
if not form then
|
||||||
wp.action = 'Cone'
|
wp.action = 'Cone'
|
||||||
else
|
else
|
||||||
form = string.lower( form )
|
form = string.lower(form)
|
||||||
if form == 'off_road' or form == 'off road' then
|
if form == 'off_road' or form == 'off road' then
|
||||||
wp.action = 'Off Road'
|
wp.action = 'Off Road'
|
||||||
elseif form == 'on_road' or form == 'on road' then
|
elseif form == 'on_road' or form == 'on road' then
|
||||||
wp.action = 'On Road'
|
wp.action = 'On Road'
|
||||||
elseif form == 'rank' or form == 'line_abrest' or form == 'line abrest' or form == 'lineabrest' then
|
elseif form == 'rank' or form == 'line_abrest' or form == 'line abrest' or form == 'lineabrest'then
|
||||||
wp.action = 'Rank'
|
wp.action = 'Rank'
|
||||||
elseif form == 'cone' then
|
elseif form == 'cone' then
|
||||||
wp.action = 'Cone'
|
wp.action = 'Cone'
|
||||||
elseif form == 'diamond' then
|
elseif form == 'diamond' then
|
||||||
wp.action = 'Diamond'
|
wp.action = 'Diamond'
|
||||||
elseif form == 'vee' then
|
elseif form == 'vee' then
|
||||||
wp.action = 'Vee'
|
wp.action = 'Vee'
|
||||||
elseif form == 'echelon_left' or form == 'echelon left' or form == 'echelonl' then
|
elseif form == 'echelon_left' or form == 'echelon left' or form == 'echelonl' then
|
||||||
wp.action = 'EchelonL'
|
wp.action = 'EchelonL'
|
||||||
elseif form == 'echelon_right' or form == 'echelon right' or form == 'echelonr' then
|
elseif form == 'echelon_right' or form == 'echelon right' or form == 'echelonr' then
|
||||||
wp.action = 'EchelonR'
|
wp.action = 'EchelonR'
|
||||||
else
|
else
|
||||||
wp.action = 'Cone' -- if nothing matched
|
wp.action = 'Cone' -- if nothing matched
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
wp.type = 'Turning Point'
|
||||||
|
|
||||||
|
return wp
|
||||||
|
|
||||||
wp.type = 'Turning Point'
|
|
||||||
return wp
|
|
||||||
end
|
end
|
||||||
|
|
||||||
routines.fixedWing.buildWP = function( point, WPtype, speed, alt, altType )
|
routines.fixedWing.buildWP = function(point, WPtype, speed, alt, altType)
|
||||||
|
|
||||||
local wp = {}
|
local wp = {}
|
||||||
wp.x = point.x
|
wp.x = point.x
|
||||||
|
|
||||||
if point.z then
|
if point.z then
|
||||||
wp.y = point.z
|
wp.y = point.z
|
||||||
else
|
else
|
||||||
wp.y = point.y
|
wp.y = point.y
|
||||||
end
|
end
|
||||||
|
|
||||||
if alt and type( alt ) == 'number' then
|
if alt and type(alt) == 'number' then
|
||||||
wp.alt = alt
|
wp.alt = alt
|
||||||
else
|
else
|
||||||
wp.alt = 2000
|
wp.alt = 2000
|
||||||
end
|
end
|
||||||
|
|
||||||
if altType then
|
if altType then
|
||||||
altType = string.lower( altType )
|
altType = string.lower(altType)
|
||||||
if altType == 'radio' or 'agl' then
|
if altType == 'radio' or 'agl' then
|
||||||
wp.alt_type = 'RADIO'
|
wp.alt_type = 'RADIO'
|
||||||
elseif altType == 'baro' or 'asl' then
|
elseif altType == 'baro' or 'asl' then
|
||||||
wp.alt_type = 'BARO'
|
wp.alt_type = 'BARO'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
wp.alt_type = 'RADIO'
|
wp.alt_type = 'RADIO'
|
||||||
end
|
end
|
||||||
|
|
||||||
if point.speed then
|
if point.speed then
|
||||||
speed = point.speed
|
speed = point.speed
|
||||||
end
|
end
|
||||||
|
|
||||||
if point.type then
|
if point.type then
|
||||||
WPtype = point.type
|
WPtype = point.type
|
||||||
end
|
end
|
||||||
|
|
||||||
if not speed then
|
if not speed then
|
||||||
wp.speed = routines.utils.kmphToMps( 500 )
|
wp.speed = routines.utils.kmphToMps(500)
|
||||||
else
|
else
|
||||||
wp.speed = speed
|
wp.speed = speed
|
||||||
end
|
end
|
||||||
|
|
||||||
if not WPtype then
|
if not WPtype then
|
||||||
wp.action = 'Turning Point'
|
wp.action = 'Turning Point'
|
||||||
else
|
else
|
||||||
WPtype = string.lower( WPtype )
|
WPtype = string.lower(WPtype)
|
||||||
if WPtype == 'flyover' or WPtype == 'fly over' or WPtype == 'fly_over' then
|
if WPtype == 'flyover' or WPtype == 'fly over' or WPtype == 'fly_over' then
|
||||||
wp.action = 'Fly Over Point'
|
wp.action = 'Fly Over Point'
|
||||||
elseif WPtype == 'turningpoint' or WPtype == 'turning point' or WPtype == 'turning_point' then
|
elseif WPtype == 'turningpoint' or WPtype == 'turning point' or WPtype == 'turning_point' then
|
||||||
wp.action = 'Turning Point'
|
wp.action = 'Turning Point'
|
||||||
else
|
else
|
||||||
wp.action = 'Turning Point'
|
wp.action = 'Turning Point'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
wp.type = 'Turning Point'
|
wp.type = 'Turning Point'
|
||||||
return wp
|
return wp
|
||||||
end
|
end
|
||||||
|
|
||||||
routines.heli.buildWP = function( point, WPtype, speed, alt, altType )
|
routines.heli.buildWP = function(point, WPtype, speed, alt, altType)
|
||||||
|
|
||||||
local wp = {}
|
local wp = {}
|
||||||
wp.x = point.x
|
wp.x = point.x
|
||||||
|
|
||||||
if point.z then
|
if point.z then
|
||||||
wp.y = point.z
|
wp.y = point.z
|
||||||
else
|
else
|
||||||
wp.y = point.y
|
wp.y = point.y
|
||||||
end
|
end
|
||||||
|
|
||||||
if alt and type( alt ) == 'number' then
|
if alt and type(alt) == 'number' then
|
||||||
wp.alt = alt
|
wp.alt = alt
|
||||||
else
|
else
|
||||||
wp.alt = 500
|
wp.alt = 500
|
||||||
end
|
end
|
||||||
|
|
||||||
if altType then
|
if altType then
|
||||||
altType = string.lower( altType )
|
altType = string.lower(altType)
|
||||||
if altType == 'radio' or 'agl' then
|
if altType == 'radio' or 'agl' then
|
||||||
wp.alt_type = 'RADIO'
|
wp.alt_type = 'RADIO'
|
||||||
elseif altType == 'baro' or 'asl' then
|
elseif altType == 'baro' or 'asl' then
|
||||||
wp.alt_type = 'BARO'
|
wp.alt_type = 'BARO'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
wp.alt_type = 'RADIO'
|
wp.alt_type = 'RADIO'
|
||||||
end
|
end
|
||||||
|
|
||||||
if point.speed then
|
if point.speed then
|
||||||
speed = point.speed
|
speed = point.speed
|
||||||
end
|
end
|
||||||
|
|
||||||
if point.type then
|
if point.type then
|
||||||
WPtype = point.type
|
WPtype = point.type
|
||||||
end
|
end
|
||||||
|
|
||||||
if not speed then
|
if not speed then
|
||||||
wp.speed = routines.utils.kmphToMps( 200 )
|
wp.speed = routines.utils.kmphToMps(200)
|
||||||
else
|
else
|
||||||
wp.speed = speed
|
wp.speed = speed
|
||||||
end
|
end
|
||||||
|
|
||||||
if not WPtype then
|
if not WPtype then
|
||||||
wp.action = 'Turning Point'
|
wp.action = 'Turning Point'
|
||||||
else
|
else
|
||||||
WPtype = string.lower( WPtype )
|
WPtype = string.lower(WPtype)
|
||||||
if WPtype == 'flyover' or WPtype == 'fly over' or WPtype == 'fly_over' then
|
if WPtype == 'flyover' or WPtype == 'fly over' or WPtype == 'fly_over' then
|
||||||
wp.action = 'Fly Over Point'
|
wp.action = 'Fly Over Point'
|
||||||
elseif WPtype == 'turningpoint' or WPtype == 'turning point' or WPtype == 'turning_point' then
|
elseif WPtype == 'turningpoint' or WPtype == 'turning point' or WPtype == 'turning_point' then
|
||||||
wp.action = 'Turning Point'
|
wp.action = 'Turning Point'
|
||||||
else
|
else
|
||||||
wp.action = 'Turning Point'
|
wp.action = 'Turning Point'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
wp.type = 'Turning Point'
|
wp.type = 'Turning Point'
|
||||||
return wp
|
return wp
|
||||||
end
|
end
|
||||||
|
|
||||||
routines.groupToRandomPoint = function( vars )
|
routines.groupToRandomPoint = function(vars)
|
||||||
local group = vars.group -- Required
|
local group = vars.group --Required
|
||||||
local point = vars.point -- required
|
local point = vars.point --required
|
||||||
local radius = vars.radius or 0
|
local radius = vars.radius or 0
|
||||||
local innerRadius = vars.innerRadius
|
local innerRadius = vars.innerRadius
|
||||||
local form = vars.form or 'Cone'
|
local form = vars.form or 'Cone'
|
||||||
local heading = vars.heading or math.random() * 2 * math.pi
|
local heading = vars.heading or math.random()*2*math.pi
|
||||||
local headingDegrees = vars.headingDegrees
|
local headingDegrees = vars.headingDegrees
|
||||||
local speed = vars.speed or routines.utils.kmphToMps( 20 )
|
local speed = vars.speed or routines.utils.kmphToMps(20)
|
||||||
|
|
||||||
local useRoads
|
|
||||||
if not vars.disableRoads then
|
|
||||||
useRoads = true
|
|
||||||
else
|
|
||||||
useRoads = false
|
|
||||||
end
|
|
||||||
|
|
||||||
local path = {}
|
local useRoads
|
||||||
|
if not vars.disableRoads then
|
||||||
|
useRoads = true
|
||||||
|
else
|
||||||
|
useRoads = false
|
||||||
|
end
|
||||||
|
|
||||||
if headingDegrees then
|
local path = {}
|
||||||
heading = headingDegrees * math.pi / 180
|
|
||||||
end
|
|
||||||
|
|
||||||
if heading >= 2 * math.pi then
|
if headingDegrees then
|
||||||
heading = heading - 2 * math.pi
|
heading = headingDegrees*math.pi/180
|
||||||
end
|
end
|
||||||
|
|
||||||
local rndCoord = routines.getRandPointInCircle( point, radius, innerRadius )
|
if heading >= 2*math.pi then
|
||||||
|
heading = heading - 2*math.pi
|
||||||
|
end
|
||||||
|
|
||||||
local offset = {}
|
local rndCoord = routines.getRandPointInCircle(point, radius, innerRadius)
|
||||||
local posStart = routines.getLeadPos( group )
|
|
||||||
|
|
||||||
offset.x = routines.utils.round( math.sin( heading - (math.pi / 2) ) * 50 + rndCoord.x, 3 )
|
local offset = {}
|
||||||
offset.z = routines.utils.round( math.cos( heading + (math.pi / 2) ) * 50 + rndCoord.y, 3 )
|
local posStart = routines.getLeadPos(group)
|
||||||
path[#path + 1] = routines.ground.buildWP( posStart, form, speed )
|
|
||||||
|
|
||||||
if useRoads == true and ((point.x - posStart.x) ^ 2 + (point.z - posStart.z) ^ 2) ^ 0.5 > radius * 1.3 then
|
offset.x = routines.utils.round(math.sin(heading - (math.pi/2)) * 50 + rndCoord.x, 3)
|
||||||
path[#path + 1] = routines.ground.buildWP( { ['x'] = posStart.x + 11, ['z'] = posStart.z + 11 }, 'off_road', speed )
|
offset.z = routines.utils.round(math.cos(heading + (math.pi/2)) * 50 + rndCoord.y, 3)
|
||||||
path[#path + 1] = routines.ground.buildWP( posStart, 'on_road', speed )
|
path[#path + 1] = routines.ground.buildWP(posStart, form, speed)
|
||||||
path[#path + 1] = routines.ground.buildWP( offset, 'on_road', speed )
|
|
||||||
else
|
|
||||||
path[#path + 1] = routines.ground.buildWP( { ['x'] = posStart.x + 25, ['z'] = posStart.z + 25 }, form, speed )
|
|
||||||
end
|
|
||||||
|
|
||||||
path[#path + 1] = routines.ground.buildWP( offset, form, speed )
|
|
||||||
path[#path + 1] = routines.ground.buildWP( rndCoord, form, speed )
|
|
||||||
|
|
||||||
routines.goRoute( group, path )
|
if useRoads == true and ((point.x - posStart.x)^2 + (point.z - posStart.z)^2)^0.5 > radius * 1.3 then
|
||||||
|
path[#path + 1] = routines.ground.buildWP({['x'] = posStart.x + 11, ['z'] = posStart.z + 11}, 'off_road', speed)
|
||||||
|
path[#path + 1] = routines.ground.buildWP(posStart, 'on_road', speed)
|
||||||
|
path[#path + 1] = routines.ground.buildWP(offset, 'on_road', speed)
|
||||||
|
else
|
||||||
|
path[#path + 1] = routines.ground.buildWP({['x'] = posStart.x + 25, ['z'] = posStart.z + 25}, form, speed)
|
||||||
|
end
|
||||||
|
|
||||||
|
path[#path + 1] = routines.ground.buildWP(offset, form, speed)
|
||||||
|
path[#path + 1] = routines.ground.buildWP(rndCoord, form, speed)
|
||||||
|
|
||||||
|
routines.goRoute(group, path)
|
||||||
|
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
routines.groupRandomDistSelf = function( gpData, dist, form, heading, speed )
|
routines.groupRandomDistSelf = function(gpData, dist, form, heading, speed)
|
||||||
local pos = routines.getLeadPos( gpData )
|
local pos = routines.getLeadPos(gpData)
|
||||||
local fakeZone = {}
|
local fakeZone = {}
|
||||||
fakeZone.radius = dist or math.random( 300, 1000 )
|
fakeZone.radius = dist or math.random(300, 1000)
|
||||||
fakeZone.point = { x = pos.x, y, pos.y, z = pos.z }
|
fakeZone.point = {x = pos.x, y = pos.y, z = pos.z}
|
||||||
routines.groupToRandomZone( gpData, fakeZone, form, heading, speed )
|
routines.groupToRandomZone(gpData, fakeZone, form, heading, speed)
|
||||||
|
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
routines.groupToRandomZone = function( gpData, zone, form, heading, speed )
|
routines.groupToRandomZone = function(gpData, zone, form, heading, speed)
|
||||||
if type( gpData ) == 'string' then
|
if type(gpData) == 'string' then
|
||||||
gpData = Group.getByName( gpData )
|
gpData = Group.getByName(gpData)
|
||||||
end
|
end
|
||||||
|
|
||||||
if type( zone ) == 'string' then
|
if type(zone) == 'string' then
|
||||||
zone = trigger.misc.getZone( zone )
|
zone = trigger.misc.getZone(zone)
|
||||||
elseif type( zone ) == 'table' and not zone.radius then
|
elseif type(zone) == 'table' and not zone.radius then
|
||||||
zone = trigger.misc.getZone( zone[math.random( 1, #zone )] )
|
zone = trigger.misc.getZone(zone[math.random(1, #zone)])
|
||||||
end
|
end
|
||||||
|
|
||||||
if speed then
|
if speed then
|
||||||
speed = routines.utils.kmphToMps( speed )
|
speed = routines.utils.kmphToMps(speed)
|
||||||
end
|
end
|
||||||
|
|
||||||
local vars = {}
|
local vars = {}
|
||||||
vars.group = gpData
|
vars.group = gpData
|
||||||
vars.radius = zone.radius
|
vars.radius = zone.radius
|
||||||
vars.form = form
|
vars.form = form
|
||||||
vars.headingDegrees = heading
|
vars.headingDegrees = heading
|
||||||
vars.speed = speed
|
vars.speed = speed
|
||||||
vars.point = routines.utils.zoneToVec3( zone )
|
vars.point = routines.utils.zoneToVec3(zone)
|
||||||
|
|
||||||
routines.groupToRandomPoint( vars )
|
routines.groupToRandomPoint(vars)
|
||||||
|
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
routines.isTerrainValid = function( coord, terrainTypes ) -- vec2/3 and enum or table of acceptable terrain types
|
routines.isTerrainValid = function(coord, terrainTypes) -- vec2/3 and enum or table of acceptable terrain types
|
||||||
if coord.z then
|
if coord.z then
|
||||||
coord.y = coord.z
|
coord.y = coord.z
|
||||||
end
|
end
|
||||||
local typeConverted = {}
|
local typeConverted = {}
|
||||||
|
|
||||||
if type( terrainTypes ) == 'string' then -- if its a string it does this check
|
if type(terrainTypes) == 'string' then -- if its a string it does this check
|
||||||
for constId, constData in pairs( land.SurfaceType ) do
|
for constId, constData in pairs(land.SurfaceType) do
|
||||||
if string.lower( constId ) == string.lower( terrainTypes ) or string.lower( constData ) == string.lower( terrainTypes ) then
|
if string.lower(constId) == string.lower(terrainTypes) or string.lower(constData) == string.lower(terrainTypes) then
|
||||||
table.insert( typeConverted, constId )
|
table.insert(typeConverted, constId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif type( terrainTypes ) == 'table' then -- if its a table it does this check
|
elseif type(terrainTypes) == 'table' then -- if its a table it does this check
|
||||||
for typeId, typeData in pairs( terrainTypes ) do
|
for typeId, typeData in pairs(terrainTypes) do
|
||||||
for constId, constData in pairs( land.SurfaceType ) do
|
for constId, constData in pairs(land.SurfaceType) do
|
||||||
if string.lower( constId ) == string.lower( typeData ) or string.lower( constData ) == string.lower( typeId ) then
|
if string.lower(constId) == string.lower(typeData) or string.lower(constData) == string.lower(typeId) then
|
||||||
table.insert( typeConverted, constId )
|
table.insert(typeConverted, constId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for validIndex, validData in pairs( typeConverted ) do
|
for validIndex, validData in pairs(typeConverted) do
|
||||||
if land.getSurfaceType( coord ) == land.SurfaceType[validData] then
|
if land.getSurfaceType(coord) == land.SurfaceType[validData] then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
routines.groupToPoint = function( gpData, point, form, heading, speed, useRoads )
|
routines.groupToPoint = function(gpData, point, form, heading, speed, useRoads)
|
||||||
if type( point ) == 'string' then
|
if type(point) == 'string' then
|
||||||
point = trigger.misc.getZone( point )
|
point = trigger.misc.getZone(point)
|
||||||
end
|
end
|
||||||
if speed then
|
if speed then
|
||||||
speed = routines.utils.kmphToMps( speed )
|
speed = routines.utils.kmphToMps(speed)
|
||||||
end
|
end
|
||||||
|
|
||||||
local vars = {}
|
local vars = {}
|
||||||
vars.group = gpData
|
vars.group = gpData
|
||||||
vars.form = form
|
vars.form = form
|
||||||
vars.headingDegrees = heading
|
vars.headingDegrees = heading
|
||||||
vars.speed = speed
|
vars.speed = speed
|
||||||
vars.disableRoads = useRoads
|
vars.disableRoads = useRoads
|
||||||
vars.point = routines.utils.zoneToVec3( point )
|
vars.point = routines.utils.zoneToVec3(point)
|
||||||
routines.groupToRandomPoint( vars )
|
routines.groupToRandomPoint(vars)
|
||||||
|
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
routines.getLeadPos = function( group )
|
|
||||||
if type( group ) == 'string' then -- group name
|
|
||||||
group = Group.getByName( group )
|
|
||||||
end
|
|
||||||
|
|
||||||
local units = group:getUnits()
|
routines.getLeadPos = function(group)
|
||||||
|
if type(group) == 'string' then -- group name
|
||||||
|
group = Group.getByName(group)
|
||||||
|
end
|
||||||
|
|
||||||
local leader = units[1]
|
local units = group:getUnits()
|
||||||
if not leader then -- SHOULD be good, but if there is a bug, this code future-proofs it then.
|
|
||||||
local lowestInd = math.huge
|
local leader = units[1]
|
||||||
for ind, unit in pairs( units ) do
|
if not leader then -- SHOULD be good, but if there is a bug, this code future-proofs it then.
|
||||||
if ind < lowestInd then
|
local lowestInd = math.huge
|
||||||
lowestInd = ind
|
for ind, unit in pairs(units) do
|
||||||
leader = unit
|
if ind < lowestInd then
|
||||||
end
|
lowestInd = ind
|
||||||
end
|
leader = unit
|
||||||
end
|
end
|
||||||
if leader and Unit.isExist( leader ) then -- maybe a little too paranoid now...
|
end
|
||||||
return leader:getPosition().p
|
end
|
||||||
end
|
if leader and Unit.isExist(leader) then -- maybe a little too paranoid now...
|
||||||
|
return leader:getPosition().p
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ vars for routines.getMGRSString:
|
--[[ vars for routines.getMGRSString:
|
||||||
|
|||||||
@@ -127,7 +127,10 @@ end
|
|||||||
--
|
--
|
||||||
-- * (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
|
-- * (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
|
||||||
--
|
--
|
||||||
function STTS.getSpeechTime( length, speed, isGoogle )
|
-- @param #number length can also be passed as #string
|
||||||
|
-- @param #number speed Defaults to 1.0
|
||||||
|
-- @param #boolean isGoogle We're using Google TTS
|
||||||
|
function STTS.getSpeechTime(length,speed,isGoogle)
|
||||||
|
|
||||||
local maxRateRatio = 3
|
local maxRateRatio = 3
|
||||||
|
|
||||||
@@ -153,7 +156,7 @@ function STTS.getSpeechTime( length, speed, isGoogle )
|
|||||||
length = string.len( length )
|
length = string.len( length )
|
||||||
end
|
end
|
||||||
|
|
||||||
return math.ceil( length / cps )
|
return length/cps --math.ceil(length/cps)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Text to speech function.
|
--- Text to speech function.
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
--- **Utilities** - Socket.
|
||||||
|
--
|
||||||
|
-- **Main Features:**
|
||||||
|
--
|
||||||
|
-- * Creates UDP Sockets
|
||||||
|
-- * Send messages to Discord
|
||||||
|
-- * Compatible with [FunkMan](https://github.com/funkyfranky/FunkMan)
|
||||||
|
-- * Compatible with [DCSServerBot](https://github.com/Special-K-s-Flightsim-Bots/DCSServerBot)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### Author: **funkyfranky**
|
||||||
|
-- @module Utilities.Socket
|
||||||
|
-- @image Utilities_Socket.png
|
||||||
|
|
||||||
|
|
||||||
|
--- SOCKET class.
|
||||||
|
-- @type SOCKET
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #number verbose Verbosity level.
|
||||||
|
-- @field #string lid Class id string for output to DCS log file.
|
||||||
|
-- @field #table socket The socket.
|
||||||
|
-- @field #number port The port.
|
||||||
|
-- @field #string host The host.
|
||||||
|
-- @field #table json JSON.
|
||||||
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
--- **At times I feel like a socket that remembers its tooth.** -- Saul Bellow
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # The SOCKET Concept
|
||||||
|
--
|
||||||
|
-- Create a UDP socket server. It enables you to send messages to discord servers via discord bots.
|
||||||
|
--
|
||||||
|
-- **Note** that you have to **de-sanitize** `require` and `package` in your `MissionScripting.lua` file, which is in your `DCS/Scripts` folder.
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- @field #SOCKET
|
||||||
|
SOCKET = {
|
||||||
|
ClassName = "SOCKET",
|
||||||
|
verbose = 0,
|
||||||
|
lid = nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Data type. This is the keyword the socket listener uses.
|
||||||
|
-- @field #string TEXT Plain text.
|
||||||
|
-- @field #string BOMBRESULT Range bombing.
|
||||||
|
-- @field #string STRAFERESULT Range strafeing result.
|
||||||
|
-- @field #string LSOGRADE Airboss LSO grade.
|
||||||
|
SOCKET.DataType={
|
||||||
|
TEXT="moose_text",
|
||||||
|
BOMBRESULT="moose_bomb_result",
|
||||||
|
STRAFERESULT="moose_strafe_result",
|
||||||
|
LSOGRADE="moose_lso_grade",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
--- SOCKET class version.
|
||||||
|
-- @field #string version
|
||||||
|
SOCKET.version="0.1.0"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- TODO list
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- TODO: A lot!
|
||||||
|
-- TODO: Messages as spoiler.
|
||||||
|
-- TODO: Send images?
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Constructor
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Create a new SOCKET object.
|
||||||
|
-- @param #SOCKET self
|
||||||
|
-- @param #number Port UDP port. Default `10042`.
|
||||||
|
-- @param #string Host Host. Default `"127.0.0.1"`.
|
||||||
|
-- @return #SOCKET self
|
||||||
|
function SOCKET:New(Port, Host)
|
||||||
|
|
||||||
|
-- Inherit everything from FSM class.
|
||||||
|
local self=BASE:Inherit(self, FSM:New()) --#SOCKET
|
||||||
|
|
||||||
|
package.path = package.path..";.\\LuaSocket\\?.lua;"
|
||||||
|
package.cpath = package.cpath..";.\\LuaSocket\\?.dll;"
|
||||||
|
|
||||||
|
self.socket = require("socket")
|
||||||
|
|
||||||
|
self.port=Port or 10042
|
||||||
|
self.host=Host or "127.0.0.1"
|
||||||
|
|
||||||
|
self.json=loadfile("Scripts\\JSON.lua")()
|
||||||
|
|
||||||
|
self.UDPSendSocket=self.socket.udp()
|
||||||
|
self.UDPSendSocket:settimeout(0)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set port.
|
||||||
|
-- @param #SOCKET self
|
||||||
|
-- @param #number Port Port. Default 10042.
|
||||||
|
-- @return #SOCKET self
|
||||||
|
function SOCKET:SetPort(Port)
|
||||||
|
self.port=Port or 10042
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set host.
|
||||||
|
-- @param #SOCKET self
|
||||||
|
-- @param #string Host Host. Default `"127.0.0.1"`.
|
||||||
|
-- @return #SOCKET self
|
||||||
|
function SOCKET:SetHost(Host)
|
||||||
|
self.host=Host or "127.0.0.1"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Send a table.
|
||||||
|
-- @param #SOCKET self
|
||||||
|
-- @param #table Table Table to send.
|
||||||
|
-- @return #SOCKET self
|
||||||
|
function SOCKET:SendTable(Table)
|
||||||
|
|
||||||
|
local json= self.json:encode(Table)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T("Json table:")
|
||||||
|
self:T(json)
|
||||||
|
|
||||||
|
-- Send data.
|
||||||
|
self.socket.try(self.UDPSendSocket:sendto(json, self.host, self.port))
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Send a text message.
|
||||||
|
-- @param #SOCKET self
|
||||||
|
-- @param #string Text Test message.
|
||||||
|
-- @return #SOCKET self
|
||||||
|
function SOCKET:SendText(Text)
|
||||||
|
|
||||||
|
local message={}
|
||||||
|
|
||||||
|
message.command = SOCKET.DataType.TEXT
|
||||||
|
message.text = Text
|
||||||
|
|
||||||
|
self:SendTable(message)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -25,9 +25,11 @@
|
|||||||
-- @field #boolean isShip Airbase is a ship.
|
-- @field #boolean isShip Airbase is a ship.
|
||||||
-- @field #table parking Parking spot data.
|
-- @field #table parking Parking spot data.
|
||||||
-- @field #table parkingByID Parking spot data table with ID as key.
|
-- @field #table parkingByID Parking spot data table with ID as key.
|
||||||
-- @field #number activerwyno Active runway number (forced).
|
|
||||||
-- @field #table parkingWhitelist List of parking spot terminal IDs considered for spawning.
|
-- @field #table parkingWhitelist List of parking spot terminal IDs considered for spawning.
|
||||||
-- @field #table parkingBlacklist List of parking spot terminal IDs **not** considered for spawning.
|
-- @field #table parkingBlacklist List of parking spot terminal IDs **not** considered for spawning.
|
||||||
|
-- @field #table runways Runways of airdromes.
|
||||||
|
-- @field #AIRBASE.Runway runwayLanding Runway used for landing.
|
||||||
|
-- @field #AIRBASE.Runway runwayTakeoff Runway used for takeoff.
|
||||||
-- @extends Wrapper.Positionable#POSITIONABLE
|
-- @extends Wrapper.Positionable#POSITIONABLE
|
||||||
|
|
||||||
--- Wrapper class to handle the DCS Airbase objects:
|
--- Wrapper class to handle the DCS Airbase objects:
|
||||||
@@ -52,7 +54,7 @@
|
|||||||
-- * @{#AIRBASE.Find}(): Find a AIRBASE instance from the _DATABASE object using a DCS Airbase object.
|
-- * @{#AIRBASE.Find}(): Find a AIRBASE instance from the _DATABASE object using a DCS Airbase object.
|
||||||
-- * @{#AIRBASE.FindByName}(): Find a AIRBASE instance from the _DATABASE object using a DCS Airbase name.
|
-- * @{#AIRBASE.FindByName}(): Find a AIRBASE instance from the _DATABASE object using a DCS Airbase name.
|
||||||
--
|
--
|
||||||
-- IMPORTANT: ONE SHOULD NEVER SANATIZE these AIRBASE OBJECT REFERENCES! (make the AIRBASE object references nil).
|
-- IMPORTANT: ONE SHOULD NEVER SANITIZE these AIRBASE OBJECT REFERENCES! (make the AIRBASE object references nil).
|
||||||
--
|
--
|
||||||
-- ## DCS Airbase APIs
|
-- ## DCS Airbase APIs
|
||||||
--
|
--
|
||||||
@@ -63,14 +65,14 @@
|
|||||||
--
|
--
|
||||||
-- @field #AIRBASE AIRBASE
|
-- @field #AIRBASE AIRBASE
|
||||||
AIRBASE = {
|
AIRBASE = {
|
||||||
ClassName="AIRBASE",
|
ClassName = "AIRBASE",
|
||||||
CategoryName = {
|
CategoryName = {
|
||||||
[Airbase.Category.AIRDROME] = "Airdrome",
|
[Airbase.Category.AIRDROME] = "Airdrome",
|
||||||
[Airbase.Category.HELIPAD] = "Helipad",
|
[Airbase.Category.HELIPAD] = "Helipad",
|
||||||
[Airbase.Category.SHIP] = "Ship",
|
[Airbase.Category.SHIP] = "Ship",
|
||||||
},
|
},
|
||||||
activerwyno=nil,
|
activerwyno = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Enumeration to identify the airbases in the Caucasus region.
|
--- Enumeration to identify the airbases in the Caucasus region.
|
||||||
--
|
--
|
||||||
@@ -121,7 +123,7 @@ AIRBASE.Caucasus = {
|
|||||||
["Nalchik"] = "Nalchik",
|
["Nalchik"] = "Nalchik",
|
||||||
["Mozdok"] = "Mozdok",
|
["Mozdok"] = "Mozdok",
|
||||||
["Beslan"] = "Beslan",
|
["Beslan"] = "Beslan",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Airbases of the Nevada map:
|
--- Airbases of the Nevada map:
|
||||||
--
|
--
|
||||||
@@ -137,7 +139,7 @@ AIRBASE.Caucasus = {
|
|||||||
-- * AIRBASE.Nevada.Laughlin_Airport
|
-- * AIRBASE.Nevada.Laughlin_Airport
|
||||||
-- * AIRBASE.Nevada.Lincoln_County
|
-- * AIRBASE.Nevada.Lincoln_County
|
||||||
-- * AIRBASE.Nevada.Mesquite
|
-- * AIRBASE.Nevada.Mesquite
|
||||||
-- * AIRBASE.Nevada.Mina_Airport_3Q0
|
-- * AIRBASE.Nevada.Mina_Airport
|
||||||
-- * AIRBASE.Nevada.North_Las_Vegas
|
-- * AIRBASE.Nevada.North_Las_Vegas
|
||||||
-- * AIRBASE.Nevada.Pahute_Mesa_Airstrip
|
-- * AIRBASE.Nevada.Pahute_Mesa_Airstrip
|
||||||
-- * AIRBASE.Nevada.Tonopah_Airport
|
-- * AIRBASE.Nevada.Tonopah_Airport
|
||||||
@@ -145,24 +147,24 @@ AIRBASE.Caucasus = {
|
|||||||
--
|
--
|
||||||
-- @field Nevada
|
-- @field Nevada
|
||||||
AIRBASE.Nevada = {
|
AIRBASE.Nevada = {
|
||||||
["Creech_AFB"] = "Creech AFB",
|
["Creech_AFB"] = "Creech",
|
||||||
["Groom_Lake_AFB"] = "Groom Lake AFB",
|
["Groom_Lake_AFB"] = "Groom Lake",
|
||||||
["McCarran_International_Airport"] = "McCarran International Airport",
|
["McCarran_International_Airport"] = "McCarran International",
|
||||||
["Nellis_AFB"] = "Nellis AFB",
|
["Nellis_AFB"] = "Nellis",
|
||||||
["Beatty_Airport"] = "Beatty Airport",
|
["Beatty_Airport"] = "Beatty",
|
||||||
["Boulder_City_Airport"] = "Boulder City Airport",
|
["Boulder_City_Airport"] = "Boulder City",
|
||||||
["Echo_Bay"] = "Echo Bay",
|
["Echo_Bay"] = "Echo Bay",
|
||||||
["Henderson_Executive_Airport"] = "Henderson Executive Airport",
|
["Henderson_Executive_Airport"] = "Henderson Executive",
|
||||||
["Jean_Airport"] = "Jean Airport",
|
["Jean_Airport"] = "Jean",
|
||||||
["Laughlin_Airport"] = "Laughlin Airport",
|
["Laughlin_Airport"] = "Laughlin",
|
||||||
["Lincoln_County"] = "Lincoln County",
|
["Lincoln_County"] = "Lincoln County",
|
||||||
["Mesquite"] = "Mesquite",
|
["Mesquite"] = "Mesquite",
|
||||||
["Mina_Airport_3Q0"] = "Mina Airport 3Q0",
|
["Mina_Airport"] = "Mina",
|
||||||
["North_Las_Vegas"] = "North Las Vegas",
|
["North_Las_Vegas"] = "North Las Vegas",
|
||||||
["Pahute_Mesa_Airstrip"] = "Pahute Mesa Airstrip",
|
["Pahute_Mesa_Airstrip"] = "Pahute Mesa",
|
||||||
["Tonopah_Airport"] = "Tonopah Airport",
|
["Tonopah_Airport"] = "Tonopah",
|
||||||
["Tonopah_Test_Range_Airfield"] = "Tonopah Test Range Airfield",
|
["Tonopah_Test_Range_Airfield"] = "Tonopah Test Range",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Airbases of the Normandy map:
|
--- Airbases of the Normandy map:
|
||||||
--
|
--
|
||||||
@@ -316,6 +318,9 @@ AIRBASE.PersianGulf = {
|
|||||||
-- * AIRBASE.TheChannel.Lympne
|
-- * AIRBASE.TheChannel.Lympne
|
||||||
-- * AIRBASE.TheChannel.Detling
|
-- * AIRBASE.TheChannel.Detling
|
||||||
-- * AIRBASE.TheChannel.High_Halden
|
-- * AIRBASE.TheChannel.High_Halden
|
||||||
|
-- * AIRBASE.TheChannel.Biggin_Hill
|
||||||
|
-- * AIRBASE.TheChannel.Eastchurch
|
||||||
|
-- * AIRBASE.TheChannel.Headcorn
|
||||||
--
|
--
|
||||||
-- @field TheChannel
|
-- @field TheChannel
|
||||||
AIRBASE.TheChannel = {
|
AIRBASE.TheChannel = {
|
||||||
@@ -328,6 +333,9 @@ AIRBASE.TheChannel = {
|
|||||||
["Lympne"] = "Lympne",
|
["Lympne"] = "Lympne",
|
||||||
["Detling"] = "Detling",
|
["Detling"] = "Detling",
|
||||||
["High_Halden"] = "High Halden",
|
["High_Halden"] = "High Halden",
|
||||||
|
["Biggin_Hill"] = "Biggin Hill",
|
||||||
|
["Eastchurch"] = "Eastchurch",
|
||||||
|
["Headcorn"] = "Headcorn",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Airbases of the Syria map:
|
--- Airbases of the Syria map:
|
||||||
@@ -346,7 +354,6 @@ AIRBASE.TheChannel = {
|
|||||||
-- * AIRBASE.Syria.Wujah_Al_Hajar
|
-- * AIRBASE.Syria.Wujah_Al_Hajar
|
||||||
-- * AIRBASE.Syria.Al_Dumayr
|
-- * AIRBASE.Syria.Al_Dumayr
|
||||||
-- * AIRBASE.Syria.Gazipasa
|
-- * AIRBASE.Syria.Gazipasa
|
||||||
-- * AIRBASE.Syria.Ru_Convoy_4
|
|
||||||
-- * AIRBASE.Syria.Hatay
|
-- * AIRBASE.Syria.Hatay
|
||||||
-- * AIRBASE.Syria.Nicosia
|
-- * AIRBASE.Syria.Nicosia
|
||||||
-- * AIRBASE.Syria.Pinarbashi
|
-- * AIRBASE.Syria.Pinarbashi
|
||||||
@@ -364,7 +371,6 @@ AIRBASE.TheChannel = {
|
|||||||
-- * AIRBASE.Syria.Akrotiri
|
-- * AIRBASE.Syria.Akrotiri
|
||||||
-- * AIRBASE.Syria.Naqoura
|
-- * AIRBASE.Syria.Naqoura
|
||||||
-- * AIRBASE.Syria.Gaziantep
|
-- * AIRBASE.Syria.Gaziantep
|
||||||
-- * AIRBASE.Syria.CVN_71
|
|
||||||
-- * AIRBASE.Syria.Sayqal
|
-- * AIRBASE.Syria.Sayqal
|
||||||
-- * AIRBASE.Syria.Tiyas
|
-- * AIRBASE.Syria.Tiyas
|
||||||
-- * AIRBASE.Syria.Shayrat
|
-- * AIRBASE.Syria.Shayrat
|
||||||
@@ -385,6 +391,17 @@ AIRBASE.TheChannel = {
|
|||||||
-- * AIRBASE.Syria.Beirut_Rafic_Hariri
|
-- * AIRBASE.Syria.Beirut_Rafic_Hariri
|
||||||
-- * AIRBASE.Syria.An_Nasiriyah
|
-- * AIRBASE.Syria.An_Nasiriyah
|
||||||
-- * AIRBASE.Syria.Abu_al_Duhur
|
-- * AIRBASE.Syria.Abu_al_Duhur
|
||||||
|
-- * AIRBASE.Syria.At_Tanf
|
||||||
|
-- * AIRBASE.Syria.H3
|
||||||
|
-- * AIRBASE.Syria.H3_Northwest
|
||||||
|
-- * AIRBASE.Syria.H3_Southwest
|
||||||
|
-- * AIRBASE.Syria.Kharab_Ishk
|
||||||
|
-- * AIRBASE.Syria.Raj_al_Issa_East
|
||||||
|
-- * AIRBASE.Syria.Raj_al_Issa_West
|
||||||
|
-- * AIRBASE.Syria.Ruwayshid
|
||||||
|
-- * AIRBASE.Syria.Sanliurfa
|
||||||
|
-- * AIRBASE.Syria.Tal_Siman
|
||||||
|
-- * AIRBASE.Syria.Deir_ez_Zor
|
||||||
--
|
--
|
||||||
--@field Syria
|
--@field Syria
|
||||||
AIRBASE.Syria={
|
AIRBASE.Syria={
|
||||||
@@ -402,7 +419,7 @@ AIRBASE.Syria={
|
|||||||
["Wujah_Al_Hajar"]="Wujah Al Hajar",
|
["Wujah_Al_Hajar"]="Wujah Al Hajar",
|
||||||
["Al_Dumayr"]="Al-Dumayr",
|
["Al_Dumayr"]="Al-Dumayr",
|
||||||
["Gazipasa"]="Gazipasa",
|
["Gazipasa"]="Gazipasa",
|
||||||
["Ru_Convoy_4"]="Ru Convoy-4",
|
--["Ru_Convoy_4"]="Ru Convoy-4",
|
||||||
["Hatay"]="Hatay",
|
["Hatay"]="Hatay",
|
||||||
["Nicosia"]="Nicosia",
|
["Nicosia"]="Nicosia",
|
||||||
["Pinarbashi"]="Pinarbashi",
|
["Pinarbashi"]="Pinarbashi",
|
||||||
@@ -440,10 +457,19 @@ AIRBASE.Syria={
|
|||||||
["Beirut_Rafic_Hariri"]="Beirut-Rafic Hariri",
|
["Beirut_Rafic_Hariri"]="Beirut-Rafic Hariri",
|
||||||
["An_Nasiriyah"]="An Nasiriyah",
|
["An_Nasiriyah"]="An Nasiriyah",
|
||||||
["Abu_al_Duhur"]="Abu al-Duhur",
|
["Abu_al_Duhur"]="Abu al-Duhur",
|
||||||
|
["At_Tanf"]="At Tanf",
|
||||||
|
["H3"]="H3",
|
||||||
|
["H3_Northwest"]="H3 Northwest",
|
||||||
|
["H3_Southwest"]="H3 Southwest",
|
||||||
|
["Kharab_Ishk"]="Kharab Ishk",
|
||||||
|
["Raj_al_Issa_East"]="Raj al Issa East",
|
||||||
|
["Raj_al_Issa_West"]="Raj al Issa West",
|
||||||
|
["Ruwayshid"]="Ruwayshid",
|
||||||
|
["Sanliurfa"]="Sanliurfa",
|
||||||
|
["Tal_Siman"]="Tal Siman",
|
||||||
|
["Deir_ez_Zor"] = "Deir ez-Zor",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Airbases of the Mariana Islands map:
|
--- Airbases of the Mariana Islands map:
|
||||||
--
|
--
|
||||||
-- * AIRBASE.MarianaIslands.Rota_Intl
|
-- * AIRBASE.MarianaIslands.Rota_Intl
|
||||||
@@ -453,16 +479,48 @@ AIRBASE.Syria={
|
|||||||
-- * AIRBASE.MarianaIslands.Tinian_Intl
|
-- * AIRBASE.MarianaIslands.Tinian_Intl
|
||||||
-- * AIRBASE.MarianaIslands.Olf_Orote
|
-- * AIRBASE.MarianaIslands.Olf_Orote
|
||||||
--
|
--
|
||||||
--@field MarianaIslands
|
-- @field MarianaIslands
|
||||||
AIRBASE.MarianaIslands={
|
AIRBASE.MarianaIslands = {
|
||||||
["Rota_Intl"]="Rota Intl",
|
["Rota_Intl"] = "Rota Intl",
|
||||||
["Andersen_AFB"]="Andersen AFB",
|
["Andersen_AFB"] = "Andersen AFB",
|
||||||
["Antonio_B_Won_Pat_Intl"]="Antonio B. Won Pat Intl",
|
["Antonio_B_Won_Pat_Intl"] = "Antonio B. Won Pat Intl",
|
||||||
["Saipan_Intl"]="Saipan Intl",
|
["Saipan_Intl"] = "Saipan Intl",
|
||||||
["Tinian_Intl"]="Tinian Intl",
|
["Tinian_Intl"] = "Tinian Intl",
|
||||||
["Olf_Orote"]="Olf Orote",
|
["Olf_Orote"] = "Olf Orote",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Airbases of the South Atlantic map:
|
||||||
|
--
|
||||||
|
-- * AIRBASE.SouthAtlantic.Port_Stanley
|
||||||
|
-- * AIRBASE.SouthAtlantic.Mount_Pleasant
|
||||||
|
-- * AIRBASE.SouthAtlantic.San_Carlos_FOB
|
||||||
|
-- * AIRBASE.SouthAtlantic.Rio_Grande
|
||||||
|
-- * AIRBASE.SouthAtlantic.Rio_Gallegos
|
||||||
|
-- * AIRBASE.SouthAtlantic.Ushuaia
|
||||||
|
-- * AIRBASE.SouthAtlantic.Ushuaia_Helo_Port
|
||||||
|
-- * AIRBASE.SouthAtlantic.Punta_Arenas
|
||||||
|
-- * AIRBASE.SouthAtlantic.Pampa_Guanaco
|
||||||
|
-- * AIRBASE.SouthAtlantic.San_Julian
|
||||||
|
-- * AIRBASE.SouthAtlantic.Puerto_Williams
|
||||||
|
-- * AIRBASE.SouthAtlantic.Puerto_Natales
|
||||||
|
-- * AIRBASE.SouthAtlantic.El_Calafate
|
||||||
|
--
|
||||||
|
--@field MarianaIslands
|
||||||
|
AIRBASE.SouthAtlantic={
|
||||||
|
["Port_Stanley"]="Port Stanley",
|
||||||
|
["Mount_Pleasant"]="Mount Pleasant",
|
||||||
|
["San_Carlos_FOB"]="San Carlos FOB",
|
||||||
|
["Rio_Grande"]="Rio Grande",
|
||||||
|
["Rio_Gallegos"]="Rio Gallegos",
|
||||||
|
["Ushuaia"]="Ushuaia",
|
||||||
|
["Ushuaia_Helo_Port"]="Ushuaia Helo Port",
|
||||||
|
["Punta_Arenas"]="Punta Arenas",
|
||||||
|
["Pampa_Guanaco"]="Pampa Guanaco",
|
||||||
|
["San_Julian"]="San Julian",
|
||||||
|
["Puerto_Williams"]="Puerto Williams",
|
||||||
|
["Puerto_Natales"]="Puerto Natales",
|
||||||
|
["El_Calafate"]="El Calafate",
|
||||||
|
}
|
||||||
|
|
||||||
--- AIRBASE.ParkingSpot ".Coordinate, ".TerminalID", ".TerminalType", ".TOAC", ".Free", ".TerminalID0", ".DistToRwy".
|
--- AIRBASE.ParkingSpot ".Coordinate, ".TerminalID", ".TerminalType", ".TOAC", ".Free", ".TerminalID0", ".DistToRwy".
|
||||||
-- @type AIRBASE.ParkingSpot
|
-- @type AIRBASE.ParkingSpot
|
||||||
@@ -473,6 +531,14 @@ AIRBASE.MarianaIslands={
|
|||||||
-- @field #boolean Free This spot is currently free, i.e. there is no alive aircraft on it at the present moment.
|
-- @field #boolean Free This spot is currently free, i.e. there is no alive aircraft on it at the present moment.
|
||||||
-- @field #number TerminalID0 Unknown what this means. If you know, please tell us!
|
-- @field #number TerminalID0 Unknown what this means. If you know, please tell us!
|
||||||
-- @field #number DistToRwy Distance to runway in meters. Currently bugged and giving the same number as the TerminalID.
|
-- @field #number DistToRwy Distance to runway in meters. Currently bugged and giving the same number as the TerminalID.
|
||||||
|
-- @field #string AirbaseName Name of the airbase.
|
||||||
|
-- @field #number MarkerID Numerical ID of marker placed at parking spot.
|
||||||
|
-- @field Wrapper.Marker#MARKER Marker The marker on the F10 map.
|
||||||
|
-- @field #string ClientSpot If `true`, this is a parking spot of a client aircraft.
|
||||||
|
-- @field #string ClientName Client unit name of this spot.
|
||||||
|
-- @field #string Status Status of spot e.g. `AIRBASE.SpotStatus.FREE`.
|
||||||
|
-- @field #string OccupiedBy Name of the aircraft occupying the spot or "unknown". Can be *nil* if spot is not occupied.
|
||||||
|
-- @field #string ReservedBy Name of the aircraft for which this spot is reserved. Can be *nil* if spot is not reserved.
|
||||||
|
|
||||||
--- Terminal Types of parking spots. See also https://wiki.hoggitworld.com/view/DCS_func_getParking
|
--- Terminal Types of parking spots. See also https://wiki.hoggitworld.com/view/DCS_func_getParking
|
||||||
--
|
--
|
||||||
@@ -507,13 +573,30 @@ AIRBASE.TerminalType = {
|
|||||||
FighterAircraft=244,
|
FighterAircraft=244,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Status of a parking spot.
|
||||||
|
-- @type AIRBASE.SpotStatus
|
||||||
|
-- @field #string FREE Spot is free.
|
||||||
|
-- @field #string OCCUPIED Spot is occupied.
|
||||||
|
-- @field #string RESERVED Spot is reserved.
|
||||||
|
AIRBASE.SpotStatus = {
|
||||||
|
FREE="Free",
|
||||||
|
OCCUPIED="Occupied",
|
||||||
|
RESERVED="Reserved",
|
||||||
|
}
|
||||||
|
|
||||||
--- Runway data.
|
--- Runway data.
|
||||||
-- @type AIRBASE.Runway
|
-- @type AIRBASE.Runway
|
||||||
-- @field #number heading Heading of the runway in degrees.
|
-- @field #string name Runway name.
|
||||||
-- @field #string idx Runway ID: heading 070° ==> idx="07".
|
-- @field #string idx Runway ID: heading 070° ==> idx="07".
|
||||||
|
-- @field #number heading True heading of the runway in degrees.
|
||||||
|
-- @field #number magheading Magnetic heading of the runway in degrees. This is what is marked on the runway.
|
||||||
-- @field #number length Length of runway in meters.
|
-- @field #number length Length of runway in meters.
|
||||||
|
-- @field #number width Width of runway in meters.
|
||||||
|
-- @field Core.Zone#ZONE_POLYGON zone Runway zone.
|
||||||
|
-- @field Core.Point#COORDINATE center Center of the runway.
|
||||||
-- @field Core.Point#COORDINATE position Position of runway start.
|
-- @field Core.Point#COORDINATE position Position of runway start.
|
||||||
-- @field Core.Point#COORDINATE endpoint End point of runway.
|
-- @field Core.Point#COORDINATE endpoint End point of runway.
|
||||||
|
-- @field #boolean isLeft If `true`, this is the left of two parallel runways. If `false`, this is the right of two runways. If `nil`, no parallel runway exists.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Registration
|
-- Registration
|
||||||
@@ -537,6 +620,9 @@ function AIRBASE:Register(AirbaseName)
|
|||||||
-- Get descriptors.
|
-- Get descriptors.
|
||||||
self.descriptors=self:GetDesc()
|
self.descriptors=self:GetDesc()
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
--self:I({airbase=AirbaseName, descriptors=self.descriptors})
|
||||||
|
|
||||||
-- Category.
|
-- Category.
|
||||||
self.category=self.descriptors and self.descriptors.category or Airbase.Category.AIRDROME
|
self.category=self.descriptors and self.descriptors.category or Airbase.Category.AIRDROME
|
||||||
|
|
||||||
@@ -553,13 +639,23 @@ function AIRBASE:Register(AirbaseName)
|
|||||||
self.isShip=false
|
self.isShip=false
|
||||||
self.category=Airbase.Category.HELIPAD
|
self.category=Airbase.Category.HELIPAD
|
||||||
_DATABASE:AddStatic(AirbaseName)
|
_DATABASE:AddStatic(AirbaseName)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E("ERROR: Unknown airbase category!")
|
self:E("ERROR: Unknown airbase category!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Init Runways.
|
||||||
|
self:_InitRunways()
|
||||||
|
|
||||||
|
-- Set the active runways based on wind direction.
|
||||||
|
if self.isAirdrome then
|
||||||
|
self:SetActiveRunway()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Init parking spots.
|
||||||
self:_InitParkingSpots()
|
self:_InitParkingSpots()
|
||||||
|
|
||||||
|
-- Get 2D position vector.
|
||||||
local vec2=self:GetVec2()
|
local vec2=self:GetVec2()
|
||||||
|
|
||||||
-- Init coordinate.
|
-- Init coordinate.
|
||||||
@@ -772,6 +868,42 @@ function AIRBASE:SetParkingSpotBlacklist(TerminalIdBlacklist)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets the ATC belonging to an airbase object to be silent and unresponsive. This is useful for disabling the award winning ATC behavior in DCS.
|
||||||
|
-- Note that this DOES NOT remove the airbase from the list. It just makes it unresponsive and silent to any radio calls to it.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @param #boolean Silent If `true`, enable silent mode. If `false` or `nil`, disable silent mode.
|
||||||
|
-- @return #AIRBASE self
|
||||||
|
function AIRBASE:SetRadioSilentMode(Silent)
|
||||||
|
|
||||||
|
-- Get DCS airbase object.
|
||||||
|
local airbase=self:GetDCSObject()
|
||||||
|
|
||||||
|
-- Set mode.
|
||||||
|
if airbase then
|
||||||
|
airbase:setRadioSilentMode(Silent)
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check whether or not the airbase has been silenced.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @return #boolean If `true`, silent mode is enabled.
|
||||||
|
function AIRBASE:GetRadioSilentMode()
|
||||||
|
|
||||||
|
-- Is silent?
|
||||||
|
local silent=nil
|
||||||
|
|
||||||
|
-- Get DCS airbase object.
|
||||||
|
local airbase=self:GetDCSObject()
|
||||||
|
|
||||||
|
-- Set mode.
|
||||||
|
if airbase then
|
||||||
|
silent=airbase:getRadioSilentMode()
|
||||||
|
end
|
||||||
|
|
||||||
|
return silent
|
||||||
|
end
|
||||||
|
|
||||||
--- Get category of airbase.
|
--- Get category of airbase.
|
||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
@@ -953,6 +1085,21 @@ function AIRBASE:_InitParkingSpots()
|
|||||||
self.NparkingTerminal[terminalType]=0
|
self.NparkingTerminal[terminalType]=0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get client coordinates.
|
||||||
|
local function isClient(coord)
|
||||||
|
local clients=_DATABASE.CLIENTS
|
||||||
|
for clientname, _client in pairs(clients) do
|
||||||
|
local client=_client --Wrapper.Client#CLIENT
|
||||||
|
if client and client.SpawnCoord then
|
||||||
|
local dist=client.SpawnCoord:Get2DDistance(coord)
|
||||||
|
if dist<2 then
|
||||||
|
return true, clientname
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false, nil
|
||||||
|
end
|
||||||
|
|
||||||
-- Put coordinates of parking spots into table.
|
-- Put coordinates of parking spots into table.
|
||||||
for _,spot in pairs(parkingdata) do
|
for _,spot in pairs(parkingdata) do
|
||||||
|
|
||||||
@@ -966,6 +1113,8 @@ function AIRBASE:_InitParkingSpots()
|
|||||||
park.TerminalID0=spot.Term_Index_0
|
park.TerminalID0=spot.Term_Index_0
|
||||||
park.TerminalType=spot.Term_Type
|
park.TerminalType=spot.Term_Type
|
||||||
park.TOAC=spot.TO_AC
|
park.TOAC=spot.TO_AC
|
||||||
|
park.ClientSpot, park.ClientName=isClient(park.Coordinate)
|
||||||
|
park.AirbaseName=self.AirbaseName
|
||||||
|
|
||||||
self.NparkingTotal=self.NparkingTotal+1
|
self.NparkingTotal=self.NparkingTotal+1
|
||||||
|
|
||||||
@@ -1024,6 +1173,7 @@ function AIRBASE:GetParkingSpotsTable(termtype)
|
|||||||
|
|
||||||
spot.Free=_isfree(_spot) -- updated
|
spot.Free=_isfree(_spot) -- updated
|
||||||
spot.TOAC=_spot.TO_AC -- updated
|
spot.TOAC=_spot.TO_AC -- updated
|
||||||
|
spot.AirbaseName=self.AirbaseName
|
||||||
|
|
||||||
table.insert(spots, spot)
|
table.insert(spots, spot)
|
||||||
|
|
||||||
@@ -1060,6 +1210,7 @@ function AIRBASE:GetFreeParkingSpotsTable(termtype, allowTOAC)
|
|||||||
|
|
||||||
spot.Free=true -- updated
|
spot.Free=true -- updated
|
||||||
spot.TOAC=_spot.TO_AC -- updated
|
spot.TOAC=_spot.TO_AC -- updated
|
||||||
|
spot.AirbaseName=self.AirbaseName
|
||||||
|
|
||||||
table.insert(freespots, spot)
|
table.insert(freespots, spot)
|
||||||
|
|
||||||
@@ -1304,14 +1455,14 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
|
|
||||||
--_spot:MarkToAll(string.format("Parking spot %d free=%s", parkingspot.TerminalID, tostring(not occupied)))
|
--_spot:MarkToAll(string.format("Parking spot %d free=%s", parkingspot.TerminalID, tostring(not occupied)))
|
||||||
if occupied then
|
if occupied then
|
||||||
self:I(string.format("%s: Parking spot id %d occupied.", airport, _termid))
|
self:T(string.format("%s: Parking spot id %d occupied.", airport, _termid))
|
||||||
else
|
else
|
||||||
self:I(string.format("%s: Parking spot id %d free.", airport, _termid))
|
self:T(string.format("%s: Parking spot id %d free.", airport, _termid))
|
||||||
if nvalid<_nspots then
|
if nvalid<_nspots then
|
||||||
table.insert(validspots, {Coordinate=_spot, TerminalID=_termid})
|
table.insert(validspots, {Coordinate=_spot, TerminalID=_termid})
|
||||||
end
|
end
|
||||||
nvalid=nvalid+1
|
nvalid=nvalid+1
|
||||||
self:I(string.format("%s: Parking spot id %d free. Nfree=%d/%d.", airport, _termid, nvalid,_nspots))
|
self:T(string.format("%s: Parking spot id %d free. Nfree=%d/%d.", airport, _termid, nvalid,_nspots))
|
||||||
end
|
end
|
||||||
|
|
||||||
end -- loop over units
|
end -- loop over units
|
||||||
@@ -1411,6 +1562,231 @@ end
|
|||||||
-- Runway
|
-- Runway
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Get runways.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @return #table Runway data.
|
||||||
|
function AIRBASE:GetRunways()
|
||||||
|
return self.runways or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get runway by its name.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @param #string Name Name of the runway, e.g. "31" or "21L".
|
||||||
|
-- @return #AIRBASE.Runway Runway data.
|
||||||
|
function AIRBASE:GetRunwayByName(Name)
|
||||||
|
|
||||||
|
if Name==nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if Name then
|
||||||
|
for _,_runway in pairs(self.runways) do
|
||||||
|
local runway=_runway --#AIRBASE.Runway
|
||||||
|
|
||||||
|
-- Name including L or R, e.g. "31L".
|
||||||
|
local name=self:GetRunwayName(runway)
|
||||||
|
|
||||||
|
if name==Name:upper() then
|
||||||
|
return runway
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E("ERROR: Could not find runway with name "..tostring(Name))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Init runways.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @param #boolean IncludeInverse If `true` or `nil`, include inverse runways.
|
||||||
|
-- @return #table Runway data.
|
||||||
|
function AIRBASE:_InitRunways(IncludeInverse)
|
||||||
|
|
||||||
|
-- Default is true.
|
||||||
|
if IncludeInverse==nil then
|
||||||
|
IncludeInverse=true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Runway table.
|
||||||
|
local Runways={}
|
||||||
|
|
||||||
|
if self:GetAirbaseCategory()~=Airbase.Category.AIRDROME then
|
||||||
|
self.runways={}
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Function to create a runway data table.
|
||||||
|
local function _createRunway(name, course, width, length, center)
|
||||||
|
|
||||||
|
-- Bearing in rad.
|
||||||
|
local bearing=-1*course
|
||||||
|
|
||||||
|
-- Heading in degrees.
|
||||||
|
local heading=math.deg(bearing)
|
||||||
|
|
||||||
|
-- Data table.
|
||||||
|
local runway={} --#AIRBASE.Runway
|
||||||
|
runway.name=string.format("%02d", tonumber(name))
|
||||||
|
runway.magheading=tonumber(runway.name)*10
|
||||||
|
runway.heading=heading
|
||||||
|
runway.width=width or 0
|
||||||
|
runway.length=length or 0
|
||||||
|
runway.center=COORDINATE:NewFromVec3(center)
|
||||||
|
|
||||||
|
-- Ensure heading is [0,360]
|
||||||
|
if runway.heading>360 then
|
||||||
|
runway.heading=runway.heading-360
|
||||||
|
elseif runway.heading<0 then
|
||||||
|
runway.heading=runway.heading+360
|
||||||
|
end
|
||||||
|
|
||||||
|
-- For example at Nellis, DCS reports two runways, i.e. 03 and 21, BUT the "course" of both is -0.700 rad = 40 deg!
|
||||||
|
-- As a workaround, I check the difference between the "magnetic" heading derived from the name and the true heading.
|
||||||
|
-- If this is too large then very likely the "inverse" heading is the one we are looking for.
|
||||||
|
if math.abs(runway.heading-runway.magheading)>60 then
|
||||||
|
self:T(string.format("WARNING: Runway %s: heading=%.1f magheading=%.1f", runway.name, runway.heading, runway.magheading))
|
||||||
|
runway.heading=runway.heading-180
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Ensure heading is [0,360]
|
||||||
|
if runway.heading>360 then
|
||||||
|
runway.heading=runway.heading-360
|
||||||
|
elseif runway.heading<0 then
|
||||||
|
runway.heading=runway.heading+360
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Start and endpoint of runway.
|
||||||
|
runway.position=runway.center:Translate(-runway.length/2, runway.heading)
|
||||||
|
runway.endpoint=runway.center:Translate( runway.length/2, runway.heading)
|
||||||
|
|
||||||
|
local init=runway.center:GetVec3()
|
||||||
|
local width = runway.width/2
|
||||||
|
local L2=runway.length/2
|
||||||
|
|
||||||
|
local offset1 = {x = init.x + (math.cos(bearing + math.pi) * L2), y = init.z + (math.sin(bearing + math.pi) * L2)}
|
||||||
|
local offset2 = {x = init.x - (math.cos(bearing + math.pi) * L2), y = init.z - (math.sin(bearing + math.pi) * L2)}
|
||||||
|
|
||||||
|
local points={}
|
||||||
|
points[1] = {x = offset1.x + (math.cos(bearing + (math.pi/2)) * width), y = offset1.y + (math.sin(bearing + (math.pi/2)) * width)}
|
||||||
|
points[2] = {x = offset1.x + (math.cos(bearing - (math.pi/2)) * width), y = offset1.y + (math.sin(bearing - (math.pi/2)) * width)}
|
||||||
|
points[3] = {x = offset2.x + (math.cos(bearing - (math.pi/2)) * width), y = offset2.y + (math.sin(bearing - (math.pi/2)) * width)}
|
||||||
|
points[4] = {x = offset2.x + (math.cos(bearing + (math.pi/2)) * width), y = offset2.y + (math.sin(bearing + (math.pi/2)) * width)}
|
||||||
|
|
||||||
|
-- Runway zone.
|
||||||
|
runway.zone=ZONE_POLYGON_BASE:New(string.format("%s Runway %s", self.AirbaseName, runway.name), points)
|
||||||
|
|
||||||
|
return runway
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Get DCS object.
|
||||||
|
local airbase=self:GetDCSObject()
|
||||||
|
|
||||||
|
if airbase then
|
||||||
|
|
||||||
|
|
||||||
|
-- Get DCS runways.
|
||||||
|
local runways=airbase:getRunways()
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T2(runways)
|
||||||
|
|
||||||
|
if runways then
|
||||||
|
|
||||||
|
-- Loop over runways.
|
||||||
|
for _,rwy in pairs(runways) do
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(rwy)
|
||||||
|
|
||||||
|
-- Get runway data.
|
||||||
|
local runway=_createRunway(rwy.Name, rwy.course, rwy.width, rwy.length, rwy.position) --#AIRBASE.Runway
|
||||||
|
|
||||||
|
-- Add to table.
|
||||||
|
table.insert(Runways, runway)
|
||||||
|
|
||||||
|
-- Include "inverse" runway.
|
||||||
|
if IncludeInverse then
|
||||||
|
|
||||||
|
-- Create "inverse".
|
||||||
|
local idx=tonumber(runway.name)
|
||||||
|
local name2=tostring(idx-18)
|
||||||
|
if idx<18 then
|
||||||
|
name2=tostring(idx+18)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create "inverse" runway.
|
||||||
|
local runway=_createRunway(name2, rwy.course-math.pi, rwy.width, rwy.length, rwy.position) --#AIRBASE.Runway
|
||||||
|
|
||||||
|
-- Add inverse to table.
|
||||||
|
table.insert(Runways, runway)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Look for identical (parallel) runways, e.g. 03L and 03R at Nellis.
|
||||||
|
local rpairs={}
|
||||||
|
for i,_ri in pairs(Runways) do
|
||||||
|
local ri=_ri --#AIRBASE.Runway
|
||||||
|
for j,_rj in pairs(Runways) do
|
||||||
|
local rj=_rj --#AIRBASE.Runway
|
||||||
|
if i<j then
|
||||||
|
if ri.name==rj.name then
|
||||||
|
rpairs[i]=j
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function isLeft(a, b, c)
|
||||||
|
--return ((b.x - a.x)*(c.z - a.z) - (b.z - a.z)*(c.x - a.x)) > 0
|
||||||
|
return ((b.z - a.z)*(c.x - a.x) - (b.x - a.x)*(c.z - a.z)) > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
for i,j in pairs(rpairs) do
|
||||||
|
local ri=Runways[i] --#AIRBASE.Runway
|
||||||
|
local rj=Runways[j] --#AIRBASE.Runway
|
||||||
|
|
||||||
|
-- Draw arrow.
|
||||||
|
--ri.center:ArrowToAll(rj.center)
|
||||||
|
|
||||||
|
local c0=ri.center
|
||||||
|
|
||||||
|
-- Vector in the direction of the runway.
|
||||||
|
local a=UTILS.VecTranslate(c0, 1000, ri.heading)
|
||||||
|
|
||||||
|
-- Vector from runway i to runway j.
|
||||||
|
local b=UTILS.VecSubstract(rj.center, ri.center)
|
||||||
|
b=UTILS.VecAdd(ri.center, b)
|
||||||
|
|
||||||
|
-- Check if rj is left of ri.
|
||||||
|
local left=isLeft(c0, a, b)
|
||||||
|
|
||||||
|
--env.info(string.format("Found pair %s: i=%d, j=%d, left==%s", ri.name, i, j, tostring(left)))
|
||||||
|
|
||||||
|
if left then
|
||||||
|
ri.isLeft=false
|
||||||
|
rj.isLeft=true
|
||||||
|
else
|
||||||
|
ri.isLeft=true
|
||||||
|
rj.isLeft=false
|
||||||
|
end
|
||||||
|
|
||||||
|
--break
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set runways.
|
||||||
|
self.runways=Runways
|
||||||
|
|
||||||
|
return Runways
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get runways data. Only for airdromes!
|
--- Get runways data. Only for airdromes!
|
||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
-- @param #number magvar (Optional) Magnetic variation in degrees.
|
-- @param #number magvar (Optional) Magnetic variation in degrees.
|
||||||
@@ -1578,27 +1954,101 @@ function AIRBASE:GetRunwayData(magvar, mark)
|
|||||||
return runways
|
return runways
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the active runway in case it cannot be determined by the wind direction.
|
--- Set the active runway for landing and takeoff.
|
||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
-- @param #number iactive Number of the active runway in the runway data table.
|
-- @param #string Name Name of the runway, e.g. "31" or "02L" or "90R". If not given, the runway is determined from the wind direction.
|
||||||
function AIRBASE:SetActiveRunway(iactive)
|
-- @param #boolean PreferLeft If `true`, perfer the left runway. If `false`, prefer the right runway. If `nil` (default), do not care about left or right.
|
||||||
self.activerwyno=iactive
|
function AIRBASE:SetActiveRunway(Name, PreferLeft)
|
||||||
|
|
||||||
|
self:SetActiveRunwayTakeoff(Name, PreferLeft)
|
||||||
|
|
||||||
|
self:SetActiveRunwayLanding(Name,PreferLeft)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the active runway based on current wind direction.
|
--- Set the active runway for landing.
|
||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
-- @param #number magvar (Optional) Magnetic variation in degrees.
|
-- @param #string Name Name of the runway, e.g. "31" or "02L" or "90R". If not given, the runway is determined from the wind direction.
|
||||||
-- @return #AIRBASE.Runway Active runway data table.
|
-- @param #boolean PreferLeft If `true`, perfer the left runway. If `false`, prefer the right runway. If `nil` (default), do not care about left or right.
|
||||||
function AIRBASE:GetActiveRunway(magvar)
|
-- @return #AIRBASE.Runway The active runway for landing.
|
||||||
|
function AIRBASE:SetActiveRunwayLanding(Name, PreferLeft)
|
||||||
|
|
||||||
-- Get runways data (initialize if necessary).
|
local runway=self:GetRunwayByName(Name)
|
||||||
local runways=self:GetRunwayData(magvar)
|
|
||||||
|
|
||||||
-- Return user forced active runway if it was set.
|
if not runway then
|
||||||
if self.activerwyno then
|
runway=self:GetRunwayIntoWind(PreferLeft)
|
||||||
return runways[self.activerwyno]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if runway then
|
||||||
|
self:T(string.format("%s: Setting active runway for landing as %s", self.AirbaseName, self:GetRunwayName(runway)))
|
||||||
|
else
|
||||||
|
self:E("ERROR: Could not set the runway for landing!")
|
||||||
|
end
|
||||||
|
|
||||||
|
self.runwayLanding=runway
|
||||||
|
|
||||||
|
return runway
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the active runways.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @return #AIRBASE.Runway The active runway for landing.
|
||||||
|
-- @return #AIRBASE.Runway The active runway for takeoff.
|
||||||
|
function AIRBASE:GetActiveRunway()
|
||||||
|
return self.runwayLanding, self.runwayTakeoff
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get the active runway for landing.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @return #AIRBASE.Runway The active runway for landing.
|
||||||
|
function AIRBASE:GetActiveRunwayLanding()
|
||||||
|
return self.runwayLanding
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the active runway for takeoff.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @return #AIRBASE.Runway The active runway for takeoff.
|
||||||
|
function AIRBASE:GetActiveRunwayTakeoff()
|
||||||
|
return self.runwayTakeoff
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the active runway for takeoff.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @param #string Name Name of the runway, e.g. "31" or "02L" or "90R". If not given, the runway is determined from the wind direction.
|
||||||
|
-- @param #boolean PreferLeft If `true`, perfer the left runway. If `false`, prefer the right runway. If `nil` (default), do not care about left or right.
|
||||||
|
-- @return #AIRBASE.Runway The active runway for landing.
|
||||||
|
function AIRBASE:SetActiveRunwayTakeoff(Name, PreferLeft)
|
||||||
|
|
||||||
|
local runway=self:GetRunwayByName(Name)
|
||||||
|
|
||||||
|
if not runway then
|
||||||
|
runway=self:GetRunwayIntoWind(PreferLeft)
|
||||||
|
end
|
||||||
|
|
||||||
|
if runway then
|
||||||
|
self:T(string.format("%s: Setting active runway for takeoff as %s", self.AirbaseName, self:GetRunwayName(runway)))
|
||||||
|
else
|
||||||
|
self:E("ERROR: Could not set the runway for takeoff!")
|
||||||
|
end
|
||||||
|
|
||||||
|
self.runwayTakeoff=runway
|
||||||
|
|
||||||
|
return runway
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get the runway where aircraft would be taking of or landing into the direction of the wind.
|
||||||
|
-- NOTE that this requires the wind to be non-zero as set in the mission editor.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @param #boolean PreferLeft If `true`, perfer the left runway. If `false`, prefer the right runway. If `nil` (default), do not care about left or right.
|
||||||
|
-- @return #AIRBASE.Runway Active runway data table.
|
||||||
|
function AIRBASE:GetRunwayIntoWind(PreferLeft)
|
||||||
|
|
||||||
|
-- Get runway data.
|
||||||
|
local runways=self:GetRunways()
|
||||||
|
|
||||||
-- Get wind vector.
|
-- Get wind vector.
|
||||||
local Vwind=self:GetCoordinate():GetWindWithTurbulenceVec3()
|
local Vwind=self:GetCoordinate():GetWindWithTurbulenceVec3()
|
||||||
local norm=UTILS.VecNorm(Vwind)
|
local norm=UTILS.VecNorm(Vwind)
|
||||||
@@ -1619,32 +2069,63 @@ function AIRBASE:GetActiveRunway(magvar)
|
|||||||
for i,_runway in pairs(runways) do
|
for i,_runway in pairs(runways) do
|
||||||
local runway=_runway --#AIRBASE.Runway
|
local runway=_runway --#AIRBASE.Runway
|
||||||
|
|
||||||
-- Angle in rad.
|
if PreferLeft==nil or PreferLeft==runway.isLeft then
|
||||||
local alpha=math.rad(runway.heading)
|
|
||||||
|
|
||||||
-- Runway vector.
|
-- Angle in rad.
|
||||||
local Vrunway={x=math.cos(alpha), y=0, z=math.sin(alpha)}
|
local alpha=math.rad(runway.heading)
|
||||||
|
|
||||||
-- Dot product: parallel component of the two vectors.
|
-- Runway vector.
|
||||||
local dot=UTILS.VecDot(Vwind, Vrunway)
|
local Vrunway={x=math.cos(alpha), y=0, z=math.sin(alpha)}
|
||||||
|
|
||||||
-- Debug.
|
-- Dot product: parallel component of the two vectors.
|
||||||
--env.info(string.format("runway=%03d° dot=%.3f", runway.heading, dot))
|
local dot=UTILS.VecDot(Vwind, Vrunway)
|
||||||
|
|
||||||
|
-- New min?
|
||||||
|
if dotmin==nil or dot<dotmin then
|
||||||
|
dotmin=dot
|
||||||
|
iact=i
|
||||||
|
end
|
||||||
|
|
||||||
-- New min?
|
|
||||||
if dotmin==nil or dot<dotmin then
|
|
||||||
dotmin=dot
|
|
||||||
iact=i
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E("WARNING: Norm of wind is zero! Cannot determine active runway based on wind direction.")
|
self:E("WARNING: Norm of wind is zero! Cannot determine runway based on wind direction")
|
||||||
end
|
end
|
||||||
|
|
||||||
return runways[iact]
|
return runways[iact]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get name of a given runway, e.g. "31L".
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @param #AIRBASE.Runway Runway The runway. Default is the active runway.
|
||||||
|
-- @param #boolean LongLeftRight If `true`, return "Left" or "Right" instead of "L" or "R".
|
||||||
|
-- @return #string Name of the runway or "XX" if it could not be found.
|
||||||
|
function AIRBASE:GetRunwayName(Runway, LongLeftRight)
|
||||||
|
|
||||||
|
Runway=Runway or self:GetActiveRunway()
|
||||||
|
|
||||||
|
local name="XX"
|
||||||
|
if Runway then
|
||||||
|
name=Runway.name
|
||||||
|
if Runway.isLeft==true then
|
||||||
|
if LongLeftRight then
|
||||||
|
name=name.." Left"
|
||||||
|
else
|
||||||
|
name=name.."L"
|
||||||
|
end
|
||||||
|
elseif Runway.isLeft==false then
|
||||||
|
if LongLeftRight then
|
||||||
|
name=name.." Right"
|
||||||
|
else
|
||||||
|
name=name.."R"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
|
||||||
--- Function that checks if at leat one unit of a group has been spawned close to a spawn point on the runway.
|
--- Function that checks if at leat one unit of a group has been spawned close to a spawn point on the runway.
|
||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
-- @param Wrapper.Group#GROUP group Group to be checked.
|
-- @param Wrapper.Group#GROUP group Group to be checked.
|
||||||
|
|||||||
@@ -13,6 +13,17 @@
|
|||||||
|
|
||||||
--- The CLIENT class
|
--- The CLIENT class
|
||||||
-- @type CLIENT
|
-- @type CLIENT
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #string ClientName Name of the client.
|
||||||
|
-- @field #string ClientBriefing Briefing.
|
||||||
|
-- @field #function ClientCallBack Callback function.
|
||||||
|
-- @field #table ClientParameters Parameters of the callback function.
|
||||||
|
-- @field #number ClientGroupID Group ID of the client.
|
||||||
|
-- @field #string ClientGroupName Group name.
|
||||||
|
-- @field #boolean ClientAlive Client alive.
|
||||||
|
-- @field #boolean ClientAlive2 Client alive 2.
|
||||||
|
-- @field #table Players Player table.
|
||||||
|
-- @field Core.Point#COORDINATE SpawnCoord Spawn coordinate from the template.
|
||||||
-- @extends Wrapper.Unit#UNIT
|
-- @extends Wrapper.Unit#UNIT
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -187,6 +187,7 @@ GROUPTEMPLATE.Takeoff = {
|
|||||||
-- @field #string GROUND_APC Infantry carriers, in particular Amoured Personell Carrier. This can be used to transport other assets.
|
-- @field #string GROUND_APC Infantry carriers, in particular Amoured Personell Carrier. This can be used to transport other assets.
|
||||||
-- @field #string GROUND_TRUCK Unarmed ground vehicles, which has the DCS "Truck" attribute.
|
-- @field #string GROUND_TRUCK Unarmed ground vehicles, which has the DCS "Truck" attribute.
|
||||||
-- @field #string GROUND_INFANTRY Ground infantry assets.
|
-- @field #string GROUND_INFANTRY Ground infantry assets.
|
||||||
|
-- @field #string GROUND_IFV Ground Infantry Fighting Vehicle.
|
||||||
-- @field #string GROUND_ARTILLERY Artillery assets.
|
-- @field #string GROUND_ARTILLERY Artillery assets.
|
||||||
-- @field #string GROUND_TANK Tanks (modern or old).
|
-- @field #string GROUND_TANK Tanks (modern or old).
|
||||||
-- @field #string GROUND_TRAIN Trains. Not that trains are **not** yet properly implemented in DCS and cannot be used currently.
|
-- @field #string GROUND_TRAIN Trains. Not that trains are **not** yet properly implemented in DCS and cannot be used currently.
|
||||||
@@ -213,6 +214,7 @@ GROUP.Attribute = {
|
|||||||
GROUND_APC="Ground_APC",
|
GROUND_APC="Ground_APC",
|
||||||
GROUND_TRUCK="Ground_Truck",
|
GROUND_TRUCK="Ground_Truck",
|
||||||
GROUND_INFANTRY="Ground_Infantry",
|
GROUND_INFANTRY="Ground_Infantry",
|
||||||
|
GROUND_IFV="Ground_IFV",
|
||||||
GROUND_ARTILLERY="Ground_Artillery",
|
GROUND_ARTILLERY="Ground_Artillery",
|
||||||
GROUND_TANK="Ground_Tank",
|
GROUND_TANK="Ground_Tank",
|
||||||
GROUND_TRAIN="Ground_Train",
|
GROUND_TRAIN="Ground_Train",
|
||||||
@@ -384,7 +386,7 @@ end
|
|||||||
-- So all event listeners will catch the destroy event of this group for each unit in the group.
|
-- So all event listeners will catch the destroy event of this group for each unit in the group.
|
||||||
-- To raise these events, provide the `GenerateEvent` parameter.
|
-- To raise these events, provide the `GenerateEvent` parameter.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #boolean GenerateEvent If true, a crash or dead event for each unit is generated. If false, if no event is triggered. If nil, a RemoveUnit event is triggered.
|
-- @param #boolean GenerateEvent If true, a crash [AIR] or dead [GROUND] event for each unit is generated. If false, if no event is triggered. If nil, a RemoveUnit event is triggered.
|
||||||
-- @param #number delay Delay in seconds before despawning the group.
|
-- @param #number delay Delay in seconds before despawning the group.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Air unit example: destroy the Helicopter and generate a S_EVENT_CRASH for each unit in the Helicopter group.
|
-- -- Air unit example: destroy the Helicopter and generate a S_EVENT_CRASH for each unit in the Helicopter group.
|
||||||
@@ -529,26 +531,32 @@ function GROUP:HasAttribute(attribute, all)
|
|||||||
-- Get all units of the group.
|
-- Get all units of the group.
|
||||||
local _units=self:GetUnits()
|
local _units=self:GetUnits()
|
||||||
|
|
||||||
local _allhave=true
|
if _units then
|
||||||
local _onehas=false
|
|
||||||
|
|
||||||
for _,_unit in pairs(_units) do
|
local _allhave=true
|
||||||
local _unit=_unit --Wrapper.Unit#UNIT
|
local _onehas=false
|
||||||
if _unit then
|
|
||||||
local _hastit=_unit:HasAttribute(attribute)
|
for _,_unit in pairs(_units) do
|
||||||
if _hastit==true then
|
local _unit=_unit --Wrapper.Unit#UNIT
|
||||||
_onehas=true
|
if _unit then
|
||||||
else
|
local _hastit=_unit:HasAttribute(attribute)
|
||||||
_allhave=false
|
if _hastit==true then
|
||||||
|
_onehas=true
|
||||||
|
else
|
||||||
|
_allhave=false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if all==true then
|
||||||
|
return _allhave
|
||||||
|
else
|
||||||
|
return _onehas
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if all==true then
|
return nil
|
||||||
return _allhave
|
|
||||||
else
|
|
||||||
return _onehas
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the maximum speed of the group.
|
--- Returns the maximum speed of the group.
|
||||||
@@ -563,16 +571,19 @@ function GROUP:GetSpeedMax()
|
|||||||
|
|
||||||
local Units=self:GetUnits()
|
local Units=self:GetUnits()
|
||||||
|
|
||||||
local speedmax=0
|
local speedmax=nil
|
||||||
|
|
||||||
for _,unit in pairs(Units) do
|
for _,unit in pairs(Units) do
|
||||||
local unit=unit --Wrapper.Unit#UNIT
|
local unit=unit --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
local speed=unit:GetSpeedMax()
|
local speed=unit:GetSpeedMax()
|
||||||
if speedmax==0 then
|
|
||||||
speedmax=speed
|
if speedmax==nil or speed<speedmax then
|
||||||
elseif speed<speedmax then
|
|
||||||
speedmax=speed
|
speedmax=speed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--env.info(string.format("FF unit %s: speed=%.1f, speedmax=%.1f", unit:GetName(), speed, speedmax))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return speedmax
|
return speedmax
|
||||||
@@ -622,7 +633,7 @@ function GROUP:GetUnits()
|
|||||||
local DCSGroup = self:GetDCSObject()
|
local DCSGroup = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
local DCSUnits = DCSGroup:getUnits()
|
local DCSUnits = DCSGroup:getUnits() or {}
|
||||||
local Units = {}
|
local Units = {}
|
||||||
for Index, UnitData in pairs( DCSUnits ) do
|
for Index, UnitData in pairs( DCSUnits ) do
|
||||||
Units[#Units+1] = UNIT:Find( UnitData )
|
Units[#Units+1] = UNIT:Find( UnitData )
|
||||||
@@ -658,6 +669,12 @@ function GROUP:GetPlayerUnits()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if an (air) group is a client or player slot. Information is retrieved from the group template.
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @return #boolean If true, group is associated with a client or player slot.
|
||||||
|
function GROUP:IsPlayer()
|
||||||
|
return self:GetUnit(1):IsPlayer()
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the UNIT wrapper class with number UnitNumber.
|
--- Returns the UNIT wrapper class with number UnitNumber.
|
||||||
-- If the underlying DCS Unit does not exist, the method will return nil. .
|
-- If the underlying DCS Unit does not exist, the method will return nil. .
|
||||||
@@ -670,16 +687,28 @@ function GROUP:GetUnit( UnitNumber )
|
|||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
|
|
||||||
local DCSUnit = DCSGroup:getUnit( UnitNumber )
|
local UnitFound = nil
|
||||||
|
-- 2.7.1 dead event bug, return the first alive unit instead
|
||||||
|
local units = DCSGroup:getUnits() or {}
|
||||||
|
|
||||||
local UnitFound = UNIT:Find(DCSUnit)
|
for _,_unit in pairs(units) do
|
||||||
|
|
||||||
|
local UnitFound = UNIT:Find(_unit)
|
||||||
|
|
||||||
|
if UnitFound then
|
||||||
|
|
||||||
|
return UnitFound
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return UnitFound
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the DCS Unit with number UnitNumber.
|
--- Returns the DCS Unit with number UnitNumber.
|
||||||
-- If the underlying DCS Unit does not exist, the method will return nil. .
|
-- If the underlying DCS Unit does not exist, the method will return nil. .
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
@@ -687,11 +716,24 @@ end
|
|||||||
-- @return DCS#Unit The DCS Unit.
|
-- @return DCS#Unit The DCS Unit.
|
||||||
function GROUP:GetDCSUnit( UnitNumber )
|
function GROUP:GetDCSUnit( UnitNumber )
|
||||||
|
|
||||||
local DCSGroup=self:GetDCSObject()
|
local DCSGroup = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
local DCSUnitFound=DCSGroup:getUnit( UnitNumber )
|
|
||||||
return DCSUnitFound
|
if DCSGroup.getUnit and DCSGroup:getUnit( UnitNumber ) then
|
||||||
|
return DCSGroup:getUnit( UnitNumber )
|
||||||
|
else
|
||||||
|
|
||||||
|
local UnitFound = nil
|
||||||
|
-- 2.7.1 dead event bug, return the first alive unit instead
|
||||||
|
local units = DCSGroup:getUnits() or {}
|
||||||
|
|
||||||
|
for _,_unit in pairs(units) do
|
||||||
|
if _unit and _unit:isExist() then
|
||||||
|
return _unit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -765,8 +807,7 @@ end
|
|||||||
|
|
||||||
--- Returns the average velocity Vec3 vector.
|
--- Returns the average velocity Vec3 vector.
|
||||||
-- @param Wrapper.Group#GROUP self
|
-- @param Wrapper.Group#GROUP self
|
||||||
-- @return DCS#Vec3 The velocity Vec3 vector
|
-- @return DCS#Vec3 The velocity Vec3 vector or `#nil` if the GROUP is not existing or alive.
|
||||||
-- @return #nil The GROUP is not existing or alive.
|
|
||||||
function GROUP:GetVelocityVec3()
|
function GROUP:GetVelocityVec3()
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
|
|
||||||
@@ -797,11 +838,19 @@ function GROUP:GetVelocityVec3()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the average group altitude in meters.
|
||||||
|
-- @param Wrapper.Group#GROUP self
|
||||||
|
-- @param #boolean FromGround Measure from the ground or from sea level (ASL). Provide **true** for measuring from the ground (AGL). **false** or **nil** if you measure from sea level.
|
||||||
|
-- @return #number The altitude of the group or nil if is not existing or alive.
|
||||||
|
function GROUP:GetAltitude(FromGround)
|
||||||
|
self:F2( self.GroupName )
|
||||||
|
return self:GetHeight(FromGround)
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the average group height in meters.
|
--- Returns the average group height in meters.
|
||||||
-- @param Wrapper.Group#GROUP self
|
-- @param Wrapper.Group#GROUP self
|
||||||
-- @param #boolean FromGround Measure from the ground or from sea level. Provide **true** for measuring from the ground. **false** or **nil** if you measure from sea level.
|
-- @param #boolean FromGround Measure from the ground or from sea level (ASL). Provide **true** for measuring from the ground (AGL). **false** or **nil** if you measure from sea level.
|
||||||
-- @return DCS#Vec3 The height of the group or nil if is not existing or alive.
|
-- @return #number The height of the group or nil if is not existing or alive.
|
||||||
function GROUP:GetHeight( FromGround )
|
function GROUP:GetHeight( FromGround )
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
|
|
||||||
@@ -901,6 +950,24 @@ function GROUP:GetTypeName()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [AIRPLANE] Get the NATO reporting name (platform, e.g. "Flanker") of a GROUP (note - first unit the group). "Bogey" if not found. Currently airplanes only!
|
||||||
|
--@param #GROUP self
|
||||||
|
--@return #string NatoReportingName or "Bogey" if unknown.
|
||||||
|
function GROUP:GetNatoReportingName()
|
||||||
|
self:F2( self.GroupName )
|
||||||
|
|
||||||
|
local DCSGroup = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSGroup then
|
||||||
|
local GroupTypeName = DCSGroup:getUnit(1):getTypeName()
|
||||||
|
self:T3( GroupTypeName )
|
||||||
|
return UTILS.GetReportingName(GroupTypeName)
|
||||||
|
end
|
||||||
|
|
||||||
|
return "Bogey"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- Gets the player name of the group.
|
--- Gets the player name of the group.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return #string The player name of the group.
|
-- @return #string The player name of the group.
|
||||||
@@ -994,24 +1061,33 @@ end
|
|||||||
-- @return Core.Point#COORDINATE The COORDINATE of the GROUP.
|
-- @return Core.Point#COORDINATE The COORDINATE of the GROUP.
|
||||||
function GROUP:GetCoordinate()
|
function GROUP:GetCoordinate()
|
||||||
|
|
||||||
local FirstUnit = self:GetUnit(1)
|
|
||||||
|
|
||||||
if FirstUnit then
|
local Units = self:GetUnits() or {}
|
||||||
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
|
|
||||||
return FirstUnitCoordinate
|
for _,_unit in pairs(Units) do
|
||||||
|
local FirstUnit = _unit -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
|
if FirstUnit then
|
||||||
|
|
||||||
|
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
|
||||||
|
|
||||||
|
if FirstUnitCoordinate then
|
||||||
|
local Heading = self:GetHeading()
|
||||||
|
FirstUnitCoordinate.Heading = Heading
|
||||||
|
return FirstUnitCoordinate
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
BASE:E( { "Cannot GetCoordinate", Group = self, Alive = self:IsAlive() } )
|
BASE:E( { "Cannot GetCoordinate", Group = self, Alive = self:IsAlive() } )
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns a random @{DCS#Vec3} vector (point in 3D of the UNIT within the mission) within a range around the first UNIT of the GROUP.
|
--- Returns a random @{DCS#Vec3} vector (point in 3D of the UNIT within the mission) within a range around the first UNIT of the GROUP.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #number Radius
|
-- @param #number Radius Radius in meters.
|
||||||
-- @return DCS#Vec3 The random 3D point vector around the first UNIT of the GROUP.
|
-- @return DCS#Vec3 The random 3D point vector around the first UNIT of the GROUP or #nil The GROUP is invalid or empty.
|
||||||
-- @return #nil The GROUP is invalid or empty
|
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- If Radius is ignored, returns the DCS#Vec3 of first UNIT of the GROUP
|
-- -- If Radius is ignored, returns the DCS#Vec3 of first UNIT of the GROUP
|
||||||
function GROUP:GetRandomVec3(Radius)
|
function GROUP:GetRandomVec3(Radius)
|
||||||
@@ -1032,18 +1108,19 @@ end
|
|||||||
|
|
||||||
--- Returns the mean heading of every UNIT in the GROUP in degrees
|
--- Returns the mean heading of every UNIT in the GROUP in degrees
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return #number mean heading of the GROUP
|
-- @return #number Mean heading of the GROUP in degrees or #nil The first UNIT is not existing or alive.
|
||||||
-- @return #nil The first UNIT is not existing or alive.
|
|
||||||
function GROUP:GetHeading()
|
function GROUP:GetHeading()
|
||||||
self:F2(self.GroupName)
|
self:F2(self.GroupName)
|
||||||
|
|
||||||
|
self:F2(self.GroupName)
|
||||||
|
|
||||||
local GroupSize = self:GetSize()
|
local GroupSize = self:GetSize()
|
||||||
local HeadingAccumulator = 0
|
local HeadingAccumulator = 0
|
||||||
|
|
||||||
local n=0
|
local n=0
|
||||||
|
local Units = self:GetUnits()
|
||||||
|
|
||||||
if GroupSize then
|
if GroupSize then
|
||||||
for i = 1, GroupSize do
|
for _,unit in pairs(Units) do
|
||||||
local unit=self:GetUnit(i)
|
|
||||||
if unit and unit:IsAlive() then
|
if unit and unit:IsAlive() then
|
||||||
HeadingAccumulator = HeadingAccumulator + unit:GetHeading()
|
HeadingAccumulator = HeadingAccumulator + unit:GetHeading()
|
||||||
n=n+1
|
n=n+1
|
||||||
@@ -1061,8 +1138,8 @@ end
|
|||||||
--- Return the fuel state and unit reference for the unit with the least
|
--- Return the fuel state and unit reference for the unit with the least
|
||||||
-- amount of fuel in the group.
|
-- amount of fuel in the group.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return #number The fuel state of the unit with the least amount of fuel
|
-- @return #number The fuel state of the unit with the least amount of fuel.
|
||||||
-- @return #Unit reference to #Unit object for further processing
|
-- @return Wrapper.Unit#UNIT reference to #Unit object for further processing.
|
||||||
function GROUP:GetFuelMin()
|
function GROUP:GetFuelMin()
|
||||||
self:F3(self.ControllableName)
|
self:F3(self.ControllableName)
|
||||||
|
|
||||||
@@ -1104,7 +1181,7 @@ function GROUP:GetFuelAvg()
|
|||||||
local TotalFuel = 0
|
local TotalFuel = 0
|
||||||
for UnitID, UnitData in pairs( self:GetUnits() ) do
|
for UnitID, UnitData in pairs( self:GetUnits() ) do
|
||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||||
local UnitFuel = Unit:GetFuel()
|
local UnitFuel = Unit:GetFuel() or 0
|
||||||
self:F( { Fuel = UnitFuel } )
|
self:F( { Fuel = UnitFuel } )
|
||||||
TotalFuel = TotalFuel + UnitFuel
|
TotalFuel = TotalFuel + UnitFuel
|
||||||
end
|
end
|
||||||
@@ -1133,6 +1210,7 @@ end
|
|||||||
-- @return #number Number of rockets left.
|
-- @return #number Number of rockets left.
|
||||||
-- @return #number Number of bombs left.
|
-- @return #number Number of bombs left.
|
||||||
-- @return #number Number of missiles left.
|
-- @return #number Number of missiles left.
|
||||||
|
-- @return #number Number of artillery shells left (with explosive mass, included in shells; shells can also be machine gun ammo)
|
||||||
function GROUP:GetAmmunition()
|
function GROUP:GetAmmunition()
|
||||||
self:F( self.ControllableName )
|
self:F( self.ControllableName )
|
||||||
|
|
||||||
@@ -1143,6 +1221,7 @@ function GROUP:GetAmmunition()
|
|||||||
local Nrockets=0
|
local Nrockets=0
|
||||||
local Nmissiles=0
|
local Nmissiles=0
|
||||||
local Nbombs=0
|
local Nbombs=0
|
||||||
|
local Narti=0
|
||||||
|
|
||||||
if DCSControllable then
|
if DCSControllable then
|
||||||
|
|
||||||
@@ -1151,19 +1230,19 @@ function GROUP:GetAmmunition()
|
|||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
-- Get ammo of the unit
|
-- Get ammo of the unit
|
||||||
local ntot, nshells, nrockets, nbombs, nmissiles = Unit:GetAmmunition()
|
local ntot, nshells, nrockets, nbombs, nmissiles, narti = Unit:GetAmmunition()
|
||||||
|
|
||||||
Ntot=Ntot+ntot
|
Ntot=Ntot+ntot
|
||||||
Nshells=Nshells+nshells
|
Nshells=Nshells+nshells
|
||||||
Nrockets=Nrockets+nrockets
|
Nrockets=Nrockets+nrockets
|
||||||
Nmissiles=Nmissiles+nmissiles
|
Nmissiles=Nmissiles+nmissiles
|
||||||
Nbombs=Nbombs+nbombs
|
Nbombs=Nbombs+nbombs
|
||||||
|
Narti=Narti+narti
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Ntot, Nshells, Nrockets, Nbombs, Nmissiles
|
return Ntot, Nshells, Nrockets, Nbombs, Nmissiles, Narti
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -1181,13 +1260,14 @@ function GROUP:IsInZone( Zone )
|
|||||||
for UnitID, UnitData in pairs(self:GetUnits()) do
|
for UnitID, UnitData in pairs(self:GetUnits()) do
|
||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
-- Get 2D vector. That's all we need for the zone check.
|
local vec2 = nil
|
||||||
local vec2=Unit:GetVec2()
|
if Unit then
|
||||||
|
-- Get 2D vector. That's all we need for the zone check.
|
||||||
|
vec2=Unit:GetVec2()
|
||||||
|
end
|
||||||
|
|
||||||
if Zone:IsVec2InZone(vec2) then
|
if vec2 and Zone:IsVec2InZone(vec2) then
|
||||||
return true -- At least one unit is in the zone. That is enough.
|
return true -- At least one unit is in the zone. That is enough.
|
||||||
else
|
|
||||||
-- This one is not but another could be.
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -2300,14 +2380,15 @@ function GROUP:GetAttribute()
|
|||||||
--- Ground ---
|
--- Ground ---
|
||||||
--------------
|
--------------
|
||||||
-- Ground
|
-- Ground
|
||||||
local apc=self:HasAttribute("Infantry carriers")
|
local apc=self:HasAttribute("APC")
|
||||||
local truck=self:HasAttribute("Trucks") and self:GetCategory()==Group.Category.GROUND
|
local truck=self:HasAttribute("Trucks") and self:GetCategory()==Group.Category.GROUND
|
||||||
local infantry=self:HasAttribute("Infantry")
|
local infantry=self:HasAttribute("Infantry")
|
||||||
local artillery=self:HasAttribute("Artillery")
|
local artillery=self:HasAttribute("Artillery")
|
||||||
local tank=self:HasAttribute("Old Tanks") or self:HasAttribute("Modern Tanks")
|
local tank=self:HasAttribute("Old Tanks") or self:HasAttribute("Modern Tanks")
|
||||||
local aaa=self:HasAttribute("AAA")
|
local aaa=self:HasAttribute("AAA") and (not self:HasAttribute("SAM elements"))
|
||||||
local ewr=self:HasAttribute("EWR")
|
local ewr=self:HasAttribute("EWR")
|
||||||
local sam=self:HasAttribute("SAM elements") and (not self:HasAttribute("AAA"))
|
local ifv=self:HasAttribute("IFV")
|
||||||
|
local sam=self:HasAttribute("SAM elements") or self:HasAttribute("Optical Tracker")
|
||||||
-- Train
|
-- Train
|
||||||
local train=self:GetCategory()==Group.Category.TRAIN
|
local train=self:GetCategory()==Group.Category.TRAIN
|
||||||
|
|
||||||
@@ -2350,6 +2431,8 @@ function GROUP:GetAttribute()
|
|||||||
attribute=GROUP.Attribute.GROUND_ARTILLERY
|
attribute=GROUP.Attribute.GROUND_ARTILLERY
|
||||||
elseif tank then
|
elseif tank then
|
||||||
attribute=GROUP.Attribute.GROUND_TANK
|
attribute=GROUP.Attribute.GROUND_TANK
|
||||||
|
elseif ifv then
|
||||||
|
attribute=GROUP.Attribute.GROUND_IFV
|
||||||
elseif apc then
|
elseif apc then
|
||||||
attribute=GROUP.Attribute.GROUND_APC
|
attribute=GROUP.Attribute.GROUND_APC
|
||||||
elseif infantry then
|
elseif infantry then
|
||||||
@@ -2609,94 +2692,120 @@ function GROUP:GetSkill()
|
|||||||
return skill
|
return skill
|
||||||
end
|
end
|
||||||
|
|
||||||
--do -- Smoke
|
|
||||||
|
--- Get the unit in the group with the highest threat level, which is still alive.
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @return Wrapper.Unit#UNIT The most dangerous unit in the group.
|
||||||
|
-- @return #number Threat level of the unit.
|
||||||
|
function GROUP:GetHighestThreat()
|
||||||
|
|
||||||
|
-- Get units of the group.
|
||||||
|
local units=self:GetUnits()
|
||||||
|
|
||||||
|
if units then
|
||||||
|
|
||||||
|
local threat=nil ; local maxtl=0
|
||||||
|
for _,_unit in pairs(units or {}) do
|
||||||
|
local unit=_unit --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
|
if unit and unit:IsAlive() then
|
||||||
|
|
||||||
|
-- Threat level of group.
|
||||||
|
local tl=unit:GetThreatLevel()
|
||||||
|
|
||||||
|
-- Check if greater the current threat.
|
||||||
|
if tl>maxtl then
|
||||||
|
maxtl=tl
|
||||||
|
threat=unit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return threat, maxtl
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get TTS friendly, optionally customized callsign mainly for **player groups**. A customized callsign is taken from the #GROUP name, after an optional '#' sign, e.g. "Aerial 1-1#Ghostrider" resulting in "Ghostrider 9", or,
|
||||||
|
-- if that isn't available, from the playername, as set in the mission editor main screen under Logbook, after an optional '|' sign (actually, more of a personal call sign), e.g. "Apple|Moose" results in "Moose 9 1". Options see below.
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @param #boolean ShortCallsign Return a shortened customized callsign, i.e. "Ghostrider 9" and not "Ghostrider 9 1"
|
||||||
|
-- @param #boolean Keepnumber (Player only) Return customized callsign, incl optional numbers at the end, e.g. "Aerial 1-1#Ghostrider 109" results in "Ghostrider 109", if you want to e.g. use historical US Navy Callsigns
|
||||||
|
-- @param #table CallsignTranslations Table to translate between DCS standard callsigns and bespoke ones. Does not apply if using customized
|
||||||
|
-- callsigns from playername or group name.
|
||||||
|
-- @return #string Callsign
|
||||||
|
-- @usage
|
||||||
|
-- -- Set Custom CAP Flight Callsigns for use with TTS
|
||||||
|
-- mygroup:GetCustomCallSign(true,false,{
|
||||||
|
-- Devil = 'Bengal',
|
||||||
|
-- Snake = 'Winder',
|
||||||
|
-- Colt = 'Camelot',
|
||||||
|
-- Enfield = 'Victory',
|
||||||
|
-- Uzi = 'Evil Eye'
|
||||||
|
-- })
|
||||||
--
|
--
|
||||||
----- Signal a flare at the position of the GROUP.
|
-- results in this outcome if the group has Callsign "Enfield 9 1" on the 1st #UNIT of the group:
|
||||||
---- @param #GROUP self
|
|
||||||
---- @param Utilities.Utils#FLARECOLOR FlareColor
|
|
||||||
--function GROUP:Flare( FlareColor )
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.signalFlare( self:GetVec3(), FlareColor , 0 )
|
|
||||||
--end
|
|
||||||
--
|
--
|
||||||
----- Signal a white flare at the position of the GROUP.
|
-- 'Victory 9'
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:FlareWhite()
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.signalFlare( self:GetVec3(), trigger.flareColor.White , 0 )
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Signal a yellow flare at the position of the GROUP.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:FlareYellow()
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.signalFlare( self:GetVec3(), trigger.flareColor.Yellow , 0 )
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Signal a green flare at the position of the GROUP.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:FlareGreen()
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.signalFlare( self:GetVec3(), trigger.flareColor.Green , 0 )
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Signal a red flare at the position of the GROUP.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:FlareRed()
|
|
||||||
-- self:F2()
|
|
||||||
-- local Vec3 = self:GetVec3()
|
|
||||||
-- if Vec3 then
|
|
||||||
-- trigger.action.signalFlare( Vec3, trigger.flareColor.Red, 0 )
|
|
||||||
-- end
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Smoke the GROUP.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:Smoke( SmokeColor, Range )
|
|
||||||
-- self:F2()
|
|
||||||
-- if Range then
|
|
||||||
-- trigger.action.smoke( self:GetRandomVec3( Range ), SmokeColor )
|
|
||||||
-- else
|
|
||||||
-- trigger.action.smoke( self:GetVec3(), SmokeColor )
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Smoke the GROUP Green.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:SmokeGreen()
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.smoke( self:GetVec3(), trigger.smokeColor.Green )
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Smoke the GROUP Red.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:SmokeRed()
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.smoke( self:GetVec3(), trigger.smokeColor.Red )
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Smoke the GROUP White.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:SmokeWhite()
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.smoke( self:GetVec3(), trigger.smokeColor.White )
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Smoke the GROUP Orange.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:SmokeOrange()
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.smoke( self:GetVec3(), trigger.smokeColor.Orange )
|
|
||||||
--end
|
|
||||||
--
|
|
||||||
----- Smoke the GROUP Blue.
|
|
||||||
---- @param #GROUP self
|
|
||||||
--function GROUP:SmokeBlue()
|
|
||||||
-- self:F2()
|
|
||||||
-- trigger.action.smoke( self:GetVec3(), trigger.smokeColor.Blue )
|
|
||||||
--end
|
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
--
|
function GROUP:GetCustomCallSign(ShortCallsign,Keepnumber,CallsignTranslations)
|
||||||
--end
|
--self:I("GetCustomCallSign")
|
||||||
|
|
||||||
|
local callsign = "Ghost 1"
|
||||||
|
if self:IsAlive() then
|
||||||
|
local IsPlayer = self:IsPlayer()
|
||||||
|
local shortcallsign = self:GetCallsign() or "unknown91" -- e.g.Uzi91, but we want Uzi 9 1
|
||||||
|
local callsignroot = string.match(shortcallsign, '(%a+)') -- Uzi
|
||||||
|
--self:I("CallSign = " .. callsignroot)
|
||||||
|
local groupname = self:GetName()
|
||||||
|
local callnumber = string.match(shortcallsign, "(%d+)$" ) or "91" -- 91
|
||||||
|
local callnumbermajor = string.char(string.byte(callnumber,1)) -- 9
|
||||||
|
local callnumberminor = string.char(string.byte(callnumber,2)) -- 1
|
||||||
|
local personalized = false
|
||||||
|
if IsPlayer and string.find(groupname,"#") then
|
||||||
|
-- personalized flight name in group naming
|
||||||
|
if Keepnumber then
|
||||||
|
shortcallsign = string.match(groupname,"#(.+)") -- Ghostrider 219
|
||||||
|
else
|
||||||
|
shortcallsign = string.match(groupname,"#%s*([%a]+)") -- Ghostrider
|
||||||
|
end
|
||||||
|
personalized = true
|
||||||
|
elseif IsPlayer and string.find(self:GetPlayerName(),"|") then
|
||||||
|
-- personalized flight name in group naming
|
||||||
|
shortcallsign = string.match(self:GetPlayerName(),"|%s*([%a]+)") -- Ghostrider
|
||||||
|
personalized = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not personalized) and CallsignTranslations and CallsignTranslations[callsignroot] then
|
||||||
|
callsignroot = CallsignTranslations[callsignroot]
|
||||||
|
end
|
||||||
|
|
||||||
|
if personalized then
|
||||||
|
-- player personalized callsign
|
||||||
|
-- remove trailing/leading spaces
|
||||||
|
shortcallsign=string.gsub(shortcallsign,"^%s*","")
|
||||||
|
shortcallsign=string.gsub(shortcallsign,"%s*$","")
|
||||||
|
if Keepnumber then
|
||||||
|
return shortcallsign -- Ghostrider 219
|
||||||
|
elseif ShortCallsign then
|
||||||
|
callsign = shortcallsign.." "..callnumbermajor -- Ghostrider 9
|
||||||
|
else
|
||||||
|
callsign = shortcallsign.." "..callnumbermajor.." "..callnumberminor -- Ghostrider 9 1
|
||||||
|
end
|
||||||
|
return callsign
|
||||||
|
end
|
||||||
|
|
||||||
|
-- AI or not personalized
|
||||||
|
if ShortCallsign then
|
||||||
|
callsign = callsignroot.." "..callnumbermajor -- Uzi/Victory 9
|
||||||
|
else
|
||||||
|
callsign = callsignroot.." "..callnumbermajor.." "..callnumberminor -- Uzi/Victory 9 1
|
||||||
|
end
|
||||||
|
|
||||||
|
--self:I("Generated Callsign = " .. callsign)
|
||||||
|
end
|
||||||
|
|
||||||
|
return callsign
|
||||||
|
end
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ IDENTIFIABLE = {
|
|||||||
|
|
||||||
local _CategoryName = {
|
local _CategoryName = {
|
||||||
[Unit.Category.AIRPLANE] = "Airplane",
|
[Unit.Category.AIRPLANE] = "Airplane",
|
||||||
[Unit.Category.HELICOPTER] = "Helicoper",
|
[Unit.Category.HELICOPTER] = "Helicopter",
|
||||||
[Unit.Category.GROUND_UNIT] = "Ground Identifiable",
|
[Unit.Category.GROUND_UNIT] = "Ground Identifiable",
|
||||||
[Unit.Category.SHIP] = "Ship",
|
[Unit.Category.SHIP] = "Ship",
|
||||||
[Unit.Category.STRUCTURE] = "Structure",
|
[Unit.Category.STRUCTURE] = "Structure",
|
||||||
@@ -56,8 +56,7 @@ end
|
|||||||
-- If the Identifiable is not alive, nil is returned.
|
-- If the Identifiable is not alive, nil is returned.
|
||||||
-- If the Identifiable is alive, true is returned.
|
-- If the Identifiable is alive, true is returned.
|
||||||
-- @param #IDENTIFIABLE self
|
-- @param #IDENTIFIABLE self
|
||||||
-- @return #boolean true if Identifiable is alive.
|
-- @return #boolean true if Identifiable is alive or `#nil` if the Identifiable is not existing or is not alive.
|
||||||
-- @return #nil if the Identifiable is not existing or is not alive.
|
|
||||||
function IDENTIFIABLE:IsAlive()
|
function IDENTIFIABLE:IsAlive()
|
||||||
self:F3( self.IdentifiableName )
|
self:F3( self.IdentifiableName )
|
||||||
|
|
||||||
@@ -77,11 +76,8 @@ end
|
|||||||
--- Returns DCS Identifiable object name.
|
--- Returns DCS Identifiable object name.
|
||||||
-- The function provides access to non-activated objects too.
|
-- The function provides access to non-activated objects too.
|
||||||
-- @param #IDENTIFIABLE self
|
-- @param #IDENTIFIABLE self
|
||||||
-- @return #string The name of the DCS Identifiable.
|
-- @return #string The name of the DCS Identifiable or `#nil`.
|
||||||
-- @return #nil The DCS Identifiable is not existing or alive.
|
|
||||||
function IDENTIFIABLE:GetName()
|
function IDENTIFIABLE:GetName()
|
||||||
self:F2( self.IdentifiableName )
|
|
||||||
|
|
||||||
local IdentifiableName = self.IdentifiableName
|
local IdentifiableName = self.IdentifiableName
|
||||||
return IdentifiableName
|
return IdentifiableName
|
||||||
end
|
end
|
||||||
@@ -148,8 +144,7 @@ end
|
|||||||
|
|
||||||
--- Returns coalition of the Identifiable.
|
--- Returns coalition of the Identifiable.
|
||||||
-- @param #IDENTIFIABLE self
|
-- @param #IDENTIFIABLE self
|
||||||
-- @return DCS#coalition.side The side of the coalition.
|
-- @return DCS#coalition.side The side of the coalition or `#nil` The DCS Identifiable is not existing or alive.
|
||||||
-- @return #nil The DCS Identifiable is not existing or alive.
|
|
||||||
function IDENTIFIABLE:GetCoalition()
|
function IDENTIFIABLE:GetCoalition()
|
||||||
self:F2( self.IdentifiableName )
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
@@ -176,7 +171,7 @@ function IDENTIFIABLE:GetCoalitionName()
|
|||||||
|
|
||||||
if DCSIdentifiable then
|
if DCSIdentifiable then
|
||||||
|
|
||||||
-- Get coaliton ID.
|
-- Get coalition ID.
|
||||||
local IdentifiableCoalition = DCSIdentifiable:getCoalition()
|
local IdentifiableCoalition = DCSIdentifiable:getCoalition()
|
||||||
self:T3( IdentifiableCoalition )
|
self:T3( IdentifiableCoalition )
|
||||||
|
|
||||||
@@ -190,8 +185,7 @@ end
|
|||||||
|
|
||||||
--- Returns country of the Identifiable.
|
--- Returns country of the Identifiable.
|
||||||
-- @param #IDENTIFIABLE self
|
-- @param #IDENTIFIABLE self
|
||||||
-- @return DCS#country.id The country identifier.
|
-- @return DCS#country.id The country identifier or `#nil` The DCS Identifiable is not existing or alive.
|
||||||
-- @return #nil The DCS Identifiable is not existing or alive.
|
|
||||||
function IDENTIFIABLE:GetCountry()
|
function IDENTIFIABLE:GetCountry()
|
||||||
self:F2( self.IdentifiableName )
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
@@ -222,8 +216,7 @@ end
|
|||||||
|
|
||||||
--- Returns Identifiable descriptor. Descriptor type depends on Identifiable category.
|
--- Returns Identifiable descriptor. Descriptor type depends on Identifiable category.
|
||||||
-- @param #IDENTIFIABLE self
|
-- @param #IDENTIFIABLE self
|
||||||
-- @return DCS#Object.Desc The Identifiable descriptor.
|
-- @return DCS#Object.Desc The Identifiable descriptor or `#nil` The DCS Identifiable is not existing or alive.
|
||||||
-- @return #nil The DCS Identifiable is not existing or alive.
|
|
||||||
function IDENTIFIABLE:GetDesc()
|
function IDENTIFIABLE:GetDesc()
|
||||||
self:F2( self.IdentifiableName )
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
@@ -242,8 +235,7 @@ end
|
|||||||
--- Check if the Object has the attribute.
|
--- Check if the Object has the attribute.
|
||||||
-- @param #IDENTIFIABLE self
|
-- @param #IDENTIFIABLE self
|
||||||
-- @param #string AttributeName The attribute name.
|
-- @param #string AttributeName The attribute name.
|
||||||
-- @return #boolean true if the attribute exists.
|
-- @return #boolean true if the attribute exists or `#nil` The DCS Identifiable is not existing or alive.
|
||||||
-- @return #nil The DCS Identifiable is not existing or alive.
|
|
||||||
function IDENTIFIABLE:HasAttribute( AttributeName )
|
function IDENTIFIABLE:HasAttribute( AttributeName )
|
||||||
self:F2( self.IdentifiableName )
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
@@ -266,8 +258,10 @@ function IDENTIFIABLE:GetCallsign()
|
|||||||
return ''
|
return ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Gets the threat level.
|
||||||
|
-- @param #IDENTIFIABLE self
|
||||||
|
-- @return #number Threat level.
|
||||||
|
-- @return #string Type.
|
||||||
function IDENTIFIABLE:GetThreatLevel()
|
function IDENTIFIABLE:GetThreatLevel()
|
||||||
|
|
||||||
return 0, "Scenery"
|
return 0, "Scenery"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,8 +13,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Author: **funkyfranky**
|
-- ### Author: **funkyfranky**
|
||||||
-- @module Wrapper.Marker
|
-- @module Wrapper.Marker
|
||||||
-- @image Wrapper_Marker.png
|
-- @image MOOSE_Core.JPG
|
||||||
|
|
||||||
|
|
||||||
--- Marker class.
|
--- Marker class.
|
||||||
-- @type MARKER
|
-- @type MARKER
|
||||||
@@ -24,7 +23,7 @@
|
|||||||
-- @field #number mid Marker ID.
|
-- @field #number mid Marker ID.
|
||||||
-- @field Core.Point#COORDINATE coordinate Coordinate of the mark.
|
-- @field Core.Point#COORDINATE coordinate Coordinate of the mark.
|
||||||
-- @field #string text Text displayed in the mark panel.
|
-- @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 #boolean readonly Marker is read-only.
|
||||||
-- @field #number coalition Coalition to which the marker is displayed.
|
-- @field #number coalition Coalition to which the marker is displayed.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
@@ -42,29 +41,29 @@
|
|||||||
-- # Create a Marker
|
-- # Create a Marker
|
||||||
--
|
--
|
||||||
-- -- Create a MARKER object at Batumi with a trivial text.
|
-- -- Create a MARKER object at Batumi with a trivial text.
|
||||||
-- local Coordinate=AIRBASE:FindByName("Batumi"):GetCoordinate()
|
-- local Coordinate = AIRBASE:FindByName( "Batumi" ):GetCoordinate()
|
||||||
-- mymarker=MARKER:New(Coordinate, "I am Batumi Airfield")
|
-- 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.
|
-- 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 speficic coaliton only, or only to a specific group.
|
-- show the marker to everyone, to a specific coalition only, or only to a specific group.
|
||||||
--
|
--
|
||||||
-- ## For Everyone
|
-- ## For Everyone
|
||||||
--
|
--
|
||||||
-- If the marker should be visible to everyone, you can use the :ToAll() function.
|
-- 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.
|
-- 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
|
-- ### 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
|
-- ## For a Group
|
||||||
--
|
--
|
||||||
@@ -76,28 +75,28 @@
|
|||||||
--
|
--
|
||||||
-- The marker text and coordinate can be updated easily as shown below.
|
-- 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.*
|
-- *This is a DCS scripting engine limitation.*
|
||||||
--
|
--
|
||||||
-- ## Update Text
|
-- ## 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
|
-- 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
|
-- ## Update Coordinate
|
||||||
--
|
--
|
||||||
-- If you created a marker "mymarker" as shown above, you can update its coordinate on the F10 map by
|
-- 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
|
-- The update can also be delayed by, e.g. 60 seconds, using
|
||||||
--
|
--
|
||||||
-- mymarker:UpdateCoordinate(NewCoordinate, 60)
|
-- mymarker:UpdateCoordinate( NewCoordinate , 60 )
|
||||||
--
|
--
|
||||||
-- # Retrieve Data
|
-- # Retrieve Data
|
||||||
--
|
--
|
||||||
@@ -105,18 +104,18 @@
|
|||||||
--
|
--
|
||||||
-- ## Text
|
-- ## Text
|
||||||
--
|
--
|
||||||
-- local text=mymarker:GetText()
|
-- local text =mymarker:GetText()
|
||||||
-- env.info("Marker Text = " .. text)
|
-- env.info( "Marker Text = " .. text )
|
||||||
--
|
--
|
||||||
-- ## Coordinate
|
-- ## Coordinate
|
||||||
--
|
--
|
||||||
-- local Coordinate=mymarker:GetCoordinate()
|
-- local Coordinate = mymarker:GetCoordinate()
|
||||||
-- env.info("Marker Coordinate LL DSM = " .. Coordinate:ToStringLLDMS())
|
-- env.info( "Marker Coordinate LL DSM = " .. Coordinate:ToStringLLDMS() )
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- # FSM Events
|
-- # 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.
|
-- These events can be captured and used for processing via OnAfter functions as shown below.
|
||||||
--
|
--
|
||||||
@@ -133,26 +132,25 @@
|
|||||||
--
|
--
|
||||||
-- # Examples
|
-- # Examples
|
||||||
--
|
--
|
||||||
--
|
|
||||||
-- @field #MARKER
|
-- @field #MARKER
|
||||||
MARKER = {
|
MARKER = {
|
||||||
ClassName = "MARKER",
|
ClassName = "MARKER",
|
||||||
Debug = false,
|
Debug = false,
|
||||||
lid = nil,
|
lid = nil,
|
||||||
mid = nil,
|
mid = nil,
|
||||||
coordinate = nil,
|
coordinate = nil,
|
||||||
text = nil,
|
text = nil,
|
||||||
message = nil,
|
message = nil,
|
||||||
readonly = nil,
|
readonly = nil,
|
||||||
coalition = nil,
|
coalition = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Marker ID. Running number.
|
--- Marker ID. Running number.
|
||||||
_MARKERID=0
|
_MARKERID = 0
|
||||||
|
|
||||||
--- Marker class version.
|
--- Marker class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
MARKER.version="0.1.0"
|
MARKER.version="0.1.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -172,38 +170,40 @@ MARKER.version="0.1.0"
|
|||||||
-- @param Core.Point#COORDINATE Coordinate Coordinate where to place the marker.
|
-- @param Core.Point#COORDINATE Coordinate Coordinate where to place the marker.
|
||||||
-- @param #string Text Text displayed on the mark panel.
|
-- @param #string Text Text displayed on the mark panel.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:New(Coordinate, Text)
|
function MARKER:New( Coordinate, Text )
|
||||||
|
|
||||||
-- Inherit everything from FSM class.
|
-- Inherit everything from FSM class.
|
||||||
|
local self = BASE:Inherit( self, FSM:New() ) -- #MARKER
|
||||||
|
|
||||||
local self=BASE:Inherit(self, FSM:New()) -- #MARKER
|
local self=BASE:Inherit(self, FSM:New()) -- #MARKER
|
||||||
|
|
||||||
self.coordinate=Coordinate
|
self.coordinate=UTILS.DeepCopy(Coordinate)
|
||||||
|
|
||||||
self.text=Text
|
self.text = Text
|
||||||
|
|
||||||
-- Defaults
|
-- Defaults
|
||||||
self.readonly=false
|
self.readonly = false
|
||||||
self.message=""
|
self.message = ""
|
||||||
|
|
||||||
-- New marker ID. This is not the one of the actual marker.
|
-- 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.
|
-- Log ID.
|
||||||
self.lid=string.format("Marker #%d | ", self.myid)
|
self.lid = string.format( "Marker #%d | ", self.myid )
|
||||||
|
|
||||||
-- Start State.
|
-- Start State.
|
||||||
self:SetStartState("Invisible")
|
self:SetStartState( "Invisible" )
|
||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("Invisible", "Added", "Visible") -- Marker was added.
|
self:AddTransition( "Invisible", "Added", "Visible" ) -- Marker was added.
|
||||||
self:AddTransition("Visible", "Removed", "Invisible") -- Marker was removed.
|
self:AddTransition( "Visible", "Removed", "Invisible" ) -- Marker was removed.
|
||||||
self:AddTransition("*", "Changed", "*") -- Marker was changed.
|
self:AddTransition( "*", "Changed", "*" ) -- Marker was changed.
|
||||||
|
|
||||||
self:AddTransition("*", "TextUpdate", "*") -- Text updated.
|
self:AddTransition( "*", "TextUpdate", "*" ) -- Text updated.
|
||||||
self:AddTransition("*", "CoordUpdate", "*") -- Coordinates updated.
|
self:AddTransition( "*", "CoordUpdate", "*" ) -- Coordinates updated.
|
||||||
|
|
||||||
--- Triggers the FSM event "Added".
|
--- Triggers the FSM event "Added".
|
||||||
-- @function [parent=#MARKER] Added
|
-- @function [parent=#MARKER] Added
|
||||||
@@ -223,7 +223,6 @@ function MARKER:New(Coordinate, Text)
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Event#EVENTDATA EventData Event data table.
|
-- @param Core.Event#EVENTDATA EventData Event data table.
|
||||||
|
|
||||||
|
|
||||||
--- Triggers the FSM event "Removed".
|
--- Triggers the FSM event "Removed".
|
||||||
-- @function [parent=#MARKER] Removed
|
-- @function [parent=#MARKER] Removed
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
@@ -242,7 +241,6 @@ function MARKER:New(Coordinate, Text)
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Event#EVENTDATA EventData Event data table.
|
-- @param Core.Event#EVENTDATA EventData Event data table.
|
||||||
|
|
||||||
|
|
||||||
--- Triggers the FSM event "Changed".
|
--- Triggers the FSM event "Changed".
|
||||||
-- @function [parent=#MARKER] Changed
|
-- @function [parent=#MARKER] Changed
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
@@ -261,7 +259,6 @@ function MARKER:New(Coordinate, Text)
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Event#EVENTDATA EventData Event data table.
|
-- @param Core.Event#EVENTDATA EventData Event data table.
|
||||||
|
|
||||||
|
|
||||||
--- Triggers the FSM event "TextUpdate".
|
--- Triggers the FSM event "TextUpdate".
|
||||||
-- @function [parent=#MARKER] TextUpdate
|
-- @function [parent=#MARKER] TextUpdate
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
@@ -280,7 +277,6 @@ function MARKER:New(Coordinate, Text)
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #string Text The new text.
|
-- @param #string Text The new text.
|
||||||
|
|
||||||
|
|
||||||
--- Triggers the FSM event "CoordUpdate".
|
--- Triggers the FSM event "CoordUpdate".
|
||||||
-- @function [parent=#MARKER] CoordUpdate
|
-- @function [parent=#MARKER] CoordUpdate
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
@@ -299,11 +295,10 @@ function MARKER:New(Coordinate, Text)
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Point#COORDINATE Coordinate The updated Coordinate.
|
-- @param Core.Point#COORDINATE Coordinate The updated Coordinate.
|
||||||
|
|
||||||
|
|
||||||
-- Handle events.
|
-- Handle events.
|
||||||
self:HandleEvent(EVENTS.MarkAdded)
|
self:HandleEvent( EVENTS.MarkAdded )
|
||||||
self:HandleEvent(EVENTS.MarkRemoved)
|
self:HandleEvent( EVENTS.MarkRemoved )
|
||||||
self:HandleEvent(EVENTS.MarkChange)
|
self:HandleEvent( EVENTS.MarkChange )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -317,7 +312,17 @@ end
|
|||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:ReadOnly()
|
function MARKER:ReadOnly()
|
||||||
|
|
||||||
self.readonly=true
|
self.readonly = true
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Marker is readonly. Text cannot be changed and marker cannot be removed.
|
||||||
|
-- @param #MARKER self
|
||||||
|
-- @return #MARKER self
|
||||||
|
function MARKER:ReadWrite()
|
||||||
|
|
||||||
|
self.readonly=false
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -326,9 +331,9 @@ end
|
|||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param #string Text Message displayed when the marker is added.
|
-- @param #string Text Message displayed when the marker is added.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:Message(Text)
|
function MARKER:Message( Text )
|
||||||
|
|
||||||
self.message=Text or ""
|
self.message = Text or ""
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -337,28 +342,28 @@ end
|
|||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:ToAll(Delay)
|
function MARKER:ToAll( Delay )
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
self:ScheduleOnce(Delay, MARKER.ToAll, self)
|
self:ScheduleOnce( Delay, MARKER.ToAll, self )
|
||||||
else
|
else
|
||||||
|
|
||||||
self.toall=true
|
self.toall = true
|
||||||
self.tocoaliton=nil
|
self.tocoalition = nil
|
||||||
self.coalition=nil
|
self.coalition = nil
|
||||||
self.togroup=nil
|
self.togroup = nil
|
||||||
self.groupname=nil
|
self.groupname = nil
|
||||||
self.groupid=nil
|
self.groupid = nil
|
||||||
|
|
||||||
-- First remove an existing mark.
|
-- First remove an existing mark.
|
||||||
if self.shown then
|
if self.shown then
|
||||||
self:Remove()
|
self:Remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.mid=UTILS.GetMarkID()
|
self.mid = UTILS.GetMarkID()
|
||||||
|
|
||||||
-- Call DCS function.
|
-- 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
|
end
|
||||||
|
|
||||||
@@ -367,32 +372,32 @@ end
|
|||||||
|
|
||||||
--- Place marker visible for a specific coalition only.
|
--- Place marker visible for a specific coalition only.
|
||||||
-- @param #MARKER self
|
-- @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.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:ToCoalition(Coalition, Delay)
|
function MARKER:ToCoalition( Coalition, Delay )
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
self:ScheduleOnce(Delay, MARKER.ToCoalition, self, Coalition)
|
self:ScheduleOnce( Delay, MARKER.ToCoalition, self, Coalition )
|
||||||
else
|
else
|
||||||
|
|
||||||
self.coalition=Coalition
|
self.coalition = Coalition
|
||||||
|
|
||||||
self.tocoaliton=true
|
self.tocoalition = true
|
||||||
self.toall=false
|
self.toall = false
|
||||||
self.togroup=false
|
self.togroup = false
|
||||||
self.groupname=nil
|
self.groupname = nil
|
||||||
self.groupid=nil
|
self.groupid = nil
|
||||||
|
|
||||||
-- First remove an existing mark.
|
-- First remove an existing mark.
|
||||||
if self.shown then
|
if self.shown then
|
||||||
self:Remove()
|
self:Remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.mid=UTILS.GetMarkID()
|
self.mid = UTILS.GetMarkID()
|
||||||
|
|
||||||
-- Call DCS function.
|
-- 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
|
end
|
||||||
|
|
||||||
@@ -403,8 +408,8 @@ end
|
|||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:ToBlue(Delay)
|
function MARKER:ToBlue( Delay )
|
||||||
self:ToCoalition(coalition.side.BLUE, Delay)
|
self:ToCoalition( coalition.side.BLUE, Delay )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -412,8 +417,8 @@ end
|
|||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:ToRed(Delay)
|
function MARKER:ToRed( Delay )
|
||||||
self:ToCoalition(coalition.side.RED, Delay)
|
self:ToCoalition( coalition.side.RED, Delay )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -421,51 +426,50 @@ end
|
|||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:ToNeutral(Delay)
|
function MARKER:ToNeutral( Delay )
|
||||||
self:ToCoalition(coalition.side.NEUTRAL, Delay)
|
self:ToCoalition( coalition.side.NEUTRAL, Delay )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Place marker visible for a specific group only.
|
--- Place marker visible for a specific group only.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param Wrapper.Group#GROUP Group The group to which the marker is displayed.
|
-- @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.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:ToGroup(Group, Delay)
|
function MARKER:ToGroup( Group, Delay )
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
self:ScheduleOnce(Delay, MARKER.ToGroup, self, Group)
|
self:ScheduleOnce( Delay, MARKER.ToGroup, self, Group )
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Check if group exists.
|
-- 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
|
if self.groupid then
|
||||||
|
|
||||||
self.groupname=Group:GetName()
|
self.groupname = Group:GetName()
|
||||||
|
|
||||||
self.togroup=true
|
self.togroup = true
|
||||||
self.tocoaliton=nil
|
self.tocoalition = nil
|
||||||
self.coalition=nil
|
self.coalition = nil
|
||||||
self.toall=nil
|
self.toall = nil
|
||||||
|
|
||||||
-- First remove an existing mark.
|
-- First remove an existing mark.
|
||||||
if self.shown then
|
if self.shown then
|
||||||
self:Remove()
|
self:Remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.mid=UTILS.GetMarkID()
|
self.mid = UTILS.GetMarkID()
|
||||||
|
|
||||||
-- Call DCS function.
|
-- 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
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
--TODO: Warning!
|
-- TODO: Warning!
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -478,17 +482,17 @@ end
|
|||||||
-- @param #string Text Updated text.
|
-- @param #string Text Updated text.
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:UpdateText(Text, Delay)
|
function MARKER:UpdateText( Text, Delay )
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
self:ScheduleOnce(Delay, MARKER.UpdateText, self, Text)
|
self:ScheduleOnce( Delay, MARKER.UpdateText, self, Text )
|
||||||
else
|
else
|
||||||
|
|
||||||
self.text=tostring(Text)
|
self.text = tostring( Text )
|
||||||
|
|
||||||
self:Refresh()
|
self:Refresh()
|
||||||
|
|
||||||
self:TextUpdate(tostring(Text))
|
self:TextUpdate( tostring( Text ) )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -500,17 +504,17 @@ end
|
|||||||
-- @param Core.Point#COORDINATE Coordinate The new coordinate.
|
-- @param Core.Point#COORDINATE Coordinate The new coordinate.
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:UpdateCoordinate(Coordinate, Delay)
|
function MARKER:UpdateCoordinate( Coordinate, Delay )
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
self:ScheduleOnce(Delay, MARKER.UpdateCoordinate, self, Coordinate)
|
self:ScheduleOnce( Delay, MARKER.UpdateCoordinate, self, Coordinate )
|
||||||
else
|
else
|
||||||
|
|
||||||
self.coordinate=Coordinate
|
self.coordinate = Coordinate
|
||||||
|
|
||||||
self:Refresh()
|
self:Refresh()
|
||||||
|
|
||||||
self:CoordUpdate(Coordinate)
|
self:CoordUpdate( Coordinate )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -521,28 +525,28 @@ end
|
|||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is created.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:Refresh(Delay)
|
function MARKER:Refresh( Delay )
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
self:ScheduleOnce(Delay, MARKER.Refresh, self)
|
self:ScheduleOnce( Delay, MARKER.Refresh, self )
|
||||||
else
|
else
|
||||||
|
|
||||||
if self.toall then
|
if self.toall then
|
||||||
|
|
||||||
self:ToAll()
|
self:ToAll()
|
||||||
|
|
||||||
elseif self.tocoaliton then
|
elseif self.tocoalition then
|
||||||
|
|
||||||
self:ToCoalition(self.coalition)
|
self:ToCoalition( self.coalition )
|
||||||
|
|
||||||
elseif self.togroup then
|
elseif self.togroup then
|
||||||
|
|
||||||
local group=GROUP:FindByName(self.groupname)
|
local group = GROUP:FindByName( self.groupname )
|
||||||
|
|
||||||
self:ToGroup(group)
|
self:ToGroup( group )
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E(self.lid.."ERROR: unknown To in :Refresh()!")
|
self:E( self.lid .. "ERROR: unknown To in :Refresh()!" )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -554,16 +558,16 @@ end
|
|||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the marker is removed.
|
-- @param #number Delay (Optional) Delay in seconds, before the marker is removed.
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:Remove(Delay)
|
function MARKER:Remove( Delay )
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
self:ScheduleOnce(Delay, MARKER.Remove, self)
|
self:ScheduleOnce( Delay, MARKER.Remove, self )
|
||||||
else
|
else
|
||||||
|
|
||||||
if self.shown then
|
if self.shown then
|
||||||
|
|
||||||
-- Call DCS function.
|
-- Call DCS function.
|
||||||
trigger.action.removeMark(self.mid)
|
trigger.action.removeMark( self.mid )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -588,26 +592,25 @@ end
|
|||||||
|
|
||||||
--- Set text that is displayed in the marker panel. Note this does not show the marker.
|
--- Set text that is displayed in the marker panel. Note this does not show the marker.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param #string Text Marker text. Default is an empty sting "".
|
-- @param #string Text Marker text. Default is an empty string "".
|
||||||
-- @return #MARKER self
|
-- @return #MARKER self
|
||||||
function MARKER:SetText(Text)
|
function MARKER:SetText( Text )
|
||||||
self.text=Text and tostring(Text) or ""
|
self.text = Text and tostring( Text ) or ""
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if marker is currently visible on the F10 map.
|
--- Check if marker is currently visible on the F10 map.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @return #boolean True if the marker is currently visible.
|
-- @return #boolean True if the marker is currently visible.
|
||||||
function MARKER:IsVisible()
|
function MARKER:IsVisible()
|
||||||
return self:Is("Visible")
|
return self:Is( "Visible" )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if marker is currently invisible on the F10 map.
|
--- Check if marker is currently invisible on the F10 map.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @return
|
-- @return
|
||||||
function MARKER:IsInvisible()
|
function MARKER:IsInvisible()
|
||||||
return self:Is("Invisible")
|
return self:Is( "Invisible" )
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -617,19 +620,19 @@ end
|
|||||||
--- Event function when a MARKER is added.
|
--- Event function when a MARKER is added.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function MARKER:OnEventMarkAdded(EventData)
|
function MARKER:OnEventMarkAdded( EventData )
|
||||||
|
|
||||||
if EventData and EventData.MarkID then
|
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
|
end
|
||||||
|
|
||||||
@@ -640,19 +643,21 @@ end
|
|||||||
--- Event function when a MARKER is removed.
|
--- Event function when a MARKER is removed.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function MARKER:OnEventMarkRemoved(EventData)
|
function MARKER:OnEventMarkRemoved( EventData )
|
||||||
|
|
||||||
if EventData and EventData.MarkID then
|
if EventData and EventData.MarkID then
|
||||||
|
|
||||||
|
local MarkID = EventData.MarkID
|
||||||
|
|
||||||
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 MarkRemoved 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
|
end
|
||||||
|
|
||||||
@@ -663,26 +668,32 @@ end
|
|||||||
--- Event function when a MARKER changed.
|
--- Event function when a MARKER changed.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function MARKER:OnEventMarkChange(EventData)
|
function MARKER:OnEventMarkChange( EventData )
|
||||||
|
|
||||||
if EventData and EventData.MarkID then
|
if EventData and EventData.MarkID then
|
||||||
|
|
||||||
|
local MarkID = EventData.MarkID
|
||||||
|
|
||||||
|
self:T3( self.lid .. string.format( "Captured event MarkChange for Mark ID=%s", tostring( MarkID ) ) )
|
||||||
|
|
||||||
|
if MarkID == self.mid 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.text=tostring(EventData.MarkText)
|
||||||
|
|
||||||
self:TextChanged(tostring(EventData.MarkText))
|
self:Changed(EventData)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- FSM Event Functions
|
-- FSM Event Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -693,17 +704,17 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Event#EVENTDATA EventData Event data table.
|
-- @param Core.Event#EVENTDATA EventData Event data table.
|
||||||
function MARKER:onafterAdded(From, Event, To, EventData)
|
function MARKER:onafterAdded( From, Event, To, EventData )
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("Captured event MarkAdded for myself:\n")
|
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( "Marker ID = %s\n", tostring( EventData.MarkID ) )
|
||||||
text=text..string.format("Coalition = %s\n", tostring(EventData.MarkCoalition))
|
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( "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( "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( "Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere" )
|
||||||
text=text..string.format("Text: \n%s", tostring(EventData.MarkText))
|
text = text .. string.format( "Text: \n%s", tostring( EventData.MarkText ) )
|
||||||
self:T2(self.lid..text)
|
self:T2( self.lid .. text )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -713,17 +724,17 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Event#EVENTDATA EventData Event data table.
|
-- @param Core.Event#EVENTDATA EventData Event data table.
|
||||||
function MARKER:onafterRemoved(From, Event, To, EventData)
|
function MARKER:onafterRemoved( From, Event, To, EventData )
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("Captured event MarkRemoved for myself:\n")
|
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( "Marker ID = %s\n", tostring( EventData.MarkID ) )
|
||||||
text=text..string.format("Coalition = %s\n", tostring(EventData.MarkCoalition))
|
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( "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( "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( "Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere" )
|
||||||
text=text..string.format("Text: \n%s", tostring(EventData.MarkText))
|
text = text .. string.format( "Text: \n%s", tostring( EventData.MarkText ) )
|
||||||
self:T2(self.lid..text)
|
self:T2( self.lid .. text )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -733,17 +744,17 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Event#EVENTDATA EventData Event data table.
|
-- @param Core.Event#EVENTDATA EventData Event data table.
|
||||||
function MARKER:onafterChanged(From, Event, To, EventData)
|
function MARKER:onafterChanged( From, Event, To, EventData )
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("Captured event MarkChange for myself:\n")
|
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( "Marker ID = %s\n", tostring( EventData.MarkID ) )
|
||||||
text=text..string.format("Coalition = %s\n", tostring(EventData.MarkCoalition))
|
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( "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( "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( "Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere" )
|
||||||
text=text..string.format("Text: \n%s", tostring(EventData.MarkText))
|
text = text .. string.format( "Text: \n%s", tostring( EventData.MarkText ) )
|
||||||
self:T2(self.lid..text)
|
self:T2( self.lid .. text )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -753,9 +764,9 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #string Text The updated text, displayed in the mark panel.
|
-- @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
|
end
|
||||||
|
|
||||||
@@ -765,12 +776,8 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Core.Point#COORDINATE Coordinate The updated coordinates.
|
-- @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
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|||||||
@@ -381,9 +381,10 @@ function POSITIONABLE:GetCoordinate()
|
|||||||
-- Get the current position.
|
-- Get the current position.
|
||||||
local PositionableVec3 = self:GetVec3()
|
local PositionableVec3 = self:GetVec3()
|
||||||
|
|
||||||
local coord = COORDINATE:NewFromVec3( PositionableVec3 )
|
local coord=COORDINATE:NewFromVec3(PositionableVec3)
|
||||||
|
local heading = self:GetHeading()
|
||||||
-- Return a new coordinate object.
|
coord.Heading = heading
|
||||||
|
-- Return a new coordiante object.
|
||||||
return coord
|
return coord
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -536,7 +537,7 @@ function POSITIONABLE:GetBoundingRadius( MinDist )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the altitude of the POSITIONABLE.
|
--- Returns the altitude above sea level of the POSITIONABLE.
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||||
-- @return DCS#Distance The altitude of the POSITIONABLE.
|
-- @return DCS#Distance The altitude of the POSITIONABLE.
|
||||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
-- @return #nil The POSITIONABLE is not existing or alive.
|
||||||
@@ -702,11 +703,11 @@ function POSITIONABLE:IsSubmarine()
|
|||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
local UnitDescriptor = DCSUnit:getDesc()
|
local UnitDescriptor = DCSUnit:getDesc()
|
||||||
if UnitDescriptor.attributes["Submarines"] == true then
|
if UnitDescriptor.attributes["Submarines"] == true then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:E( { "Cannot check IsSubmarine", Positionable = self, Alive = self:IsAlive() } )
|
self:E( { "Cannot check IsSubmarine", Positionable = self, Alive = self:IsAlive() } )
|
||||||
@@ -778,11 +779,11 @@ function POSITIONABLE:GetRelativeVelocity( Positionable )
|
|||||||
return UTILS.VecNorm( vtot )
|
return UTILS.VecNorm( vtot )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the POSITIONABLE height in meters.
|
|
||||||
|
--- Returns the POSITIONABLE height above sea level in meters.
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||||
-- @return DCS#Vec3 The height of the POSITIONABLE in meters.
|
-- @return DCS#Vec3 Height of the positionable in meters (or nil, if the object does not exist).
|
||||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
function POSITIONABLE:GetHeight() --R2.1
|
||||||
function POSITIONABLE:GetHeight()
|
|
||||||
self:F2( self.PositionableName )
|
self:F2( self.PositionableName )
|
||||||
|
|
||||||
local DCSPositionable = self:GetDCSObject()
|
local DCSPositionable = self:GetDCSObject()
|
||||||
@@ -1176,6 +1177,30 @@ function POSITIONABLE:MessageToClient( Message, Duration, Client, Name )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Send a message to a @{Wrapper.Unit}.
|
||||||
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @param #string Message The message text
|
||||||
|
-- @param DCS#Duration Duration The duration of the message.
|
||||||
|
-- @param Wrapper.Unit#UNIT MessageUnit The UNIT object receiving the message.
|
||||||
|
-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable.
|
||||||
|
function POSITIONABLE:MessageToUnit( Message, Duration, MessageUnit, Name )
|
||||||
|
self:F2( { Message, Duration } )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
if DCSObject then
|
||||||
|
if DCSObject:isExist() then
|
||||||
|
if MessageUnit:IsAlive() then
|
||||||
|
self:GetMessage( Message, Duration, Name ):ToUnit( MessageUnit )
|
||||||
|
else
|
||||||
|
BASE:E( { "Message not sent to Unit; Unit is not alive...", Message = Message, MessageUnit = MessageUnit } )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
BASE:E( { "Message not sent to Unit; Positionable is not alive ...", Message = Message, Positionable = self, MessageUnit = MessageUnit } )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Send a message to a @{Wrapper.Group}.
|
--- Send a message to a @{Wrapper.Group}.
|
||||||
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
@@ -1207,6 +1232,33 @@ function POSITIONABLE:MessageToGroup( Message, Duration, MessageGroup, Name )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Send a message to a @{Wrapper.Unit}.
|
||||||
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @param #string Message The message text
|
||||||
|
-- @param DCS#Duration Duration The duration of the message.
|
||||||
|
-- @param Wrapper.Unit#UNIT MessageUnit The UNIT object receiving the message.
|
||||||
|
-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable.
|
||||||
|
function POSITIONABLE:MessageToUnit( Message, Duration, MessageUnit, Name )
|
||||||
|
self:F2( { Message, Duration } )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
if DCSObject then
|
||||||
|
if DCSObject:isExist() then
|
||||||
|
if MessageUnit:IsAlive() then
|
||||||
|
self:GetMessage( Message, Duration, Name ):ToUnit( MessageUnit )
|
||||||
|
else
|
||||||
|
BASE:E( { "Message not sent to Unit; Unit is not alive...", Message = Message, MessageUnit = MessageUnit } )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
BASE:E( { "Message not sent to Unit; Positionable is not alive ...", Message = Message, Positionable = self, MessageUnit = MessageUnit } )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Send a message of a message type to a @{Wrapper.Group}.
|
--- Send a message of a message type to a @{Wrapper.Group}.
|
||||||
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
@@ -1249,6 +1301,54 @@ function POSITIONABLE:MessageToSetGroup( Message, Duration, MessageSetGroup, Nam
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Send a message to a @{Core.Set#SET_UNIT}.
|
||||||
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @param #string Message The message text
|
||||||
|
-- @param DCS#Duration Duration The duration of the message.
|
||||||
|
-- @param Core.Set#SET_UNIT MessageSetUnit The SET_UNIT collection receiving the message.
|
||||||
|
-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable.
|
||||||
|
function POSITIONABLE:MessageToSetUnit( Message, Duration, MessageSetUnit, Name )
|
||||||
|
self:F2( { Message, Duration } )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
if DCSObject then
|
||||||
|
if DCSObject:isExist() then
|
||||||
|
MessageSetUnit:ForEachUnit(
|
||||||
|
function( MessageGroup )
|
||||||
|
self:GetMessage( Message, Duration, Name ):ToUnit( MessageGroup )
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Send a message to a @{Core.Set#SET_UNIT}.
|
||||||
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @param #string Message The message text
|
||||||
|
-- @param DCS#Duration Duration The duration of the message.
|
||||||
|
-- @param Core.Set#SET_UNIT MessageSetUnit The SET_UNIT collection receiving the message.
|
||||||
|
-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable.
|
||||||
|
function POSITIONABLE:MessageToSetUnit( Message, Duration, MessageSetUnit, Name )
|
||||||
|
self:F2( { Message, Duration } )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
if DCSObject then
|
||||||
|
if DCSObject:isExist() then
|
||||||
|
MessageSetUnit:ForEachUnit(
|
||||||
|
function( MessageGroup )
|
||||||
|
self:GetMessage( Message, Duration, Name ):ToUnit( MessageGroup )
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Send a message to the players in the @{Wrapper.Group}.
|
--- Send a message to the players in the @{Wrapper.Group}.
|
||||||
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
@@ -1431,17 +1531,15 @@ do -- Cargo
|
|||||||
return ItemCount
|
return ItemCount
|
||||||
end
|
end
|
||||||
|
|
||||||
-- --- Get Cargo Bay Free Volume in m3.
|
--- Get the number of infantry soldiers that can be embarked into an aircraft (airplane or helicopter).
|
||||||
-- -- @param #POSITIONABLE self
|
-- Returns `nil` for ground or ship units.
|
||||||
-- -- @return #number CargoBayFreeVolume
|
-- @param #POSITIONABLE self
|
||||||
-- function POSITIONABLE:GetCargoBayFreeVolume()
|
-- @return #number Descent number of soldiers that fit into the unit. Returns `#nil` for ground and ship units.
|
||||||
-- local CargoVolume = 0
|
function POSITIONABLE:GetTroopCapacity()
|
||||||
-- for CargoName, Cargo in pairs( self.__.Cargo ) do
|
local DCSunit=self:GetDCSObject() --DCS#Unit
|
||||||
-- CargoVolume = CargoVolume + Cargo:GetVolume()
|
local capacity=DCSunit:getDescentCapacity()
|
||||||
-- end
|
return capacity
|
||||||
-- return self.__.CargoBayVolumeLimit - CargoVolume
|
end
|
||||||
-- end
|
|
||||||
--
|
|
||||||
|
|
||||||
--- Get Cargo Bay Free Weight in kg.
|
--- Get Cargo Bay Free Weight in kg.
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
@@ -1460,55 +1558,97 @@ do -- Cargo
|
|||||||
return self.__.CargoBayWeightLimit - CargoWeight
|
return self.__.CargoBayWeightLimit - CargoWeight
|
||||||
end
|
end
|
||||||
|
|
||||||
-- --- Get Cargo Bay Volume Limit in m3.
|
|
||||||
-- -- @param #POSITIONABLE self
|
|
||||||
-- -- @param #number VolumeLimit
|
|
||||||
-- function POSITIONABLE:SetCargoBayVolumeLimit( VolumeLimit )
|
|
||||||
-- self.__.CargoBayVolumeLimit = VolumeLimit
|
|
||||||
-- end
|
|
||||||
|
|
||||||
--- Set Cargo Bay Weight Limit in kg.
|
--- Set Cargo Bay Weight Limit in kg.
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
-- @param #number WeightLimit
|
-- @param #number WeightLimit (Optional) Weight limit in kg. If not given, the value is taken from the descriptors or hard coded.
|
||||||
function POSITIONABLE:SetCargoBayWeightLimit( WeightLimit )
|
function POSITIONABLE:SetCargoBayWeightLimit( WeightLimit )
|
||||||
|
|
||||||
if WeightLimit then
|
if WeightLimit then
|
||||||
|
---
|
||||||
|
-- User defined value
|
||||||
|
---
|
||||||
self.__.CargoBayWeightLimit = WeightLimit
|
self.__.CargoBayWeightLimit = WeightLimit
|
||||||
elseif self.__.CargoBayWeightLimit ~= nil then
|
elseif self.__.CargoBayWeightLimit ~= nil then
|
||||||
-- Value already set ==> Do nothing!
|
-- Value already set ==> Do nothing!
|
||||||
else
|
else
|
||||||
-- If WeightLimit is not provided, we will calculate it depending on the type of unit.
|
---
|
||||||
|
-- Weightlimit is not provided, we will calculate it depending on the type of unit.
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Descriptors that contain the type name and for aircraft also weights.
|
||||||
|
local Desc = self:GetDesc()
|
||||||
|
self:F({Desc=Desc})
|
||||||
|
|
||||||
|
-- Unit type name.
|
||||||
|
local TypeName=Desc.typeName or "Unknown Type"
|
||||||
|
|
||||||
-- When an airplane or helicopter, we calculate the WeightLimit based on the descriptor.
|
-- When an airplane or helicopter, we calculate the WeightLimit based on the descriptor.
|
||||||
if self:IsAir() then
|
if self:IsAir() then
|
||||||
local Desc = self:GetDesc()
|
|
||||||
self:F( { Desc = Desc } )
|
|
||||||
|
|
||||||
|
-- Max takeoff weight if DCS descriptors have unrealstic values.
|
||||||
local Weights = {
|
local Weights = {
|
||||||
["C-17A"] = 35000, -- 77519 cannot be used, because it loads way too many APCs and infantry.
|
-- C-17A
|
||||||
["C-130"] = 22000 -- The real value cannot be used, because it loads way too many APCs and infantry.
|
-- Wiki says: max=265,352, empty=128,140, payload=77,516 (134 troops, 1 M1 Abrams tank, 2 M2 Bradley or 3 Stryker)
|
||||||
|
-- DCS says: max=265,350, empty=125,645, fuel=132,405 ==> Cargo Bay=7300 kg with a full fuel load (lot of fuel!) and 73300 with half a fuel load.
|
||||||
|
--["C-17A"] = 35000, --77519 cannot be used, because it loads way too much apcs and infantry.
|
||||||
|
-- C-130:
|
||||||
|
-- DCS says: max=79,380, empty=36,400, fuel=10,415 kg ==> Cargo Bay=32,565 kg with fuel load.
|
||||||
|
-- Wiki says: max=70,307, empty=34,382, payload=19,000 kg (92 passengers, 2-3 Humvees or 2 M113s), max takeoff weight 70,037 kg.
|
||||||
|
-- Here we say two M113s should be transported. Each one weights 11,253 kg according to DCS. So the cargo weight should be 23,000 kg with a full load of fuel.
|
||||||
|
-- This results in a max takeoff weight of 69,815 kg (23,000+10,415+36,400), which is very close to the Wiki value of 70,037 kg.
|
||||||
|
["C-130"] = 70000,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__.CargoBayWeightLimit = Weights[Desc.typeName] or (Desc.massMax - (Desc.massEmpty + Desc.fuelMassMax))
|
-- Max (takeoff) weight (empty+fuel+cargo weight).
|
||||||
|
local massMax= Desc.massMax or 0
|
||||||
|
|
||||||
|
-- Adjust value if set above.
|
||||||
|
local maxTakeoff=Weights[TypeName]
|
||||||
|
if maxTakeoff then
|
||||||
|
massMax=maxTakeoff
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Empty weight.
|
||||||
|
local massEmpty=Desc.massEmpty or 0
|
||||||
|
|
||||||
|
-- Fuel. The descriptor provides the max fuel mass in kg. This needs to be multiplied by the relative fuel amount to calculate the actual fuel mass on board.
|
||||||
|
local massFuelMax=Desc.fuelMassMax or 0
|
||||||
|
local relFuel=math.min(self:GetFuel() or 1.0, 1.0) -- We take 1.0 as max in case of external fuel tanks.
|
||||||
|
local massFuel=massFuelMax*relFuel
|
||||||
|
|
||||||
|
-- Number of soldiers according to DCS function
|
||||||
|
--local troopcapacity=self:GetTroopCapacity() or 0
|
||||||
|
|
||||||
|
-- Calculate max cargo weight, which is the max (takeoff) weight minus the empty weight minus the actual fuel weight.
|
||||||
|
local CargoWeight=massMax-(massEmpty+massFuel)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(string.format("Setting Cargo bay weight limit [%s]=%d kg (Mass max=%d, empty=%d, fuelMax=%d kg (rel=%.3f), fuel=%d kg", TypeName, CargoWeight, massMax, massEmpty, massFuelMax, relFuel, massFuel))
|
||||||
|
--self:T(string.format("Descent Troop Capacity=%d ==> %d kg (for 95 kg soldier)", troopcapacity, troopcapacity*95))
|
||||||
|
|
||||||
|
-- Set value.
|
||||||
|
self.__.CargoBayWeightLimit = CargoWeight
|
||||||
|
|
||||||
elseif self:IsShip() then
|
elseif self:IsShip() then
|
||||||
local Desc = self:GetDesc()
|
|
||||||
self:F( { Desc = Desc } )
|
|
||||||
|
|
||||||
|
-- Hard coded cargo weights in kg.
|
||||||
local Weights = {
|
local Weights = {
|
||||||
["Type_071"] = 245000,
|
["Type_071"] = 245000,
|
||||||
["LHA_Tarawa"] = 500000,
|
["LHA_Tarawa"] = 500000,
|
||||||
["Ropucha-class"] = 150000,
|
["Ropucha-class"] = 150000,
|
||||||
["Dry-cargo ship-1"] = 70000,
|
["Dry-cargo ship-1"] = 70000,
|
||||||
["Dry-cargo ship-2"] = 70000,
|
["Dry-cargo ship-2"] = 70000,
|
||||||
["Higgins_boat"] = 3700, -- Higgins Boat can load 3700 kg of general cargo or 36 men (source wikipedia).
|
["Higgins_boat"] = 3700, -- Higgins Boat can load 3700 kg of general cargo or 36 men (source wikipedia).
|
||||||
["USS_Samuel_Chase"] = 25000, -- Let's say 25 tons for now. Wiki says 33 Higgins boats, which would be 264 tons (can't be right!) and/or 578 troops.
|
["USS_Samuel_Chase"] = 25000, -- Let's say 25 tons for now. Wiki says 33 Higgins boats, which would be 264 tons (can't be right!) and/or 578 troops.
|
||||||
["LST_Mk2"] = 2100000 -- Can carry 2100 tons according to wiki source!
|
["LST_Mk2"] = 2100000, -- Can carry 2100 tons according to wiki source!
|
||||||
|
["speedboat"] = 500, -- 500 kg ~ 5 persons
|
||||||
|
["Seawise_Giant"] =261000000, -- Gross tonnage is 261,000 tonns.
|
||||||
}
|
}
|
||||||
self.__.CargoBayWeightLimit = (Weights[Desc.typeName] or 50000)
|
self.__.CargoBayWeightLimit = ( Weights[TypeName] or 50000 )
|
||||||
|
|
||||||
else
|
else
|
||||||
local Desc = self:GetDesc()
|
|
||||||
|
|
||||||
|
-- Hard coded number of soldiers.
|
||||||
local Weights = {
|
local Weights = {
|
||||||
["AAV7"] = 25,
|
["AAV7"] = 25,
|
||||||
["Bedford_MWD"] = 8, -- new by kappa
|
["Bedford_MWD"] = 8, -- new by kappa
|
||||||
@@ -1544,22 +1684,42 @@ do -- Cargo
|
|||||||
["KrAZ6322"] = 12,
|
["KrAZ6322"] = 12,
|
||||||
["M 818"] = 12,
|
["M 818"] = 12,
|
||||||
["Tigr_233036"] = 6,
|
["Tigr_233036"] = 6,
|
||||||
["TPZ"] = 10,
|
["TPZ"] = 10, -- Fuchs
|
||||||
["UAZ-469"] = 4, -- new by kappa
|
["UAZ-469"] = 4, -- new by kappa
|
||||||
["Ural-375"] = 12,
|
["Ural-375"] = 12,
|
||||||
["Ural-4320-31"] = 14,
|
["Ural-4320-31"] = 14,
|
||||||
["Ural-4320 APA-5D"] = 10,
|
["Ural-4320 APA-5D"] = 10,
|
||||||
["Ural-4320T"] = 14,
|
["Ural-4320T"] = 14,
|
||||||
["ZBD04A"] = 7, -- new by kappa
|
["ZBD04A"] = 7, -- new by kappa
|
||||||
["VAB_Mephisto"] = 8 -- new by Apple
|
["VAB_Mephisto"] = 8, -- new by Apple
|
||||||
|
["tt_KORD"] = 6, -- 2.7.1 HL/TT
|
||||||
|
["tt_DSHK"] = 6,
|
||||||
|
["HL_KORD"] = 6,
|
||||||
|
["HL_DSHK"] = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
local CargoBayWeightLimit = (Weights[Desc.typeName] or 0) * 95
|
-- Assuming that each passenger weighs 95 kg on average.
|
||||||
|
local CargoBayWeightLimit = ( Weights[TypeName] or 0 ) * 95
|
||||||
|
|
||||||
self.__.CargoBayWeightLimit = CargoBayWeightLimit
|
self.__.CargoBayWeightLimit = CargoBayWeightLimit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:F( { CargoBayWeightLimit = self.__.CargoBayWeightLimit } )
|
|
||||||
|
self:F({CargoBayWeightLimit = self.__.CargoBayWeightLimit})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get Cargo Bay Weight Limit in kg.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @return #number Max cargo weight in kg.
|
||||||
|
function POSITIONABLE:GetCargoBayWeightLimit()
|
||||||
|
|
||||||
|
if self.__.CargoBayWeightLimit==nil then
|
||||||
|
self:SetCargoBayWeightLimit()
|
||||||
|
end
|
||||||
|
|
||||||
|
return self.__.CargoBayWeightLimit
|
||||||
|
end
|
||||||
|
|
||||||
end --- Cargo
|
end --- Cargo
|
||||||
|
|
||||||
--- Signal a flare at the position of the POSITIONABLE.
|
--- Signal a flare at the position of the POSITIONABLE.
|
||||||
|
|||||||
@@ -57,3 +57,40 @@ end
|
|||||||
function SCENERY:GetThreatLevel()
|
function SCENERY:GetThreatLevel()
|
||||||
return 0, "Scenery"
|
return 0, "Scenery"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Find a SCENERY object by it's name/id.
|
||||||
|
--@param #SCENERY self
|
||||||
|
--@param #string name The name/id of the scenery object as taken from the ME. Ex. '595785449'
|
||||||
|
--@return #SCENERY Scenery Object or nil if not found.
|
||||||
|
function SCENERY:FindByName(name)
|
||||||
|
local findAirbase = function ()
|
||||||
|
local airbases = AIRBASE.GetAllAirbases()
|
||||||
|
for index,airbase in pairs(airbases) do
|
||||||
|
local surftype = airbase:GetCoordinate():GetSurfaceType()
|
||||||
|
if surftype ~= land.SurfaceType.SHALLOW_WATER and surftype ~= land.SurfaceType.WATER then
|
||||||
|
return airbase:GetCoordinate()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local sceneryScan = function (scancoord)
|
||||||
|
if scancoord ~= nil then
|
||||||
|
local _,_,sceneryfound,_,_,scenerylist = scancoord:ScanObjects(200, false, false, true)
|
||||||
|
if sceneryfound == true then
|
||||||
|
scenerylist[1].id_ = name
|
||||||
|
SCENERY.SceneryObject = SCENERY:Register(scenerylist[1].id_, scenerylist[1])
|
||||||
|
return SCENERY.SceneryObject
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if SCENERY.SceneryObject then
|
||||||
|
SCENERY.SceneryObject.SceneryObject.id_ = name
|
||||||
|
SCENERY.SceneryObject.SceneryName = name
|
||||||
|
return SCENERY:Register(SCENERY.SceneryObject.SceneryObject.id_, SCENERY.SceneryObject.SceneryObject)
|
||||||
|
else
|
||||||
|
return sceneryScan(findAirbase())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -10,8 +10,11 @@
|
|||||||
--
|
--
|
||||||
-- @module Wrapper.Static
|
-- @module Wrapper.Static
|
||||||
-- @image Wrapper_Static.JPG
|
-- @image Wrapper_Static.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type STATIC
|
--- @type STATIC
|
||||||
-- @extends Wrapper.Positionable#POSITIONABLE
|
-- @extends Wrapper.Positionable#POSITIONABLE
|
||||||
|
|
||||||
--- Wrapper class to handle Static objects.
|
--- Wrapper class to handle Static objects.
|
||||||
--
|
--
|
||||||
-- Note that Statics are almost the same as Units, but they don't have a controller.
|
-- Note that Statics are almost the same as Units, but they don't have a controller.
|
||||||
@@ -37,10 +40,13 @@
|
|||||||
--
|
--
|
||||||
-- * @{#STATIC.FindByName}(): Find a STATIC instance from the _DATABASE object using a DCS Static name.
|
-- * @{#STATIC.FindByName}(): Find a STATIC instance from the _DATABASE object using a DCS Static name.
|
||||||
--
|
--
|
||||||
-- IMPORTANT: ONE SHOULD NEVER SANITIZE these STATIC OBJECT REFERENCES! (make the STATIC object references nil).
|
-- IMPORTANT: ONE SHOULD NEVER SANATIZE these STATIC OBJECT REFERENCES! (make the STATIC object references nil).
|
||||||
--
|
--
|
||||||
-- @field #STATIC
|
-- @field #STATIC
|
||||||
STATIC = { ClassName = "STATIC" }
|
STATIC = {
|
||||||
|
ClassName = "STATIC",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Register a static object.
|
--- Register a static object.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
@@ -52,6 +58,7 @@ function STATIC:Register( StaticName )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Finds a STATIC from the _DATABASE using a DCSStatic object.
|
--- Finds a STATIC from the _DATABASE using a DCSStatic object.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param DCS#StaticObject DCSStatic An existing DCS Static object reference.
|
-- @param DCS#StaticObject DCSStatic An existing DCS Static object reference.
|
||||||
@@ -90,9 +97,8 @@ end
|
|||||||
|
|
||||||
--- Destroys the STATIC.
|
--- Destroys the STATIC.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param #boolean GenerateEvent (Optional) true to generate a crash or dead event, false to not generate any event. `nil` (default) creates a remove event.
|
-- @param #boolean GenerateEvent (Optional) true if you want to generate a crash or dead event for the static.
|
||||||
-- @return #nil The DCS StaticObject is not existing or alive.
|
-- @return #nil The DCS StaticObject is not existing or alive.
|
||||||
--
|
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Air static example: destroy the static Helicopter and generate a S_EVENT_CRASH.
|
-- -- Air static example: destroy the static Helicopter and generate a S_EVENT_CRASH.
|
||||||
-- Helicopter = STATIC:FindByName( "Helicopter" )
|
-- Helicopter = STATIC:FindByName( "Helicopter" )
|
||||||
@@ -111,7 +117,7 @@ end
|
|||||||
-- @usage
|
-- @usage
|
||||||
-- -- Destroy without event generation example.
|
-- -- Destroy without event generation example.
|
||||||
-- Ship = STATIC:FindByName( "Boat" )
|
-- Ship = STATIC:FindByName( "Boat" )
|
||||||
-- Ship:Destroy( false ) -- Don't generate any event upon destruction.
|
-- Ship:Destroy( false ) -- Don't generate an event upon destruction.
|
||||||
--
|
--
|
||||||
function STATIC:Destroy( GenerateEvent )
|
function STATIC:Destroy( GenerateEvent )
|
||||||
self:F2( self.ObjectName )
|
self:F2( self.ObjectName )
|
||||||
@@ -142,6 +148,7 @@ function STATIC:Destroy( GenerateEvent )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get DCS object of static of static.
|
--- Get DCS object of static of static.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @return DCS static object
|
-- @return DCS static object
|
||||||
@@ -173,6 +180,7 @@ function STATIC:GetUnits()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get threat level of static.
|
--- Get threat level of static.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @return #number Threat level 1.
|
-- @return #number Threat level 1.
|
||||||
@@ -186,15 +194,15 @@ end
|
|||||||
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
||||||
-- @param #number Heading The heading of the static respawn in degrees. Default is 0 deg.
|
-- @param #number Heading The heading of the static respawn in degrees. Default is 0 deg.
|
||||||
-- @param #number Delay Delay in seconds before the static is spawned.
|
-- @param #number Delay Delay in seconds before the static is spawned.
|
||||||
function STATIC:SpawnAt( Coordinate, Heading, Delay )
|
function STATIC:SpawnAt(Coordinate, Heading, Delay)
|
||||||
|
|
||||||
Heading = Heading or 0
|
Heading=Heading or 0
|
||||||
|
|
||||||
if Delay and Delay > 0 then
|
if Delay and Delay>0 then
|
||||||
SCHEDULER:New( nil, self.SpawnAt, { self, Coordinate, Heading }, Delay )
|
SCHEDULER:New(nil, self.SpawnAt, {self, Coordinate, Heading}, Delay)
|
||||||
else
|
else
|
||||||
|
|
||||||
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName )
|
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName)
|
||||||
|
|
||||||
SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName )
|
SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName )
|
||||||
|
|
||||||
@@ -203,45 +211,48 @@ function STATIC:SpawnAt( Coordinate, Heading, Delay )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the @{Wrapper.Unit} at the same location with the same properties.
|
--- Respawn the @{Wrapper.Unit} at the same location with the same properties.
|
||||||
-- This is useful to respawn a cargo after it has been destroyed.
|
-- This is useful to respawn a cargo after it has been destroyed.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
||||||
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
|
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
|
||||||
function STATIC:ReSpawn( CountryID, Delay )
|
function STATIC:ReSpawn(CountryID, Delay)
|
||||||
|
|
||||||
if Delay and Delay > 0 then
|
if Delay and Delay>0 then
|
||||||
SCHEDULER:New( nil, self.ReSpawn, { self, CountryID }, Delay )
|
SCHEDULER:New(nil, self.ReSpawn, {self, CountryID}, Delay)
|
||||||
else
|
else
|
||||||
|
|
||||||
CountryID = CountryID or self:GetCountry()
|
CountryID=CountryID or self:GetCountry()
|
||||||
|
|
||||||
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName, CountryID )
|
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, CountryID)
|
||||||
|
|
||||||
SpawnStatic:Spawn( nil, self.StaticName )
|
SpawnStatic:Spawn(nil, self.StaticName)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the @{Wrapper.Unit} at a defined Coordinate with an optional heading.
|
--- Respawn the @{Wrapper.Unit} at a defined Coordinate with an optional heading.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
||||||
-- @param #number Heading (Optional) The heading of the static respawn in degrees. Default is the current heading.
|
-- @param #number Heading (Optional) The heading of the static respawn in degrees. Default the current heading.
|
||||||
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default is now.
|
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
|
||||||
function STATIC:ReSpawnAt( Coordinate, Heading, Delay )
|
function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
||||||
|
|
||||||
-- Heading=Heading or 0
|
--Heading=Heading or 0
|
||||||
|
|
||||||
if Delay and Delay > 0 then
|
if Delay and Delay>0 then
|
||||||
SCHEDULER:New( nil, self.ReSpawnAt, { self, Coordinate, Heading }, Delay )
|
SCHEDULER:New(nil, self.ReSpawnAt, {self, Coordinate, Heading}, Delay)
|
||||||
else
|
else
|
||||||
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName, self:GetCountry() )
|
|
||||||
|
|
||||||
SpawnStatic:SpawnFromCoordinate( Coordinate, Heading, self.StaticName )
|
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, self:GetCountry())
|
||||||
|
|
||||||
|
SpawnStatic:SpawnFromCoordinate(Coordinate, Heading, self.StaticName)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
--- @type UNIT
|
--- @type UNIT
|
||||||
-- @field #string ClassName Name of the class.
|
-- @field #string ClassName Name of the class.
|
||||||
-- @field #string UnitName Name of the unit.
|
-- @field #string UnitName Name of the unit.
|
||||||
|
-- @field #string GroupName Name of the group the unit belongs to.
|
||||||
-- @extends Wrapper.Controllable#CONTROLLABLE
|
-- @extends Wrapper.Controllable#CONTROLLABLE
|
||||||
|
|
||||||
--- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object.
|
--- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object.
|
||||||
@@ -86,10 +87,11 @@
|
|||||||
-- * Use the @{#UNIT.IsLOS}() method to check if the given unit is within line of sight.
|
-- * Use the @{#UNIT.IsLOS}() method to check if the given unit is within line of sight.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- @field #UNIT UNIT
|
-- @field #UNIT
|
||||||
UNIT = {
|
UNIT = {
|
||||||
ClassName="UNIT",
|
ClassName="UNIT",
|
||||||
UnitName=nil,
|
UnitName=nil,
|
||||||
|
GroupName=nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,11 +112,20 @@ UNIT = {
|
|||||||
function UNIT:Register( UnitName )
|
function UNIT:Register( UnitName )
|
||||||
|
|
||||||
-- Inherit CONTROLLABLE.
|
-- Inherit CONTROLLABLE.
|
||||||
local self = BASE:Inherit( self, CONTROLLABLE:New( UnitName ) )
|
local self = BASE:Inherit( self, CONTROLLABLE:New( UnitName ) ) --#UNIT
|
||||||
|
|
||||||
-- Set unit name.
|
-- Set unit name.
|
||||||
self.UnitName = UnitName
|
self.UnitName = UnitName
|
||||||
|
|
||||||
|
local unit=Unit.getByName(self.UnitName)
|
||||||
|
|
||||||
|
if unit then
|
||||||
|
local group = unit:getGroup()
|
||||||
|
if group then
|
||||||
|
self.GroupName=group:getName()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Set event prio.
|
-- Set event prio.
|
||||||
self:SetEventPriority( 3 )
|
self:SetEventPriority( 3 )
|
||||||
|
|
||||||
@@ -168,6 +179,29 @@ function UNIT:GetDCSObject()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the unit altitude above sea level in meters.
|
||||||
|
-- @param Wrapper.Unit#UNIT self
|
||||||
|
-- @param #boolean FromGround Measure from the ground or from sea level (ASL). Provide **true** for measuring from the ground (AGL). **false** or **nil** if you measure from sea level.
|
||||||
|
-- @return #number The height of the group or nil if is not existing or alive.
|
||||||
|
function UNIT:GetAltitude(FromGround)
|
||||||
|
|
||||||
|
local DCSUnit = Unit.getByName( self.UnitName )
|
||||||
|
|
||||||
|
if DCSUnit then
|
||||||
|
local altitude = 0
|
||||||
|
local point = DCSUnit:getPoint() --DCS#Vec3
|
||||||
|
altitude = point.y
|
||||||
|
if FromGround then
|
||||||
|
local land = land.getHeight( { x = point.x, y = point.z } ) or 0
|
||||||
|
altitude = altitude - land
|
||||||
|
end
|
||||||
|
return altitude
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- Respawn the @{Wrapper.Unit} using a (tweaked) template of the parent Group.
|
--- Respawn the @{Wrapper.Unit} using a (tweaked) template of the parent Group.
|
||||||
--
|
--
|
||||||
-- This function will:
|
-- This function will:
|
||||||
@@ -260,6 +294,8 @@ function UNIT:ReSpawnAt( Coordinate, Heading )
|
|||||||
_DATABASE:Spawn( SpawnGroupTemplate )
|
_DATABASE:Spawn( SpawnGroupTemplate )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns if the unit is activated.
|
--- Returns if the unit is activated.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean `true` if Unit is activated. `nil` The DCS Unit is not existing or alive.
|
-- @return #boolean `true` if Unit is activated. `nil` The DCS Unit is not existing or alive.
|
||||||
@@ -296,6 +332,8 @@ function UNIT:IsAlive()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns the Unit's callsign - the localized string.
|
--- Returns the Unit's callsign - the localized string.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #string The Callsign of the Unit.
|
-- @return #string The Callsign of the Unit.
|
||||||
@@ -401,6 +439,17 @@ function UNIT:GetClient()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [AIRPLANE] Get the NATO reporting name of a UNIT. Currently airplanes only!
|
||||||
|
--@param #UNIT self
|
||||||
|
--@return #string NatoReportingName or "Bogey" if unknown.
|
||||||
|
function UNIT:GetNatoReportingName()
|
||||||
|
|
||||||
|
local typename = self:GetTypeName()
|
||||||
|
return UTILS.GetReportingName(typename)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the unit's number in the group.
|
--- Returns the unit's number in the group.
|
||||||
-- The number is the same number the unit has in ME.
|
-- The number is the same number the unit has in ME.
|
||||||
-- It may not be changed during the mission.
|
-- It may not be changed during the mission.
|
||||||
@@ -517,6 +566,63 @@ function UNIT:IsTanker()
|
|||||||
return tanker, system
|
return tanker, system
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if the unit can supply ammo. Currently, we have
|
||||||
|
--
|
||||||
|
-- * M 818
|
||||||
|
-- * Ural-375
|
||||||
|
-- * ZIL-135
|
||||||
|
--
|
||||||
|
-- This list needs to be extended, if DCS adds other units capable of supplying ammo.
|
||||||
|
--
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean If `true`, unit can supply ammo.
|
||||||
|
function UNIT:IsAmmoSupply()
|
||||||
|
|
||||||
|
-- Type name is the only thing we can check. There is no attribute (Sep. 2021) which would tell us.
|
||||||
|
local typename=self:GetTypeName()
|
||||||
|
|
||||||
|
if typename=="M 818" then
|
||||||
|
-- Blue ammo truck.
|
||||||
|
return true
|
||||||
|
elseif typename=="Ural-375" then
|
||||||
|
-- Red ammo truck.
|
||||||
|
return true
|
||||||
|
elseif typename=="ZIL-135" then
|
||||||
|
-- Red ammo truck. Checked that it can also provide ammo.
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if the unit can supply fuel. Currently, we have
|
||||||
|
--
|
||||||
|
-- * M978 HEMTT Tanker
|
||||||
|
-- * ATMZ-5
|
||||||
|
-- * ATMZ-10
|
||||||
|
-- * ATZ-5
|
||||||
|
--
|
||||||
|
-- This list needs to be extended, if DCS adds other units capable of supplying fuel.
|
||||||
|
--
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean If `true`, unit can supply fuel.
|
||||||
|
function UNIT:IsFuelSupply()
|
||||||
|
|
||||||
|
-- Type name is the only thing we can check. There is no attribute (Sep. 2021) which would tell us.
|
||||||
|
local typename=self:GetTypeName()
|
||||||
|
|
||||||
|
if typename=="M978 HEMTT Tanker" then
|
||||||
|
return true
|
||||||
|
elseif typename=="ATMZ-5" then
|
||||||
|
return true
|
||||||
|
elseif typename=="ATMZ-10" then
|
||||||
|
return true
|
||||||
|
elseif typename=="ATZ-5" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the unit's group if it exist and nil otherwise.
|
--- Returns the unit's group if it exist and nil otherwise.
|
||||||
-- @param Wrapper.Unit#UNIT self
|
-- @param Wrapper.Unit#UNIT self
|
||||||
@@ -544,14 +650,14 @@ end
|
|||||||
-- @return #string The name of the DCS Unit.
|
-- @return #string The name of the DCS Unit.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
-- @return #nil The DCS Unit is not existing or alive.
|
||||||
function UNIT:GetPrefix()
|
function UNIT:GetPrefix()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 )
|
local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 )
|
||||||
self:T3( UnitPrefix )
|
self:T3( UnitPrefix )
|
||||||
return UnitPrefix
|
return UnitPrefix
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -592,6 +698,7 @@ end
|
|||||||
-- @return #number Number of rockets left.
|
-- @return #number Number of rockets left.
|
||||||
-- @return #number Number of bombs left.
|
-- @return #number Number of bombs left.
|
||||||
-- @return #number Number of missiles left.
|
-- @return #number Number of missiles left.
|
||||||
|
-- @return #number Number of artillery shells left (with explosive mass, included in shells; shells can also be machine gun ammo)
|
||||||
function UNIT:GetAmmunition()
|
function UNIT:GetAmmunition()
|
||||||
|
|
||||||
-- Init counter.
|
-- Init counter.
|
||||||
@@ -600,6 +707,7 @@ function UNIT:GetAmmunition()
|
|||||||
local nrockets=0
|
local nrockets=0
|
||||||
local nmissiles=0
|
local nmissiles=0
|
||||||
local nbombs=0
|
local nbombs=0
|
||||||
|
local narti=0
|
||||||
|
|
||||||
local unit=self
|
local unit=self
|
||||||
|
|
||||||
@@ -637,6 +745,10 @@ function UNIT:GetAmmunition()
|
|||||||
-- Add up all shells.
|
-- Add up all shells.
|
||||||
nshells=nshells+Nammo
|
nshells=nshells+Nammo
|
||||||
|
|
||||||
|
if ammotable[w].desc.warhead and ammotable[w].desc.warhead.explosiveMass and ammotable[w].desc.warhead.explosiveMass > 0 then
|
||||||
|
narti=narti+Nammo
|
||||||
|
end
|
||||||
|
|
||||||
elseif Category==Weapon.Category.ROCKET then
|
elseif Category==Weapon.Category.ROCKET then
|
||||||
|
|
||||||
-- Add up all rockets.
|
-- Add up all rockets.
|
||||||
@@ -673,11 +785,9 @@ function UNIT:GetAmmunition()
|
|||||||
-- Total amount of ammunition.
|
-- Total amount of ammunition.
|
||||||
nammo=nshells+nrockets+nmissiles+nbombs
|
nammo=nshells+nrockets+nmissiles+nbombs
|
||||||
|
|
||||||
return nammo, nshells, nrockets, nbombs, nmissiles
|
return nammo, nshells, nrockets, nbombs, nmissiles, narti
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns the unit sensors.
|
--- Returns the unit sensors.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return DCS#Unit.Sensors Table of sensors.
|
-- @return DCS#Unit.Sensors Table of sensors.
|
||||||
@@ -726,7 +836,9 @@ function UNIT:HasSEAD()
|
|||||||
|
|
||||||
local HasSEAD = false
|
local HasSEAD = false
|
||||||
if UnitSEADAttributes["RADAR_BAND1_FOR_ARM"] and UnitSEADAttributes["RADAR_BAND1_FOR_ARM"] == true or
|
if UnitSEADAttributes["RADAR_BAND1_FOR_ARM"] and UnitSEADAttributes["RADAR_BAND1_FOR_ARM"] == true or
|
||||||
UnitSEADAttributes["RADAR_BAND2_FOR_ARM"] and UnitSEADAttributes["RADAR_BAND2_FOR_ARM"] == true then
|
UnitSEADAttributes["RADAR_BAND2_FOR_ARM"] and UnitSEADAttributes["RADAR_BAND2_FOR_ARM"] == true or
|
||||||
|
UnitSEADAttributes["Optical Tracker"] and UnitSEADAttributes["Optical Tracker"] == true
|
||||||
|
then
|
||||||
HasSEAD = true
|
HasSEAD = true
|
||||||
end
|
end
|
||||||
return HasSEAD
|
return HasSEAD
|
||||||
@@ -954,6 +1066,7 @@ end
|
|||||||
-- @return #string Some text.
|
-- @return #string Some text.
|
||||||
function UNIT:GetThreatLevel()
|
function UNIT:GetThreatLevel()
|
||||||
|
|
||||||
|
|
||||||
local ThreatLevel = 0
|
local ThreatLevel = 0
|
||||||
local ThreatText = ""
|
local ThreatText = ""
|
||||||
|
|
||||||
@@ -979,6 +1092,7 @@ function UNIT:GetThreatLevel()
|
|||||||
"LR SAMs"
|
"LR SAMs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if Attributes["LR SAM"] then ThreatLevel = 10
|
if Attributes["LR SAM"] then ThreatLevel = 10
|
||||||
elseif Attributes["MR SAM"] then ThreatLevel = 9
|
elseif Attributes["MR SAM"] then ThreatLevel = 9
|
||||||
elseif Attributes["SR SAM"] and
|
elseif Attributes["SR SAM"] and
|
||||||
@@ -992,7 +1106,7 @@ function UNIT:GetThreatLevel()
|
|||||||
elseif ( Attributes["Tanks"] or Attributes["IFV"] ) and
|
elseif ( Attributes["Tanks"] or Attributes["IFV"] ) and
|
||||||
not Attributes["ATGM"] then ThreatLevel = 3
|
not Attributes["ATGM"] then ThreatLevel = 3
|
||||||
elseif Attributes["Old Tanks"] or Attributes["APC"] or Attributes["Artillery"] then ThreatLevel = 2
|
elseif Attributes["Old Tanks"] or Attributes["APC"] or Attributes["Artillery"] then ThreatLevel = 2
|
||||||
elseif Attributes["Infantry"] then ThreatLevel = 1
|
elseif Attributes["Infantry"] or Attributes["EWR"] then ThreatLevel = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
ThreatText = ThreatLevels[ThreatLevel+1]
|
ThreatText = ThreatLevels[ThreatLevel+1]
|
||||||
@@ -1014,6 +1128,7 @@ function UNIT:GetThreatLevel()
|
|||||||
"Fighter"
|
"Fighter"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if Attributes["Fighters"] then ThreatLevel = 10
|
if Attributes["Fighters"] then ThreatLevel = 10
|
||||||
elseif Attributes["Multirole fighters"] then ThreatLevel = 9
|
elseif Attributes["Multirole fighters"] then ThreatLevel = 9
|
||||||
elseif Attributes["Battleplanes"] then ThreatLevel = 8
|
elseif Attributes["Battleplanes"] then ThreatLevel = 8
|
||||||
@@ -1111,26 +1226,32 @@ end
|
|||||||
-- @return true If the other DCS Unit is within the radius of the 2D point of the DCS Unit.
|
-- @return true If the other DCS Unit is within the radius of the 2D point of the DCS Unit.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
-- @return #nil The DCS Unit is not existing or alive.
|
||||||
function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
|
function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
|
||||||
self:F2( { self.UnitName, AwaitUnit.UnitName, Radius } )
|
self:F2( { self.UnitName, AwaitUnit.UnitName, Radius } )
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
local UnitVec3 = self:GetVec3()
|
local UnitVec3 = self:GetVec3()
|
||||||
local AwaitUnitVec3 = AwaitUnit:GetVec3()
|
local AwaitUnitVec3 = AwaitUnit:GetVec3()
|
||||||
|
|
||||||
if (((UnitVec3.x - AwaitUnitVec3.x)^2 + (UnitVec3.z - AwaitUnitVec3.z)^2)^0.5 <= Radius) then
|
if (((UnitVec3.x - AwaitUnitVec3.x)^2 + (UnitVec3.z - AwaitUnitVec3.z)^2)^0.5 <= Radius) then
|
||||||
self:T3( "true" )
|
self:T3( "true" )
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
self:T3( "false" )
|
self:T3( "false" )
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns if the unit is a friendly unit.
|
--- Returns if the unit is a friendly unit.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean IsFriendly evaluation result.
|
-- @return #boolean IsFriendly evaluation result.
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ Utilities/Enums.lua
|
|||||||
Utilities/Profiler.lua
|
Utilities/Profiler.lua
|
||||||
Utilities/Templates.lua
|
Utilities/Templates.lua
|
||||||
Utilities/STTS.lua
|
Utilities/STTS.lua
|
||||||
|
Utilities/FiFo.lua
|
||||||
|
Utilities/Socket.lua
|
||||||
|
|
||||||
Core/Base.lua
|
Core/Base.lua
|
||||||
Core/Beacon.lua
|
Core/Beacon.lua
|
||||||
@@ -28,6 +30,10 @@ Core/SpawnStatic.lua
|
|||||||
Core/Timer.lua
|
Core/Timer.lua
|
||||||
Core/Goal.lua
|
Core/Goal.lua
|
||||||
Core/Spot.lua
|
Core/Spot.lua
|
||||||
|
Core/MarkerOps_Base.lua
|
||||||
|
Core/Astar.lua
|
||||||
|
Core/Condition.lua
|
||||||
|
Core/TextAndSound.lua
|
||||||
|
|
||||||
Wrapper/Object.lua
|
Wrapper/Object.lua
|
||||||
Wrapper/Identifiable.lua
|
Wrapper/Identifiable.lua
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ Documentation on the MOOSE class hierarchy, usage guides and background informat
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [MOOSE Youtube Channel](https://www.youtube.com/channel/UCjrA9j5LQoWsG4SpS8i79Qg)
|
## [MOOSE Youtube Tutorials](https://youtube.com/playlist?list=PLLkY2GByvtC2ME0Q9wrKRDE6qnXJYV3iT)
|
||||||
|
|
||||||
MOOSE has a [broadcast and training channel on YouTube](https://www.youtube.com/channel/UCjrA9j5LQoWsG4SpS8i79Qg) with various channels that you can watch.
|
Pene has kindly created a [tutorial series for MOOSE](https://youtube.com/playlist?list=PLLkY2GByvtC2ME0Q9wrKRDE6qnXJYV3iT)
|
||||||
|
with various videos that you can watch.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user