mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Compare commits
191 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fac5ac9f0 | ||
|
|
d83cabbab6 | ||
|
|
5f9d4405b1 | ||
|
|
bdd9efa2cc | ||
|
|
a778e910f7 | ||
|
|
24b09e22f7 | ||
|
|
b40331b04e | ||
|
|
2d1fcb9be8 | ||
|
|
5fcd394ddd | ||
|
|
7a0f53ebf3 | ||
|
|
a2580122de | ||
|
|
a6de09a0ca | ||
|
|
5e3b50c158 | ||
|
|
2262f27d18 | ||
|
|
4668132b37 | ||
|
|
1fc526e80f | ||
|
|
ceb77e2837 | ||
|
|
6f7a29d372 | ||
|
|
137f0251fb | ||
|
|
e375f3a401 | ||
|
|
10986f8a0d | ||
|
|
16dc3860f7 | ||
|
|
1355f2f562 | ||
|
|
e620062a95 | ||
|
|
333ed629bb | ||
|
|
813b9d90aa | ||
|
|
c87e91d845 | ||
|
|
5fc39daa9d | ||
|
|
09372df86d | ||
|
|
7c0605e82f | ||
|
|
a847d890ba | ||
|
|
778ae1b8e5 | ||
|
|
1f1ab1664c | ||
|
|
6df4fffafd | ||
|
|
dade17a67f | ||
|
|
64be0ffee5 | ||
|
|
59ceb01d19 | ||
|
|
783e29f189 | ||
|
|
42d8a9f59d | ||
|
|
9e7caba089 | ||
|
|
af39a3ae9c | ||
|
|
399f9883a9 | ||
|
|
9815216bd5 | ||
|
|
ce01534535 | ||
|
|
aec65209d0 | ||
|
|
c985d40ca0 | ||
|
|
d0ca76926e | ||
|
|
1fd15bcd4d | ||
|
|
90b588420f | ||
|
|
073e619015 | ||
|
|
3a0d2a5c51 | ||
|
|
d9528292af | ||
|
|
07a76ced88 | ||
|
|
830dd05514 | ||
|
|
ca7949d8c4 | ||
|
|
a3805118a0 | ||
|
|
34fde09c12 | ||
|
|
983d518a69 | ||
|
|
c14dec7412 | ||
|
|
78ab7547f3 | ||
|
|
2e6957984f | ||
|
|
433a66d530 | ||
|
|
7081448c40 | ||
|
|
7d3ad15f39 | ||
|
|
c7c1bcfff4 | ||
|
|
d0728afee7 | ||
|
|
4f25c9a408 | ||
|
|
01330bf00c | ||
|
|
01de638b8e | ||
|
|
3e8c7ad1df | ||
|
|
22c6a03161 | ||
|
|
7868a2e9de | ||
|
|
b7db198125 | ||
|
|
dd8b2caa24 | ||
|
|
1e4cfd473c | ||
|
|
4364cb8e53 | ||
|
|
044fb66ca0 | ||
|
|
84857d2a32 | ||
|
|
cc17027a7a | ||
|
|
02db5ba532 | ||
|
|
fc52e06318 | ||
|
|
0f5f2658a6 | ||
|
|
27d36f3e0d | ||
|
|
9ce1b90eb1 | ||
|
|
38c19b1442 | ||
|
|
d3419d218a | ||
|
|
2f34526c55 | ||
|
|
f9dcc9d95c | ||
|
|
ebc355ee6a | ||
|
|
a0b49fbd67 | ||
|
|
ae213c4cf1 | ||
|
|
8dea86b921 | ||
|
|
44003a8fda | ||
|
|
b883bb1e62 | ||
|
|
db35a67bd7 | ||
|
|
1bfc98fa99 | ||
|
|
efb687cbb5 | ||
|
|
668f12391e | ||
|
|
dfaccd6aa5 | ||
|
|
2220f1829f | ||
|
|
76fde11f47 | ||
|
|
bc5946c76e | ||
|
|
1f041a8acf | ||
|
|
892cb90d62 | ||
|
|
3d7172fdf7 | ||
|
|
3fa3644e1e | ||
|
|
28411d2093 | ||
|
|
26deaca166 | ||
|
|
1346317ad9 | ||
|
|
e11bb71c2d | ||
|
|
95baed1aac | ||
|
|
3b364c7650 | ||
|
|
2a4e242eb2 | ||
|
|
39471212d3 | ||
|
|
8b2237d183 | ||
|
|
6c1a4f1e0d | ||
|
|
abc26b1e5c | ||
|
|
b338f486e5 | ||
|
|
b761078c18 | ||
|
|
202d649085 | ||
|
|
616690391c | ||
|
|
e1e0095d9b | ||
|
|
465c395294 | ||
|
|
a8cbf81851 | ||
|
|
0e78e9c92b | ||
|
|
7c4d640690 | ||
|
|
73bddddba4 | ||
|
|
833206a3b5 | ||
|
|
743baac945 | ||
|
|
0764d076db | ||
|
|
504aa19c03 | ||
|
|
9a3effd063 | ||
|
|
d4a49ae68b | ||
|
|
ca1018f80b | ||
|
|
b9bd8d88a9 | ||
|
|
21412e0061 | ||
|
|
5761e11157 | ||
|
|
7d3f1235e7 | ||
|
|
473001c95b | ||
|
|
532cc0b4df | ||
|
|
08fb4e3736 | ||
|
|
6b7e66efa5 | ||
|
|
18fd587ab0 | ||
|
|
5fd8139f00 | ||
|
|
ac68744deb | ||
|
|
cec02bc44f | ||
|
|
a924a0b641 | ||
|
|
ee15b04142 | ||
|
|
2c67a66d88 | ||
|
|
1fdb3b7daa | ||
|
|
181ed6046e | ||
|
|
ba14330281 | ||
|
|
4c890d18d1 | ||
|
|
2eb4118d56 | ||
|
|
67d53034df | ||
|
|
a5632ec3a4 | ||
|
|
0804a3567a | ||
|
|
ef8c71d27c | ||
|
|
879ea847e9 | ||
|
|
be3c418919 | ||
|
|
2c749bf5c9 | ||
|
|
24eaa7441c | ||
|
|
82f4c9d526 | ||
|
|
2205100942 | ||
|
|
801475e146 | ||
|
|
d7ee243a00 | ||
|
|
d5ceabadb0 | ||
|
|
1253e241ff | ||
|
|
80b2b26018 | ||
|
|
e3f523d648 | ||
|
|
2fcb31f3ac | ||
|
|
2fce93d925 | ||
|
|
db6354b60d | ||
|
|
f10d676921 | ||
|
|
0532c54cd5 | ||
|
|
becaf47a66 | ||
|
|
9ea8443286 | ||
|
|
f76fa58a5f | ||
|
|
c8b36b8c99 | ||
|
|
5b37e7b249 | ||
|
|
cfca4fdc46 | ||
|
|
a4704d0e2f | ||
|
|
7538f63c00 | ||
|
|
bfaf88f017 | ||
|
|
b5965bbf81 | ||
|
|
bcbda4eb64 | ||
|
|
7306cc1102 | ||
|
|
6406ce696b | ||
|
|
0d9d0be0c3 | ||
|
|
059d8ccfc0 | ||
|
|
bd9022c010 |
1
.github/workflows/build-docs.yml
vendored
1
.github/workflows/build-docs.yml
vendored
@@ -57,6 +57,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Update apt-get (needed for act docker image)
|
- name: Update apt-get (needed for act docker image)
|
||||||
run: |
|
run: |
|
||||||
|
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
|
||||||
sudo apt-get -qq update
|
sudo apt-get -qq update
|
||||||
|
|
||||||
- name: Install tree
|
- name: Install tree
|
||||||
|
|||||||
1
.github/workflows/build-includes.yml
vendored
1
.github/workflows/build-includes.yml
vendored
@@ -47,6 +47,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Update apt-get (needed for act docker image)
|
- name: Update apt-get (needed for act docker image)
|
||||||
run: |
|
run: |
|
||||||
|
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
|
||||||
sudo apt-get -qq update
|
sudo apt-get -qq update
|
||||||
|
|
||||||
- name: Install tree
|
- name: Install tree
|
||||||
|
|||||||
@@ -1151,14 +1151,14 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
local AirbaseName = EventData.PlaceName -- The name of the airbase that was captured.
|
local AirbaseName = EventData.PlaceName -- The name of the airbase that was captured.
|
||||||
|
|
||||||
self:I( "Captured " .. AirbaseName )
|
self:T( "Captured " .. AirbaseName )
|
||||||
|
|
||||||
-- Now search for all squadrons located at the airbase, and sanitize them.
|
-- Now search for all squadrons located at the airbase, and sanitize them.
|
||||||
for SquadronName, Squadron in pairs( self.DefenderSquadrons ) do
|
for SquadronName, Squadron in pairs( self.DefenderSquadrons ) do
|
||||||
if Squadron.AirbaseName == AirbaseName then
|
if Squadron.AirbaseName == AirbaseName then
|
||||||
Squadron.ResourceCount = -999 -- The base has been captured, and the resources are eliminated. No more spawning.
|
Squadron.ResourceCount = -999 -- The base has been captured, and the resources are eliminated. No more spawning.
|
||||||
Squadron.Captured = true
|
Squadron.Captured = true
|
||||||
self:I( "Squadron " .. SquadronName .. " captured." )
|
self:T( "Squadron " .. SquadronName .. " captured." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1828,7 +1828,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
self:SetSquadronCapInterval( SquadronName, self.DefenderDefault.CapLimit, self.DefenderDefault.CapMinSeconds, self.DefenderDefault.CapMaxSeconds, 1 )
|
self:SetSquadronCapInterval( SquadronName, self.DefenderDefault.CapLimit, self.DefenderDefault.CapMinSeconds, self.DefenderDefault.CapMaxSeconds, 1 )
|
||||||
|
|
||||||
self:I( { CAP = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, Zone, PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType, EngageAltType } } )
|
self:T( { CAP = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, Zone, PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType, EngageAltType } } )
|
||||||
|
|
||||||
-- Add the CAP to the EWR network.
|
-- Add the CAP to the EWR network.
|
||||||
|
|
||||||
@@ -2085,7 +2085,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
Intercept.EngageCeilingAltitude = EngageCeilingAltitude
|
Intercept.EngageCeilingAltitude = EngageCeilingAltitude
|
||||||
Intercept.EngageAltType = EngageAltType
|
Intercept.EngageAltType = EngageAltType
|
||||||
|
|
||||||
self:I( { GCI = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
self:T( { GCI = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set squadron GCI.
|
--- Set squadron GCI.
|
||||||
@@ -3000,17 +3000,17 @@ do -- AI_A2A_DISPATCHER
|
|||||||
for FriendlyDistance, AIFriendly in UTILS.spairs( DefenderFriendlies or {} ) do
|
for FriendlyDistance, AIFriendly in UTILS.spairs( DefenderFriendlies or {} ) do
|
||||||
-- We only allow to ENGAGE targets as long as the Units on both sides are balanced.
|
-- We only allow to ENGAGE targets as long as the Units on both sides are balanced.
|
||||||
if AttackerCount > DefenderCount then
|
if AttackerCount > DefenderCount then
|
||||||
--self:I("***** AI_A2A_DISPATCHER:CountDefendersToBeEngaged() *****\nThis is supposed to be a UNIT:")
|
--self:T("***** AI_A2A_DISPATCHER:CountDefendersToBeEngaged() *****\nThis is supposed to be a UNIT:")
|
||||||
if AIFriendly then
|
if AIFriendly then
|
||||||
local classname = AIFriendly.ClassName or "No Class Name"
|
local classname = AIFriendly.ClassName or "No Class Name"
|
||||||
local unitname = AIFriendly.IdentifiableName or "No Unit Name"
|
local unitname = AIFriendly.IdentifiableName or "No Unit Name"
|
||||||
--self:I("Class Name: " .. classname)
|
--self:T("Class Name: " .. classname)
|
||||||
--self:I("Unit Name: " .. unitname)
|
--self:T("Unit Name: " .. unitname)
|
||||||
--self:I({AIFriendly})
|
--self:T({AIFriendly})
|
||||||
end
|
end
|
||||||
local Friendly = nil
|
local Friendly = nil
|
||||||
if AIFriendly and AIFriendly:IsAlive() then
|
if AIFriendly and AIFriendly:IsAlive() then
|
||||||
--self:I("AIFriendly alive, getting GROUP")
|
--self:T("AIFriendly alive, getting GROUP")
|
||||||
Friendly = AIFriendly:GetGroup() -- Wrapper.Group#GROUP
|
Friendly = AIFriendly:GetGroup() -- Wrapper.Group#GROUP
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3952,7 +3952,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
--- @type AI_A2A_GCICAP
|
-- @type AI_A2A_GCICAP
|
||||||
-- @extends #AI_A2A_DISPATCHER
|
-- @extends #AI_A2A_DISPATCHER
|
||||||
|
|
||||||
--- Create an automatic air defence system for a coalition setting up GCI and CAP air defenses.
|
--- Create an automatic air defence system for a coalition setting up GCI and CAP air defenses.
|
||||||
@@ -4322,23 +4322,23 @@ do
|
|||||||
|
|
||||||
-- Setup squadrons
|
-- Setup squadrons
|
||||||
|
|
||||||
self:I( { Airbases = AirbaseNames } )
|
self:T( { Airbases = AirbaseNames } )
|
||||||
|
|
||||||
self:I( "Defining Templates for Airbases ..." )
|
self:T( "Defining Templates for Airbases ..." )
|
||||||
for AirbaseID, AirbaseName in pairs( AirbaseNames ) do
|
for AirbaseID, AirbaseName in pairs( AirbaseNames ) do
|
||||||
local Airbase = _DATABASE:FindAirbase( AirbaseName ) -- Wrapper.Airbase#AIRBASE
|
local Airbase = _DATABASE:FindAirbase( AirbaseName ) -- Wrapper.Airbase#AIRBASE
|
||||||
local AirbaseName = Airbase:GetName()
|
local AirbaseName = Airbase:GetName()
|
||||||
local AirbaseCoord = Airbase:GetCoordinate()
|
local AirbaseCoord = Airbase:GetCoordinate()
|
||||||
local AirbaseZone = ZONE_RADIUS:New( "Airbase", AirbaseCoord:GetVec2(), 3000 )
|
local AirbaseZone = ZONE_RADIUS:New( "Airbase", AirbaseCoord:GetVec2(), 3000 )
|
||||||
local Templates = nil
|
local Templates = nil
|
||||||
self:I( { Airbase = AirbaseName } )
|
self:T( { Airbase = AirbaseName } )
|
||||||
for TemplateID, Template in pairs( self.Templates:GetSet() ) do
|
for TemplateID, Template in pairs( self.Templates:GetSet() ) do
|
||||||
local Template = Template -- Wrapper.Group#GROUP
|
local Template = Template -- Wrapper.Group#GROUP
|
||||||
local TemplateCoord = Template:GetCoordinate()
|
local TemplateCoord = Template:GetCoordinate()
|
||||||
if AirbaseZone:IsVec2InZone( TemplateCoord:GetVec2() ) then
|
if AirbaseZone:IsVec2InZone( TemplateCoord:GetVec2() ) then
|
||||||
Templates = Templates or {}
|
Templates = Templates or {}
|
||||||
table.insert( Templates, Template:GetName() )
|
table.insert( Templates, Template:GetName() )
|
||||||
self:I( { Template = Template:GetName() } )
|
self:T( { Template = Template:GetName() } )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Templates then
|
if Templates then
|
||||||
@@ -4354,13 +4354,13 @@ do
|
|||||||
self.CAPTemplates:FilterPrefixes( CapPrefixes )
|
self.CAPTemplates:FilterPrefixes( CapPrefixes )
|
||||||
self.CAPTemplates:FilterOnce()
|
self.CAPTemplates:FilterOnce()
|
||||||
|
|
||||||
self:I( "Setting up CAP ..." )
|
self:T( "Setting up CAP ..." )
|
||||||
for CAPID, CAPTemplate in pairs( self.CAPTemplates:GetSet() ) do
|
for CAPID, CAPTemplate in pairs( self.CAPTemplates:GetSet() ) do
|
||||||
local CAPZone = ZONE_POLYGON:New( CAPTemplate:GetName(), CAPTemplate )
|
local CAPZone = ZONE_POLYGON:New( CAPTemplate:GetName(), CAPTemplate )
|
||||||
-- Now find the closest airbase from the ZONE (start or center)
|
-- Now find the closest airbase from the ZONE (start or center)
|
||||||
local AirbaseDistance = 99999999
|
local AirbaseDistance = 99999999
|
||||||
local AirbaseClosest = nil -- Wrapper.Airbase#AIRBASE
|
local AirbaseClosest = nil -- Wrapper.Airbase#AIRBASE
|
||||||
self:I( { CAPZoneGroup = CAPID } )
|
self:T( { CAPZoneGroup = CAPID } )
|
||||||
for AirbaseID, AirbaseName in pairs( AirbaseNames ) do
|
for AirbaseID, AirbaseName in pairs( AirbaseNames ) do
|
||||||
local Airbase = _DATABASE:FindAirbase( AirbaseName ) -- Wrapper.Airbase#AIRBASE
|
local Airbase = _DATABASE:FindAirbase( AirbaseName ) -- Wrapper.Airbase#AIRBASE
|
||||||
local AirbaseName = Airbase:GetName()
|
local AirbaseName = Airbase:GetName()
|
||||||
@@ -4368,7 +4368,7 @@ do
|
|||||||
local Squadron = self.DefenderSquadrons[AirbaseName]
|
local Squadron = self.DefenderSquadrons[AirbaseName]
|
||||||
if Squadron then
|
if Squadron then
|
||||||
local Distance = AirbaseCoord:Get2DDistance( CAPZone:GetCoordinate() )
|
local Distance = AirbaseCoord:Get2DDistance( CAPZone:GetCoordinate() )
|
||||||
self:I( { AirbaseDistance = Distance } )
|
self:T( { AirbaseDistance = Distance } )
|
||||||
if Distance < AirbaseDistance then
|
if Distance < AirbaseDistance then
|
||||||
AirbaseDistance = Distance
|
AirbaseDistance = Distance
|
||||||
AirbaseClosest = Airbase
|
AirbaseClosest = Airbase
|
||||||
@@ -4376,7 +4376,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if AirbaseClosest then
|
if AirbaseClosest then
|
||||||
self:I( { CAPAirbase = AirbaseClosest:GetName() } )
|
self:T( { CAPAirbase = AirbaseClosest:GetName() } )
|
||||||
self:SetSquadronCap( AirbaseClosest:GetName(), CAPZone, 6000, 10000, 500, 800, 800, 1200, "RADIO" )
|
self:SetSquadronCap( AirbaseClosest:GetName(), CAPZone, 6000, 10000, 500, 800, 800, 1200, "RADIO" )
|
||||||
self:SetSquadronCapInterval( AirbaseClosest:GetName(), CapLimit, 300, 600, 1 )
|
self:SetSquadronCapInterval( AirbaseClosest:GetName(), CapLimit, 300, 600, 1 )
|
||||||
end
|
end
|
||||||
@@ -4384,14 +4384,14 @@ do
|
|||||||
|
|
||||||
-- Setup GCI.
|
-- Setup GCI.
|
||||||
-- GCI is setup for all Squadrons.
|
-- GCI is setup for all Squadrons.
|
||||||
self:I( "Setting up GCI ..." )
|
self:T( "Setting up GCI ..." )
|
||||||
for AirbaseID, AirbaseName in pairs( AirbaseNames ) do
|
for AirbaseID, AirbaseName in pairs( AirbaseNames ) do
|
||||||
local Airbase = _DATABASE:FindAirbase( AirbaseName ) -- Wrapper.Airbase#AIRBASE
|
local Airbase = _DATABASE:FindAirbase( AirbaseName ) -- Wrapper.Airbase#AIRBASE
|
||||||
local AirbaseName = Airbase:GetName()
|
local AirbaseName = Airbase:GetName()
|
||||||
local Squadron = self.DefenderSquadrons[AirbaseName]
|
local Squadron = self.DefenderSquadrons[AirbaseName]
|
||||||
self:F( { Airbase = AirbaseName } )
|
self:F( { Airbase = AirbaseName } )
|
||||||
if Squadron then
|
if Squadron then
|
||||||
self:I( { GCIAirbase = AirbaseName } )
|
self:T( { GCIAirbase = AirbaseName } )
|
||||||
self:SetSquadronGci( AirbaseName, 800, 1200 )
|
self:SetSquadronGci( AirbaseName, 800, 1200 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -904,14 +904,14 @@ do -- AI_A2G_DISPATCHER
|
|||||||
-- @type AI_A2G_DISPATCHER.DefenseCoordinates
|
-- @type AI_A2G_DISPATCHER.DefenseCoordinates
|
||||||
-- @map <#string,Core.Point#COORDINATE> A list of all defense coordinates mapped per defense coordinate name.
|
-- @map <#string,Core.Point#COORDINATE> A list of all defense coordinates mapped per defense coordinate name.
|
||||||
|
|
||||||
--- @field #AI_A2G_DISPATCHER.DefenseCoordinates DefenseCoordinates
|
-- @field #AI_A2G_DISPATCHER.DefenseCoordinates DefenseCoordinates
|
||||||
AI_A2G_DISPATCHER.DefenseCoordinates = {}
|
AI_A2G_DISPATCHER.DefenseCoordinates = {}
|
||||||
|
|
||||||
--- Enumerator for spawns at airbases.
|
--- Enumerator for spawns at airbases.
|
||||||
-- @type AI_A2G_DISPATCHER.Takeoff
|
-- @type AI_A2G_DISPATCHER.Takeoff
|
||||||
-- @extends Wrapper.Group#GROUP.Takeoff
|
-- @extends Wrapper.Group#GROUP.Takeoff
|
||||||
|
|
||||||
--- @field #AI_A2G_DISPATCHER.Takeoff Takeoff
|
-- @field #AI_A2G_DISPATCHER.Takeoff Takeoff
|
||||||
AI_A2G_DISPATCHER.Takeoff = GROUP.Takeoff
|
AI_A2G_DISPATCHER.Takeoff = GROUP.Takeoff
|
||||||
|
|
||||||
--- Defines Landing location.
|
--- Defines Landing location.
|
||||||
@@ -942,7 +942,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
-- @type AI_A2G_DISPATCHER.DefenseQueue
|
-- @type AI_A2G_DISPATCHER.DefenseQueue
|
||||||
-- @list<#AI_A2G_DISPATCHER.DefenseQueueItem> DefenseQueueItem A list of all defenses being queued ...
|
-- @list<#AI_A2G_DISPATCHER.DefenseQueueItem> DefenseQueueItem A list of all defenses being queued ...
|
||||||
|
|
||||||
--- @field #AI_A2G_DISPATCHER.DefenseQueue DefenseQueue
|
-- @field #AI_A2G_DISPATCHER.DefenseQueue DefenseQueue
|
||||||
AI_A2G_DISPATCHER.DefenseQueue = {}
|
AI_A2G_DISPATCHER.DefenseQueue = {}
|
||||||
|
|
||||||
--- Defense approach types.
|
--- Defense approach types.
|
||||||
@@ -1136,7 +1136,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_DISPATCHER:onafterStart( From, Event, To )
|
function AI_A2G_DISPATCHER:onafterStart( From, Event, To )
|
||||||
|
|
||||||
self:GetParent( self ).onafterStart( self, From, Event, To )
|
self:GetParent( self ).onafterStart( self, From, Event, To )
|
||||||
@@ -1147,7 +1147,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
for Resource = 1, DefenderSquadron.ResourceCount or 0 do
|
for Resource = 1, DefenderSquadron.ResourceCount or 0 do
|
||||||
self:ResourcePark( DefenderSquadron )
|
self:ResourcePark( DefenderSquadron )
|
||||||
end
|
end
|
||||||
self:I( "Parked resources for squadron " .. DefenderSquadron.Name )
|
self:T( "Parked resources for squadron " .. DefenderSquadron.Name )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1201,7 +1201,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_DISPATCHER:ResourcePark( DefenderSquadron )
|
function AI_A2G_DISPATCHER:ResourcePark( DefenderSquadron )
|
||||||
local TemplateID = math.random( 1, #DefenderSquadron.Spawn )
|
local TemplateID = math.random( 1, #DefenderSquadron.Spawn )
|
||||||
local Spawn = DefenderSquadron.Spawn[ TemplateID ] -- Core.Spawn#SPAWN
|
local Spawn = DefenderSquadron.Spawn[ TemplateID ] -- Core.Spawn#SPAWN
|
||||||
@@ -1218,33 +1218,33 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_A2G_DISPATCHER:OnEventBaseCaptured( EventData )
|
function AI_A2G_DISPATCHER:OnEventBaseCaptured( EventData )
|
||||||
|
|
||||||
local AirbaseName = EventData.PlaceName -- The name of the airbase that was captured.
|
local AirbaseName = EventData.PlaceName -- The name of the airbase that was captured.
|
||||||
|
|
||||||
self:I( "Captured " .. AirbaseName )
|
self:T( "Captured " .. AirbaseName )
|
||||||
|
|
||||||
-- Now search for all squadrons located at the airbase, and sanitize them.
|
-- Now search for all squadrons located at the airbase, and sanitize them.
|
||||||
for SquadronName, Squadron in pairs( self.DefenderSquadrons ) do
|
for SquadronName, Squadron in pairs( self.DefenderSquadrons ) do
|
||||||
if Squadron.AirbaseName == AirbaseName then
|
if Squadron.AirbaseName == AirbaseName then
|
||||||
Squadron.ResourceCount = -999 -- The base has been captured, and the resources are eliminated. No more spawning.
|
Squadron.ResourceCount = -999 -- The base has been captured, and the resources are eliminated. No more spawning.
|
||||||
Squadron.Captured = true
|
Squadron.Captured = true
|
||||||
self:I( "Squadron " .. SquadronName .. " captured." )
|
self:T( "Squadron " .. SquadronName .. " captured." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_A2G_DISPATCHER:OnEventCrashOrDead( EventData )
|
function AI_A2G_DISPATCHER:OnEventCrashOrDead( EventData )
|
||||||
self.Detection:ForgetDetectedUnit( EventData.IniUnitName )
|
self.Detection:ForgetDetectedUnit( EventData.IniUnitName )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_A2G_DISPATCHER:OnEventLand( EventData )
|
function AI_A2G_DISPATCHER:OnEventLand( EventData )
|
||||||
self:F( "Landed" )
|
self:F( "Landed" )
|
||||||
@@ -1261,7 +1261,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
end
|
end
|
||||||
DefenderUnit:Destroy()
|
DefenderUnit:Destroy()
|
||||||
self:ResourcePark( Squadron, Defender )
|
self:ResourcePark( Squadron )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if DefenderUnit:GetLife() ~= DefenderUnit:GetLife0() then
|
if DefenderUnit:GetLife() ~= DefenderUnit:GetLife0() then
|
||||||
@@ -1273,7 +1273,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_A2G_DISPATCHER:OnEventEngineShutdown( EventData )
|
function AI_A2G_DISPATCHER:OnEventEngineShutdown( EventData )
|
||||||
local DefenderUnit = EventData.IniUnit
|
local DefenderUnit = EventData.IniUnit
|
||||||
@@ -1289,7 +1289,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
end
|
end
|
||||||
DefenderUnit:Destroy()
|
DefenderUnit:Destroy()
|
||||||
self:ResourcePark( Squadron, Defender )
|
self:ResourcePark( Squadron )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1297,7 +1297,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
|
|
||||||
do -- Manage the defensive behaviour
|
do -- Manage the defensive behaviour
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #string DefenseCoordinateName The name of the coordinate to be defended by A2G defenses.
|
-- @param #string DefenseCoordinateName The name of the coordinate to be defended by A2G defenses.
|
||||||
-- @param Core.Point#COORDINATE DefenseCoordinate The coordinate to be defended by A2G defenses.
|
-- @param Core.Point#COORDINATE DefenseCoordinate The coordinate to be defended by A2G defenses.
|
||||||
function AI_A2G_DISPATCHER:AddDefenseCoordinate( DefenseCoordinateName, DefenseCoordinate )
|
function AI_A2G_DISPATCHER:AddDefenseCoordinate( DefenseCoordinateName, DefenseCoordinate )
|
||||||
@@ -1305,19 +1305,19 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_DISPATCHER:SetDefenseReactivityLow()
|
function AI_A2G_DISPATCHER:SetDefenseReactivityLow()
|
||||||
self.DefenseReactivity = 0.05
|
self.DefenseReactivity = 0.05
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_DISPATCHER:SetDefenseReactivityMedium()
|
function AI_A2G_DISPATCHER:SetDefenseReactivityMedium()
|
||||||
self.DefenseReactivity = 0.15
|
self.DefenseReactivity = 0.15
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_DISPATCHER:SetDefenseReactivityHigh()
|
function AI_A2G_DISPATCHER:SetDefenseReactivityHigh()
|
||||||
self.DefenseReactivity = 0.5
|
self.DefenseReactivity = 0.5
|
||||||
end
|
end
|
||||||
@@ -1351,14 +1351,14 @@ do -- AI_A2G_DISPATCHER
|
|||||||
-- 1. the **distance of the closest airbase to target**, being smaller than the **Defend Radius**.
|
-- 1. the **distance of the closest airbase to target**, being smaller than the **Defend Radius**.
|
||||||
-- 2. the **distance to any defense reference point**.
|
-- 2. the **distance to any defense reference point**.
|
||||||
--
|
--
|
||||||
-- The **default** defense radius is defined as **400000** or **40km**. Override the default defense radius when the era of the warfare is early, or,
|
-- The **default** defense radius is defined as **40000** or **40km**. Override the default defense radius when the era of the warfare is early, or,
|
||||||
-- when you don't want to let the AI_A2G_DISPATCHER react immediately when a certain border or area is not being crossed.
|
-- when you don't want to let the AI_A2G_DISPATCHER react immediately when a certain border or area is not being crossed.
|
||||||
--
|
--
|
||||||
-- Use the method @{#AI_A2G_DISPATCHER.SetDefendRadius}() to set a specific defend radius for all squadrons,
|
-- Use the method @{#AI_A2G_DISPATCHER.SetDefendRadius}() to set a specific defend radius for all squadrons,
|
||||||
-- **the Defense Radius is defined for ALL squadrons which are operational.**
|
-- **the Defense Radius is defined for ALL squadrons which are operational.**
|
||||||
--
|
--
|
||||||
-- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #number DefenseRadius (Optional, Default = 200000) The defense radius to engage detected targets from the nearest capable and available squadron airbase.
|
-- @param #number DefenseRadius (Optional, Default = 20000) The defense radius to engage detected targets from the nearest capable and available squadron airbase.
|
||||||
-- @return #AI_A2G_DISPATCHER
|
-- @return #AI_A2G_DISPATCHER
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
@@ -1373,7 +1373,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
--
|
--
|
||||||
function AI_A2G_DISPATCHER:SetDefenseRadius( DefenseRadius )
|
function AI_A2G_DISPATCHER:SetDefenseRadius( DefenseRadius )
|
||||||
|
|
||||||
self.DefenseRadius = DefenseRadius or 100000
|
self.DefenseRadius = DefenseRadius or 40000
|
||||||
|
|
||||||
self.Detection:SetAcceptRange( self.DefenseRadius )
|
self.Detection:SetAcceptRange( self.DefenseRadius )
|
||||||
|
|
||||||
@@ -1868,7 +1868,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
-- @param #string SquadronName The squadron name.
|
-- @param #string SquadronName The squadron name.
|
||||||
-- @param #number TakeoffInterval Only Takeoff new units each specified interval in seconds in 10 seconds steps.
|
-- @param #number TakeoffInterval Only Takeoff new units each specified interval in seconds in 10 seconds steps.
|
||||||
-- @usage
|
-- @usage
|
||||||
@@ -2144,7 +2144,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
Sead.EngageAltType = EngageAltType
|
Sead.EngageAltType = EngageAltType
|
||||||
Sead.Defend = true
|
Sead.Defend = true
|
||||||
|
|
||||||
self:I( { SEAD = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
self:T( { SEAD = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -2234,7 +2234,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
|
|
||||||
self:SetSquadronPatrolInterval( SquadronName, self.DefenderDefault.PatrolLimit, self.DefenderDefault.PatrolMinSeconds, self.DefenderDefault.PatrolMaxSeconds, 1, "SEAD" )
|
self:SetSquadronPatrolInterval( SquadronName, self.DefenderDefault.PatrolLimit, self.DefenderDefault.PatrolMinSeconds, self.DefenderDefault.PatrolMaxSeconds, 1, "SEAD" )
|
||||||
|
|
||||||
self:I( { SEAD = { Zone:GetName(), PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
self:T( { SEAD = { Zone:GetName(), PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -2295,7 +2295,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
Cas.EngageAltType = EngageAltType
|
Cas.EngageAltType = EngageAltType
|
||||||
Cas.Defend = true
|
Cas.Defend = true
|
||||||
|
|
||||||
self:I( { CAS = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
self:T( { CAS = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -2385,7 +2385,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
|
|
||||||
self:SetSquadronPatrolInterval( SquadronName, self.DefenderDefault.PatrolLimit, self.DefenderDefault.PatrolMinSeconds, self.DefenderDefault.PatrolMaxSeconds, 1, "CAS" )
|
self:SetSquadronPatrolInterval( SquadronName, self.DefenderDefault.PatrolLimit, self.DefenderDefault.PatrolMinSeconds, self.DefenderDefault.PatrolMaxSeconds, 1, "CAS" )
|
||||||
|
|
||||||
self:I( { CAS = { Zone:GetName(), PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
self:T( { CAS = { Zone:GetName(), PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -2446,7 +2446,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
Bai.EngageAltType = EngageAltType
|
Bai.EngageAltType = EngageAltType
|
||||||
Bai.Defend = true
|
Bai.Defend = true
|
||||||
|
|
||||||
self:I( { BAI = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
self:T( { BAI = { SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -2536,7 +2536,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
|
|
||||||
self:SetSquadronPatrolInterval( SquadronName, self.DefenderDefault.PatrolLimit, self.DefenderDefault.PatrolMinSeconds, self.DefenderDefault.PatrolMaxSeconds, 1, "BAI" )
|
self:SetSquadronPatrolInterval( SquadronName, self.DefenderDefault.PatrolLimit, self.DefenderDefault.PatrolMinSeconds, self.DefenderDefault.PatrolMaxSeconds, 1, "BAI" )
|
||||||
|
|
||||||
self:I( { BAI = { Zone:GetName(), PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
self:T( { BAI = { Zone:GetName(), PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType } } )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -3369,7 +3369,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_DISPATCHER:AddDefenderToSquadron( Squadron, Defender, Size )
|
function AI_A2G_DISPATCHER:AddDefenderToSquadron( Squadron, Defender, Size )
|
||||||
self.Defenders = self.Defenders or {}
|
self.Defenders = self.Defenders or {}
|
||||||
local DefenderName = Defender:GetName()
|
local DefenderName = Defender:GetName()
|
||||||
@@ -3380,7 +3380,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
self:F( { DefenderName = DefenderName, SquadronResourceCount = Squadron.ResourceCount } )
|
self:F( { DefenderName = DefenderName, SquadronResourceCount = Squadron.ResourceCount } )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_DISPATCHER:RemoveDefenderFromSquadron( Squadron, Defender )
|
function AI_A2G_DISPATCHER:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
self.Defenders = self.Defenders or {}
|
self.Defenders = self.Defenders or {}
|
||||||
local DefenderName = Defender:GetName()
|
local DefenderName = Defender:GetName()
|
||||||
@@ -3796,7 +3796,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_Fsm:onafterLostControl( DefenderGroup, From, Event, To )
|
function AI_A2G_Fsm:onafterLostControl( DefenderGroup, From, Event, To )
|
||||||
self:F({"LostControl", DefenderGroup:GetName()})
|
self:F({"LostControl", DefenderGroup:GetName()})
|
||||||
self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To )
|
self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To )
|
||||||
@@ -3813,7 +3813,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_Fsm:onafterHome( DefenderGroup, From, Event, To, Action )
|
function AI_A2G_Fsm:onafterHome( DefenderGroup, From, Event, To, Action )
|
||||||
self:F({"Home", DefenderGroup:GetName()})
|
self:F({"Home", DefenderGroup:GetName()})
|
||||||
self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To )
|
self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To )
|
||||||
@@ -3894,7 +3894,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup )
|
||||||
|
|
||||||
if Squadron then
|
if Squadron then
|
||||||
local FirstUnit = AttackSetUnit:GetFirst()
|
local FirstUnit = AttackSetUnit:GetRandomSurely()
|
||||||
local Coordinate = FirstUnit:GetCoordinate() -- Core.Point#COORDINATE
|
local Coordinate = FirstUnit:GetCoordinate() -- Core.Point#COORDINATE
|
||||||
if self.SetSendPlayerMessages then
|
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 )
|
||||||
@@ -3933,7 +3933,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_Fsm:onafterLostControl( DefenderGroup, From, Event, To )
|
function AI_A2G_Fsm:onafterLostControl( DefenderGroup, From, Event, To )
|
||||||
self:F({"Defender LostControl", DefenderGroup:GetName()})
|
self:F({"Defender LostControl", DefenderGroup:GetName()})
|
||||||
self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To )
|
self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To )
|
||||||
@@ -3950,7 +3950,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2G_DISPATCHER self
|
-- @param #AI_A2G_DISPATCHER self
|
||||||
function AI_A2G_Fsm:onafterHome( DefenderGroup, From, Event, To, Action )
|
function AI_A2G_Fsm:onafterHome( DefenderGroup, From, Event, To, Action )
|
||||||
self:F({"Defender Home", DefenderGroup:GetName()})
|
self:F({"Defender Home", DefenderGroup:GetName()})
|
||||||
self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To )
|
self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To )
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
-- @module AI.AI_Air
|
-- @module AI.AI_Air
|
||||||
-- @image MOOSE.JPG
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
--- @type AI_AIR
|
-- @type AI_AIR
|
||||||
-- @extends Core.Fsm#FSM_CONTROLLABLE
|
-- @extends Core.Fsm#FSM_CONTROLLABLE
|
||||||
|
|
||||||
--- The AI_AIR class implements the core functions to operate an AI @{Wrapper.Group}.
|
--- The AI_AIR class implements the core functions to operate an AI @{Wrapper.Group}.
|
||||||
@@ -264,7 +264,7 @@ function AI_AIR:New( AIGroup )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP self
|
-- @param Wrapper.Group#GROUP self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function GROUP:OnEventTakeoff( EventData, Fsm )
|
function GROUP:OnEventTakeoff( EventData, Fsm )
|
||||||
Fsm:Takeoff()
|
Fsm:Takeoff()
|
||||||
@@ -446,13 +446,13 @@ function AI_AIR:onafterReturn( Controllable, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
function AI_AIR:onbeforeStatus()
|
function AI_AIR:onbeforeStatus()
|
||||||
|
|
||||||
return self.CheckStatus
|
return self.CheckStatus
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
function AI_AIR:onafterStatus()
|
function AI_AIR:onafterStatus()
|
||||||
|
|
||||||
if self.Controllable and self.Controllable:IsAlive() then
|
if self.Controllable and self.Controllable:IsAlive() then
|
||||||
@@ -465,7 +465,7 @@ function AI_AIR:onafterStatus()
|
|||||||
local DistanceFromHomeBase = self.HomeAirbase:GetCoordinate():Get2DDistance( self.Controllable:GetCoordinate() )
|
local DistanceFromHomeBase = self.HomeAirbase:GetCoordinate():Get2DDistance( self.Controllable:GetCoordinate() )
|
||||||
|
|
||||||
if DistanceFromHomeBase > self.DisengageRadius then
|
if DistanceFromHomeBase > self.DisengageRadius then
|
||||||
self:I( self.Controllable:GetName() .. " is too far from home base, RTB!" )
|
self:T( self.Controllable:GetName() .. " is too far from home base, RTB!" )
|
||||||
self:Hold( 300 )
|
self:Hold( 300 )
|
||||||
RTB = false
|
RTB = false
|
||||||
end
|
end
|
||||||
@@ -489,10 +489,10 @@ function AI_AIR:onafterStatus()
|
|||||||
if Fuel < self.FuelThresholdPercentage then
|
if Fuel < self.FuelThresholdPercentage then
|
||||||
|
|
||||||
if self.TankerName then
|
if self.TankerName then
|
||||||
self:I( self.Controllable:GetName() .. " is out of fuel: " .. Fuel .. " ... Refuelling at Tanker!" )
|
self:T( self.Controllable:GetName() .. " is out of fuel: " .. Fuel .. " ... Refuelling at Tanker!" )
|
||||||
self:Refuel()
|
self:Refuel()
|
||||||
else
|
else
|
||||||
self:I( self.Controllable:GetName() .. " is out of fuel: " .. Fuel .. " ... RTB!" )
|
self:T( self.Controllable:GetName() .. " is out of fuel: " .. Fuel .. " ... RTB!" )
|
||||||
local OldAIControllable = self.Controllable
|
local OldAIControllable = self.Controllable
|
||||||
|
|
||||||
local OrbitTask = OldAIControllable:TaskOrbitCircle( math.random( self.PatrolFloorAltitude, self.PatrolCeilingAltitude ), self.PatrolMinSpeed )
|
local OrbitTask = OldAIControllable:TaskOrbitCircle( math.random( self.PatrolFloorAltitude, self.PatrolCeilingAltitude ), self.PatrolMinSpeed )
|
||||||
@@ -518,7 +518,7 @@ function AI_AIR:onafterStatus()
|
|||||||
-- Note that a group can consist of more units, so if one unit is damaged of a group, the mission may continue.
|
-- Note that a group can consist of more units, so if one unit is damaged of a group, the mission may continue.
|
||||||
-- The damaged unit will RTB due to DCS logic, and the others will continue to engage.
|
-- The damaged unit will RTB due to DCS logic, and the others will continue to engage.
|
||||||
if ( Damage / InitialLife ) < self.PatrolDamageThreshold then
|
if ( Damage / InitialLife ) < self.PatrolDamageThreshold then
|
||||||
self:I( self.Controllable:GetName() .. " is damaged: " .. Damage .. " ... RTB!" )
|
self:T( self.Controllable:GetName() .. " is damaged: " .. Damage .. " ... RTB!" )
|
||||||
self:Damaged()
|
self:Damaged()
|
||||||
RTB = true
|
RTB = true
|
||||||
self:SetStatusOff()
|
self:SetStatusOff()
|
||||||
@@ -536,7 +536,7 @@ function AI_AIR:onafterStatus()
|
|||||||
if Damage ~= InitialLife then
|
if Damage ~= InitialLife then
|
||||||
self:Damaged()
|
self:Damaged()
|
||||||
else
|
else
|
||||||
self:I( self.Controllable:GetName() .. " control lost! " )
|
self:T( self.Controllable:GetName() .. " control lost! " )
|
||||||
|
|
||||||
self:LostControl()
|
self:LostControl()
|
||||||
end
|
end
|
||||||
@@ -560,7 +560,7 @@ function AI_AIR:onafterStatus()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_AIR.RTBRoute( AIGroup, Fsm )
|
function AI_AIR.RTBRoute( AIGroup, Fsm )
|
||||||
|
|
||||||
AIGroup:F( { "AI_AIR.RTBRoute:", AIGroup:GetName() } )
|
AIGroup:F( { "AI_AIR.RTBRoute:", AIGroup:GetName() } )
|
||||||
@@ -571,7 +571,7 @@ function AI_AIR.RTBRoute( AIGroup, Fsm )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_AIR.RTBHold( AIGroup, Fsm )
|
function AI_AIR.RTBHold( AIGroup, Fsm )
|
||||||
|
|
||||||
AIGroup:F( { "AI_AIR.RTBHold:", AIGroup:GetName() } )
|
AIGroup:F( { "AI_AIR.RTBHold:", AIGroup:GetName() } )
|
||||||
@@ -598,7 +598,7 @@ function AI_AIR:SetRTBSpeedFactors(MinFactor,MaxFactor)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
||||||
self:F( { AIGroup, From, Event, To } )
|
self:F( { AIGroup, From, Event, To } )
|
||||||
@@ -617,7 +617,10 @@ function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
|||||||
--- Calculate the target route point.
|
--- Calculate the target route point.
|
||||||
|
|
||||||
local FromCoord = AIGroup:GetCoordinate()
|
local FromCoord = AIGroup:GetCoordinate()
|
||||||
|
if not FromCoord then return end
|
||||||
|
|
||||||
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()+3000 -- 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 )
|
||||||
@@ -638,13 +641,13 @@ function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
|||||||
local ToAirbaseCoord = ToTargetCoord2
|
local ToAirbaseCoord = ToTargetCoord2
|
||||||
|
|
||||||
if Distance < 5000 then
|
if Distance < 5000 then
|
||||||
self:I( "RTB and near the airbase!" )
|
self:T( "RTB and near the airbase!" )
|
||||||
self:Home()
|
self:Home()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not AIGroup:InAir() == true then
|
if not AIGroup:InAir() == true then
|
||||||
self:I( "Not anymore in the air, considered Home." )
|
self:T( "Not anymore in the air, considered Home." )
|
||||||
self:Home()
|
self:Home()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -686,12 +689,12 @@ function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_AIR:onafterHome( AIGroup, From, Event, To )
|
function AI_AIR:onafterHome( AIGroup, From, Event, To )
|
||||||
self:F( { AIGroup, From, Event, To } )
|
self:F( { AIGroup, From, Event, To } )
|
||||||
|
|
||||||
self:I( "Group " .. self.Controllable:GetName() .. " ... Home! ( " .. self:GetState() .. " )" )
|
self:T( "Group " .. self.Controllable:GetName() .. " ... Home! ( " .. self:GetState() .. " )" )
|
||||||
|
|
||||||
if AIGroup and AIGroup:IsAlive() then
|
if AIGroup and AIGroup:IsAlive() then
|
||||||
end
|
end
|
||||||
@@ -700,15 +703,17 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_AIR:onafterHold( AIGroup, From, Event, To, HoldTime )
|
function AI_AIR:onafterHold( AIGroup, From, Event, To, HoldTime )
|
||||||
self:F( { AIGroup, From, Event, To } )
|
self:F( { AIGroup, From, Event, To } )
|
||||||
|
|
||||||
self:I( "Group " .. self.Controllable:GetName() .. " ... Holding! ( " .. self:GetState() .. " )" )
|
self:T( "Group " .. self.Controllable:GetName() .. " ... Holding! ( " .. self:GetState() .. " )" )
|
||||||
|
|
||||||
if AIGroup and AIGroup:IsAlive() then
|
if AIGroup and AIGroup:IsAlive() then
|
||||||
local OrbitTask = AIGroup:TaskOrbitCircle( math.random( self.PatrolFloorAltitude, self.PatrolCeilingAltitude ), self.PatrolMinSpeed )
|
local Coordinate = AIGroup:GetCoordinate()
|
||||||
|
if Coordinate == nil then return end
|
||||||
|
local OrbitTask = AIGroup:TaskOrbitCircle( math.random( self.PatrolFloorAltitude, self.PatrolCeilingAltitude ), self.PatrolMinSpeed, Coordinate )
|
||||||
local TimedOrbitTask = AIGroup:TaskControlled( OrbitTask, AIGroup:TaskCondition( nil, nil, nil, nil, HoldTime , nil ) )
|
local TimedOrbitTask = AIGroup:TaskControlled( OrbitTask, AIGroup:TaskCondition( nil, nil, nil, nil, HoldTime , nil ) )
|
||||||
|
|
||||||
local RTBTask = AIGroup:TaskFunction( "AI_AIR.RTBHold", self )
|
local RTBTask = AIGroup:TaskFunction( "AI_AIR.RTBHold", self )
|
||||||
@@ -722,17 +727,17 @@ function AI_AIR:onafterHold( AIGroup, From, Event, To, HoldTime )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_AIR.Resume( AIGroup, Fsm )
|
function AI_AIR.Resume( AIGroup, Fsm )
|
||||||
|
|
||||||
AIGroup:I( { "AI_AIR.Resume:", AIGroup:GetName() } )
|
AIGroup:T( { "AI_AIR.Resume:", AIGroup:GetName() } )
|
||||||
if AIGroup:IsAlive() then
|
if AIGroup:IsAlive() then
|
||||||
Fsm:__RTB( Fsm.TaskDelay )
|
Fsm:__RTB( Fsm.TaskDelay )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
||||||
self:F( { AIGroup, From, Event, To } )
|
self:F( { AIGroup, From, Event, To } )
|
||||||
@@ -744,7 +749,7 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
|||||||
|
|
||||||
if Tanker and Tanker:IsAlive() and Tanker:IsAirPlane() then
|
if Tanker and Tanker:IsAlive() and Tanker:IsAirPlane() then
|
||||||
|
|
||||||
self:I( "Group " .. self.Controllable:GetName() .. " ... Refuelling! State=" .. self:GetState() .. ", Refuelling tanker " .. self.TankerName )
|
self:T( "Group " .. self.Controllable:GetName() .. " ... Refuelling! State=" .. self:GetState() .. ", Refuelling tanker " .. self.TankerName )
|
||||||
|
|
||||||
local RefuelRoute = {}
|
local RefuelRoute = {}
|
||||||
|
|
||||||
@@ -798,13 +803,13 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
function AI_AIR:onafterDead()
|
function AI_AIR:onafterDead()
|
||||||
self:SetStatusOff()
|
self:SetStatusOff()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_AIR:OnCrash( EventData )
|
function AI_AIR:OnCrash( EventData )
|
||||||
|
|
||||||
@@ -815,7 +820,7 @@ function AI_AIR:OnCrash( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_AIR:OnEjection( EventData )
|
function AI_AIR:OnEjection( EventData )
|
||||||
|
|
||||||
@@ -824,7 +829,7 @@ function AI_AIR:OnEjection( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR self
|
-- @param #AI_AIR self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_AIR:OnPilotDead( EventData )
|
function AI_AIR:OnPilotDead( EventData )
|
||||||
|
|
||||||
|
|||||||
@@ -900,14 +900,14 @@ do -- AI_AIR_DISPATCHER
|
|||||||
-- @type AI_AIR_DISPATCHER.DefenseCoordinates
|
-- @type AI_AIR_DISPATCHER.DefenseCoordinates
|
||||||
-- @map <#string,Core.Point#COORDINATE> A list of all defense coordinates mapped per defense coordinate name.
|
-- @map <#string,Core.Point#COORDINATE> A list of all defense coordinates mapped per defense coordinate name.
|
||||||
|
|
||||||
--- @field #AI_AIR_DISPATCHER.DefenseCoordinates DefenseCoordinates
|
-- @field #AI_AIR_DISPATCHER.DefenseCoordinates DefenseCoordinates
|
||||||
AI_AIR_DISPATCHER.DefenseCoordinates = {}
|
AI_AIR_DISPATCHER.DefenseCoordinates = {}
|
||||||
|
|
||||||
--- Enumerator for spawns at airbases
|
--- Enumerator for spawns at airbases
|
||||||
-- @type AI_AIR_DISPATCHER.Takeoff
|
-- @type AI_AIR_DISPATCHER.Takeoff
|
||||||
-- @extends Wrapper.Group#GROUP.Takeoff
|
-- @extends Wrapper.Group#GROUP.Takeoff
|
||||||
|
|
||||||
--- @field #AI_AIR_DISPATCHER.Takeoff Takeoff
|
-- @field #AI_AIR_DISPATCHER.Takeoff Takeoff
|
||||||
AI_AIR_DISPATCHER.Takeoff = GROUP.Takeoff
|
AI_AIR_DISPATCHER.Takeoff = GROUP.Takeoff
|
||||||
|
|
||||||
--- Defnes Landing location.
|
--- Defnes Landing location.
|
||||||
@@ -938,7 +938,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
-- @type AI_AIR_DISPATCHER.DefenseQueue
|
-- @type AI_AIR_DISPATCHER.DefenseQueue
|
||||||
-- @list<#AI_AIR_DISPATCHER.DefenseQueueItem> DefenseQueueItem A list of all defenses being queued ...
|
-- @list<#AI_AIR_DISPATCHER.DefenseQueueItem> DefenseQueueItem A list of all defenses being queued ...
|
||||||
|
|
||||||
--- @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
|
||||||
@@ -1130,7 +1130,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
function AI_AIR_DISPATCHER:onafterStart( From, Event, To )
|
function AI_AIR_DISPATCHER:onafterStart( From, Event, To )
|
||||||
|
|
||||||
self:GetParent( self ).onafterStart( self, From, Event, To )
|
self:GetParent( self ).onafterStart( self, From, Event, To )
|
||||||
@@ -1141,7 +1141,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
for Resource = 1, DefenderSquadron.ResourceCount or 0 do
|
for Resource = 1, DefenderSquadron.ResourceCount or 0 do
|
||||||
self:ResourcePark( DefenderSquadron )
|
self:ResourcePark( DefenderSquadron )
|
||||||
end
|
end
|
||||||
self:I( "Parked resources for squadron " .. DefenderSquadron.Name )
|
self:T( "Parked resources for squadron " .. DefenderSquadron.Name )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1194,7 +1194,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
function AI_AIR_DISPATCHER:ResourcePark( DefenderSquadron )
|
function AI_AIR_DISPATCHER:ResourcePark( DefenderSquadron )
|
||||||
local TemplateID = math.random( 1, #DefenderSquadron.Spawn )
|
local TemplateID = math.random( 1, #DefenderSquadron.Spawn )
|
||||||
local Spawn = DefenderSquadron.Spawn[ TemplateID ] -- Core.Spawn#SPAWN
|
local Spawn = DefenderSquadron.Spawn[ TemplateID ] -- Core.Spawn#SPAWN
|
||||||
@@ -1211,31 +1211,31 @@ do -- AI_AIR_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_AIR_DISPATCHER:OnEventBaseCaptured( EventData )
|
function AI_AIR_DISPATCHER:OnEventBaseCaptured( EventData )
|
||||||
|
|
||||||
local AirbaseName = EventData.PlaceName -- The name of the airbase that was captured.
|
local AirbaseName = EventData.PlaceName -- The name of the airbase that was captured.
|
||||||
|
|
||||||
self:I( "Captured " .. AirbaseName )
|
self:T( "Captured " .. AirbaseName )
|
||||||
|
|
||||||
-- Now search for all squadrons located at the airbase, and sanitize them.
|
-- Now search for all squadrons located at the airbase, and sanitize them.
|
||||||
for SquadronName, Squadron in pairs( self.DefenderSquadrons ) do
|
for SquadronName, Squadron in pairs( self.DefenderSquadrons ) do
|
||||||
if Squadron.AirbaseName == AirbaseName then
|
if Squadron.AirbaseName == AirbaseName then
|
||||||
Squadron.ResourceCount = -999 -- The base has been captured, and the resources are eliminated. No more spawning.
|
Squadron.ResourceCount = -999 -- The base has been captured, and the resources are eliminated. No more spawning.
|
||||||
Squadron.Captured = true
|
Squadron.Captured = true
|
||||||
self:I( "Squadron " .. SquadronName .. " captured." )
|
self:T( "Squadron " .. SquadronName .. " captured." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_AIR_DISPATCHER:OnEventCrashOrDead( EventData )
|
function AI_AIR_DISPATCHER:OnEventCrashOrDead( EventData )
|
||||||
self.Detection:ForgetDetectedUnit( EventData.IniUnitName )
|
self.Detection:ForgetDetectedUnit( EventData.IniUnitName )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_AIR_DISPATCHER:OnEventLand( EventData )
|
function AI_AIR_DISPATCHER:OnEventLand( EventData )
|
||||||
self:F( "Landed" )
|
self:F( "Landed" )
|
||||||
@@ -1252,7 +1252,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
end
|
end
|
||||||
DefenderUnit:Destroy()
|
DefenderUnit:Destroy()
|
||||||
self:ResourcePark( Squadron, Defender )
|
self:ResourcePark( Squadron )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if DefenderUnit:GetLife() ~= DefenderUnit:GetLife0() then
|
if DefenderUnit:GetLife() ~= DefenderUnit:GetLife0() then
|
||||||
@@ -1263,7 +1263,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_AIR_DISPATCHER:OnEventEngineShutdown( EventData )
|
function AI_AIR_DISPATCHER:OnEventEngineShutdown( EventData )
|
||||||
local DefenderUnit = EventData.IniUnit
|
local DefenderUnit = EventData.IniUnit
|
||||||
@@ -1279,31 +1279,31 @@ do -- AI_AIR_DISPATCHER
|
|||||||
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
end
|
end
|
||||||
DefenderUnit:Destroy()
|
DefenderUnit:Destroy()
|
||||||
self:ResourcePark( Squadron, Defender )
|
self:ResourcePark( Squadron )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- Manage the defensive behaviour
|
do -- Manage the defensive behaviour
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param #string DefenseCoordinateName The name of the coordinate to be defended by AIR defenses.
|
-- @param #string DefenseCoordinateName The name of the coordinate to be defended by AIR defenses.
|
||||||
-- @param Core.Point#COORDINATE DefenseCoordinate The coordinate to be defended by AIR defenses.
|
-- @param Core.Point#COORDINATE DefenseCoordinate The coordinate to be defended by AIR defenses.
|
||||||
function AI_AIR_DISPATCHER:AddDefenseCoordinate( DefenseCoordinateName, DefenseCoordinate )
|
function AI_AIR_DISPATCHER:AddDefenseCoordinate( DefenseCoordinateName, DefenseCoordinate )
|
||||||
self.DefenseCoordinates[DefenseCoordinateName] = DefenseCoordinate
|
self.DefenseCoordinates[DefenseCoordinateName] = DefenseCoordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
function AI_AIR_DISPATCHER:SetDefenseReactivityLow()
|
function AI_AIR_DISPATCHER:SetDefenseReactivityLow()
|
||||||
self.DefenseReactivity = 0.05
|
self.DefenseReactivity = 0.05
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
function AI_AIR_DISPATCHER:SetDefenseReactivityMedium()
|
function AI_AIR_DISPATCHER:SetDefenseReactivityMedium()
|
||||||
self.DefenseReactivity = 0.15
|
self.DefenseReactivity = 0.15
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
function AI_AIR_DISPATCHER:SetDefenseReactivityHigh()
|
function AI_AIR_DISPATCHER:SetDefenseReactivityHigh()
|
||||||
self.DefenseReactivity = 0.5
|
self.DefenseReactivity = 0.5
|
||||||
end
|
end
|
||||||
@@ -1867,7 +1867,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param #string SquadronName The squadron name.
|
-- @param #string SquadronName The squadron name.
|
||||||
-- @param #number TakeoffInterval Only Takeoff new units each specified interval in seconds in 10 seconds steps.
|
-- @param #number TakeoffInterval Only Takeoff new units each specified interval in seconds in 10 seconds steps.
|
||||||
-- @usage
|
-- @usage
|
||||||
@@ -2769,7 +2769,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
|
|
||||||
-- TODO: Need to model the resources in a squadron.
|
-- TODO: Need to model the resources in a squadron.
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param AI.AI_Air_Squadron#AI_AIR_SQUADRON Squadron
|
-- @param AI.AI_Air_Squadron#AI_AIR_SQUADRON Squadron
|
||||||
function AI_AIR_DISPATCHER:AddDefenderToSquadron( Squadron, Defender, Size )
|
function AI_AIR_DISPATCHER:AddDefenderToSquadron( Squadron, Defender, Size )
|
||||||
self.Defenders = self.Defenders or {}
|
self.Defenders = self.Defenders or {}
|
||||||
@@ -2782,7 +2782,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
self:F( { DefenderName = DefenderName, SquadronResourceCount = Squadron.ResourceCount } )
|
self:F( { DefenderName = DefenderName, SquadronResourceCount = Squadron.ResourceCount } )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param AI.AI_Air_Squadron#AI_AIR_SQUADRON Squadron
|
-- @param AI.AI_Air_Squadron#AI_AIR_SQUADRON Squadron
|
||||||
function AI_AIR_DISPATCHER:RemoveDefenderFromSquadron( Squadron, Defender )
|
function AI_AIR_DISPATCHER:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
self.Defenders = self.Defenders or {}
|
self.Defenders = self.Defenders or {}
|
||||||
@@ -2795,7 +2795,7 @@ do -- AI_AIR_DISPATCHER
|
|||||||
self:F( { DefenderName = DefenderName, SquadronResourceCount = SquadronResourceCount } )
|
self:F( { DefenderName = DefenderName, SquadronResourceCount = SquadronResourceCount } )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_DISPATCHER self
|
-- @param #AI_AIR_DISPATCHER self
|
||||||
-- @param Wrapper.Group#GROUP Defender
|
-- @param Wrapper.Group#GROUP Defender
|
||||||
-- @return AI.AI_Air_Squadron#AI_AIR_SQUADRON The Squadron.
|
-- @return AI.AI_Air_Squadron#AI_AIR_SQUADRON The Squadron.
|
||||||
function AI_AIR_DISPATCHER:GetSquadronFromDefender( Defender )
|
function AI_AIR_DISPATCHER:GetSquadronFromDefender( Defender )
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @type AI_AIR_ENGAGE
|
-- @type AI_AIR_ENGAGE
|
||||||
-- @extends AI.AI_Air#AI_AIR
|
-- @extends AI.AI_AIR#AI_AIR
|
||||||
|
|
||||||
|
|
||||||
--- Implements the core functions to intercept intruders. Use the Engage trigger to intercept intruders.
|
--- Implements the core functions to intercept intruders. Use the Engage trigger to intercept intruders.
|
||||||
@@ -351,7 +351,7 @@ function AI_AIR_ENGAGE:onafterAbort( AIGroup, From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR_ENGAGE self
|
-- @param #AI_AIR_ENGAGE self
|
||||||
-- @param Wrapper.Group#GROUP AIGroup The Group Object managed by the FSM.
|
-- @param Wrapper.Group#GROUP AIGroup The Group Object managed by the FSM.
|
||||||
-- @param #string From The From State string.
|
-- @param #string From The From State string.
|
||||||
-- @param #string Event The Event string.
|
-- @param #string Event The Event string.
|
||||||
@@ -361,7 +361,7 @@ function AI_AIR_ENGAGE:onafterAccomplish( AIGroup, From, Event, To )
|
|||||||
--self:SetDetectionOff()
|
--self:SetDetectionOff()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_ENGAGE self
|
-- @param #AI_AIR_ENGAGE self
|
||||||
-- @param Wrapper.Group#GROUP AIGroup The Group Object managed by the FSM.
|
-- @param Wrapper.Group#GROUP AIGroup The Group Object managed by the FSM.
|
||||||
-- @param #string From The From State string.
|
-- @param #string From The From State string.
|
||||||
-- @param #string Event The Event string.
|
-- @param #string Event The Event string.
|
||||||
@@ -374,7 +374,7 @@ function AI_AIR_ENGAGE:onafterDestroy( AIGroup, From, Event, To, EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_ENGAGE self
|
-- @param #AI_AIR_ENGAGE self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_AIR_ENGAGE:OnEventDead( EventData )
|
function AI_AIR_ENGAGE:OnEventDead( EventData )
|
||||||
self:F( { "EventDead", EventData } )
|
self:F( { "EventDead", EventData } )
|
||||||
@@ -387,9 +387,9 @@ function AI_AIR_ENGAGE:OnEventDead( EventData )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AIControllable
|
-- @param Wrapper.Group#GROUP AIControllable
|
||||||
function AI_AIR_ENGAGE.___EngageRoute( AIGroup, Fsm, AttackSetUnit )
|
function AI_AIR_ENGAGE.___EngageRoute( AIGroup, Fsm, AttackSetUnit )
|
||||||
Fsm:I(string.format("AI_AIR_ENGAGE.___EngageRoute: %s", tostring(AIGroup:GetName())))
|
Fsm:T(string.format("AI_AIR_ENGAGE.___EngageRoute: %s", tostring(AIGroup:GetName())))
|
||||||
|
|
||||||
if AIGroup and AIGroup:IsAlive() then
|
if AIGroup and AIGroup:IsAlive() then
|
||||||
Fsm:__EngageRoute( Fsm.TaskDelay or 0.1, AttackSetUnit )
|
Fsm:__EngageRoute( Fsm.TaskDelay or 0.1, AttackSetUnit )
|
||||||
@@ -397,14 +397,14 @@ function AI_AIR_ENGAGE.___EngageRoute( AIGroup, Fsm, AttackSetUnit )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR_ENGAGE self
|
-- @param #AI_AIR_ENGAGE self
|
||||||
-- @param Wrapper.Group#GROUP DefenderGroup The GroupGroup managed by the FSM.
|
-- @param Wrapper.Group#GROUP DefenderGroup The GroupGroup managed by the FSM.
|
||||||
-- @param #string From The From State string.
|
-- @param #string From The From State string.
|
||||||
-- @param #string Event The Event string.
|
-- @param #string Event The Event string.
|
||||||
-- @param #string To The To State string.
|
-- @param #string To The To State string.
|
||||||
-- @param Core.Set#SET_UNIT AttackSetUnit Unit set to be attacked.
|
-- @param Core.Set#SET_UNIT AttackSetUnit Unit set to be attacked.
|
||||||
function AI_AIR_ENGAGE:onafterEngageRoute( DefenderGroup, From, Event, To, AttackSetUnit )
|
function AI_AIR_ENGAGE:onafterEngageRoute( DefenderGroup, From, Event, To, AttackSetUnit )
|
||||||
self:I( { DefenderGroup, From, Event, To, AttackSetUnit } )
|
self:T( { DefenderGroup, From, Event, To, AttackSetUnit } )
|
||||||
|
|
||||||
local DefenderGroupName = DefenderGroup:GetName()
|
local DefenderGroupName = DefenderGroup:GetName()
|
||||||
|
|
||||||
@@ -426,7 +426,13 @@ function AI_AIR_ENGAGE:onafterEngageRoute( DefenderGroup, From, Event, To, Attac
|
|||||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
local DefenderCoord = DefenderGroup:GetPointVec3()
|
||||||
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:GetRandomSurely():GetPointVec3()
|
||||||
|
|
||||||
|
if TargetCoord == nil 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 )
|
||||||
@@ -435,12 +441,12 @@ function AI_AIR_ENGAGE:onafterEngageRoute( DefenderGroup, From, Event, To, Attac
|
|||||||
-- TODO: A factor of * 3 is way too close. This causes the AI not to engange until merged sometimes!
|
-- TODO: A factor of * 3 is way too close. This causes the AI not to engange until merged sometimes!
|
||||||
if TargetDistance <= EngageDistance * 9 then
|
if TargetDistance <= EngageDistance * 9 then
|
||||||
|
|
||||||
--self:I(string.format("AI_AIR_ENGAGE onafterEngageRoute ==> __Engage - target distance = %.1f km", TargetDistance/1000))
|
--self:T(string.format("AI_AIR_ENGAGE onafterEngageRoute ==> __Engage - target distance = %.1f km", TargetDistance/1000))
|
||||||
self:__Engage( 0.1, AttackSetUnit )
|
self:__Engage( 0.1, AttackSetUnit )
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
--self:I(string.format("FF AI_AIR_ENGAGE onafterEngageRoute ==> Routing - target distance = %.1f km", TargetDistance/1000))
|
--self:T(string.format("FF AI_AIR_ENGAGE onafterEngageRoute ==> Routing - target distance = %.1f km", TargetDistance/1000))
|
||||||
|
|
||||||
local EngageRoute = {}
|
local EngageRoute = {}
|
||||||
local AttackTasks = {}
|
local AttackTasks = {}
|
||||||
@@ -472,16 +478,16 @@ function AI_AIR_ENGAGE:onafterEngageRoute( DefenderGroup, From, Event, To, Attac
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- TODO: This will make an A2A Dispatcher CAP flight to return rather than going back to patrolling!
|
-- TODO: This will make an A2A Dispatcher CAP flight to return rather than going back to patrolling!
|
||||||
self:I( DefenderGroupName .. ": No targets found -> Going RTB")
|
self:T( DefenderGroupName .. ": No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AIControllable
|
-- @param Wrapper.Group#GROUP AIControllable
|
||||||
function AI_AIR_ENGAGE.___Engage( AIGroup, Fsm, AttackSetUnit )
|
function AI_AIR_ENGAGE.___Engage( AIGroup, Fsm, AttackSetUnit )
|
||||||
|
|
||||||
Fsm:I(string.format("AI_AIR_ENGAGE.___Engage: %s", tostring(AIGroup:GetName())))
|
Fsm:T(string.format("AI_AIR_ENGAGE.___Engage: %s", tostring(AIGroup:GetName())))
|
||||||
|
|
||||||
if AIGroup and AIGroup:IsAlive() then
|
if AIGroup and AIGroup:IsAlive() then
|
||||||
local delay=Fsm.TaskDelay or 0.1
|
local delay=Fsm.TaskDelay or 0.1
|
||||||
@@ -490,7 +496,7 @@ function AI_AIR_ENGAGE.___Engage( AIGroup, Fsm, AttackSetUnit )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_AIR_ENGAGE self
|
-- @param #AI_AIR_ENGAGE self
|
||||||
-- @param Wrapper.Group#GROUP DefenderGroup The GroupGroup managed by the FSM.
|
-- @param Wrapper.Group#GROUP DefenderGroup The GroupGroup managed by the FSM.
|
||||||
-- @param #string From The From State string.
|
-- @param #string From The From State string.
|
||||||
-- @param #string Event The Event string.
|
-- @param #string Event The Event string.
|
||||||
@@ -516,7 +522,7 @@ function AI_AIR_ENGAGE:onafterEngage( DefenderGroup, From, Event, To, AttackSetU
|
|||||||
local DefenderCoord = DefenderGroup:GetPointVec3()
|
local DefenderCoord = DefenderGroup:GetPointVec3()
|
||||||
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:GetRandomSurely():GetPointVec3()
|
||||||
if not TargetCoord then
|
if not TargetCoord then
|
||||||
self:Return()
|
self:Return()
|
||||||
return
|
return
|
||||||
@@ -547,12 +553,12 @@ function AI_AIR_ENGAGE:onafterEngage( DefenderGroup, From, Event, To, AttackSetU
|
|||||||
local AttackUnitTasks = self:CreateAttackUnitTasks( AttackSetUnit, DefenderGroup, EngageAltitude ) -- Polymorphic
|
local AttackUnitTasks = self:CreateAttackUnitTasks( AttackSetUnit, DefenderGroup, EngageAltitude ) -- Polymorphic
|
||||||
|
|
||||||
if #AttackUnitTasks == 0 then
|
if #AttackUnitTasks == 0 then
|
||||||
self:I( DefenderGroupName .. ": No valid targets found -> Going RTB")
|
self:T( DefenderGroupName .. ": No valid targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
local text=string.format("%s: Engaging targets at distance %.2f NM", DefenderGroupName, UTILS.MetersToNM(TargetDistance))
|
local text=string.format("%s: Engaging targets at distance %.2f NM", DefenderGroupName, UTILS.MetersToNM(TargetDistance))
|
||||||
self:I(text)
|
self:T(text)
|
||||||
DefenderGroup:OptionROEOpenFire()
|
DefenderGroup:OptionROEOpenFire()
|
||||||
DefenderGroup:OptionROTEvadeFire()
|
DefenderGroup:OptionROTEvadeFire()
|
||||||
DefenderGroup:OptionKeepWeaponsOnThreat()
|
DefenderGroup:OptionKeepWeaponsOnThreat()
|
||||||
@@ -569,13 +575,13 @@ function AI_AIR_ENGAGE:onafterEngage( DefenderGroup, From, Event, To, AttackSetU
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- TODO: This will make an A2A Dispatcher CAP flight to return rather than going back to patrolling!
|
-- TODO: This will make an A2A Dispatcher CAP flight to return rather than going back to patrolling!
|
||||||
self:I( DefenderGroupName .. ": No targets found -> returning.")
|
self:T( DefenderGroupName .. ": No targets found -> returning.")
|
||||||
self:Return()
|
self:Return()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AIEngage
|
-- @param Wrapper.Group#GROUP AIEngage
|
||||||
function AI_AIR_ENGAGE.Resume( AIEngage, Fsm )
|
function AI_AIR_ENGAGE.Resume( AIEngage, Fsm )
|
||||||
|
|
||||||
AIEngage:F( { "Resume:", AIEngage:GetName() } )
|
AIEngage:F( { "Resume:", AIEngage:GetName() } )
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @type AI_AIR_SQUADRON
|
-- @type AI_AIR_SQUADRON
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ AI_AIR_SQUADRON = {
|
|||||||
-- @return #AI_AIR_SQUADRON
|
-- @return #AI_AIR_SQUADRON
|
||||||
function AI_AIR_SQUADRON:New( SquadronName, AirbaseName, TemplatePrefixes, ResourceCount )
|
function AI_AIR_SQUADRON:New( SquadronName, AirbaseName, TemplatePrefixes, ResourceCount )
|
||||||
|
|
||||||
self:I( { Air_Squadron = { SquadronName, AirbaseName, TemplatePrefixes, ResourceCount } } )
|
self:T( { Air_Squadron = { SquadronName, AirbaseName, TemplatePrefixes, ResourceCount } } )
|
||||||
|
|
||||||
local AI_Air_Squadron = BASE:New() -- #AI_AIR_SQUADRON
|
local AI_Air_Squadron = BASE:New() -- #AI_AIR_SQUADRON
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
-- @module AI.AI_Cargo
|
-- @module AI.AI_Cargo
|
||||||
-- @image Cargo.JPG
|
-- @image Cargo.JPG
|
||||||
|
|
||||||
--- @type AI_CARGO
|
-- @type AI_CARGO
|
||||||
-- @extends Core.Fsm#FSM_CONTROLLABLE
|
-- @extends Core.Fsm#FSM_CONTROLLABLE
|
||||||
|
|
||||||
|
|
||||||
@@ -547,7 +547,7 @@ function AI_CARGO:onafterUnloaded( Carrier, From, Event, To, Cargo, CarrierUnit,
|
|||||||
for _, CarrierUnit in pairs( Carrier:GetUnits() ) do
|
for _, CarrierUnit in pairs( Carrier:GetUnits() ) do
|
||||||
local CarrierUnit = CarrierUnit -- Wrapper.Unit#UNIT
|
local CarrierUnit = CarrierUnit -- Wrapper.Unit#UNIT
|
||||||
local IsEmpty = CarrierUnit:IsCargoEmpty()
|
local IsEmpty = CarrierUnit:IsCargoEmpty()
|
||||||
self:I({ IsEmpty = IsEmpty })
|
self:T({ IsEmpty = IsEmpty })
|
||||||
if not IsEmpty then
|
if not IsEmpty then
|
||||||
AllUnloaded = false
|
AllUnloaded = false
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
-- @image AI_Cargo_Dispatcher.JPG
|
-- @image AI_Cargo_Dispatcher.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type AI_CARGO_DISPATCHER
|
-- @type AI_CARGO_DISPATCHER
|
||||||
-- @field Core.Set#SET_GROUP CarrierSet The set of @{Wrapper.Group#GROUP} objects of carriers that will transport the cargo.
|
-- @field Core.Set#SET_GROUP CarrierSet The set of @{Wrapper.Group#GROUP} objects of carriers that will transport the cargo.
|
||||||
-- @field Core.Set#SET_CARGO CargoSet The set of @{Cargo.Cargo#CARGO} objects, which can be CARGO_GROUP, CARGO_CRATE, CARGO_SLINGLOAD objects.
|
-- @field Core.Set#SET_CARGO CargoSet The set of @{Cargo.Cargo#CARGO} objects, which can be CARGO_GROUP, CARGO_CRATE, CARGO_SLINGLOAD objects.
|
||||||
-- @field Core.Zone#SET_ZONE PickupZoneSet The set of pickup zones, which are used to where the cargo can be picked up by the carriers. If nil, then cargo can be picked up everywhere.
|
-- @field Core.Zone#SET_ZONE PickupZoneSet The set of pickup zones, which are used to where the cargo can be picked up by the carriers. If nil, then cargo can be picked up everywhere.
|
||||||
@@ -1161,7 +1161,7 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
|
|||||||
else
|
else
|
||||||
local text=string.format("WARNING: Cargo %s is too heavy to be loaded into transport. Cargo weight %.1f > %.1f load capacity of carrier %s.",
|
local text=string.format("WARNING: Cargo %s is too heavy to be loaded into transport. Cargo weight %.1f > %.1f load capacity of carrier %s.",
|
||||||
tostring(Cargo:GetName()), Cargo:GetWeight(), LargestLoadCapacity, tostring(Carrier:GetName()))
|
tostring(Cargo:GetName()), Cargo:GetWeight(), LargestLoadCapacity, tostring(Carrier:GetName()))
|
||||||
self:I(text)
|
self:T(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -556,7 +556,7 @@ function AI_ESCORT:SetFlightMenuFormation( Formation )
|
|||||||
|
|
||||||
if MenuFormation then
|
if MenuFormation then
|
||||||
local Arguments = MenuFormation.Arguments
|
local Arguments = MenuFormation.Arguments
|
||||||
--self:I({Arguments=unpack(Arguments)})
|
--self:T({Arguments=unpack(Arguments)})
|
||||||
local FlightMenuFormation = MENU_GROUP:New( self.PlayerGroup, "Formation", self.MainMenu )
|
local FlightMenuFormation = MENU_GROUP:New( self.PlayerGroup, "Formation", self.MainMenu )
|
||||||
local MenuFlightFormationID = MENU_GROUP_COMMAND:New( self.PlayerGroup, Formation, FlightMenuFormation,
|
local MenuFlightFormationID = MENU_GROUP_COMMAND:New( self.PlayerGroup, Formation, FlightMenuFormation,
|
||||||
function ( self, Formation, ... )
|
function ( self, Formation, ... )
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
-- @image MOOSE.JPG
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type AI_ESCORT_DISPATCHER
|
-- @type AI_ESCORT_DISPATCHER
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ AI_ESCORT_DISPATCHER = {
|
|||||||
ClassName = "AI_ESCORT_DISPATCHER",
|
ClassName = "AI_ESCORT_DISPATCHER",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @field #list
|
-- @field #list
|
||||||
AI_ESCORT_DISPATCHER.AI_Escorts = {}
|
AI_ESCORT_DISPATCHER.AI_Escorts = {}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ function AI_ESCORT_DISPATCHER:onafterStart( From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_ESCORT_DISPATCHER self
|
-- @param #AI_ESCORT_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_ESCORT_DISPATCHER:OnEventExit( EventData )
|
function AI_ESCORT_DISPATCHER:OnEventExit( EventData )
|
||||||
|
|
||||||
@@ -110,11 +110,11 @@ function AI_ESCORT_DISPATCHER:OnEventExit( EventData )
|
|||||||
local PlayerGroup = EventData.IniGroup
|
local PlayerGroup = EventData.IniGroup
|
||||||
local PlayerUnit = EventData.IniUnit
|
local PlayerUnit = EventData.IniUnit
|
||||||
|
|
||||||
self:I({EscortAirbase= self.EscortAirbase } )
|
self:T({EscortAirbase= self.EscortAirbase } )
|
||||||
self:I({PlayerGroupName = PlayerGroupName } )
|
self:T({PlayerGroupName = PlayerGroupName } )
|
||||||
self:I({PlayerGroup = PlayerGroup})
|
self:T({PlayerGroup = PlayerGroup})
|
||||||
self:I({FirstGroup = self.CarrierSet:GetFirst()})
|
self:T({FirstGroup = self.CarrierSet:GetFirst()})
|
||||||
self:I({FindGroup = self.CarrierSet:FindGroup( PlayerGroupName )})
|
self:T({FindGroup = self.CarrierSet:FindGroup( PlayerGroupName )})
|
||||||
|
|
||||||
if self.CarrierSet:FindGroup( PlayerGroupName ) then
|
if self.CarrierSet:FindGroup( PlayerGroupName ) then
|
||||||
if self.AI_Escorts[PlayerGroupName] then
|
if self.AI_Escorts[PlayerGroupName] then
|
||||||
@@ -125,7 +125,7 @@ function AI_ESCORT_DISPATCHER:OnEventExit( EventData )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_ESCORT_DISPATCHER self
|
-- @param #AI_ESCORT_DISPATCHER self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_ESCORT_DISPATCHER:OnEventBirth( EventData )
|
function AI_ESCORT_DISPATCHER:OnEventBirth( EventData )
|
||||||
|
|
||||||
@@ -133,17 +133,17 @@ function AI_ESCORT_DISPATCHER:OnEventBirth( EventData )
|
|||||||
local PlayerGroup = EventData.IniGroup
|
local PlayerGroup = EventData.IniGroup
|
||||||
local PlayerUnit = EventData.IniUnit
|
local PlayerUnit = EventData.IniUnit
|
||||||
|
|
||||||
self:I({EscortAirbase= self.EscortAirbase } )
|
self:T({EscortAirbase= self.EscortAirbase } )
|
||||||
self:I({PlayerGroupName = PlayerGroupName } )
|
self:T({PlayerGroupName = PlayerGroupName } )
|
||||||
self:I({PlayerGroup = PlayerGroup})
|
self:T({PlayerGroup = PlayerGroup})
|
||||||
self:I({FirstGroup = self.CarrierSet:GetFirst()})
|
self:T({FirstGroup = self.CarrierSet:GetFirst()})
|
||||||
self:I({FindGroup = self.CarrierSet:FindGroup( PlayerGroupName )})
|
self:T({FindGroup = self.CarrierSet:FindGroup( PlayerGroupName )})
|
||||||
|
|
||||||
if self.CarrierSet:FindGroup( PlayerGroupName ) then
|
if self.CarrierSet:FindGroup( PlayerGroupName ) then
|
||||||
if not self.AI_Escorts[PlayerGroupName] then
|
if not self.AI_Escorts[PlayerGroupName] then
|
||||||
local LeaderUnit = PlayerUnit
|
local LeaderUnit = PlayerUnit
|
||||||
local EscortGroup = self.EscortSpawn:SpawnAtAirbase( self.EscortAirbase, SPAWN.Takeoff.Hot )
|
local EscortGroup = self.EscortSpawn:SpawnAtAirbase( self.EscortAirbase, SPAWN.Takeoff.Hot )
|
||||||
self:I({EscortGroup = EscortGroup})
|
self:T({EscortGroup = EscortGroup})
|
||||||
|
|
||||||
self:ScheduleOnce( 1,
|
self:ScheduleOnce( 1,
|
||||||
function( EscortGroup )
|
function( EscortGroup )
|
||||||
|
|||||||
@@ -652,15 +652,15 @@ function AI_PATROL_ZONE:onafterStart( Controllable, From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
--- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable+
|
||||||
function AI_PATROL_ZONE:onbeforeDetect( Controllable, From, Event, To )
|
function AI_PATROL_ZONE:onbeforeDetect( Controllable, From, Event, To )
|
||||||
|
|
||||||
return self.DetectOn and self.DetectActivated
|
return self.DetectOn and self.DetectActivated
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
--- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||||
function AI_PATROL_ZONE:onafterDetect( Controllable, From, Event, To )
|
function AI_PATROL_ZONE:onafterDetect( Controllable, From, Event, To )
|
||||||
|
|
||||||
local Detected = false
|
local Detected = false
|
||||||
@@ -705,7 +705,7 @@ function AI_PATROL_ZONE:onafterDetect( Controllable, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param Wrapper.Controllable#CONTROLLABLE AIControllable
|
-- @param Wrapper.Controllable#CONTROLLABLE AIControllable
|
||||||
-- This static method is called from the route path within the last task at the last waypoint of the Controllable.
|
-- This static method is called from the route path within the last task at the last waypoint of the Controllable.
|
||||||
-- Note that this method is required, as triggers the next route when patrolling for the Controllable.
|
-- Note that this method is required, as triggers the next route when patrolling for the Controllable.
|
||||||
function AI_PATROL_ZONE:_NewPatrolRoute( AIControllable )
|
function AI_PATROL_ZONE:_NewPatrolRoute( AIControllable )
|
||||||
@@ -822,13 +822,13 @@ function AI_PATROL_ZONE:onafterRoute( Controllable, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
function AI_PATROL_ZONE:onbeforeStatus()
|
function AI_PATROL_ZONE:onbeforeStatus()
|
||||||
|
|
||||||
return self.CheckStatus
|
return self.CheckStatus
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
function AI_PATROL_ZONE:onafterStatus()
|
function AI_PATROL_ZONE:onafterStatus()
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
@@ -838,7 +838,7 @@ function AI_PATROL_ZONE:onafterStatus()
|
|||||||
|
|
||||||
local Fuel = self.Controllable:GetFuelMin()
|
local Fuel = self.Controllable:GetFuelMin()
|
||||||
if Fuel < self.PatrolFuelThresholdPercentage then
|
if Fuel < self.PatrolFuelThresholdPercentage then
|
||||||
self:I( self.Controllable:GetName() .. " is out of fuel:" .. Fuel .. ", RTB!" )
|
self:T( self.Controllable:GetName() .. " is out of fuel:" .. Fuel .. ", RTB!" )
|
||||||
local OldAIControllable = self.Controllable
|
local OldAIControllable = self.Controllable
|
||||||
|
|
||||||
local OrbitTask = OldAIControllable:TaskOrbitCircle( math.random( self.PatrolFloorAltitude, self.PatrolCeilingAltitude ), self.PatrolMinSpeed )
|
local OrbitTask = OldAIControllable:TaskOrbitCircle( math.random( self.PatrolFloorAltitude, self.PatrolCeilingAltitude ), self.PatrolMinSpeed )
|
||||||
@@ -852,7 +852,7 @@ function AI_PATROL_ZONE:onafterStatus()
|
|||||||
-- TODO: Check GROUP damage function.
|
-- TODO: Check GROUP damage function.
|
||||||
local Damage = self.Controllable:GetLife()
|
local Damage = self.Controllable:GetLife()
|
||||||
if Damage <= self.PatrolDamageThreshold then
|
if Damage <= self.PatrolDamageThreshold then
|
||||||
self:I( self.Controllable:GetName() .. " is damaged:" .. Damage .. ", RTB!" )
|
self:T( self.Controllable:GetName() .. " is damaged:" .. Damage .. ", RTB!" )
|
||||||
RTB = true
|
RTB = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -864,7 +864,7 @@ function AI_PATROL_ZONE:onafterStatus()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
function AI_PATROL_ZONE:onafterRTB()
|
function AI_PATROL_ZONE:onafterRTB()
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
@@ -903,13 +903,13 @@ function AI_PATROL_ZONE:onafterRTB()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
function AI_PATROL_ZONE:onafterDead()
|
function AI_PATROL_ZONE:onafterDead()
|
||||||
self:SetDetectionOff()
|
self:SetDetectionOff()
|
||||||
self:SetStatusOff()
|
self:SetStatusOff()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_PATROL_ZONE:OnCrash( EventData )
|
function AI_PATROL_ZONE:OnCrash( EventData )
|
||||||
|
|
||||||
@@ -920,7 +920,7 @@ function AI_PATROL_ZONE:OnCrash( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_PATROL_ZONE:OnEjection( EventData )
|
function AI_PATROL_ZONE:OnEjection( EventData )
|
||||||
|
|
||||||
@@ -929,7 +929,7 @@ function AI_PATROL_ZONE:OnEjection( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_PATROL_ZONE self
|
-- @param #AI_PATROL_ZONE self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function AI_PATROL_ZONE:OnPilotDead( EventData )
|
function AI_PATROL_ZONE:OnPilotDead( EventData )
|
||||||
|
|
||||||
|
|||||||
@@ -1150,13 +1150,22 @@ end
|
|||||||
-- @return #string Text
|
-- @return #string Text
|
||||||
function BASE:_Serialize(Arguments)
|
function BASE:_Serialize(Arguments)
|
||||||
local text = UTILS.PrintTableToLog({Arguments}, 0, true)
|
local text = UTILS.PrintTableToLog({Arguments}, 0, true)
|
||||||
text = string.gsub(text,"\n","")
|
text = string.gsub(text,"(\n+)","")
|
||||||
text = string.gsub(text,"%(%(","%(")
|
text = string.gsub(text,"%(%(","%(")
|
||||||
text = string.gsub(text,"%)%)","%)")
|
text = string.gsub(text,"%)%)","%)")
|
||||||
text = string.gsub(text,"(%s+)","")
|
text = string.gsub(text,"(%s+)"," ")
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
----- (Internal) Serialize arguments
|
||||||
|
---- @param #BASE self
|
||||||
|
---- @param #table Arguments
|
||||||
|
---- @return #string Text
|
||||||
|
--function BASE:_Serialize(Arguments)
|
||||||
|
-- local text=UTILS.BasicSerialize(Arguments)
|
||||||
|
-- return text
|
||||||
|
--end
|
||||||
|
|
||||||
--- Trace a function call. This function is private.
|
--- Trace a function call. This function is private.
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Arguments A #table or any field.
|
-- @param Arguments A #table or any field.
|
||||||
|
|||||||
@@ -38,11 +38,13 @@
|
|||||||
-- @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 @{Wrapper.Controllable#CONTROLLABLE} that will receive radio capabilities.
|
-- @field Wrapper.Controllable#CONTROLLABLE Positionable The @{Wrapper.Controllable#CONTROLLABLE} that will receive radio capabilities.
|
||||||
|
-- @field #number UniqueName Counter to make the unique naming work.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
BEACON = {
|
BEACON = {
|
||||||
ClassName = "BEACON",
|
ClassName = "BEACON",
|
||||||
Positionable = nil,
|
Positionable = nil,
|
||||||
name = nil,
|
name = nil,
|
||||||
|
UniqueName = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Beacon types supported by DCS.
|
--- Beacon types supported by DCS.
|
||||||
@@ -384,7 +386,9 @@ end
|
|||||||
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
|
||||||
|
|
||||||
|
Modulation = Modulation or radio.modulation.AM
|
||||||
|
|
||||||
-- 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
|
||||||
@@ -395,7 +399,7 @@ function BEACON:RadioBeacon(FileName, Frequency, Modulation, Power, BeaconDurati
|
|||||||
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
|
||||||
@@ -421,7 +425,9 @@ function BEACON:RadioBeacon(FileName, Frequency, Modulation, Power, BeaconDurati
|
|||||||
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))
|
BEACON.UniqueName = BEACON.UniqueName + 1
|
||||||
|
self.BeaconName = "MooseBeacon"..tostring(BEACON.UniqueName)
|
||||||
|
trigger.action.radioTransmission(FileName, self.Positionable:GetPositionVec3(), Modulation, true, Frequency, Power, self.BeaconName)
|
||||||
|
|
||||||
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,
|
SCHEDULER:New( nil,
|
||||||
@@ -429,7 +435,8 @@ function BEACON:RadioBeacon(FileName, Frequency, Modulation, Power, BeaconDurati
|
|||||||
self:StopRadioBeacon()
|
self:StopRadioBeacon()
|
||||||
end, {}, BeaconDuration)
|
end, {}, BeaconDuration)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Stops the Radio Beacon
|
--- Stops the Radio Beacon
|
||||||
@@ -438,7 +445,7 @@ end
|
|||||||
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(self.BeaconName)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
--
|
--
|
||||||
-- @module Core.ClientMenu
|
-- @module Core.ClientMenu
|
||||||
-- @image Core_Menu.JPG
|
-- @image Core_Menu.JPG
|
||||||
-- last change: Oct 2023
|
-- last change: May 2024
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
@@ -51,6 +51,7 @@
|
|||||||
-- @field #boolean Generic
|
-- @field #boolean Generic
|
||||||
-- @field #boolean debug
|
-- @field #boolean debug
|
||||||
-- @field #CLIENTMENUMANAGER Controller
|
-- @field #CLIENTMENUMANAGER Controller
|
||||||
|
-- @field #active boolean
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -58,7 +59,7 @@
|
|||||||
CLIENTMENU = {
|
CLIENTMENU = {
|
||||||
ClassName = "CLIENTMENUE",
|
ClassName = "CLIENTMENUE",
|
||||||
lid = "",
|
lid = "",
|
||||||
version = "0.1.1",
|
version = "0.1.2",
|
||||||
name = nil,
|
name = nil,
|
||||||
path = nil,
|
path = nil,
|
||||||
group = nil,
|
group = nil,
|
||||||
@@ -70,6 +71,7 @@ CLIENTMENU = {
|
|||||||
debug = false,
|
debug = false,
|
||||||
Controller = nil,
|
Controller = nil,
|
||||||
groupname = nil,
|
groupname = nil,
|
||||||
|
active = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -114,7 +116,7 @@ function CLIENTMENU:NewEntry(Client,Text,Parent,Function,...)
|
|||||||
if self.Functionargs and self.debug then
|
if self.Functionargs and self.debug then
|
||||||
self:T({"Functionargs",self.Functionargs})
|
self:T({"Functionargs",self.Functionargs})
|
||||||
end
|
end
|
||||||
if not self.Generic then
|
if not self.Generic and self.active == false then
|
||||||
if Function ~= nil then
|
if Function ~= nil then
|
||||||
local ErrorHandler = function( errmsg )
|
local ErrorHandler = function( errmsg )
|
||||||
env.info( "MOOSE Error in CLIENTMENU COMMAND function: " .. errmsg )
|
env.info( "MOOSE Error in CLIENTMENU COMMAND function: " .. errmsg )
|
||||||
@@ -133,8 +135,10 @@ function CLIENTMENU:NewEntry(Client,Text,Parent,Function,...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.path = missionCommands.addCommandForGroup(self.GroupID,Text,self.parentpath, self.CallHandler)
|
self.path = missionCommands.addCommandForGroup(self.GroupID,Text,self.parentpath, self.CallHandler)
|
||||||
|
self.active = true
|
||||||
else
|
else
|
||||||
self.path = missionCommands.addSubMenuForGroup(self.GroupID,Text,self.parentpath)
|
self.path = missionCommands.addSubMenuForGroup(self.GroupID,Text,self.parentpath)
|
||||||
|
self.active = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if self.parentpath then
|
if self.parentpath then
|
||||||
@@ -200,6 +204,7 @@ function CLIENTMENU:RemoveF10()
|
|||||||
if not status then
|
if not status then
|
||||||
self:I(string.format("**** Error Removing Menu Entry %s for %s!",tostring(self.name),self.groupname))
|
self:I(string.format("**** Error Removing Menu Entry %s for %s!",tostring(self.name),self.groupname))
|
||||||
end
|
end
|
||||||
|
self.active = false
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -412,7 +417,7 @@ end
|
|||||||
CLIENTMENUMANAGER = {
|
CLIENTMENUMANAGER = {
|
||||||
ClassName = "CLIENTMENUMANAGER",
|
ClassName = "CLIENTMENUMANAGER",
|
||||||
lid = "",
|
lid = "",
|
||||||
version = "0.1.4",
|
version = "0.1.5a",
|
||||||
name = nil,
|
name = nil,
|
||||||
clientset = nil,
|
clientset = nil,
|
||||||
menutree = {},
|
menutree = {},
|
||||||
@@ -676,6 +681,7 @@ end
|
|||||||
function CLIENTMENUMANAGER:Propagate(Client)
|
function CLIENTMENUMANAGER:Propagate(Client)
|
||||||
self:T(self.lid.."Propagate")
|
self:T(self.lid.."Propagate")
|
||||||
--self:I(UTILS.PrintTableToLog(Client,1))
|
--self:I(UTILS.PrintTableToLog(Client,1))
|
||||||
|
local knownunits = {} -- track so we can ID multi seated
|
||||||
local Set = self.clientset.Set
|
local Set = self.clientset.Set
|
||||||
if Client then
|
if Client then
|
||||||
Set = {Client}
|
Set = {Client}
|
||||||
@@ -684,28 +690,36 @@ function CLIENTMENUMANAGER:Propagate(Client)
|
|||||||
for _,_client in pairs(Set) do
|
for _,_client in pairs(Set) do
|
||||||
local client = _client -- Wrapper.Client#CLIENT
|
local client = _client -- Wrapper.Client#CLIENT
|
||||||
if client and client:IsAlive() then
|
if client and client:IsAlive() then
|
||||||
|
local playerunit = client:GetName()
|
||||||
|
--local playergroup = client:GetGroup()
|
||||||
local playername = client:GetPlayerName() or "none"
|
local playername = client:GetPlayerName() or "none"
|
||||||
if not self.playertree[playername] then
|
if not knownunits[playerunit] then
|
||||||
self.playertree[playername] = {}
|
knownunits[playerunit] = true
|
||||||
end
|
else
|
||||||
for level,branch in pairs (self.menutree) do
|
self:I("Player in multi seat unit: "..playername)
|
||||||
self:T("Building branch:" .. level)
|
break -- multi seat already build
|
||||||
for _,leaf in pairs(branch) do
|
end
|
||||||
self:T("Building leaf:" .. leaf)
|
if not self.playertree[playername] then
|
||||||
local entry = self:FindEntryByUUID(leaf)
|
self.playertree[playername] = {}
|
||||||
if entry then
|
end
|
||||||
self:T("Found generic entry:" .. entry.UUID)
|
for level,branch in pairs (self.menutree) do
|
||||||
local parent = nil
|
self:T("Building branch:" .. level)
|
||||||
if entry.Parent and entry.Parent.UUID then
|
for _,leaf in pairs(branch) do
|
||||||
parent = self.playertree[playername][entry.Parent.UUID] or self:FindEntryByUUID(entry.Parent.UUID)
|
self:T("Building leaf:" .. leaf)
|
||||||
end
|
local entry = self:FindEntryByUUID(leaf)
|
||||||
self.playertree[playername][entry.UUID] = CLIENTMENU:NewEntry(client,entry.name,parent,entry.Function,unpack(entry.Functionargs))
|
if entry then
|
||||||
self.playertree[playername][entry.UUID].Once = entry.Once
|
self:T("Found generic entry:" .. entry.UUID)
|
||||||
else
|
local parent = nil
|
||||||
self:T("NO generic entry for:" .. leaf)
|
if entry.Parent and entry.Parent.UUID then
|
||||||
end
|
parent = self.playertree[playername][entry.Parent.UUID] or self:FindEntryByUUID(entry.Parent.UUID)
|
||||||
end
|
end
|
||||||
|
self.playertree[playername][entry.UUID] = CLIENTMENU:NewEntry(client,entry.name,parent,entry.Function,unpack(entry.Functionargs))
|
||||||
|
self.playertree[playername][entry.UUID].Once = entry.Once
|
||||||
|
else
|
||||||
|
self:T("NO generic entry for:" .. leaf)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -719,6 +733,7 @@ end
|
|||||||
function CLIENTMENUMANAGER:AddEntry(Entry,Client)
|
function CLIENTMENUMANAGER:AddEntry(Entry,Client)
|
||||||
self:T(self.lid.."AddEntry")
|
self:T(self.lid.."AddEntry")
|
||||||
local Set = self.clientset.Set
|
local Set = self.clientset.Set
|
||||||
|
local knownunits = {}
|
||||||
if Client then
|
if Client then
|
||||||
Set = {Client}
|
Set = {Client}
|
||||||
end
|
end
|
||||||
@@ -726,6 +741,13 @@ function CLIENTMENUMANAGER:AddEntry(Entry,Client)
|
|||||||
local client = _client -- Wrapper.Client#CLIENT
|
local client = _client -- Wrapper.Client#CLIENT
|
||||||
if client and client:IsAlive() then
|
if client and client:IsAlive() then
|
||||||
local playername = client:GetPlayerName()
|
local playername = client:GetPlayerName()
|
||||||
|
local unitname = client:GetName()
|
||||||
|
if not knownunits[unitname] then
|
||||||
|
knownunits[unitname] = true
|
||||||
|
else
|
||||||
|
self:I("Player in multi seat unit: "..playername)
|
||||||
|
break
|
||||||
|
end
|
||||||
if Entry then
|
if Entry then
|
||||||
self:T("Adding generic entry:" .. Entry.UUID)
|
self:T("Adding generic entry:" .. Entry.UUID)
|
||||||
local parent = nil
|
local parent = nil
|
||||||
|
|||||||
@@ -1009,7 +1009,7 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, Category
|
|||||||
self.Templates.Groups[GroupTemplateName].CategoryID = CategoryID
|
self.Templates.Groups[GroupTemplateName].CategoryID = CategoryID
|
||||||
self.Templates.Groups[GroupTemplateName].CoalitionID = CoalitionSide
|
self.Templates.Groups[GroupTemplateName].CoalitionID = CoalitionSide
|
||||||
self.Templates.Groups[GroupTemplateName].CountryID = CountryID
|
self.Templates.Groups[GroupTemplateName].CountryID = CountryID
|
||||||
|
|
||||||
local UnitNames = {}
|
local UnitNames = {}
|
||||||
|
|
||||||
for unit_num, UnitTemplate in pairs( GroupTemplate.units ) do
|
for unit_num, UnitTemplate in pairs( GroupTemplate.units ) do
|
||||||
@@ -1074,7 +1074,7 @@ end
|
|||||||
-- @param #string unitname Name of the associated unit.
|
-- @param #string unitname Name of the associated unit.
|
||||||
-- @return #number Octal
|
-- @return #number Octal
|
||||||
function DATABASE:GetNextSTN(octal,unitname)
|
function DATABASE:GetNextSTN(octal,unitname)
|
||||||
local first = UTILS.OctalToDecimal(octal)
|
local first = UTILS.OctalToDecimal(octal) or 0
|
||||||
if self.STNS[first] == unitname then return octal end
|
if self.STNS[first] == unitname then return octal end
|
||||||
local nextoctal = 77777
|
local nextoctal = 77777
|
||||||
local found = false
|
local found = false
|
||||||
@@ -1111,7 +1111,7 @@ end
|
|||||||
-- @param #string unitname Name of the associated unit.
|
-- @param #string unitname Name of the associated unit.
|
||||||
-- @return #number Octal
|
-- @return #number Octal
|
||||||
function DATABASE:GetNextSADL(octal,unitname)
|
function DATABASE:GetNextSADL(octal,unitname)
|
||||||
local first = UTILS.OctalToDecimal(octal)
|
local first = UTILS.OctalToDecimal(octal) or 0
|
||||||
if self.SADL[first] == unitname then return octal end
|
if self.SADL[first] == unitname then return octal end
|
||||||
local nextoctal = 7777
|
local nextoctal = 7777
|
||||||
local found = false
|
local found = false
|
||||||
@@ -1147,10 +1147,13 @@ end
|
|||||||
-- @param #string GroupName Group name.
|
-- @param #string GroupName Group name.
|
||||||
-- @return #table Group template table.
|
-- @return #table Group template table.
|
||||||
function DATABASE:GetGroupTemplate( GroupName )
|
function DATABASE:GetGroupTemplate( GroupName )
|
||||||
local GroupTemplate = self.Templates.Groups[GroupName].Template
|
local GroupTemplate=nil
|
||||||
GroupTemplate.SpawnCoalitionID = self.Templates.Groups[GroupName].CoalitionID
|
if self.Templates.Groups[GroupName] then
|
||||||
GroupTemplate.SpawnCategoryID = self.Templates.Groups[GroupName].CategoryID
|
GroupTemplate = self.Templates.Groups[GroupName].Template
|
||||||
GroupTemplate.SpawnCountryID = self.Templates.Groups[GroupName].CountryID
|
GroupTemplate.SpawnCoalitionID = self.Templates.Groups[GroupName].CoalitionID
|
||||||
|
GroupTemplate.SpawnCategoryID = self.Templates.Groups[GroupName].CategoryID
|
||||||
|
GroupTemplate.SpawnCountryID = self.Templates.Groups[GroupName].CountryID
|
||||||
|
end
|
||||||
return GroupTemplate
|
return GroupTemplate
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1685,7 +1688,7 @@ function DATABASE:_EventOnPlayerLeaveUnit( Event )
|
|||||||
if Event.IniObjectCategory == 1 then
|
if Event.IniObjectCategory == 1 then
|
||||||
|
|
||||||
-- Try to get the player name. This can be buggy for multicrew aircraft!
|
-- Try to get the player name. This can be buggy for multicrew aircraft!
|
||||||
local PlayerName = Event.IniUnit:GetPlayerName() or FindPlayerName(Event.IniUnitName)
|
local PlayerName = Event.IniPlayerName or Event.IniUnit:GetPlayerName() or FindPlayerName(Event.IniUnitName)
|
||||||
|
|
||||||
if PlayerName then
|
if PlayerName then
|
||||||
|
|
||||||
@@ -2081,7 +2084,7 @@ function DATABASE:_RegisterTemplates()
|
|||||||
for group_num, Template in pairs(obj_type_data.group) do
|
for group_num, Template in pairs(obj_type_data.group) do
|
||||||
|
|
||||||
if obj_type_name ~= "static" and Template and Template.units and type(Template.units) == 'table' then --making sure again- this is a valid group
|
if obj_type_name ~= "static" and Template and Template.units and type(Template.units) == 'table' then --making sure again- this is a valid group
|
||||||
|
|
||||||
self:_RegisterGroupTemplate(Template, CoalitionSide, _DATABASECategory[string.lower(CategoryName)], CountryID)
|
self:_RegisterGroupTemplate(Template, CoalitionSide, _DATABASECategory[string.lower(CategoryName)], CountryID)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1301,7 +1301,7 @@ function EVENT:onEvent( Event )
|
|||||||
-- STATIC
|
-- STATIC
|
||||||
---
|
---
|
||||||
Event.TgtDCSUnit = Event.target
|
Event.TgtDCSUnit = Event.target
|
||||||
if Event.target:isExist() and Event.id ~= 33 then -- leave out ejected seat object
|
if Event.target.isExist and Event.target:isExist() and Event.id ~= 33 then -- leave out ejected seat object, check that isExist exists (Kiowa Hellfire issue, Special K)
|
||||||
Event.TgtDCSUnitName = Event.TgtDCSUnit:getName()
|
Event.TgtDCSUnitName = Event.TgtDCSUnit:getName()
|
||||||
-- Workaround for borked target info on cruise missiles
|
-- Workaround for borked target info on cruise missiles
|
||||||
if Event.TgtDCSUnitName and Event.TgtDCSUnitName ~= "" then
|
if Event.TgtDCSUnitName and Event.TgtDCSUnitName ~= "" then
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -395,29 +395,36 @@ end
|
|||||||
--- Sends a MESSAGE to all players.
|
--- Sends a MESSAGE to all players.
|
||||||
-- @param #MESSAGE self
|
-- @param #MESSAGE self
|
||||||
-- @param Core.Settings#Settings Settings (Optional) Settings for message display.
|
-- @param Core.Settings#Settings Settings (Optional) Settings for message display.
|
||||||
-- @return #MESSAGE
|
-- @param #number Delay (Optional) Delay in seconds before the message is send. Default instantly (`nil`).
|
||||||
|
-- @return #MESSAGE self
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Send a message created to all players.
|
-- -- Send a message created to all players.
|
||||||
-- MessageAll = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25 ):ToAll()
|
-- MessageAll = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25 ):ToAll()
|
||||||
-- or
|
-- or
|
||||||
-- MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25 ):ToAll()
|
-- MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25 ):ToAll()
|
||||||
-- or
|
-- or
|
||||||
-- MessageAll = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25 )
|
-- MessageAll = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25 )
|
||||||
-- MessageAll:ToAll()
|
-- MessageAll:ToAll()
|
||||||
--
|
--
|
||||||
function MESSAGE:ToAll( Settings )
|
function MESSAGE:ToAll( Settings, Delay )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
if self.MessageType then
|
if Delay and Delay>0 then
|
||||||
local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS
|
self:ScheduleOnce(Delay, MESSAGE.ToAll, self, Settings, 0)
|
||||||
self.MessageDuration = Settings:GetMessageTime( self.MessageType )
|
else
|
||||||
self.MessageCategory = "" -- self.MessageType .. ": "
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.MessageDuration ~= 0 then
|
if self.MessageType then
|
||||||
self:T( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ) .. " / " .. self.MessageDuration )
|
local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS
|
||||||
trigger.action.outText( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen )
|
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.outText( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen )
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -509,10 +516,10 @@ function MESSAGE.SetMSRS(PathToSRS,Port,PathToCredentials,Frequency,Modulation,G
|
|||||||
end
|
end
|
||||||
|
|
||||||
_MESSAGESRS.label = Label or MSRS.Label or "MESSAGE"
|
_MESSAGESRS.label = Label or MSRS.Label or "MESSAGE"
|
||||||
_MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE")
|
_MESSAGESRS.MSRS:SetLabel(_MESSAGESRS.label)
|
||||||
|
|
||||||
_MESSAGESRS.port = Port or MSRS.port or 5002
|
_MESSAGESRS.port = Port or MSRS.port or 5002
|
||||||
_MESSAGESRS.MSRS:SetPort(Port or 5002)
|
_MESSAGESRS.MSRS:SetPort(_MESSAGESRS.port)
|
||||||
|
|
||||||
_MESSAGESRS.volume = Volume or MSRS.volume or 1
|
_MESSAGESRS.volume = Volume or MSRS.volume or 1
|
||||||
_MESSAGESRS.MSRS:SetVolume(_MESSAGESRS.volume)
|
_MESSAGESRS.MSRS:SetVolume(_MESSAGESRS.volume)
|
||||||
|
|||||||
@@ -1516,6 +1516,7 @@ do
|
|||||||
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
|
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
|
||||||
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
|
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
|
||||||
self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash )
|
self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash )
|
||||||
|
self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnDeadOrCrash )
|
||||||
if self.Filter.Zones then
|
if self.Filter.Zones then
|
||||||
self.ZoneTimer = TIMER:New(self._ContinousZoneFilter,self)
|
self.ZoneTimer = TIMER:New(self._ContinousZoneFilter,self)
|
||||||
local timing = self.ZoneTimerInterval or 30
|
local timing = self.ZoneTimerInterval or 30
|
||||||
@@ -3477,7 +3478,7 @@ do -- SET_STATIC
|
|||||||
|
|
||||||
--- Add STATIC(s) to SET_STATIC.
|
--- Add STATIC(s) to SET_STATIC.
|
||||||
-- @param #SET_STATIC self
|
-- @param #SET_STATIC self
|
||||||
-- @param #string AddStatic A single STATIC.
|
-- @param Wrapper.Static#STATIC AddStatic A single STATIC.
|
||||||
-- @return #SET_STATIC self
|
-- @return #SET_STATIC self
|
||||||
function SET_STATIC:AddStatic( AddStatic )
|
function SET_STATIC:AddStatic( AddStatic )
|
||||||
self:F2( AddStatic:GetName() )
|
self:F2( AddStatic:GetName() )
|
||||||
@@ -4388,8 +4389,8 @@ do -- SET_CLIENT
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Builds a set of CLIENTs that contain the given string in their unit/pilot name.
|
--- Builds a set of CLIENTs that contain the given string in their **unit/pilot** name and **NOT** the group name!
|
||||||
-- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all clients that **contain** the string.
|
-- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all clients that **contain** the string. Pattern matching applies.
|
||||||
-- @param #SET_CLIENT self
|
-- @param #SET_CLIENT self
|
||||||
-- @param #string Prefixes The string pattern(s) that needs to be contained in the unit/pilot name. Can also be passed as a `#table` of strings.
|
-- @param #string Prefixes The string pattern(s) that needs to be contained in the unit/pilot name. Can also be passed as a `#table` of strings.
|
||||||
-- @return #SET_CLIENT self
|
-- @return #SET_CLIENT self
|
||||||
|
|||||||
@@ -202,19 +202,19 @@
|
|||||||
--
|
--
|
||||||
-- ### Link-16 Datalink STN and SADL IDs (limited at the moment to F15/16/18/AWACS/Tanker/B1B, but not the F15E for clients, SADL A10CII only)
|
-- ### Link-16 Datalink STN and SADL IDs (limited at the moment to F15/16/18/AWACS/Tanker/B1B, but not the F15E for clients, SADL A10CII only)
|
||||||
--
|
--
|
||||||
-- *{#SPAWN.InitSTN}(): Set the STN of the first unit in the group. All other units will have consecutive STNs, provided they have not been used yet.
|
-- * @{#SPAWN.InitSTN}(): Set the STN of the first unit in the group. All other units will have consecutive STNs, provided they have not been used yet.
|
||||||
-- *{#SPAWN.InitSADL}(): Set the SADL of the first unit in the group. All other units will have consecutive SADLs, provided they have not been used yet.
|
-- * @{#SPAWN.InitSADL}(): Set the SADL of the first unit in the group. All other units will have consecutive SADLs, provided they have not been used yet.
|
||||||
--
|
--
|
||||||
-- ### Callsigns
|
-- ### Callsigns
|
||||||
--
|
--
|
||||||
-- *{#SPAWN.InitRandomizeCallsign}(): Set a random callsign name per spawn.
|
-- * @{#SPAWN.InitRandomizeCallsign}(): Set a random callsign name per spawn.
|
||||||
-- *{#SPAWN.SpawnInitCallSign}(): Set a specific callsign for a spawned group.
|
-- * @{#SPAWN.SpawnInitCallSign}(): Set a specific callsign for a spawned group.
|
||||||
--
|
--
|
||||||
-- ### Speed
|
-- ### Speed
|
||||||
--
|
--
|
||||||
-- *{#SPAWN.InitSpeedMps}(): Set the initial speed on spawning in meters per second.
|
-- * @{#SPAWN.InitSpeedMps}(): Set the initial speed on spawning in meters per second.
|
||||||
-- *{#SPAWN.InitSpeedKph}(): Set the initial speed on spawning in kilometers per hour.
|
-- * @{#SPAWN.InitSpeedKph}(): Set the initial speed on spawning in kilometers per hour.
|
||||||
-- *{#SPAWN.InitSpeedKnots}(): Set the initial speed on spawning in knots.
|
-- * @{#SPAWN.InitSpeedKnots}(): Set the initial speed on spawning in knots.
|
||||||
--
|
--
|
||||||
-- ## SPAWN **Spawn** methods
|
-- ## SPAWN **Spawn** methods
|
||||||
--
|
--
|
||||||
@@ -292,9 +292,10 @@ SPAWN = {
|
|||||||
|
|
||||||
--- Enumerator for spawns at airbases
|
--- Enumerator for spawns at airbases
|
||||||
-- @type SPAWN.Takeoff
|
-- @type SPAWN.Takeoff
|
||||||
-- @extends Wrapper.Group#GROUP.Takeoff
|
-- @field #number Air Take off happens in air.
|
||||||
|
-- @field #number Runway Spawn on runway. Does not work in MP!
|
||||||
-- @field #SPAWN.Takeoff Takeoff
|
-- @field #number Hot Spawn at parking with engines on.
|
||||||
|
-- @field #number Cold Spawn at parking with engines off.
|
||||||
SPAWN.Takeoff = {
|
SPAWN.Takeoff = {
|
||||||
Air = 1,
|
Air = 1,
|
||||||
Runway = 2,
|
Runway = 2,
|
||||||
@@ -619,12 +620,14 @@ end
|
|||||||
-- and any spaces before and after the resulting name are removed.
|
-- and any spaces before and after the resulting name are removed.
|
||||||
-- IMPORTANT! This method MUST be the first used after :New !!!
|
-- IMPORTANT! This method MUST be the first used after :New !!!
|
||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
-- @param #boolean KeepUnitNames (optional) If true, the unit names are kept, false or not provided to make new unit names.
|
-- @param #boolean KeepUnitNames (optional) If true, the unit names are kept, false or not provided create new unit names.
|
||||||
-- @return #SPAWN self
|
-- @return #SPAWN self
|
||||||
function SPAWN:InitKeepUnitNames( KeepUnitNames )
|
function SPAWN:InitKeepUnitNames( KeepUnitNames )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self.SpawnInitKeepUnitNames = KeepUnitNames or true
|
self.SpawnInitKeepUnitNames = false
|
||||||
|
|
||||||
|
if KeepUnitNames == true then self.SpawnInitKeepUnitNames = true end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -1208,11 +1211,12 @@ end
|
|||||||
-- @param #number Major Major number, i.e. the group number of this name, e.g. 1 - resulting in e.g. Texaco-2-1
|
-- @param #number Major Major number, i.e. the group number of this name, e.g. 1 - resulting in e.g. Texaco-2-1
|
||||||
-- @return #SPAWN self
|
-- @return #SPAWN self
|
||||||
function SPAWN:InitCallSign(ID,Name,Minor,Major)
|
function SPAWN:InitCallSign(ID,Name,Minor,Major)
|
||||||
|
local Name = Name or "Enfield"
|
||||||
self.SpawnInitCallSign = true
|
self.SpawnInitCallSign = true
|
||||||
self.SpawnInitCallSignID = ID or 1
|
self.SpawnInitCallSignID = ID or 1
|
||||||
self.SpawnInitCallSignMinor = Minor or 1
|
self.SpawnInitCallSignMinor = Minor or 1
|
||||||
self.SpawnInitCallSignMajor = Major or 1
|
self.SpawnInitCallSignMajor = Major or 1
|
||||||
self.SpawnInitCallSignName = string.lower(Name) or "enfield"
|
self.SpawnInitCallSignName=string.lower(Name):gsub("^%l", string.upper)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1467,6 +1471,30 @@ do -- Delay methods
|
|||||||
|
|
||||||
end -- Delay methods
|
end -- Delay methods
|
||||||
|
|
||||||
|
--- Hide the group on the map view (visible to game master slots!).
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @return #SPAWN The SPAWN object
|
||||||
|
function SPAWN:InitHiddenOnMap()
|
||||||
|
self.SpawnHiddenOnMap = true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Hide the group on MFDs (visible to game master slots!).
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @return #SPAWN The SPAWN object
|
||||||
|
function SPAWN:InitHiddenOnMFD()
|
||||||
|
self.SpawnHiddenOnMFD = true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Hide the group on planner (visible to game master slots!).
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @return #SPAWN The SPAWN object
|
||||||
|
function SPAWN:InitHiddenOnPlanner()
|
||||||
|
self.SpawnHiddenOnPlanner = true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Will spawn a group based on the internal index.
|
--- Will spawn a group based on the internal index.
|
||||||
-- Note: This method uses the global _DATABASE object (an instance of @{Core.Database#DATABASE}), which contains ALL initial and new spawned objects in MOOSE.
|
-- Note: This method uses the global _DATABASE object (an instance of @{Core.Database#DATABASE}), which contains ALL initial and new spawned objects in MOOSE.
|
||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
@@ -1584,8 +1612,8 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
RandomVec2 = PointVec3:GetRandomVec2InRadius( self.SpawnOuterRadius, self.SpawnInnerRadius )
|
RandomVec2 = PointVec3:GetRandomVec2InRadius( self.SpawnOuterRadius, self.SpawnInnerRadius )
|
||||||
numTries = numTries + 1
|
numTries = numTries + 1
|
||||||
inZone = SpawnZone:IsVec2InZone(RandomVec2)
|
inZone = SpawnZone:IsVec2InZone(RandomVec2)
|
||||||
self:I("Retrying " .. numTries .. "spawn " .. SpawnTemplate.name .. " in Zone " .. SpawnZone:GetName() .. "!")
|
--self:I("Retrying " .. numTries .. "spawn " .. SpawnTemplate.name .. " in Zone " .. SpawnZone:GetName() .. "!")
|
||||||
self:I(SpawnZone)
|
--self:I(SpawnZone)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (not inZone) then
|
if (not inZone) then
|
||||||
@@ -1740,7 +1768,20 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
if self.SpawnInitModu then
|
if self.SpawnInitModu then
|
||||||
SpawnTemplate.modulation = self.SpawnInitModu
|
SpawnTemplate.modulation = self.SpawnInitModu
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- hiding options
|
||||||
|
if self.SpawnHiddenOnPlanner then
|
||||||
|
SpawnTemplate.hiddenOnPlanner=true
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.SpawnHiddenOnMFD then
|
||||||
|
SpawnTemplate.hiddenOnMFD=true
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.SpawnHiddenOnMap then
|
||||||
|
SpawnTemplate.hidden=true
|
||||||
|
end
|
||||||
|
|
||||||
-- Set country, coalition and category.
|
-- 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
|
||||||
@@ -3238,7 +3279,7 @@ end
|
|||||||
--- Get the index from a given group.
|
--- Get the index from a given group.
|
||||||
-- The function will search the name of the group for a #, and will return the number behind the #-mark.
|
-- The function will search the name of the group for a #, and will return the number behind the #-mark.
|
||||||
function SPAWN:GetSpawnIndexFromGroup( SpawnGroup )
|
function SPAWN:GetSpawnIndexFromGroup( SpawnGroup )
|
||||||
self:F2( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnGroup } )
|
self:F3( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnGroup } )
|
||||||
|
|
||||||
local IndexString = string.match( SpawnGroup:GetName(), "#(%d*)$" ):sub( 2 )
|
local IndexString = string.match( SpawnGroup:GetName(), "#(%d*)$" ):sub( 2 )
|
||||||
local Index = tonumber( IndexString )
|
local Index = tonumber( IndexString )
|
||||||
@@ -3250,7 +3291,7 @@ end
|
|||||||
|
|
||||||
--- Return the last maximum index that can be used.
|
--- Return the last maximum index that can be used.
|
||||||
function SPAWN:_GetLastIndex()
|
function SPAWN:_GetLastIndex()
|
||||||
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
|
self:F3( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
|
||||||
|
|
||||||
return self.SpawnMaxGroups
|
return self.SpawnMaxGroups
|
||||||
end
|
end
|
||||||
@@ -3398,24 +3439,28 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.SpawnInitKeepUnitNames == false then
|
if self.SpawnInitKeepUnitNames == false then
|
||||||
for UnitID = 1, #SpawnTemplate.units do
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
|
if not string.find(SpawnTemplate.units[UnitID].name,"#IFF_",1,true) then --Razbam IFF hack for F15E etc
|
||||||
|
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
|
||||||
|
end
|
||||||
SpawnTemplate.units[UnitID].unitId = nil
|
SpawnTemplate.units[UnitID].unitId = nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for UnitID = 1, #SpawnTemplate.units do
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
local SpawnInitKeepUnitIFF = false
|
local SpawnInitKeepUnitIFF = false
|
||||||
if string.find(SpawnTemplate.units[UnitID].name,"#IFF_",1,true) then --Razbam IFF hack for F15E etc
|
if string.find(SpawnTemplate.units[UnitID].name,"#IFF_",1,true) then --Razbam IFF hack for F15E etc
|
||||||
SpawnInitKeepUnitIFF = true
|
SpawnInitKeepUnitIFF = true
|
||||||
end
|
|
||||||
local UnitPrefix, Rest
|
|
||||||
if SpawnInitKeepUnitIFF == false then
|
|
||||||
UnitPrefix, Rest = string.match( SpawnTemplate.units[UnitID].name, "^([^#]+)#?" ):gsub( "^%s*(.-)%s*$", "%1" )
|
|
||||||
self:T( { UnitPrefix, Rest } )
|
|
||||||
else
|
|
||||||
UnitPrefix=SpawnTemplate.units[UnitID].name
|
|
||||||
end
|
end
|
||||||
SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
local UnitPrefix, Rest
|
||||||
|
if SpawnInitKeepUnitIFF == false then
|
||||||
|
UnitPrefix, Rest = string.match( SpawnTemplate.units[UnitID].name, "^([^#]+)#?" ):gsub( "^%s*(.-)%s*$", "%1" )
|
||||||
|
SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
||||||
|
self:T( { UnitPrefix, Rest } )
|
||||||
|
--else
|
||||||
|
--UnitPrefix=SpawnTemplate.units[UnitID].name
|
||||||
|
end
|
||||||
|
--SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
||||||
|
|
||||||
SpawnTemplate.units[UnitID].unitId = nil
|
SpawnTemplate.units[UnitID].unitId = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3076,9 +3076,25 @@ function ZONE_POLYGON:NewFromDrawing(DrawingName)
|
|||||||
-- points for the drawings are saved in local space, so add the object's map x and y coordinates to get
|
-- points for the drawings are saved in local space, so add the object's map x and y coordinates to get
|
||||||
-- world space points we can use
|
-- world space points we can use
|
||||||
for _, point in UTILS.spairs(object["points"]) do
|
for _, point in UTILS.spairs(object["points"]) do
|
||||||
|
-- check if we want to skip adding a point
|
||||||
|
local skip = false
|
||||||
local p = {x = object["mapX"] + point["x"],
|
local p = {x = object["mapX"] + point["x"],
|
||||||
y = object["mapY"] + point["y"] }
|
y = object["mapY"] + point["y"] }
|
||||||
table.add(points, p)
|
|
||||||
|
-- Check if the same coordinates already exist in the list, skip if they do
|
||||||
|
-- This can happen when drawing a Polygon in Free mode, DCS adds points on
|
||||||
|
-- top of each other that are in the `mission` file, but not visible in the
|
||||||
|
-- Mission Editor
|
||||||
|
for _, pt in pairs(points) do
|
||||||
|
if pt.x == p.x and pt.y == p.y then
|
||||||
|
skip = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- if it's a unique point, add it
|
||||||
|
if not skip then
|
||||||
|
table.add(points, p)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif object["polygonMode"] == "rect" then
|
elseif object["polygonMode"] == "rect" then
|
||||||
-- the points for a rect are saved as local coordinates with an angle. To get the world space points from this
|
-- the points for a rect are saved as local coordinates with an angle. To get the world space points from this
|
||||||
@@ -3096,6 +3112,7 @@ function ZONE_POLYGON:NewFromDrawing(DrawingName)
|
|||||||
|
|
||||||
points = {p1, p2, p3, p4}
|
points = {p1, p2, p3, p4}
|
||||||
else
|
else
|
||||||
|
-- bring the Arrow code over from Shape/Polygon
|
||||||
-- something else that might be added in the future
|
-- something else that might be added in the future
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
-- @image Designation.JPG
|
-- @image Designation.JPG
|
||||||
--
|
--
|
||||||
-- Date: 24 Oct 2021
|
-- Date: 24 Oct 2021
|
||||||
-- Last Update: Jan 2024
|
-- Last Update: May 2024
|
||||||
--
|
--
|
||||||
--- Class AUTOLASE
|
--- Class AUTOLASE
|
||||||
-- @type AUTOLASE
|
-- @type AUTOLASE
|
||||||
@@ -88,6 +88,7 @@
|
|||||||
-- @field #table LaserCodes
|
-- @field #table LaserCodes
|
||||||
-- @field #table playermenus
|
-- @field #table playermenus
|
||||||
-- @field #boolean smokemenu
|
-- @field #boolean smokemenu
|
||||||
|
-- @field #boolean threatmenu
|
||||||
-- @extends Ops.Intel#INTEL
|
-- @extends Ops.Intel#INTEL
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -117,7 +118,7 @@ AUTOLASE = {
|
|||||||
|
|
||||||
--- AUTOLASE class version.
|
--- AUTOLASE class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AUTOLASE.version = "0.1.23"
|
AUTOLASE.version = "0.1.25"
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
-- Begin Functional.Autolase.lua
|
-- Begin Functional.Autolase.lua
|
||||||
@@ -205,6 +206,7 @@ function AUTOLASE:New(RecceSet, Coalition, Alias, PilotSet)
|
|||||||
self:SetLaserCodes( { 1688, 1130, 4785, 6547, 1465, 4578 } ) -- set self.LaserCodes
|
self:SetLaserCodes( { 1688, 1130, 4785, 6547, 1465, 4578 } ) -- set self.LaserCodes
|
||||||
self.playermenus = {}
|
self.playermenus = {}
|
||||||
self.smokemenu = true
|
self.smokemenu = true
|
||||||
|
self.threatmenu = true
|
||||||
|
|
||||||
-- Set some string id for output to DCS.log file.
|
-- Set some string id for output to DCS.log file.
|
||||||
self.lid=string.format("AUTOLASE %s (%s) | ", self.alias, self.coalition and UTILS.GetCoalitionName(self.coalition) or "unknown")
|
self.lid=string.format("AUTOLASE %s (%s) | ", self.alias, self.coalition and UTILS.GetCoalitionName(self.coalition) or "unknown")
|
||||||
@@ -323,39 +325,51 @@ end
|
|||||||
function AUTOLASE:SetPilotMenu()
|
function AUTOLASE:SetPilotMenu()
|
||||||
if self.usepilotset then
|
if self.usepilotset then
|
||||||
local pilottable = self.pilotset:GetSetObjects() or {}
|
local pilottable = self.pilotset:GetSetObjects() or {}
|
||||||
|
local grouptable = {}
|
||||||
for _,_unit in pairs (pilottable) do
|
for _,_unit in pairs (pilottable) do
|
||||||
local Unit = _unit -- Wrapper.Unit#UNIT
|
local Unit = _unit -- Wrapper.Unit#UNIT
|
||||||
if Unit and Unit:IsAlive() then
|
if Unit and Unit:IsAlive() then
|
||||||
local Group = Unit:GetGroup()
|
local Group = Unit:GetGroup()
|
||||||
|
local GroupName = Group:GetName() or "none"
|
||||||
local unitname = Unit:GetName()
|
local unitname = Unit:GetName()
|
||||||
if self.playermenus[unitname] then self.playermenus[unitname]:Remove() end
|
if not grouptable[GroupName] == true then
|
||||||
local lasetopm = MENU_GROUP:New(Group,"Autolase",nil)
|
if self.playermenus[unitname] then self.playermenus[unitname]:Remove() end -- menus
|
||||||
self.playermenus[unitname] = lasetopm
|
local lasetopm = MENU_GROUP:New(Group,"Autolase",nil)
|
||||||
local lasemenu = MENU_GROUP_COMMAND:New(Group,"Status",lasetopm,self.ShowStatus,self,Group,Unit)
|
self.playermenus[unitname] = lasetopm
|
||||||
if self.smokemenu then
|
local lasemenu = MENU_GROUP_COMMAND:New(Group,"Status",lasetopm,self.ShowStatus,self,Group,Unit)
|
||||||
local smoke = (self.smoketargets == true) and "off" or "on"
|
if self.smokemenu then
|
||||||
local smoketext = string.format("Switch smoke targets to %s",smoke)
|
local smoke = (self.smoketargets == true) and "off" or "on"
|
||||||
local smokemenu = MENU_GROUP_COMMAND:New(Group,smoketext,lasetopm,self.SetSmokeTargets,self,(not self.smoketargets))
|
local smoketext = string.format("Switch smoke targets to %s",smoke)
|
||||||
end
|
local smokemenu = MENU_GROUP_COMMAND:New(Group,smoketext,lasetopm,self.SetSmokeTargets,self,(not self.smoketargets))
|
||||||
for _,_grp in pairs(self.RecceSet.Set) do
|
end -- smokement
|
||||||
local grp = _grp -- Wrapper.Group#GROUP
|
if self.threatmenu then
|
||||||
local unit = grp:GetUnit(1)
|
local threatmenutop = MENU_GROUP:New(Group,"Set min lasing threat",lasetopm)
|
||||||
--local name = grp:GetName()
|
for i=0,10,2 do
|
||||||
if unit and unit:IsAlive() then
|
local text = "Threatlevel "..tostring(i)
|
||||||
local name = unit:GetName()
|
local threatmenu = MENU_GROUP_COMMAND:New(Group,text,threatmenutop,self.SetMinThreatLevel,self,i)
|
||||||
local mname = string.gsub(name,".%d+.%d+$","")
|
end -- threatlevel
|
||||||
local code = self:GetLaserCode(name)
|
end -- threatmenu
|
||||||
local unittop = MENU_GROUP:New(Group,"Change laser code for "..mname,lasetopm)
|
for _,_grp in pairs(self.RecceSet.Set) do
|
||||||
for _,_code in pairs(self.LaserCodes) do
|
local grp = _grp -- Wrapper.Group#GROUP
|
||||||
local text = tostring(_code)
|
local unit = grp:GetUnit(1)
|
||||||
if _code == code then text = text.."(*)" end
|
--local name = grp:GetName()
|
||||||
local changemenu = MENU_GROUP_COMMAND:New(Group,text,unittop,self.SetRecceLaserCode,self,name,_code,true)
|
if unit and unit:IsAlive() then
|
||||||
end
|
local name = unit:GetName()
|
||||||
end
|
local mname = string.gsub(name,".%d+.%d+$","")
|
||||||
end
|
local code = self:GetLaserCode(name)
|
||||||
|
local unittop = MENU_GROUP:New(Group,"Change laser code for "..mname,lasetopm)
|
||||||
|
for _,_code in pairs(self.LaserCodes) do
|
||||||
|
local text = tostring(_code)
|
||||||
|
if _code == code then text = text.."(*)" end
|
||||||
|
local changemenu = MENU_GROUP_COMMAND:New(Group,text,unittop,self.SetRecceLaserCode,self,name,_code,true)
|
||||||
|
end -- Codes
|
||||||
|
end -- unit alive
|
||||||
|
end -- Recceset
|
||||||
|
grouptable[GroupName] = true
|
||||||
|
end -- grouptable[GroupName]
|
||||||
--lasemenu:Refresh()
|
--lasemenu:Refresh()
|
||||||
end
|
end -- unit alive
|
||||||
end
|
end -- pilot loop
|
||||||
else
|
else
|
||||||
if not self.NoMenus then
|
if not self.NoMenus then
|
||||||
self.Menu = MENU_COALITION_COMMAND:New(self.coalition,"Autolase",nil,self.ShowStatus,self)
|
self.Menu = MENU_COALITION_COMMAND:New(self.coalition,"Autolase",nil,self.ShowStatus,self)
|
||||||
@@ -602,6 +616,21 @@ function AUTOLASE:DisableSmokeMenu()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (User) Show the "Switch min threat lasing..." menu entry for pilots. On by default.
|
||||||
|
-- @param #AUTOLASE self
|
||||||
|
-- @return #AUTOLASE self
|
||||||
|
function AUTOLASE:EnableThreatLevelMenu()
|
||||||
|
self.threatmenu = true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (User) Do not show the "Switch min threat lasing..." menu entry for pilots.
|
||||||
|
-- @param #AUTOLASE self
|
||||||
|
-- @return #AUTOLASE self
|
||||||
|
function AUTOLASE:DisableThreatLevelMenu()
|
||||||
|
self.threatmenu = false
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- (Internal) Function to calculate line of sight.
|
--- (Internal) Function to calculate line of sight.
|
||||||
-- @param #AUTOLASE self
|
-- @param #AUTOLASE self
|
||||||
@@ -730,6 +759,7 @@ function AUTOLASE:ShowStatus(Group,Unit)
|
|||||||
report:Add(string.format("Recce %s has code %d",name,code))
|
report:Add(string.format("Recce %s has code %d",name,code))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
report:Add(string.format("Lasing min threat level %d",self.minthreatlevel))
|
||||||
local lines = 0
|
local lines = 0
|
||||||
for _ind,_entry in pairs(self.CurrentLasing) do
|
for _ind,_entry in pairs(self.CurrentLasing) do
|
||||||
local entry = _entry -- #AUTOLASE.LaserSpot
|
local entry = _entry -- #AUTOLASE.LaserSpot
|
||||||
|
|||||||
@@ -184,7 +184,7 @@
|
|||||||
|
|
||||||
do -- DESIGNATE
|
do -- DESIGNATE
|
||||||
|
|
||||||
--- @type DESIGNATE
|
-- @type DESIGNATE
|
||||||
-- @extends Core.Fsm#FSM_PROCESS
|
-- @extends Core.Fsm#FSM_PROCESS
|
||||||
|
|
||||||
--- Manage the designation of detected targets.
|
--- Manage the designation of detected targets.
|
||||||
@@ -525,7 +525,7 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
self.AttackSet:ForEachGroupAlive(
|
self.AttackSet:ForEachGroupAlive(
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AttackGroup
|
-- @param Wrapper.Group#GROUP AttackGroup
|
||||||
function( AttackGroup )
|
function( AttackGroup )
|
||||||
self.FlashStatusMenu[AttackGroup] = FlashMenu
|
self.FlashStatusMenu[AttackGroup] = FlashMenu
|
||||||
end
|
end
|
||||||
@@ -554,7 +554,7 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
self.AttackSet:ForEachGroupAlive(
|
self.AttackSet:ForEachGroupAlive(
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP AttackGroup
|
-- @param Wrapper.Group#GROUP AttackGroup
|
||||||
function( AttackGroup )
|
function( AttackGroup )
|
||||||
self.FlashDetectionMessage[AttackGroup] = FlashDetectionMessage
|
self.FlashDetectionMessage[AttackGroup] = FlashDetectionMessage
|
||||||
end
|
end
|
||||||
@@ -826,7 +826,7 @@ do -- DESIGNATE
|
|||||||
-- This Detection is obsolete, remove from the designate scope
|
-- This Detection is obsolete, remove from the designate scope
|
||||||
self.Designating[DesignateIndex] = nil
|
self.Designating[DesignateIndex] = nil
|
||||||
self.AttackSet:ForEachGroupAlive(
|
self.AttackSet:ForEachGroupAlive(
|
||||||
--- @param Wrapper.Group#GROUP AttackGroup
|
-- @param Wrapper.Group#GROUP AttackGroup
|
||||||
function( AttackGroup )
|
function( AttackGroup )
|
||||||
if AttackGroup:IsAlive() == true then
|
if AttackGroup:IsAlive() == true then
|
||||||
local DetectionText = self.Detection:DetectedItemReportSummary( DetectedItem, AttackGroup ):Text( ", " )
|
local DetectionText = self.Detection:DetectedItemReportSummary( DetectedItem, AttackGroup ):Text( ", " )
|
||||||
@@ -903,7 +903,7 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
self.AttackSet:ForEachGroupAlive(
|
self.AttackSet:ForEachGroupAlive(
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP GroupReport
|
-- @param Wrapper.Group#GROUP GroupReport
|
||||||
function( AttackGroup )
|
function( AttackGroup )
|
||||||
|
|
||||||
if self.FlashStatusMenu[AttackGroup] or ( MenuAttackGroup and ( AttackGroup:GetName() == MenuAttackGroup:GetName() ) ) then
|
if self.FlashStatusMenu[AttackGroup] or ( MenuAttackGroup and ( AttackGroup:GetName() == MenuAttackGroup:GetName() ) ) then
|
||||||
@@ -1060,7 +1060,7 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
self.AttackSet:ForEachGroupAlive(
|
self.AttackSet:ForEachGroupAlive(
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP GroupReport
|
-- @param Wrapper.Group#GROUP GroupReport
|
||||||
function( AttackGroup )
|
function( AttackGroup )
|
||||||
|
|
||||||
self:ScheduleOnce( Delay, self.SetMenu, self, AttackGroup )
|
self:ScheduleOnce( Delay, self.SetMenu, self, AttackGroup )
|
||||||
@@ -1198,7 +1198,7 @@ do -- DESIGNATE
|
|||||||
--local ReportTypes = REPORT:New()
|
--local ReportTypes = REPORT:New()
|
||||||
--local ReportLaserCodes = REPORT:New()
|
--local ReportLaserCodes = REPORT:New()
|
||||||
|
|
||||||
TargetSetUnit:Flush( self )
|
--TargetSetUnit:Flush( self )
|
||||||
|
|
||||||
--self:F( { Recces = self.Recces } )
|
--self:F( { Recces = self.Recces } )
|
||||||
for TargetUnit, RecceData in pairs( self.Recces ) do
|
for TargetUnit, RecceData in pairs( self.Recces ) do
|
||||||
@@ -1229,10 +1229,12 @@ do -- DESIGNATE
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if TargetSetUnit == nil then return end
|
||||||
|
|
||||||
if self.AutoLase or ( not self.AutoLase and ( self.LaseStart + Duration >= timer.getTime() ) ) then
|
if self.AutoLase or ( not self.AutoLase and ( self.LaseStart + Duration >= timer.getTime() ) ) then
|
||||||
|
|
||||||
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
||||||
--- @param Wrapper.Unit#UNIT SmokeUnit
|
-- @param Wrapper.Unit#UNIT SmokeUnit
|
||||||
function( TargetUnit )
|
function( TargetUnit )
|
||||||
|
|
||||||
self:F( { TargetUnit = TargetUnit:GetName() } )
|
self:F( { TargetUnit = TargetUnit:GetName() } )
|
||||||
@@ -1253,7 +1255,7 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
||||||
local RecceUnitDesc = RecceUnit:GetDesc()
|
local RecceUnitDesc = RecceUnit:GetDesc()
|
||||||
--self:F( { RecceUnit = RecceUnit:GetName(), RecceDescription = RecceUnitDesc } )
|
--self:F( { RecceUnit = RecceUnit:GetName(), RecceDescription = RecceUnitDesc } )x
|
||||||
|
|
||||||
if RecceUnit:IsLasing() == false then
|
if RecceUnit:IsLasing() == false then
|
||||||
--self:F( { IsDetected = RecceUnit:IsDetected( TargetUnit ), IsLOS = RecceUnit:IsLOS( TargetUnit ) } )
|
--self:F( { IsDetected = RecceUnit:IsDetected( TargetUnit ), IsLOS = RecceUnit:IsLOS( TargetUnit ) } )
|
||||||
@@ -1275,9 +1277,10 @@ do -- DESIGNATE
|
|||||||
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
|
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
|
||||||
local AttackSet = self.AttackSet
|
local AttackSet = self.AttackSet
|
||||||
local DesignateName = self.DesignateName
|
local DesignateName = self.DesignateName
|
||||||
|
local typename = TargetUnit:GetTypeName()
|
||||||
|
|
||||||
function Spot:OnAfterDestroyed( From, Event, To )
|
function Spot:OnAfterDestroyed( From, Event, To )
|
||||||
self.Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed. " .. TargetSetUnit:Count() .. " targets left.",
|
self.Recce:MessageToSetGroup( "Target " ..typename .. " destroyed. " .. TargetSetUnit:CountAlive() .. " targets left.",
|
||||||
5, AttackSet, self.DesignateName )
|
5, AttackSet, self.DesignateName )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1285,7 +1288,7 @@ 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 " .. TargetUnitType .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.",
|
||||||
10, self.AttackSet, DesignateName )
|
10, self.AttackSet, DesignateName )
|
||||||
if not MarkedTypes[TargetUnitType] then
|
if not MarkedTypes[TargetUnitType] then
|
||||||
MarkedTypes[TargetUnitType] = true
|
MarkedTypes[TargetUnitType] = true
|
||||||
@@ -1392,7 +1395,7 @@ do -- DESIGNATE
|
|||||||
local MarkedCount = 0
|
local MarkedCount = 0
|
||||||
|
|
||||||
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
||||||
--- @param Wrapper.Unit#UNIT SmokeUnit
|
-- @param Wrapper.Unit#UNIT SmokeUnit
|
||||||
function( SmokeUnit )
|
function( SmokeUnit )
|
||||||
|
|
||||||
if MarkedCount < self.MaximumMarkings then
|
if MarkedCount < self.MaximumMarkings then
|
||||||
@@ -1457,9 +1460,10 @@ do -- DESIGNATE
|
|||||||
-- @param #DESIGNATE self
|
-- @param #DESIGNATE self
|
||||||
-- @return #DESIGNATE
|
-- @return #DESIGNATE
|
||||||
function DESIGNATE:onafterDoneSmoking( From, Event, To, Index )
|
function DESIGNATE:onafterDoneSmoking( From, Event, To, Index )
|
||||||
|
if self.Designating[Index] ~= nil then
|
||||||
self.Designating[Index] = string.gsub( self.Designating[Index], "S", "" )
|
self.Designating[Index] = string.gsub( self.Designating[Index], "S", "" )
|
||||||
self:SetDesignateMenu()
|
self:SetDesignateMenu()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- DoneIlluminating
|
--- DoneIlluminating
|
||||||
@@ -1472,5 +1476,3 @@ do -- DESIGNATE
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -545,7 +545,7 @@ do -- DETECTION_BASE
|
|||||||
-- @param #string To The To State string.
|
-- @param #string To The To State string.
|
||||||
function DETECTION_BASE:onafterDetect( From, Event, To )
|
function DETECTION_BASE:onafterDetect( From, Event, To )
|
||||||
|
|
||||||
local DetectDelay = 0.1
|
local DetectDelay = 0.15
|
||||||
self.DetectionCount = 0
|
self.DetectionCount = 0
|
||||||
self.DetectionRun = 0
|
self.DetectionRun = 0
|
||||||
self:UnIdentifyAllDetectedObjects() -- Resets the DetectedObjectsIdentified table
|
self:UnIdentifyAllDetectedObjects() -- Resets the DetectedObjectsIdentified table
|
||||||
@@ -604,7 +604,7 @@ do -- DETECTION_BASE
|
|||||||
-- @param #number DetectionTimeStamp Time stamp of detection event.
|
-- @param #number DetectionTimeStamp Time stamp of detection event.
|
||||||
function DETECTION_BASE:onafterDetection( From, Event, To, Detection, DetectionTimeStamp )
|
function DETECTION_BASE:onafterDetection( From, Event, To, Detection, DetectionTimeStamp )
|
||||||
|
|
||||||
-- self:F( { DetectedObjects = self.DetectedObjects } )
|
self:I( { DetectedObjects = self.DetectedObjects } )
|
||||||
|
|
||||||
self.DetectionRun = self.DetectionRun + 1
|
self.DetectionRun = self.DetectionRun + 1
|
||||||
|
|
||||||
@@ -612,14 +612,14 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
if Detection and Detection:IsAlive() then
|
if Detection and Detection:IsAlive() then
|
||||||
|
|
||||||
-- self:T( { "DetectionGroup is Alive", DetectionGroup:GetName() } )
|
self:I( { "DetectionGroup is Alive", Detection:GetName() } )
|
||||||
|
|
||||||
local DetectionGroupName = Detection:GetName()
|
local DetectionGroupName = Detection:GetName()
|
||||||
local DetectionUnit = Detection:GetUnit( 1 )
|
local DetectionUnit = Detection:GetUnit( 1 )
|
||||||
|
|
||||||
local DetectedUnits = {}
|
local DetectedUnits = {}
|
||||||
|
|
||||||
local DetectedTargets = Detection:GetDetectedTargets(
|
local DetectedTargets = DetectionUnit:GetDetectedTargets(
|
||||||
self.DetectVisual,
|
self.DetectVisual,
|
||||||
self.DetectOptical,
|
self.DetectOptical,
|
||||||
self.DetectRadar,
|
self.DetectRadar,
|
||||||
@@ -628,8 +628,10 @@ do -- DETECTION_BASE
|
|||||||
self.DetectDLINK
|
self.DetectDLINK
|
||||||
)
|
)
|
||||||
|
|
||||||
self:F( { DetectedTargets = DetectedTargets } )
|
--self:I( { DetectedTargets = DetectedTargets } )
|
||||||
|
--self:I(UTILS.PrintTableToLog(DetectedTargets))
|
||||||
|
|
||||||
|
|
||||||
for DetectionObjectID, Detection in pairs( DetectedTargets ) do
|
for DetectionObjectID, Detection in pairs( DetectedTargets ) do
|
||||||
local DetectedObject = Detection.object -- DCS#Object
|
local DetectedObject = Detection.object -- DCS#Object
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
-- @module Functional.Mantis
|
-- @module Functional.Mantis
|
||||||
-- @image Functional.Mantis.jpg
|
-- @image Functional.Mantis.jpg
|
||||||
--
|
--
|
||||||
-- Last Update: Feb 2024
|
-- Last Update: May 2024
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **MANTIS** class, extends Core.Base#BASE
|
--- **MANTIS** class, extends Core.Base#BASE
|
||||||
@@ -58,6 +58,7 @@
|
|||||||
-- @field #boolean ShoradLink If true, #MANTIS has #SHORAD enabled
|
-- @field #boolean ShoradLink If true, #MANTIS has #SHORAD enabled
|
||||||
-- @field #number ShoradTime Timer in seconds, how long #SHORAD will be active after a detection inside of the defense range
|
-- @field #number ShoradTime Timer in seconds, how long #SHORAD will be active after a detection inside of the defense range
|
||||||
-- @field #number ShoradActDistance Distance of an attacker in meters from a Mantis SAM site, on which Shorad will be switched on. Useful to not give away Shorad sites too early. Default 15km. Should be smaller than checkradius.
|
-- @field #number ShoradActDistance Distance of an attacker in meters from a Mantis SAM site, on which Shorad will be switched on. Useful to not give away Shorad sites too early. Default 15km. Should be smaller than checkradius.
|
||||||
|
-- @field #boolean checkforfriendlies If true, do not activate a SAM installation if a friendly aircraft is in firing range.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -187,29 +188,34 @@
|
|||||||
-- -- This is effectively a 3-stage filter allowing for zone overlap. A coordinate is accepted first when
|
-- -- This is effectively a 3-stage filter allowing for zone overlap. A coordinate is accepted first when
|
||||||
-- -- it is inside any AcceptZone. Then RejectZones are checked, which enforces both borders, but also overlaps of
|
-- -- it is inside any AcceptZone. Then RejectZones are checked, which enforces both borders, but also overlaps of
|
||||||
-- -- Accept- and RejectZones. Last, if it is inside a conflict zone, it is accepted.
|
-- -- Accept- and RejectZones. Last, if it is inside a conflict zone, it is accepted.
|
||||||
-- `mybluemantis:AddZones(AcceptZones,RejectZones,ConflictZones)`
|
-- mybluemantis:AddZones(AcceptZones,RejectZones,ConflictZones)
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- ### 2.1.2 Change the number of long-, mid- and short-range systems going live on a detected target:
|
-- ### 2.1.2 Change the number of long-, mid- and short-range systems going live on a detected target:
|
||||||
--
|
--
|
||||||
-- -- parameters are numbers. Defaults are 1,2,2,6 respectively
|
-- -- parameters are numbers. Defaults are 1,2,2,6 respectively
|
||||||
-- `mybluemantis:SetMaxActiveSAMs(Short,Mid,Long,Classic)`
|
-- mybluemantis:SetMaxActiveSAMs(Short,Mid,Long,Classic)
|
||||||
--
|
--
|
||||||
-- ### 2.1.3 SHORAD will automatically be added from SAM sites of type "short-range"
|
-- ### 2.1.3 SHORAD will automatically be added from SAM sites of type "short-range"
|
||||||
--
|
--
|
||||||
-- ### 2.1.4 Advanced features
|
-- ### 2.1.4 Advanced features
|
||||||
--
|
--
|
||||||
-- -- switch off auto mode **before** you start MANTIS.
|
-- -- switch off auto mode **before** you start MANTIS.
|
||||||
-- `mybluemantis.automode = false`
|
-- mybluemantis.automode = false
|
||||||
--
|
--
|
||||||
-- -- switch off auto shorad **before** you start MANTIS.
|
-- -- switch off auto shorad **before** you start MANTIS.
|
||||||
-- `mybluemantis.autoshorad = false`
|
-- mybluemantis.autoshorad = false
|
||||||
--
|
--
|
||||||
-- -- scale of the activation range, i.e. don't activate at the fringes of max range, defaults below.
|
-- -- scale of the activation range, i.e. don't activate at the fringes of max range, defaults below.
|
||||||
-- -- also see engagerange below.
|
-- -- also see engagerange below.
|
||||||
-- ` self.radiusscale[MANTIS.SamType.LONG] = 1.1`
|
-- self.radiusscale[MANTIS.SamType.LONG] = 1.1
|
||||||
-- ` self.radiusscale[MANTIS.SamType.MEDIUM] = 1.2`
|
-- self.radiusscale[MANTIS.SamType.MEDIUM] = 1.2
|
||||||
-- ` self.radiusscale[MANTIS.SamType.SHORT] = 1.3`
|
-- self.radiusscale[MANTIS.SamType.SHORT] = 1.3
|
||||||
|
--
|
||||||
|
-- ### 2.1.5 Friendlies check in firing range
|
||||||
|
--
|
||||||
|
-- -- For some scenarios, like Cold War, it might be useful not to activate SAMs if friendly aircraft are around to avoid death by friendly fire.
|
||||||
|
-- mybluemantis.checkforfriendlies = true
|
||||||
--
|
--
|
||||||
-- # 3. Default settings [both modes unless stated otherwise]
|
-- # 3. Default settings [both modes unless stated otherwise]
|
||||||
--
|
--
|
||||||
@@ -321,6 +327,7 @@ MANTIS = {
|
|||||||
automode = true,
|
automode = true,
|
||||||
autoshorad = true,
|
autoshorad = true,
|
||||||
ShoradGroupSet = nil,
|
ShoradGroupSet = nil,
|
||||||
|
checkforfriendlies = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Advanced state enumerator
|
--- Advanced state enumerator
|
||||||
@@ -502,7 +509,8 @@ do
|
|||||||
-- DONE: Treat Awacs separately, since they might be >80km off site
|
-- DONE: Treat Awacs separately, since they might be >80km off site
|
||||||
-- DONE: Allow tables of prefixes for the setup
|
-- DONE: Allow tables of prefixes for the setup
|
||||||
-- DONE: Auto-Mode with range setups for various known SAM types.
|
-- DONE: Auto-Mode with range setups for various known SAM types.
|
||||||
|
|
||||||
|
self.name = name or "mymantis"
|
||||||
self.SAM_Templates_Prefix = samprefix or "Red SAM"
|
self.SAM_Templates_Prefix = samprefix or "Red SAM"
|
||||||
self.EWR_Templates_Prefix = ewrprefix or "Red EWR"
|
self.EWR_Templates_Prefix = ewrprefix or "Red EWR"
|
||||||
self.HQ_Template_CC = hq or nil
|
self.HQ_Template_CC = hq or nil
|
||||||
@@ -631,7 +639,7 @@ do
|
|||||||
|
|
||||||
-- TODO Version
|
-- TODO Version
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
self.version="0.8.16"
|
self.version="0.8.18"
|
||||||
self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
|
self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
|
||||||
|
|
||||||
--- FSM Functions ---
|
--- FSM Functions ---
|
||||||
@@ -1255,6 +1263,10 @@ do
|
|||||||
-- DEBUG
|
-- DEBUG
|
||||||
set = self:_PreFilterHeight(height)
|
set = self:_PreFilterHeight(height)
|
||||||
end
|
end
|
||||||
|
local friendlyset -- Core.Set#SET_GROUP
|
||||||
|
if self.checkforfriendlies == true then
|
||||||
|
friendlyset = SET_GROUP:New():FilterCoalitions(self.Coalition):FilterCategories({"plane","helicopter"}):FilterFunction(function(grp) if grp and grp:InAir() then return true else return false end end):FilterOnce()
|
||||||
|
end
|
||||||
for _,_coord in pairs (set) do
|
for _,_coord in pairs (set) do
|
||||||
local coord = _coord -- get current coord to check
|
local coord = _coord -- get current coord to check
|
||||||
-- output for cross-check
|
-- output for cross-check
|
||||||
@@ -1279,8 +1291,16 @@ do
|
|||||||
local m = MESSAGE:New(text,10,"Check"):ToAllIf(self.debug)
|
local m = MESSAGE:New(text,10,"Check"):ToAllIf(self.debug)
|
||||||
self:T(self.lid..text)
|
self:T(self.lid..text)
|
||||||
end
|
end
|
||||||
|
-- friendlies around?
|
||||||
|
local nofriendlies = true
|
||||||
|
if self.checkforfriendlies == true then
|
||||||
|
local closestfriend, distance = friendlyset:GetClosestGroup(samcoordinate)
|
||||||
|
if closestfriend and distance and distance < rad then
|
||||||
|
nofriendlies = false
|
||||||
|
end
|
||||||
|
end
|
||||||
-- end output to cross-check
|
-- end output to cross-check
|
||||||
if targetdistance <= rad and zonecheck then
|
if targetdistance <= rad and zonecheck == true and nofriendlies == true then
|
||||||
return true, targetdistance
|
return true, targetdistance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@
|
|||||||
-- Implementation is based on the [Simple Range Script](https://forums.eagle.ru/showthread.php?t=157991) by Ciribob, which itself was motivated
|
-- Implementation is based on the [Simple Range Script](https://forums.eagle.ru/showthread.php?t=157991) by Ciribob, which itself was motivated
|
||||||
-- by a script by SNAFU [see here](https://forums.eagle.ru/showthread.php?t=109174).
|
-- by a script by SNAFU [see here](https://forums.eagle.ru/showthread.php?t=109174).
|
||||||
--
|
--
|
||||||
-- [476th - Air Weapons Range Objects mod](http://www.476vfightergroup.com/downloads.php?do=file&id=287) is highly recommended for this class.
|
-- [476th - Air Weapons Range Objects mod](https://www.476vfightergroup.com/downloads.php?do=download&downloadid=482) is highly recommended for this class.
|
||||||
--
|
--
|
||||||
-- **Main Features:**
|
-- **Main Features:**
|
||||||
--
|
--
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Contributions: FlightControl, Ciribob
|
-- ### Contributions: FlightControl, Ciribob
|
||||||
-- ### SRS Additions: Applevangelist
|
-- ### SRS Additions: Applevangelist
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
-- @module Functional.Range
|
-- @module Functional.Range
|
||||||
-- @image Range.JPG
|
-- @image Range.JPG
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
-- @field #string targetpath Path where to save the target sheets.
|
-- @field #string targetpath Path where to save the target sheets.
|
||||||
-- @field #string targetprefix File prefix for target sheet files.
|
-- @field #string targetprefix File prefix for target sheet files.
|
||||||
-- @field Sound.SRS#MSRS controlmsrs SRS wrapper for range controller.
|
-- @field Sound.SRS#MSRS controlmsrs SRS wrapper for range controller.
|
||||||
-- @field Sound.SRS#MSRSQUEUE controlsrsQ SRS queue for range controller.
|
-- @field Sound.SRS#MSRSQUEUE controlsrsQ SRS queue for range controller.
|
||||||
-- @field Sound.SRS#MSRS instructmsrs SRS wrapper for range instructor.
|
-- @field Sound.SRS#MSRS instructmsrs SRS wrapper for range instructor.
|
||||||
-- @field Sound.SRS#MSRSQUEUE instructsrsQ SRS queue for range instructor.
|
-- @field Sound.SRS#MSRSQUEUE instructsrsQ SRS queue for range instructor.
|
||||||
-- @field #number Coalition Coalition side for the menu, if any.
|
-- @field #number Coalition Coalition side for the menu, if any.
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Specifying Coordinates
|
-- ## Specifying Coordinates
|
||||||
--
|
--
|
||||||
-- It is also possible to specify coordinates rather than unit or static objects as bombing target locations. This has the advantage, that even when the unit/static object is dead, the specified
|
-- It is also possible to specify coordinates rather than unit or static objects as bombing target locations. This has the advantage, that even when the unit/static object is dead, the specified
|
||||||
-- coordinate will still be a valid impact point. This can be done via the @{#RANGE.AddBombingTargetCoordinate}(*coord*, *name*, *goodhitrange*) function.
|
-- coordinate will still be a valid impact point. This can be done via the @{#RANGE.AddBombingTargetCoordinate}(*coord*, *name*, *goodhitrange*) function.
|
||||||
--
|
--
|
||||||
-- # Fine Tuning
|
-- # Fine Tuning
|
||||||
@@ -231,8 +231,8 @@
|
|||||||
-- By default, the sound files are placed in the "Range Soundfiles/" folder inside the mission (.miz) file. Another folder can be specified via the @{#RANGE.SetSoundfilesPath}(*path*) function.
|
-- By default, the sound files are placed in the "Range Soundfiles/" folder inside the mission (.miz) file. Another folder can be specified via the @{#RANGE.SetSoundfilesPath}(*path*) function.
|
||||||
--
|
--
|
||||||
-- ## Voice output via SRS
|
-- ## Voice output via SRS
|
||||||
--
|
--
|
||||||
-- Alternatively, the voice output can be fully done via SRS, **no sound file additions needed**. Set up SRS with @{#RANGE.SetSRS}().
|
-- Alternatively, the voice output can be fully done via SRS, **no sound file additions needed**. Set up SRS with @{#RANGE.SetSRS}().
|
||||||
-- Range control and instructor frequencies and voices can then be set via @{#RANGE.SetSRSRangeControl}() and @{#RANGE.SetSRSRangeInstructor}().
|
-- Range control and instructor frequencies and voices can then be set via @{#RANGE.SetSRSRangeControl}() and @{#RANGE.SetSRSRangeInstructor}().
|
||||||
--
|
--
|
||||||
-- # Persistence
|
-- # Persistence
|
||||||
@@ -243,11 +243,11 @@
|
|||||||
-- The next time you start the mission, these results are also automatically loaded.
|
-- The next time you start the mission, these results are also automatically loaded.
|
||||||
--
|
--
|
||||||
-- Strafing results are currently **not** saved.
|
-- Strafing results are currently **not** saved.
|
||||||
--
|
--
|
||||||
-- # FSM Events
|
-- # FSM Events
|
||||||
--
|
--
|
||||||
-- This class creates additional events that can be used by mission designers for custom reactions
|
-- This class creates additional events that can be used by mission designers for custom reactions
|
||||||
--
|
--
|
||||||
-- * `EnterRange` when a player enters a range zone. See @{#RANGE.OnAfterEnterRange}
|
-- * `EnterRange` when a player enters a range zone. See @{#RANGE.OnAfterEnterRange}
|
||||||
-- * `ExitRange` when a player leaves a range zone. See @{#RANGE.OnAfterExitRange}
|
-- * `ExitRange` when a player leaves a range zone. See @{#RANGE.OnAfterExitRange}
|
||||||
-- * `Impact` on impact of a player's weapon on a bombing target. See @{#RANGE.OnAfterImpact}
|
-- * `Impact` on impact of a player's weapon on a bombing target. See @{#RANGE.OnAfterImpact}
|
||||||
@@ -371,7 +371,7 @@ RANGE = {
|
|||||||
-- @param #number boxlength Length of strafe pit box in meters.
|
-- @param #number boxlength Length of strafe pit box in meters.
|
||||||
-- @param #number boxwidth Width of strafe pit box in meters.
|
-- @param #number boxwidth Width of strafe pit box in meters.
|
||||||
-- @param #number goodpass Number of hits for a good strafing pit pass.
|
-- @param #number goodpass Number of hits for a good strafing pit pass.
|
||||||
-- @param #number foulline Distance of foul line in meters.
|
-- @param #number foulline Distance of foul line in meters.
|
||||||
RANGE.Defaults = {
|
RANGE.Defaults = {
|
||||||
goodhitrange = 25,
|
goodhitrange = 25,
|
||||||
strafemaxalt = 914,
|
strafemaxalt = 914,
|
||||||
@@ -625,9 +625,9 @@ function RANGE:New( RangeName, Coalition )
|
|||||||
-- Get range name.
|
-- Get range name.
|
||||||
-- TODO: make sure that the range name is not given twice. This would lead to problems in the F10 radio menu.
|
-- TODO: make sure that the range name is not given twice. This would lead to problems in the F10 radio menu.
|
||||||
self.rangename = RangeName or "Practice Range"
|
self.rangename = RangeName or "Practice Range"
|
||||||
|
|
||||||
self.Coalition = Coalition
|
self.Coalition = Coalition
|
||||||
|
|
||||||
-- Log id.
|
-- Log id.
|
||||||
self.lid = string.format( "RANGE %s | ", self.rangename )
|
self.lid = string.format( "RANGE %s | ", self.rangename )
|
||||||
|
|
||||||
@@ -993,9 +993,9 @@ end
|
|||||||
-- @param #string Host Host. Default "127.0.0.1".
|
-- @param #string Host Host. Default "127.0.0.1".
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:SetFunkManOn(Port, Host)
|
function RANGE:SetFunkManOn(Port, Host)
|
||||||
|
|
||||||
self.funkmanSocket=SOCKET:New(Port, Host)
|
self.funkmanSocket=SOCKET:New(Port, Host)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1200,7 +1200,7 @@ end
|
|||||||
-- @param #string PathToSRS Path to SRS directory.
|
-- @param #string PathToSRS Path to SRS directory.
|
||||||
-- @param #number Port SRS port. Default 5002.
|
-- @param #number Port SRS port. Default 5002.
|
||||||
-- @param #number Coalition Coalition side, e.g. `coalition.side.BLUE` or `coalition.side.RED`. Default `coalition.side.BLUE`.
|
-- @param #number Coalition Coalition side, e.g. `coalition.side.BLUE` or `coalition.side.RED`. Default `coalition.side.BLUE`.
|
||||||
-- @param #number Frequency Frequency to use. Default is 256 MHz for range control and 305 MHz for instructor. If given, both control and instructor get this frequency.
|
-- @param #number Frequency Frequency to use. Default is 256 MHz for range control and 305 MHz for instructor. If given, both control and instructor get this frequency.
|
||||||
-- @param #number Modulation Modulation to use, defaults to radio.modulation.AM
|
-- @param #number Modulation Modulation to use, defaults to radio.modulation.AM
|
||||||
-- @param #number Volume Volume, between 0.0 and 1.0. Defaults to 1.0
|
-- @param #number Volume Volume, between 0.0 and 1.0. Defaults to 1.0
|
||||||
-- @param #string PathToGoogleKey Path to Google TTS credentials.
|
-- @param #string PathToGoogleKey Path to Google TTS credentials.
|
||||||
@@ -1208,9 +1208,9 @@ end
|
|||||||
function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume, PathToGoogleKey)
|
function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume, PathToGoogleKey)
|
||||||
|
|
||||||
if PathToSRS or MSRS.path then
|
if PathToSRS or MSRS.path then
|
||||||
|
|
||||||
self.useSRS=true
|
self.useSRS=true
|
||||||
|
|
||||||
self.controlmsrs=MSRS:New(PathToSRS or MSRS.path, Frequency or 256, Modulation or radio.modulation.AM)
|
self.controlmsrs=MSRS:New(PathToSRS or MSRS.path, Frequency or 256, Modulation or radio.modulation.AM)
|
||||||
self.controlmsrs:SetPort(Port or MSRS.port)
|
self.controlmsrs:SetPort(Port or MSRS.port)
|
||||||
self.controlmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
self.controlmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
||||||
@@ -1224,14 +1224,12 @@ function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume,
|
|||||||
self.instructmsrs:SetLabel("RANGEI")
|
self.instructmsrs:SetLabel("RANGEI")
|
||||||
self.instructmsrs:SetVolume(Volume or 1.0)
|
self.instructmsrs:SetVolume(Volume or 1.0)
|
||||||
self.instructsrsQ = MSRSQUEUE:New("INSTRUCT")
|
self.instructsrsQ = MSRSQUEUE:New("INSTRUCT")
|
||||||
|
|
||||||
if PathToGoogleKey then
|
if PathToGoogleKey then
|
||||||
self.controlmsrs:SetProviderOptionsGoogle(PathToGoogleKey,PathToGoogleKey)
|
self.controlmsrs:SetGoogle(PathToGoogleKey)
|
||||||
self.controlmsrs:SetProvider(MSRS.Provider.GOOGLE)
|
self.instructmsrs:SetGoogle(PathToGoogleKey)
|
||||||
self.instructmsrs:SetProviderOptionsGoogle(PathToGoogleKey,PathToGoogleKey)
|
|
||||||
self.instructmsrs:SetProvider(MSRS.Provider.GOOGLE)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E(self.lid..string.format("ERROR: No SRS path specified!"))
|
self:E(self.lid..string.format("ERROR: No SRS path specified!"))
|
||||||
end
|
end
|
||||||
@@ -1741,9 +1739,9 @@ end
|
|||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function RANGE:OnEventBirth( EventData )
|
function RANGE:OnEventBirth( EventData )
|
||||||
self:F( { eventbirth = EventData } )
|
self:F( { eventbirth = EventData } )
|
||||||
|
|
||||||
if not EventData.IniPlayerName then return end
|
if not EventData.IniPlayerName then return end
|
||||||
|
|
||||||
local _unitName = EventData.IniUnitName
|
local _unitName = EventData.IniUnitName
|
||||||
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )
|
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )
|
||||||
|
|
||||||
@@ -1764,7 +1762,7 @@ function RANGE:OnEventBirth( EventData )
|
|||||||
|
|
||||||
-- Reset current strafe status.
|
-- Reset current strafe status.
|
||||||
self.strafeStatus[_uid] = nil
|
self.strafeStatus[_uid] = nil
|
||||||
|
|
||||||
if self.Coalition then
|
if self.Coalition then
|
||||||
if EventData.IniCoalition == self.Coalition then
|
if EventData.IniCoalition == self.Coalition then
|
||||||
self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName )
|
self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName )
|
||||||
@@ -1773,7 +1771,7 @@ function RANGE:OnEventBirth( EventData )
|
|||||||
-- Add Menu commands after a delay of 0.1 seconds.
|
-- Add Menu commands after a delay of 0.1 seconds.
|
||||||
self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName )
|
self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- By default, some bomb impact points and do not flare each hit on target.
|
-- By default, some bomb impact points and do not flare each hit on target.
|
||||||
self.PlayerSettings[_playername] = {} -- #RANGE.PlayerData
|
self.PlayerSettings[_playername] = {} -- #RANGE.PlayerData
|
||||||
self.PlayerSettings[_playername].smokebombimpact = self.defaultsmokebomb
|
self.PlayerSettings[_playername].smokebombimpact = self.defaultsmokebomb
|
||||||
@@ -1907,21 +1905,21 @@ function RANGE._OnImpact(weapon, self, playerData, attackHdg, attackAlt, attackV
|
|||||||
local _distance = nil
|
local _distance = nil
|
||||||
local _closeCoord = nil --Core.Point#COORDINATE
|
local _closeCoord = nil --Core.Point#COORDINATE
|
||||||
local _hitquality = "POOR"
|
local _hitquality = "POOR"
|
||||||
|
|
||||||
-- Get callsign.
|
-- Get callsign.
|
||||||
local _callsign = self:_myname( playerData.unitname )
|
local _callsign = self:_myname( playerData.unitname )
|
||||||
|
|
||||||
local _playername=playerData.playername
|
local _playername=playerData.playername
|
||||||
|
|
||||||
local _unit=playerData.unit
|
local _unit=playerData.unit
|
||||||
|
|
||||||
-- Coordinate of impact point.
|
-- Coordinate of impact point.
|
||||||
local impactcoord = weapon:GetImpactCoordinate()
|
local impactcoord = weapon:GetImpactCoordinate()
|
||||||
|
|
||||||
-- Check if impact happened in range zone.
|
-- Check if impact happened in range zone.
|
||||||
local insidezone = self.rangezone:IsCoordinateInZone( impactcoord )
|
local insidezone = self.rangezone:IsCoordinateInZone( impactcoord )
|
||||||
|
|
||||||
|
|
||||||
-- Smoke impact point of bomb.
|
-- Smoke impact point of bomb.
|
||||||
if playerData.smokebombimpact and insidezone then
|
if playerData.smokebombimpact and insidezone then
|
||||||
if playerData.delaysmoke then
|
if playerData.delaysmoke then
|
||||||
@@ -1930,19 +1928,19 @@ function RANGE._OnImpact(weapon, self, playerData, attackHdg, attackAlt, attackV
|
|||||||
impactcoord:Smoke( playerData.smokecolor )
|
impactcoord:Smoke( playerData.smokecolor )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Loop over defined bombing targets.
|
-- Loop over defined bombing targets.
|
||||||
for _, _bombtarget in pairs( self.bombingTargets ) do
|
for _, _bombtarget in pairs( self.bombingTargets ) do
|
||||||
local bombtarget=_bombtarget --#RANGE.BombTarget
|
local bombtarget=_bombtarget --#RANGE.BombTarget
|
||||||
|
|
||||||
-- Get target coordinate.
|
-- Get target coordinate.
|
||||||
local targetcoord = self:_GetBombTargetCoordinate( _bombtarget )
|
local targetcoord = self:_GetBombTargetCoordinate( _bombtarget )
|
||||||
|
|
||||||
if targetcoord then
|
if targetcoord then
|
||||||
|
|
||||||
-- Distance between bomb and target.
|
-- Distance between bomb and target.
|
||||||
local _temp = impactcoord:Get2DDistance( targetcoord )
|
local _temp = impactcoord:Get2DDistance( targetcoord )
|
||||||
|
|
||||||
-- Find closest target to last known position of the bomb.
|
-- Find closest target to last known position of the bomb.
|
||||||
if _distance == nil or _temp < _distance then
|
if _distance == nil or _temp < _distance then
|
||||||
_distance = _temp
|
_distance = _temp
|
||||||
@@ -1959,21 +1957,21 @@ function RANGE._OnImpact(weapon, self, playerData, attackHdg, attackAlt, attackV
|
|||||||
else
|
else
|
||||||
_hitquality = "POOR"
|
_hitquality = "POOR"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Count if bomb fell less than ~1 km away from the target.
|
-- Count if bomb fell less than ~1 km away from the target.
|
||||||
if _distance and _distance <= self.scorebombdistance then
|
if _distance and _distance <= self.scorebombdistance then
|
||||||
-- Init bomb player results.
|
-- Init bomb player results.
|
||||||
if not self.bombPlayerResults[_playername] then
|
if not self.bombPlayerResults[_playername] then
|
||||||
self.bombPlayerResults[_playername] = {}
|
self.bombPlayerResults[_playername] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Local results.
|
-- Local results.
|
||||||
local _results = self.bombPlayerResults[_playername]
|
local _results = self.bombPlayerResults[_playername]
|
||||||
|
|
||||||
local result = {} -- #RANGE.BombResult
|
local result = {} -- #RANGE.BombResult
|
||||||
result.command=SOCKET.DataType.BOMBRESULT
|
result.command=SOCKET.DataType.BOMBRESULT
|
||||||
result.name = _closetTarget.name or "unknown"
|
result.name = _closetTarget.name or "unknown"
|
||||||
@@ -1995,24 +1993,24 @@ function RANGE._OnImpact(weapon, self, playerData, attackHdg, attackAlt, attackV
|
|||||||
result.attackVel = attackVel
|
result.attackVel = attackVel
|
||||||
result.attackAlt = attackAlt
|
result.attackAlt = attackAlt
|
||||||
result.date=os and os.date() or "n/a"
|
result.date=os and os.date() or "n/a"
|
||||||
|
|
||||||
-- Add to table.
|
-- Add to table.
|
||||||
table.insert( _results, result )
|
table.insert( _results, result )
|
||||||
|
|
||||||
-- Call impact.
|
-- Call impact.
|
||||||
self:Impact( result, playerData )
|
self:Impact( result, playerData )
|
||||||
|
|
||||||
elseif insidezone then
|
elseif insidezone then
|
||||||
|
|
||||||
-- Send message.
|
-- Send message.
|
||||||
-- DONE SRS message
|
-- DONE SRS message
|
||||||
local _message = string.format( "%s, weapon impacted too far from nearest range target (>%.1f km). No score!", _callsign, self.scorebombdistance / 1000 )
|
local _message = string.format( "%s, weapon impacted too far from nearest range target (>%.1f km). No score!", _callsign, self.scorebombdistance / 1000 )
|
||||||
if self.useSRS then
|
if self.useSRS then
|
||||||
local ttstext = string.format( "%s, weapon impacted too far from nearest range target, mor than %.1f kilometer. No score!", _callsign, self.scorebombdistance / 1000 )
|
local ttstext = string.format( "%s, weapon impacted too far from nearest range target, mor than %.1f kilometer. No score!", _callsign, self.scorebombdistance / 1000 )
|
||||||
self.controlsrsQ:NewTransmission(ttstext,nil,self.controlmsrs,nil,2)
|
self.controlsrsQ:NewTransmission(ttstext,nil,self.controlmsrs,nil,2)
|
||||||
end
|
end
|
||||||
self:_DisplayMessageToGroup( _unit, _message, nil, false )
|
self:_DisplayMessageToGroup( _unit, _message, nil, false )
|
||||||
|
|
||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
-- weapon impacted too far from the nearest target! No Score!
|
-- weapon impacted too far from the nearest target! No Score!
|
||||||
if self.useSRS then
|
if self.useSRS then
|
||||||
@@ -2021,11 +2019,11 @@ function RANGE._OnImpact(weapon, self, playerData, attackHdg, attackAlt, attackV
|
|||||||
self.rangecontrol:NewTransmission( RANGE.Sound.RCWeaponImpactedTooFar.filename, RANGE.Sound.RCWeaponImpactedTooFar.duration, self.soundpath, nil, nil, _message, self.subduration )
|
self.rangecontrol:NewTransmission( RANGE.Sound.RCWeaponImpactedTooFar.filename, RANGE.Sound.RCWeaponImpactedTooFar.duration, self.soundpath, nil, nil, _message, self.subduration )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
self:T( self.lid .. "Weapon impacted outside range zone." )
|
self:T( self.lid .. "Weapon impacted outside range zone." )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Range event handler for event shot (when a unit releases a rocket or bomb (but not a fast firing gun).
|
--- Range event handler for event shot (when a unit releases a rocket or bomb (but not a fast firing gun).
|
||||||
@@ -2038,7 +2036,7 @@ function RANGE:OnEventShot( EventData )
|
|||||||
if EventData.Weapon == nil or EventData.IniDCSUnit == nil or EventData.IniPlayerName == nil then
|
if EventData.Weapon == nil or EventData.IniDCSUnit == nil or EventData.IniPlayerName == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create weapon object.
|
-- Create weapon object.
|
||||||
local weapon=WEAPON:New(EventData.weapon)
|
local weapon=WEAPON:New(EventData.weapon)
|
||||||
|
|
||||||
@@ -2050,7 +2048,7 @@ function RANGE:OnEventShot( EventData )
|
|||||||
|
|
||||||
-- Get player unit and name.
|
-- Get player unit and name.
|
||||||
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )
|
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )
|
||||||
|
|
||||||
-- Distance Player-to-Range. Set this to larger value than the threshold.
|
-- Distance Player-to-Range. Set this to larger value than the threshold.
|
||||||
local dPR = self.BombtrackThreshold * 2
|
local dPR = self.BombtrackThreshold * 2
|
||||||
|
|
||||||
@@ -2065,16 +2063,16 @@ function RANGE:OnEventShot( EventData )
|
|||||||
|
|
||||||
-- Player data.
|
-- Player data.
|
||||||
local playerData = self.PlayerSettings[_playername] -- #RANGE.PlayerData
|
local playerData = self.PlayerSettings[_playername] -- #RANGE.PlayerData
|
||||||
|
|
||||||
-- Attack parameters.
|
-- Attack parameters.
|
||||||
local attackHdg=_unit:GetHeading()
|
local attackHdg=_unit:GetHeading()
|
||||||
local attackAlt=_unit:GetHeight()
|
local attackAlt=_unit:GetHeight()
|
||||||
attackAlt = UTILS.MetersToFeet(attackAlt)
|
attackAlt = UTILS.MetersToFeet(attackAlt)
|
||||||
local attackVel=_unit:GetVelocityKNOTS()
|
local attackVel=_unit:GetVelocityKNOTS()
|
||||||
|
|
||||||
-- Tracking info and init of last bomb position.
|
-- Tracking info and init of last bomb position.
|
||||||
self:T( self.lid .. string.format( "RANGE %s: Tracking %s - %s.", self.rangename, weapon:GetTypeName(), weapon:GetName()))
|
self:T( self.lid .. string.format( "RANGE %s: Tracking %s - %s.", self.rangename, weapon:GetTypeName(), weapon:GetName()))
|
||||||
|
|
||||||
-- Set callback function on impact.
|
-- Set callback function on impact.
|
||||||
weapon:SetFuncImpact(RANGE._OnImpact, self, playerData, attackHdg, attackAlt, attackVel)
|
weapon:SetFuncImpact(RANGE._OnImpact, self, playerData, attackHdg, attackAlt, attackVel)
|
||||||
|
|
||||||
@@ -2146,33 +2144,33 @@ end
|
|||||||
function RANGE:onafterEnterRange( From, Event, To, player )
|
function RANGE:onafterEnterRange( From, Event, To, player )
|
||||||
|
|
||||||
if self.instructor and self.rangecontrol then
|
if self.instructor and self.rangecontrol then
|
||||||
|
|
||||||
if self.useSRS then
|
if self.useSRS then
|
||||||
|
|
||||||
|
|
||||||
local text = string.format("You entered the bombing range. For hit assessment, contact the range controller at %.3f MHz", self.rangecontrolfreq)
|
local text = string.format("You entered the bombing range. For hit assessment, contact the range controller at %.3f MHz", self.rangecontrolfreq)
|
||||||
local ttstext = string.format("You entered the bombing range. For hit assessment, contact the range controller at %.3f mega hertz.", self.rangecontrolfreq)
|
local ttstext = string.format("You entered the bombing range. For hit assessment, contact the range controller at %.3f mega hertz.", self.rangecontrolfreq)
|
||||||
|
|
||||||
local group = player.client:GetGroup()
|
local group = player.client:GetGroup()
|
||||||
|
|
||||||
self.instructsrsQ:NewTransmission(ttstext, nil, self.instructmsrs, nil, 1, {group}, text, 10)
|
self.instructsrsQ:NewTransmission(ttstext, nil, self.instructmsrs, nil, 1, {group}, text, 10)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Range control radio frequency split.
|
-- Range control radio frequency split.
|
||||||
local RF = UTILS.Split( string.format( "%.3f", self.rangecontrolfreq ), "." )
|
local RF = UTILS.Split( string.format( "%.3f", self.rangecontrolfreq ), "." )
|
||||||
|
|
||||||
-- Radio message that player entered the range
|
-- Radio message that player entered the range
|
||||||
|
|
||||||
-- You entered the bombing range. For hit assessment, contact the range controller at xy MHz
|
-- You entered the bombing range. For hit assessment, contact the range controller at xy MHz
|
||||||
self.instructor:NewTransmission( RANGE.Sound.IREnterRange.filename, RANGE.Sound.IREnterRange.duration, self.soundpath )
|
self.instructor:NewTransmission( RANGE.Sound.IREnterRange.filename, RANGE.Sound.IREnterRange.duration, self.soundpath )
|
||||||
self.instructor:Number2Transmission( RF[1] )
|
self.instructor:Number2Transmission( RF[1] )
|
||||||
|
|
||||||
if tonumber( RF[2] ) > 0 then
|
if tonumber( RF[2] ) > 0 then
|
||||||
self.instructor:NewTransmission( RANGE.Sound.IRDecimal.filename, RANGE.Sound.IRDecimal.duration, self.soundpath )
|
self.instructor:NewTransmission( RANGE.Sound.IRDecimal.filename, RANGE.Sound.IRDecimal.duration, self.soundpath )
|
||||||
self.instructor:Number2Transmission( RF[2] )
|
self.instructor:Number2Transmission( RF[2] )
|
||||||
end
|
end
|
||||||
|
|
||||||
self.instructor:NewTransmission( RANGE.Sound.IRMegaHertz.filename, RANGE.Sound.IRMegaHertz.duration, self.soundpath )
|
self.instructor:NewTransmission( RANGE.Sound.IRMegaHertz.filename, RANGE.Sound.IRMegaHertz.duration, self.soundpath )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2190,11 +2188,11 @@ function RANGE:onafterExitRange( From, Event, To, player )
|
|||||||
if self.instructor then
|
if self.instructor then
|
||||||
-- You left the bombing range zone. Have a nice day!
|
-- You left the bombing range zone. Have a nice day!
|
||||||
if self.useSRS then
|
if self.useSRS then
|
||||||
|
|
||||||
local text = "You left the bombing range zone. "
|
local text = "You left the bombing range zone. "
|
||||||
|
|
||||||
local r=math.random(5)
|
local r=math.random(5)
|
||||||
|
|
||||||
if r==1 then
|
if r==1 then
|
||||||
text=text.."Have a nice day!"
|
text=text.."Have a nice day!"
|
||||||
elseif r==2 then
|
elseif r==2 then
|
||||||
@@ -2204,9 +2202,9 @@ function RANGE:onafterExitRange( From, Event, To, player )
|
|||||||
elseif r==4 then
|
elseif r==4 then
|
||||||
text=text.."See you in two weeks!"
|
text=text.."See you in two weeks!"
|
||||||
elseif r==5 then
|
elseif r==5 then
|
||||||
text=text.."!"
|
text=text.."!"
|
||||||
end
|
end
|
||||||
|
|
||||||
self.instructsrsQ:NewTransmission(text, nil, self.instructmsrs, nil, 1, {player.client:GetGroup()}, text, 10)
|
self.instructsrsQ:NewTransmission(text, nil, self.instructmsrs, nil, 1, {player.client:GetGroup()}, text, 10)
|
||||||
else
|
else
|
||||||
self.instructor:NewTransmission( RANGE.Sound.IRExitRange.filename, RANGE.Sound.IRExitRange.duration, self.soundpath )
|
self.instructor:NewTransmission( RANGE.Sound.IRExitRange.filename, RANGE.Sound.IRExitRange.duration, self.soundpath )
|
||||||
@@ -2240,7 +2238,7 @@ function RANGE:onafterImpact( From, Event, To, result, player )
|
|||||||
text = text .. string.format( " %s hit.", result.quality )
|
text = text .. string.format( " %s hit.", result.quality )
|
||||||
|
|
||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
|
|
||||||
if self.useSRS then
|
if self.useSRS then
|
||||||
local group = player.client:GetGroup()
|
local group = player.client:GetGroup()
|
||||||
self.controlsrsQ:NewTransmission(text,nil,self.controlmsrs,nil,1,{group},text,10)
|
self.controlsrsQ:NewTransmission(text,nil,self.controlmsrs,nil,1,{group},text,10)
|
||||||
@@ -2265,10 +2263,10 @@ function RANGE:onafterImpact( From, Event, To, result, player )
|
|||||||
|
|
||||||
-- Unit.
|
-- Unit.
|
||||||
if player.unitname and not self.useSRS then
|
if player.unitname and not self.useSRS then
|
||||||
|
|
||||||
-- Get unit.
|
-- Get unit.
|
||||||
local unit = UNIT:FindByName( player.unitname )
|
local unit = UNIT:FindByName( player.unitname )
|
||||||
|
|
||||||
-- Send message.
|
-- Send message.
|
||||||
self:_DisplayMessageToGroup( unit, text, nil, true )
|
self:_DisplayMessageToGroup( unit, text, nil, true )
|
||||||
self:T( self.lid .. text )
|
self:T( self.lid .. text )
|
||||||
@@ -2278,7 +2276,7 @@ function RANGE:onafterImpact( From, Event, To, result, player )
|
|||||||
if self.autosave then
|
if self.autosave then
|
||||||
self:Save()
|
self:Save()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Send result to FunkMan, which creates fancy MatLab figures and sends them to Discord via a bot.
|
-- Send result to FunkMan, which creates fancy MatLab figures and sends them to Discord via a bot.
|
||||||
if self.funkmanSocket then
|
if self.funkmanSocket then
|
||||||
self.funkmanSocket:SendTable(result)
|
self.funkmanSocket:SendTable(result)
|
||||||
@@ -2547,7 +2545,7 @@ function RANGE:_DisplayMyStrafePitResults( _unitName )
|
|||||||
local _message = string.format( "My Top %d Strafe Pit Results:\n", self.ndisplayresult )
|
local _message = string.format( "My Top %d Strafe Pit Results:\n", self.ndisplayresult )
|
||||||
|
|
||||||
-- Get player results.
|
-- Get player results.
|
||||||
local _results = self.strafePlayerResults[_playername]
|
local _results = self.strafePlayerResults[_playername]
|
||||||
|
|
||||||
-- Create message.
|
-- Create message.
|
||||||
if _results == nil then
|
if _results == nil then
|
||||||
@@ -2853,7 +2851,7 @@ function RANGE:_DisplayRangeInfo( _unitname )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
text = text .. string.format( "Instructor %.3f MHz (Relay=%s)\n", self.instructorfreq, alive )
|
text = text .. string.format( "Instructor %.3f MHz (Relay=%s)\n", self.instructorfreq, alive )
|
||||||
end
|
end
|
||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
local alive = "N/A"
|
local alive = "N/A"
|
||||||
if self.rangecontrolrelayname then
|
if self.rangecontrolrelayname then
|
||||||
@@ -3081,10 +3079,10 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
local unitheading = 0 -- RangeBoss
|
local unitheading = 0 -- RangeBoss
|
||||||
|
|
||||||
if _unit and _playername then
|
if _unit and _playername then
|
||||||
|
|
||||||
-- Player data.
|
-- Player data.
|
||||||
local playerData=self.PlayerSettings[_playername] -- #RANGE.PlayerData
|
local playerData=self.PlayerSettings[_playername] -- #RANGE.PlayerData
|
||||||
|
|
||||||
--- Function to check if unit is in zone and facing in the right direction and is below the max alt.
|
--- Function to check if unit is in zone and facing in the right direction and is below the max alt.
|
||||||
local function checkme( targetheading, _zone )
|
local function checkme( targetheading, _zone )
|
||||||
local zone = _zone -- Core.Zone#ZONE
|
local zone = _zone -- Core.Zone#ZONE
|
||||||
@@ -3098,7 +3096,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
if towardspit then
|
if towardspit then
|
||||||
|
|
||||||
local vec3 = _unit:GetVec3()
|
local vec3 = _unit:GetVec3()
|
||||||
local vec2 = { x = vec3.x, y = vec3.z } -- DCS#Vec2
|
local vec2 = { x = vec3.x, y = vec3.z } -- DCS#Vec2
|
||||||
local landheight = land.getHeight( vec2 )
|
local landheight = land.getHeight( vec2 )
|
||||||
local unitalt = vec3.y - landheight
|
local unitalt = vec3.y - landheight
|
||||||
|
|
||||||
@@ -3145,7 +3143,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Send message.
|
-- Send message.
|
||||||
self:_DisplayMessageToGroup( _unit, _msg, nil, true )
|
self:_DisplayMessageToGroup( _unit, _msg, nil, true )
|
||||||
|
|
||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
if self.useSRS then
|
if self.useSRS then
|
||||||
local group = _unit:GetGroup()
|
local group = _unit:GetGroup()
|
||||||
@@ -3164,9 +3162,9 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Result.
|
-- Result.
|
||||||
local _result = self.strafeStatus[_unitID] --#RANGE.StrafeStatus
|
local _result = self.strafeStatus[_unitID] --#RANGE.StrafeStatus
|
||||||
|
|
||||||
local _sound = nil -- #RANGE.Soundfile
|
local _sound = nil -- #RANGE.Soundfile
|
||||||
|
|
||||||
-- Calculate accuracy of run. Number of hits wrt number of rounds fired.
|
-- Calculate accuracy of run. Number of hits wrt number of rounds fired.
|
||||||
local shots = _result.ammo - _ammo
|
local shots = _result.ammo - _ammo
|
||||||
local accur = 0
|
local accur = 0
|
||||||
@@ -3176,7 +3174,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
accur = 100
|
accur = 100
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Results text and sound message.
|
-- Results text and sound message.
|
||||||
local resulttext=""
|
local resulttext=""
|
||||||
if _result.pastfoulline == true then --
|
if _result.pastfoulline == true then --
|
||||||
@@ -3213,7 +3211,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Send message.
|
-- Send message.
|
||||||
self:_DisplayMessageToGroup( _unit, _text )
|
self:_DisplayMessageToGroup( _unit, _text )
|
||||||
|
|
||||||
-- Strafe result.
|
-- Strafe result.
|
||||||
local result = {} -- #RANGE.StrafeResult
|
local result = {} -- #RANGE.StrafeResult
|
||||||
result.command=SOCKET.DataType.STRAFERESULT
|
result.command=SOCKET.DataType.STRAFERESULT
|
||||||
@@ -3230,14 +3228,14 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
result.rangename = self.rangename
|
result.rangename = self.rangename
|
||||||
result.airframe=playerData.airframe
|
result.airframe=playerData.airframe
|
||||||
result.invalid = _result.pastfoulline
|
result.invalid = _result.pastfoulline
|
||||||
|
|
||||||
-- Griger Results.
|
-- Griger Results.
|
||||||
self:StrafeResult(playerData, result)
|
self:StrafeResult(playerData, result)
|
||||||
|
|
||||||
-- Save trap sheet.
|
-- Save trap sheet.
|
||||||
if playerData and playerData.targeton and self.targetsheet then
|
if playerData and playerData.targeton and self.targetsheet then
|
||||||
self:_SaveTargetSheet( _playername, result )
|
self:_SaveTargetSheet( _playername, result )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Voice over.
|
-- Voice over.
|
||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
@@ -3302,7 +3300,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Send message.
|
-- Send message.
|
||||||
self:_DisplayMessageToGroup( _unit, _msg, 10, true )
|
self:_DisplayMessageToGroup( _unit, _msg, 10, true )
|
||||||
|
|
||||||
-- Trigger event that player is rolling in.
|
-- Trigger event that player is rolling in.
|
||||||
self:RollingIn(playerData, target)
|
self:RollingIn(playerData, target)
|
||||||
|
|
||||||
@@ -3438,18 +3436,18 @@ function RANGE:_GetBombTargetCoordinate( target )
|
|||||||
local coord = nil -- Core.Point#COORDINATE
|
local coord = nil -- Core.Point#COORDINATE
|
||||||
|
|
||||||
if target.type == RANGE.TargetType.UNIT then
|
if target.type == RANGE.TargetType.UNIT then
|
||||||
|
|
||||||
-- Check if alive
|
-- Check if alive
|
||||||
if target.target and target.target:IsAlive() then
|
if target.target and target.target:IsAlive() then
|
||||||
-- Get current position.
|
-- Get current position.
|
||||||
coord = target.target:GetCoordinate()
|
coord = target.target:GetCoordinate()
|
||||||
-- Save as last known position in case target dies.
|
-- Save as last known position in case target dies.
|
||||||
target.coordinate=coord
|
target.coordinate=coord
|
||||||
else
|
else
|
||||||
-- Use stored position.
|
-- Use stored position.
|
||||||
coord = target.coordinate
|
coord = target.coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif target.type == RANGE.TargetType.STATIC then
|
elseif target.type == RANGE.TargetType.STATIC then
|
||||||
|
|
||||||
-- Static targets dont move.
|
-- Static targets dont move.
|
||||||
@@ -3459,11 +3457,11 @@ function RANGE:_GetBombTargetCoordinate( target )
|
|||||||
|
|
||||||
-- Coordinates dont move.
|
-- Coordinates dont move.
|
||||||
coord = target.coordinate
|
coord = target.coordinate
|
||||||
|
|
||||||
elseif target.type == RANGE.TargetType.SCENERY then
|
elseif target.type == RANGE.TargetType.SCENERY then
|
||||||
|
|
||||||
-- Coordinates dont move.
|
-- Coordinates dont move.
|
||||||
coord = target.coordinate
|
coord = target.coordinate
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E( self.lid .. "ERROR: Unknown target type." )
|
self:E( self.lid .. "ERROR: Unknown target type." )
|
||||||
@@ -3670,7 +3668,7 @@ function RANGE:_DisplayMessageToGroup( _unit, _text, _time, _clear, display, _to
|
|||||||
local playermessage = self.PlayerSettings[playername].messages
|
local playermessage = self.PlayerSettings[playername].messages
|
||||||
|
|
||||||
-- Send message to player if messages enabled and not only for the examiner.
|
-- Send message to player if messages enabled and not only for the examiner.
|
||||||
|
|
||||||
if _gid and (playermessage == true or display) and (not self.examinerexclusive) then
|
if _gid and (playermessage == true or display) and (not self.examinerexclusive) then
|
||||||
if _togroup and _grp then
|
if _togroup and _grp then
|
||||||
local m = MESSAGE:New(_text,_time,nil,_clear):ToGroup(_grp)
|
local m = MESSAGE:New(_text,_time,nil,_clear):ToGroup(_grp)
|
||||||
@@ -4025,9 +4023,9 @@ function RANGE:_GetPlayerUnitAndName( _unitName )
|
|||||||
self:F2( _unitName )
|
self:F2( _unitName )
|
||||||
|
|
||||||
if _unitName ~= nil then
|
if _unitName ~= nil then
|
||||||
|
|
||||||
local multiplayer = false
|
local multiplayer = false
|
||||||
|
|
||||||
-- Get DCS unit from its name.
|
-- Get DCS unit from its name.
|
||||||
local DCSunit = Unit.getByName( _unitName )
|
local DCSunit = Unit.getByName( _unitName )
|
||||||
|
|
||||||
@@ -4066,7 +4064,7 @@ function RANGE:_myname( unitname )
|
|||||||
if grp and grp:IsAlive() then
|
if grp and grp:IsAlive() then
|
||||||
pname = grp:GetCustomCallSign(true,true)
|
pname = grp:GetCustomCallSign(true,true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return pname
|
return pname
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
--
|
--
|
||||||
-- @module Functional.Stratego
|
-- @module Functional.Stratego
|
||||||
-- @image Functional.Stratego.png
|
-- @image Functional.Stratego.png
|
||||||
|
-- Last Update May 2024
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -41,7 +42,9 @@
|
|||||||
-- @field #boolean usebudget
|
-- @field #boolean usebudget
|
||||||
-- @field #number CaptureUnits
|
-- @field #number CaptureUnits
|
||||||
-- @field #number CaptureThreatlevel
|
-- @field #number CaptureThreatlevel
|
||||||
|
-- @field #table CaptureObjectCategories
|
||||||
-- @field #boolean ExcludeShips
|
-- @field #boolean ExcludeShips
|
||||||
|
-- @field Core.Zone#ZONE StrategoZone
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
@@ -154,6 +157,7 @@
|
|||||||
-- @{#STRATEGO.FindRoute}(): Find a route between two nodes.
|
-- @{#STRATEGO.FindRoute}(): Find a route between two nodes.
|
||||||
-- @{#STRATEGO.SetCaptureOptions}(): Set how many units of which minimum threat level are needed to capture one node (i.e. the underlying OpsZone).
|
-- @{#STRATEGO.SetCaptureOptions}(): Set how many units of which minimum threat level are needed to capture one node (i.e. the underlying OpsZone).
|
||||||
-- @{#STRATEGO.SetDebug}(): Set debug and draw options.
|
-- @{#STRATEGO.SetDebug}(): Set debug and draw options.
|
||||||
|
-- @{#STRATEGO.SetStrategoZone}(): Set a zone to restrict STRATEGO analytics to, can be any kind of ZONE Object.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- ## Visualisation example code for the Syria map:
|
-- ## Visualisation example code for the Syria map:
|
||||||
@@ -177,7 +181,7 @@ STRATEGO = {
|
|||||||
debug = false,
|
debug = false,
|
||||||
drawzone = false,
|
drawzone = false,
|
||||||
markzone = false,
|
markzone = false,
|
||||||
version = "0.2.5",
|
version = "0.3.1",
|
||||||
portweight = 3,
|
portweight = 3,
|
||||||
POIweight = 1,
|
POIweight = 1,
|
||||||
maxrunways = 3,
|
maxrunways = 3,
|
||||||
@@ -196,6 +200,7 @@ STRATEGO = {
|
|||||||
usebudget = false,
|
usebudget = false,
|
||||||
CaptureUnits = 3,
|
CaptureUnits = 3,
|
||||||
CaptureThreatlevel = 1,
|
CaptureThreatlevel = 1,
|
||||||
|
CaptureObjectCategories = {Object.Category.UNIT},
|
||||||
ExcludeShips = true,
|
ExcludeShips = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,9 +212,10 @@ STRATEGO = {
|
|||||||
-- @field #number coalition
|
-- @field #number coalition
|
||||||
-- @field #boolean port
|
-- @field #boolean port
|
||||||
-- @field Core.Zone#ZONE_RADIUS zone,
|
-- @field Core.Zone#ZONE_RADIUS zone,
|
||||||
-- @field Core.Point#COORDINATRE coord
|
-- @field Core.Point#COORDINATE coord
|
||||||
-- @field #string type
|
-- @field #string type
|
||||||
-- @field Ops.OpsZone#OPSZONE opszone
|
-- @field Ops.OpsZone#OPSZONE opszone
|
||||||
|
-- @field #number connections
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @type STRATEGO.DistData
|
-- @type STRATEGO.DistData
|
||||||
@@ -377,6 +383,15 @@ function STRATEGO:SetDebug(Debug,DrawZones,MarkZones)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [USER] Restrict Stratego to analyse this zone only.
|
||||||
|
-- @param #STRATEGO self
|
||||||
|
-- @param Core.Zone#ZONE Zone The Zone to restrict Stratego to, can be any kind of ZONE Object.
|
||||||
|
-- @return #STRATEGO self
|
||||||
|
function STRATEGO:SetStrategoZone(Zone)
|
||||||
|
self.StrategoZone = Zone
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- [USER] Set weights for nodes and routes to determine their importance.
|
--- [USER] Set weights for nodes and routes to determine their importance.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #number MaxRunways Set the maximum number of runways the big (equals strategic) airbases on the map have. Defaults to 3. The weight of an airbase node hence equals the number of runways.
|
-- @param #number MaxRunways Set the maximum number of runways the big (equals strategic) airbases on the map have. Defaults to 3. The weight of an airbase node hence equals the number of runways.
|
||||||
@@ -407,11 +422,13 @@ end
|
|||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #number CaptureUnits Number of units needed, defaults to three.
|
-- @param #number CaptureUnits Number of units needed, defaults to three.
|
||||||
-- @param #number CaptureThreatlevel Threat level needed, can be 0..10, defaults to one.
|
-- @param #number CaptureThreatlevel Threat level needed, can be 0..10, defaults to one.
|
||||||
|
-- @param #table CaptureCategories Table of object categories which can capture a node, defaults to `{Object.Category.UNIT}`.
|
||||||
-- @return #STRATEGO self
|
-- @return #STRATEGO self
|
||||||
function STRATEGO:SetCaptureOptions(CaptureUnits,CaptureThreatlevel)
|
function STRATEGO:SetCaptureOptions(CaptureUnits,CaptureThreatlevel,CaptureCategories)
|
||||||
self:T(self.lid.."SetCaptureOptions")
|
self:T(self.lid.."SetCaptureOptions")
|
||||||
self.CaptureUnits = CaptureUnits or 3
|
self.CaptureUnits = CaptureUnits or 3
|
||||||
self.CaptureThreatlevel = CaptureThreatlevel or 1
|
self.CaptureThreatlevel = CaptureThreatlevel or 1
|
||||||
|
self.CaptureObjectCategories = CaptureCategories or {Object.Category.UNIT}
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -425,12 +442,19 @@ function STRATEGO:AnalyseBases()
|
|||||||
local airbasetable = self.airbasetable
|
local airbasetable = self.airbasetable
|
||||||
local nonconnectedab = self.nonconnectedab
|
local nonconnectedab = self.nonconnectedab
|
||||||
local easynames = self.easynames
|
local easynames = self.easynames
|
||||||
|
local zone = self.StrategoZone -- Core.Zone#ZONE_POLYGON
|
||||||
|
|
||||||
-- find bases with >= 1 runways
|
-- find bases with >= 1 runways
|
||||||
self.bases:ForEach(
|
self.bases:ForEach(
|
||||||
function(afb)
|
function(afb)
|
||||||
local ab = afb -- Wrapper.Airbase#AIRBASE
|
local ab = afb -- Wrapper.Airbase#AIRBASE
|
||||||
|
local abvec2 = ab:GetVec2()
|
||||||
if self.ExcludeShips and ab:IsShip() then return end
|
if self.ExcludeShips and ab:IsShip() then return end
|
||||||
|
if zone ~= nil then
|
||||||
|
if not zone:IsVec2InZone(abvec2) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
local abname = ab:GetName()
|
local abname = ab:GetName()
|
||||||
local runways = ab:GetRunways()
|
local runways = ab:GetRunways()
|
||||||
local numrwys = #runways
|
local numrwys = #runways
|
||||||
@@ -467,6 +491,7 @@ function STRATEGO:AnalyseBases()
|
|||||||
coord = coord,
|
coord = coord,
|
||||||
type = abtype,
|
type = abtype,
|
||||||
opszone = opszone,
|
opszone = opszone,
|
||||||
|
connections = 0,
|
||||||
}
|
}
|
||||||
airbasetable[abname] = tbl
|
airbasetable[abname] = tbl
|
||||||
nonconnectedab[abname] = true
|
nonconnectedab[abname] = true
|
||||||
@@ -507,6 +532,7 @@ function STRATEGO:GetNewOpsZone(Zone,Coalition)
|
|||||||
local opszone = OPSZONE:New(Zone,Coalition or 0)
|
local opszone = OPSZONE:New(Zone,Coalition or 0)
|
||||||
opszone:SetCaptureNunits(self.CaptureUnits)
|
opszone:SetCaptureNunits(self.CaptureUnits)
|
||||||
opszone:SetCaptureThreatlevel(self.CaptureThreatlevel)
|
opszone:SetCaptureThreatlevel(self.CaptureThreatlevel)
|
||||||
|
opszone:SetObjectCategories(self.CaptureObjectCategories)
|
||||||
opszone:SetDrawZone(self.drawzone)
|
opszone:SetDrawZone(self.drawzone)
|
||||||
opszone:SetMarkZone(self.markzone)
|
opszone:SetMarkZone(self.markzone)
|
||||||
opszone:Start()
|
opszone:Start()
|
||||||
@@ -552,10 +578,12 @@ function STRATEGO:AnalysePOIs(Set,Weight,Key)
|
|||||||
coord = coord,
|
coord = coord,
|
||||||
type = Key,
|
type = Key,
|
||||||
opszone = opszone,
|
opszone = opszone,
|
||||||
|
connections = 0,
|
||||||
}
|
}
|
||||||
airbasetable[zone:GetName()] = tbl
|
airbasetable[zname] = tbl
|
||||||
nonconnectedab[zone:GetName()] = true
|
nonconnectedab[zname] = true
|
||||||
local name = string.gsub(zname,"[%p%s]",".")
|
local name = string.gsub(zname,"[%p%s]",".")
|
||||||
|
--self:I({name=name,zone=zname})
|
||||||
easynames[name]=zname
|
easynames[name]=zname
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@@ -566,7 +594,7 @@ end
|
|||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @return #STRATEGO self
|
-- @return #STRATEGO self
|
||||||
function STRATEGO:GetToFrom(StartPoint,EndPoint)
|
function STRATEGO:GetToFrom(StartPoint,EndPoint)
|
||||||
self:T(self.lid.."GetToFrom")
|
self:T(self.lid.."GetToFrom "..tostring(StartPoint).." "..tostring(EndPoint))
|
||||||
local pstart = string.gsub(StartPoint,"[%p%s]",".")
|
local pstart = string.gsub(StartPoint,"[%p%s]",".")
|
||||||
local pend = string.gsub(EndPoint,"[%p%s]",".")
|
local pend = string.gsub(EndPoint,"[%p%s]",".")
|
||||||
local fromto = pstart..";"..pend
|
local fromto = pstart..";"..pend
|
||||||
@@ -574,11 +602,35 @@ function STRATEGO:GetToFrom(StartPoint,EndPoint)
|
|||||||
return fromto, tofrom
|
return fromto, tofrom
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [USER] Get available connecting nodes from one start node
|
||||||
|
-- @param #STRATEGO self
|
||||||
|
-- @param #string StartPoint The starting name
|
||||||
|
-- @return #boolean found
|
||||||
|
-- @return #table Nodes
|
||||||
|
function STRATEGO:GetRoutesFromNode(StartPoint)
|
||||||
|
self:T(self.lid.."GetRoutesFromNode")
|
||||||
|
local pstart = string.gsub(StartPoint,"[%p%s]",".")
|
||||||
|
local found = false
|
||||||
|
pstart=pstart..";"
|
||||||
|
local routes = {}
|
||||||
|
local listed = {}
|
||||||
|
for _,_data in pairs(self.routexists) do
|
||||||
|
if string.find(_data,pstart,1,true) and not listed[_data] then
|
||||||
|
local target = string.gsub(_data,pstart,"")
|
||||||
|
local fname = self.easynames[target]
|
||||||
|
table.insert(routes,fname)
|
||||||
|
found = true
|
||||||
|
listed[_data] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return found,routes
|
||||||
|
end
|
||||||
|
|
||||||
--- [USER] Manually add a route, for e.g. Island hopping or to connect isolated networks. Use **after** STRATEGO has been started!
|
--- [USER] Manually add a route, for e.g. Island hopping or to connect isolated networks. Use **after** STRATEGO has been started!
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Startpoint Starting Point, e.g. AIRBASE.Syria.Hatay
|
-- @param #string Startpoint Starting Point, e.g. AIRBASE.Syria.Hatay
|
||||||
-- @param #string Endpoint End Point, e.g. AIRBASE.Syria.H4
|
-- @param #string Endpoint End Point, e.g. AIRBASE.Syria.H4
|
||||||
-- @param #table Color (Optional) RGB color table {r, g, b}, e.g. {1,0,0} for red. Defaults to lila.
|
-- @param #table Color (Optional) RGB color table {r, g, b}, e.g. {1,0,0} for red. Defaults to violet.
|
||||||
-- @param #number Linetype (Optional) Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 5.
|
-- @param #number Linetype (Optional) Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 5.
|
||||||
-- @param #boolean Draw (Optional) If true, draw route on the F10 map. Defaukt false.
|
-- @param #boolean Draw (Optional) If true, draw route on the F10 map. Defaukt false.
|
||||||
-- @return #STRATEGO self
|
-- @return #STRATEGO self
|
||||||
@@ -606,6 +658,8 @@ function STRATEGO:AddRoutesManually(Startpoint,Endpoint,Color,Linetype,Draw)
|
|||||||
local factor = self.airbasetable[Startpoint].baseweight*self.routefactor
|
local factor = self.airbasetable[Startpoint].baseweight*self.routefactor
|
||||||
self.airbasetable[Startpoint].weight = self.airbasetable[Startpoint].weight+factor
|
self.airbasetable[Startpoint].weight = self.airbasetable[Startpoint].weight+factor
|
||||||
self.airbasetable[Endpoint].weight = self.airbasetable[Endpoint].weight+factor
|
self.airbasetable[Endpoint].weight = self.airbasetable[Endpoint].weight+factor
|
||||||
|
self.airbasetable[Endpoint].connections = self.airbasetable[Endpoint].connections + 2
|
||||||
|
self.airbasetable[Startpoint].connections = self.airbasetable[Startpoint].connections+2
|
||||||
if self.debug or Draw then
|
if self.debug or Draw then
|
||||||
startcoordinate:LineToAll(targetcoordinate,-1,color,1,linetype,nil,string.format("%dkm",dist))
|
startcoordinate:LineToAll(targetcoordinate,-1,color,1,linetype,nil,string.format("%dkm",dist))
|
||||||
end
|
end
|
||||||
@@ -624,7 +678,7 @@ function STRATEGO:AnalyseRoutes(tgtrwys,factor,color,linetype)
|
|||||||
for _,_data in pairs(self.airbasetable) do
|
for _,_data in pairs(self.airbasetable) do
|
||||||
local fromto,tofrom = self:GetToFrom(startpoint,_data.name)
|
local fromto,tofrom = self:GetToFrom(startpoint,_data.name)
|
||||||
if _data.name == startpoint then
|
if _data.name == startpoint then
|
||||||
-- sam as we
|
-- same as we
|
||||||
elseif _data.baseweight == tgtrwys and not (self.routexists[fromto] or self.routexists[tofrom]) then
|
elseif _data.baseweight == tgtrwys and not (self.routexists[fromto] or self.routexists[tofrom]) then
|
||||||
local tgtc = _data.coord
|
local tgtc = _data.coord
|
||||||
local dist = UTILS.Round(tgtc:Get2DDistance(startcoord),-2)/1000
|
local dist = UTILS.Round(tgtc:Get2DDistance(startcoord),-2)/1000
|
||||||
@@ -646,6 +700,8 @@ function STRATEGO:AnalyseRoutes(tgtrwys,factor,color,linetype)
|
|||||||
self.nonconnectedab[startpoint] = false
|
self.nonconnectedab[startpoint] = false
|
||||||
self.airbasetable[startpoint].weight = self.airbasetable[startpoint].weight+factor
|
self.airbasetable[startpoint].weight = self.airbasetable[startpoint].weight+factor
|
||||||
self.airbasetable[_data.name].weight = self.airbasetable[_data.name].weight+factor
|
self.airbasetable[_data.name].weight = self.airbasetable[_data.name].weight+factor
|
||||||
|
self.airbasetable[startpoint].connections = self.airbasetable[startpoint].connections + 1
|
||||||
|
self.airbasetable[_data.name].connections = self.airbasetable[_data.name].connections + 1
|
||||||
if self.debug then
|
if self.debug then
|
||||||
startcoord:LineToAll(tgtc,-1,color,1,linetype,nil,string.format("%dkm",dist))
|
startcoord:LineToAll(tgtc,-1,color,1,linetype,nil,string.format("%dkm",dist))
|
||||||
end
|
end
|
||||||
@@ -692,6 +748,8 @@ function STRATEGO:AnalyseUnconnected(Color)
|
|||||||
end
|
end
|
||||||
self.airbasetable[startpoint].weight = self.airbasetable[startpoint].weight+1
|
self.airbasetable[startpoint].weight = self.airbasetable[startpoint].weight+1
|
||||||
self.airbasetable[closest].weight = self.airbasetable[closest].weight+1
|
self.airbasetable[closest].weight = self.airbasetable[closest].weight+1
|
||||||
|
self.airbasetable[startpoint].connections = self.airbasetable[startpoint].connections+2
|
||||||
|
self.airbasetable[closest].connections = self.airbasetable[closest].connections+2
|
||||||
local data = {
|
local data = {
|
||||||
start = startpoint,
|
start = startpoint,
|
||||||
target = closest,
|
target = closest,
|
||||||
@@ -708,14 +766,50 @@ function STRATEGO:AnalyseUnconnected(Color)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
function STRATEGO:PruneDeadEnds(abtable)
|
||||||
|
local found = false
|
||||||
|
local newtable = {}
|
||||||
|
for name, _data in pairs(abtable) do
|
||||||
|
local data = _data -- #STRATEGO.Data
|
||||||
|
if data.connections > 2 then
|
||||||
|
newtable[name] = data
|
||||||
|
else
|
||||||
|
-- dead end
|
||||||
|
found = true
|
||||||
|
local neighbors, nearest, distance = self:FindNeighborNodes(name)
|
||||||
|
--self:I("Pruning "..name)
|
||||||
|
if nearest then
|
||||||
|
for _name,_ in pairs(neighbors) do
|
||||||
|
local abname = self.easynames[_name] or _name
|
||||||
|
--self:I({easyname=_name,airbasename=abname})
|
||||||
|
if abtable[abname] then
|
||||||
|
abtable[abname].connections = abtable[abname].connections -1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if self.debug then
|
||||||
|
data.coord:CircleToAll(5000,-1,{1,1,1},1,{1,1,1},1,3,true,"Dead End")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
abtable = nil
|
||||||
|
return found,newtable
|
||||||
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
--- [USER] Get a list of the nodes with the highest weight.
|
--- [USER] Get a list of the nodes with the highest weight.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #number Coalition (Optional) Find for this coalition only. E.g. coalition.side.BLUE.
|
-- @param #number Coalition (Optional) Find for this coalition only. E.g. coalition.side.BLUE.
|
||||||
-- @return #table Table of nodes.
|
-- @return #table Table of nodes.
|
||||||
-- @return #number Weight The consolidated weight associated with the nodes.
|
-- @return #number Weight The consolidated weight associated with the nodes.
|
||||||
|
-- @return #number Highest Highest weight found.
|
||||||
|
-- @return #string Name of the node with the highest weight.
|
||||||
function STRATEGO:GetHighestWeightNodes(Coalition)
|
function STRATEGO:GetHighestWeightNodes(Coalition)
|
||||||
self:T(self.lid.."GetHighestWeightNodes")
|
self:T(self.lid.."GetHighestWeightNodes")
|
||||||
local weight = 0
|
local weight = 0
|
||||||
|
local highest = 0
|
||||||
|
local highname = nil
|
||||||
local airbases = {}
|
local airbases = {}
|
||||||
for _name,_data in pairs(self.airbasetable) do
|
for _name,_data in pairs(self.airbasetable) do
|
||||||
local okay = true
|
local okay = true
|
||||||
@@ -729,8 +823,12 @@ function STRATEGO:GetHighestWeightNodes(Coalition)
|
|||||||
if not airbases[weight] then airbases[weight]={} end
|
if not airbases[weight] then airbases[weight]={} end
|
||||||
table.insert(airbases[weight],_name)
|
table.insert(airbases[weight],_name)
|
||||||
end
|
end
|
||||||
|
if _data.weight > highest and okay then
|
||||||
|
highest = _data.weight
|
||||||
|
highname = _name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return airbases[weight],weight
|
return airbases[weight],weight,highest,highname
|
||||||
end
|
end
|
||||||
|
|
||||||
--- [USER] Get a list of the nodes a weight less than the given parameter.
|
--- [USER] Get a list of the nodes a weight less than the given parameter.
|
||||||
@@ -759,9 +857,39 @@ function STRATEGO:GetNextHighestWeightNodes(Weight, Coalition)
|
|||||||
return airbases[weight],weight
|
return airbases[weight],weight
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [USER] Set the aggregated weight of a single node found by its name manually.
|
||||||
|
-- @param #STRATEGO self
|
||||||
|
-- @param #string Name The name to look for.
|
||||||
|
-- @param #number Weight The weight to be set.
|
||||||
|
-- @return #boolean success
|
||||||
|
function STRATEGO:SetNodeWeight(Name,Weight)
|
||||||
|
self:T(self.lid.."SetNodeWeight")
|
||||||
|
if Name and Weight and self.airbasetable[Name] then
|
||||||
|
self.airbasetable[Name].weight = Weight or 0
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Set the base weight of a single node found by its name manually.
|
||||||
|
-- @param #STRATEGO self
|
||||||
|
-- @param #string Name The name to look for.
|
||||||
|
-- @param #number Weight The weight to be set.
|
||||||
|
-- @return #boolean success
|
||||||
|
function STRATEGO:SetNodeBaseWeight(Name,Weight)
|
||||||
|
self:T(self.lid.."SetNodeBaseWeight")
|
||||||
|
if Name and Weight and self.airbasetable[Name] then
|
||||||
|
self.airbasetable[Name].baseweight = Weight or 0
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- [USER] Get the aggregated weight of a node by its name.
|
--- [USER] Get the aggregated weight of a node by its name.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string Name The name to look for.
|
||||||
-- @return #number Weight The weight or 0 if not found.
|
-- @return #number Weight The weight or 0 if not found.
|
||||||
function STRATEGO:GetNodeWeight(Name)
|
function STRATEGO:GetNodeWeight(Name)
|
||||||
self:T(self.lid.."GetNodeWeight")
|
self:T(self.lid.."GetNodeWeight")
|
||||||
@@ -774,7 +902,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Get the base weight of a node by its name.
|
--- [USER] Get the base weight of a node by its name.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string Name The name to look for.
|
||||||
-- @return #number Weight The base weight or 0 if not found.
|
-- @return #number Weight The base weight or 0 if not found.
|
||||||
function STRATEGO:GetNodeBaseWeight(Name)
|
function STRATEGO:GetNodeBaseWeight(Name)
|
||||||
self:T(self.lid.."GetNodeBaseWeight")
|
self:T(self.lid.."GetNodeBaseWeight")
|
||||||
@@ -787,7 +915,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Get the COALITION of a node by its name.
|
--- [USER] Get the COALITION of a node by its name.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return #number Coalition The coalition.
|
-- @return #number Coalition The coalition.
|
||||||
function STRATEGO:GetNodeCoalition(Name)
|
function STRATEGO:GetNodeCoalition(Name)
|
||||||
self:T(self.lid.."GetNodeCoalition")
|
self:T(self.lid.."GetNodeCoalition")
|
||||||
@@ -800,7 +928,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Get the TYPE of a node by its name.
|
--- [USER] Get the TYPE of a node by its name.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return #string Type Type of the node, e.g. STRATEGO.Type.AIRBASE or nil if not found.
|
-- @return #string Type Type of the node, e.g. STRATEGO.Type.AIRBASE or nil if not found.
|
||||||
function STRATEGO:GetNodeType(Name)
|
function STRATEGO:GetNodeType(Name)
|
||||||
self:T(self.lid.."GetNodeType")
|
self:T(self.lid.."GetNodeType")
|
||||||
@@ -813,7 +941,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Get the ZONE of a node by its name.
|
--- [USER] Get the ZONE of a node by its name.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return Core.Zone#ZONE Zone The Zone of the node or nil if not found.
|
-- @return Core.Zone#ZONE Zone The Zone of the node or nil if not found.
|
||||||
function STRATEGO:GetNodeZone(Name)
|
function STRATEGO:GetNodeZone(Name)
|
||||||
self:T(self.lid.."GetNodeZone")
|
self:T(self.lid.."GetNodeZone")
|
||||||
@@ -826,7 +954,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Get the OPSZONE of a node by its name.
|
--- [USER] Get the OPSZONE of a node by its name.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return Ops.OpsZone#OPSZONE OpsZone The OpsZone of the node or nil if not found.
|
-- @return Ops.OpsZone#OPSZONE OpsZone The OpsZone of the node or nil if not found.
|
||||||
function STRATEGO:GetNodeOpsZone(Name)
|
function STRATEGO:GetNodeOpsZone(Name)
|
||||||
self:T(self.lid.."GetNodeOpsZone")
|
self:T(self.lid.."GetNodeOpsZone")
|
||||||
@@ -839,7 +967,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Get the COORDINATE of a node by its name.
|
--- [USER] Get the COORDINATE of a node by its name.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return Core.Point#COORDINATE Coordinate The Coordinate of the node or nil if not found.
|
-- @return Core.Point#COORDINATE Coordinate The Coordinate of the node or nil if not found.
|
||||||
function STRATEGO:GetNodeCoordinate(Name)
|
function STRATEGO:GetNodeCoordinate(Name)
|
||||||
self:T(self.lid.."GetNodeCoordinate")
|
self:T(self.lid.."GetNodeCoordinate")
|
||||||
@@ -852,7 +980,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Check if the TYPE of a node is AIRBASE.
|
--- [USER] Check if the TYPE of a node is AIRBASE.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return #boolean Outcome
|
-- @return #boolean Outcome
|
||||||
function STRATEGO:IsAirbase(Name)
|
function STRATEGO:IsAirbase(Name)
|
||||||
self:T(self.lid.."IsAirbase")
|
self:T(self.lid.."IsAirbase")
|
||||||
@@ -865,7 +993,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Check if the TYPE of a node is PORT.
|
--- [USER] Check if the TYPE of a node is PORT.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return #boolean Outcome
|
-- @return #boolean Outcome
|
||||||
function STRATEGO:IsPort(Name)
|
function STRATEGO:IsPort(Name)
|
||||||
self:T(self.lid.."IsPort")
|
self:T(self.lid.."IsPort")
|
||||||
@@ -878,7 +1006,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Check if the TYPE of a node is POI.
|
--- [USER] Check if the TYPE of a node is POI.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return #boolean Outcome
|
-- @return #boolean Outcome
|
||||||
function STRATEGO:IsPOI(Name)
|
function STRATEGO:IsPOI(Name)
|
||||||
self:T(self.lid.."IsPOI")
|
self:T(self.lid.."IsPOI")
|
||||||
@@ -891,7 +1019,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Check if the TYPE of a node is FARP.
|
--- [USER] Check if the TYPE of a node is FARP.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return #boolean Outcome
|
-- @return #boolean Outcome
|
||||||
function STRATEGO:IsFARP(Name)
|
function STRATEGO:IsFARP(Name)
|
||||||
self:T(self.lid.."IsFARP")
|
self:T(self.lid.."IsFARP")
|
||||||
@@ -904,7 +1032,7 @@ end
|
|||||||
|
|
||||||
--- [USER] Check if the TYPE of a node is SHIP.
|
--- [USER] Check if the TYPE of a node is SHIP.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Name.
|
-- @param #string The name to look for.
|
||||||
-- @return #boolean Outcome
|
-- @return #boolean Outcome
|
||||||
function STRATEGO:IsShip(Name)
|
function STRATEGO:IsShip(Name)
|
||||||
self:T(self.lid.."IsShip")
|
self:T(self.lid.."IsShip")
|
||||||
@@ -1087,35 +1215,67 @@ function STRATEGO:FindNeighborNodes(Name,Enemies,Friends)
|
|||||||
self:T(self.lid.."FindNeighborNodes")
|
self:T(self.lid.."FindNeighborNodes")
|
||||||
local neighbors = {}
|
local neighbors = {}
|
||||||
local name = string.gsub(Name,"[%p%s]",".")
|
local name = string.gsub(Name,"[%p%s]",".")
|
||||||
|
--self:I({Name=Name,name=name})
|
||||||
local shortestdist = 1000*1000
|
local shortestdist = 1000*1000
|
||||||
local nearest = nil
|
local nearest = nil
|
||||||
for _route,_data in pairs(self.disttable) do
|
for _route,_data in pairs(self.disttable) do
|
||||||
if string.find(_route,name,1,true) then
|
if string.find(_route,name,1,true) then
|
||||||
local dist = self.disttable[_route] -- #STRATEGO.DistData
|
local dist = self.disttable[_route] -- #STRATEGO.DistData
|
||||||
|
--self:I({route=_route,name=name})
|
||||||
local tname = string.gsub(_route,name,"")
|
local tname = string.gsub(_route,name,"")
|
||||||
local tname = string.gsub(tname,";","")
|
local tname = string.gsub(tname,";","")
|
||||||
|
--self:I({tname=tname,cname=self.easynames[tname]})
|
||||||
local cname = self.easynames[tname] -- name of target
|
local cname = self.easynames[tname] -- name of target
|
||||||
local encoa = self.coalition == coalition.side.BLUE and coalition.side.RED or coalition.side.BLUE
|
if cname then
|
||||||
if Enemies == true then
|
local encoa = self.coalition == coalition.side.BLUE and coalition.side.RED or coalition.side.BLUE
|
||||||
if self.airbasetable[cname].coalition == encoa then
|
if Enemies == true then
|
||||||
neighbors[cname] = dist
|
if self.airbasetable[cname].coalition == encoa then
|
||||||
|
neighbors[cname] = dist
|
||||||
|
end
|
||||||
|
elseif Friends == true then
|
||||||
|
if self.airbasetable[cname].coalition ~= encoa then
|
||||||
|
neighbors[cname] = dist
|
||||||
|
end
|
||||||
|
else
|
||||||
|
neighbors[cname] = dist
|
||||||
end
|
end
|
||||||
elseif Friends == true then
|
if neighbors[cname] and dist.dist < shortestdist then
|
||||||
if self.airbasetable[cname].coalition ~= encoa then
|
shortestdist = dist.dist
|
||||||
neighbors[cname] = dist
|
nearest = cname
|
||||||
end
|
end
|
||||||
else
|
|
||||||
neighbors[cname] = dist
|
|
||||||
end
|
|
||||||
if neighbors[cname] and dist.dist < shortestdist then
|
|
||||||
shortestdist = dist.dist
|
|
||||||
nearest = cname
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return neighbors, nearest, shortestdist
|
return neighbors, nearest, shortestdist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [INTERNAL] Route Finding - Find the next hop towards an end node from a start node
|
||||||
|
-- @param #STRATEGO self
|
||||||
|
-- @param #string Start The name of the start node.
|
||||||
|
-- @param #string End The name of the end node.
|
||||||
|
-- @param #table InRoute Table of node names making up the route so far.
|
||||||
|
-- @return #string Name of the next closest node
|
||||||
|
function STRATEGO:_GetNextClosest(Start,End,InRoute)
|
||||||
|
local ecoord = self.airbasetable[End].coord
|
||||||
|
local nodes,nearest = self:FindNeighborNodes(Start)
|
||||||
|
--self:I(tostring(nearest))
|
||||||
|
local closest = nil
|
||||||
|
local closedist = 1000*1000
|
||||||
|
for _name,_dist in pairs(nodes) do
|
||||||
|
local kcoord = self.airbasetable[_name].coord
|
||||||
|
local nnodes = self.airbasetable[_name].connections > 2 and true or false
|
||||||
|
if _name == End then nnodes = true end
|
||||||
|
if kcoord ~= nil and ecoord ~= nil and nnodes == true and InRoute[_name] ~= true then
|
||||||
|
local dist = math.floor((kcoord:Get2DDistance(ecoord)/1000)+0.5)
|
||||||
|
if (dist < closedist ) then
|
||||||
|
closedist = dist
|
||||||
|
closest = _name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return closest
|
||||||
|
end
|
||||||
|
|
||||||
--- [USER] Find a route between two nodes.
|
--- [USER] Find a route between two nodes.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
-- @param #string Start The name of the start node.
|
-- @param #string Start The name of the start node.
|
||||||
@@ -1124,15 +1284,19 @@ end
|
|||||||
-- @param #boolean Draw If true, draw the route on the map.
|
-- @param #boolean Draw If true, draw the route on the map.
|
||||||
-- @param #table Color (Optional) RGB color table {r, g, b}, e.g. {1,0,0} for red. Defaults to black.
|
-- @param #table Color (Optional) RGB color table {r, g, b}, e.g. {1,0,0} for red. Defaults to black.
|
||||||
-- @param #number LineType (Optional) Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 6.
|
-- @param #number LineType (Optional) Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 6.
|
||||||
|
-- @param #boolean NoOptimize If set to true, do not optimize (shorten) the resulting route if possible.
|
||||||
-- @return #table Route Table of #string name entries of the route
|
-- @return #table Route Table of #string name entries of the route
|
||||||
-- @return #boolean Complete If true, the route was found end-to-end.
|
-- @return #boolean Complete If true, the route was found end-to-end.
|
||||||
function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType)
|
-- @return #boolean Reverse If true, the route was found with a reverse search, the route table will be from sorted from end point to start point.
|
||||||
|
function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType,NoOptimize)
|
||||||
self:T(self.lid.."FindRoute")
|
self:T(self.lid.."FindRoute")
|
||||||
--self:I({Start,End,Hops})
|
--self:I({Start,End,Hops})
|
||||||
--local bases = UTILS.DeepCopy(self.airbasetable)
|
--local bases = UTILS.DeepCopy(self.airbasetable)
|
||||||
local Route = {}
|
local Route = {}
|
||||||
|
local InRoute = {}
|
||||||
local hops = Hops or 4
|
local hops = Hops or 4
|
||||||
local routecomplete = false
|
local routecomplete = false
|
||||||
|
local reverse = false
|
||||||
|
|
||||||
local function Checker(neighbors)
|
local function Checker(neighbors)
|
||||||
for _name,_data in pairs(neighbors) do
|
for _name,_data in pairs(neighbors) do
|
||||||
@@ -1143,26 +1307,7 @@ function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType)
|
|||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function NextClosest(Start,End)
|
|
||||||
local ecoord = self.airbasetable[End].coord
|
|
||||||
local nodes = self:FindNeighborNodes(Start)
|
|
||||||
local closest = nil
|
|
||||||
local closedist = 1000*1000
|
|
||||||
for _name,_dist in pairs(nodes) do
|
|
||||||
local kcoord = self.airbasetable[_name].coord
|
|
||||||
local dist = math.floor((kcoord:Get2DDistance(ecoord)/1000)+0.5)
|
|
||||||
if dist < closedist then
|
|
||||||
closedist = dist
|
|
||||||
closest = _name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if closest then
|
|
||||||
--MESSAGE:New(string.format("Start %s | End %s | Nextclosest %s",Start,End,closest),10,"STRATEGO"):ToLog():ToAll()
|
|
||||||
return closest
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function DrawRoute(Route)
|
local function DrawRoute(Route)
|
||||||
for i=1,#Route-1 do
|
for i=1,#Route-1 do
|
||||||
local p1=Route[i]
|
local p1=Route[i]
|
||||||
@@ -1177,6 +1322,7 @@ function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType)
|
|||||||
|
|
||||||
-- One hop
|
-- One hop
|
||||||
Route[#Route+1] = Start
|
Route[#Route+1] = Start
|
||||||
|
InRoute[Start] = true
|
||||||
local nodes = self:FindNeighborNodes(Start)
|
local nodes = self:FindNeighborNodes(Start)
|
||||||
local endpoint = Checker(nodes)
|
local endpoint = Checker(nodes)
|
||||||
|
|
||||||
@@ -1186,9 +1332,11 @@ function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType)
|
|||||||
else
|
else
|
||||||
local spoint = Start
|
local spoint = Start
|
||||||
for i=1,hops do
|
for i=1,hops do
|
||||||
local Next = NextClosest(spoint,End)
|
--self:I("Start="..tostring(spoint))
|
||||||
if Next then
|
local Next = self:_GetNextClosest(spoint,End,InRoute)
|
||||||
|
if Next ~= nil then
|
||||||
Route[#Route+1] = Next
|
Route[#Route+1] = Next
|
||||||
|
InRoute[Next] = true
|
||||||
local nodes = self:FindNeighborNodes(Next)
|
local nodes = self:FindNeighborNodes(Next)
|
||||||
local endpoint = Checker(nodes)
|
local endpoint = Checker(nodes)
|
||||||
if endpoint then
|
if endpoint then
|
||||||
@@ -1198,11 +1346,59 @@ function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType)
|
|||||||
else
|
else
|
||||||
spoint = Next
|
spoint = Next
|
||||||
end
|
end
|
||||||
end
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (self.debug or Draw) then DrawRoute(Route) end
|
|
||||||
return Route, routecomplete
|
-- optimize route
|
||||||
|
local function OptimizeRoute(Route)
|
||||||
|
local foundcut = false
|
||||||
|
local largestcut = 0
|
||||||
|
local cut = {}
|
||||||
|
for i=1,#Route do
|
||||||
|
--self:I({Start=Route[i]})
|
||||||
|
local found,nodes = self:GetRoutesFromNode(Route[i])
|
||||||
|
for _,_name in pairs(nodes or {}) do
|
||||||
|
for j=i+2,#Route do
|
||||||
|
if _name == Route[j] then
|
||||||
|
--self:I({"Shortcut",Route[i],Route[j]})
|
||||||
|
if j-i > largestcut then
|
||||||
|
largestcut = j-i
|
||||||
|
cut = {i=i,j=j}
|
||||||
|
foundcut = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if foundcut then
|
||||||
|
local newroute = {}
|
||||||
|
for i=1,#Route do
|
||||||
|
if i<= cut.i or i>=cut.j then
|
||||||
|
table.insert(newroute,Route[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return newroute
|
||||||
|
end
|
||||||
|
return Route, foundcut
|
||||||
|
end
|
||||||
|
|
||||||
|
if routecomplete == true and NoOptimize ~= true then
|
||||||
|
local foundcut = true
|
||||||
|
while foundcut ~= false do
|
||||||
|
Route, foundcut = OptimizeRoute(Route)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- reverse search
|
||||||
|
Route, routecomplete = self:FindRoute(End,Start,Hops,Draw,Color,LineType)
|
||||||
|
reverse = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if (self.debug or Draw) then DrawRoute(Route) end
|
||||||
|
|
||||||
|
return Route, routecomplete, reverse
|
||||||
end
|
end
|
||||||
|
|
||||||
--- [USER] Add budget points.
|
--- [USER] Add budget points.
|
||||||
@@ -1309,6 +1505,139 @@ function STRATEGO:FindAffordableConsolidationTarget()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [INTERNAL] Internal helper function to check for islands, aka Floodtest
|
||||||
|
-- @param #STRATEGO self
|
||||||
|
-- @param #string next Name of the start node
|
||||||
|
-- @param #table filled #table of visited nodes
|
||||||
|
-- @param #table unfilled #table if unvisited nodes
|
||||||
|
-- @return #STRATEGO self
|
||||||
|
function STRATEGO:_FloodNext(next,filled,unfilled)
|
||||||
|
local start = self:FindNeighborNodes(next)
|
||||||
|
for _name,_ in pairs (start) do
|
||||||
|
if filled[_name] ~= true then
|
||||||
|
self:T("Flooding ".._name)
|
||||||
|
filled[_name] = true
|
||||||
|
unfilled[_name] = nil
|
||||||
|
self:_FloodNext(_name,filled,unfilled)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [INTERNAL] Internal helper function to check for islands, aka Floodtest
|
||||||
|
-- @param #STRATEGO self
|
||||||
|
-- @param #string Start Name of the start node
|
||||||
|
-- @param #table ABTable (Optional) #table of node names to check.
|
||||||
|
-- @return #STRATEGO self
|
||||||
|
function STRATEGO:_FloodFill(Start,ABTable)
|
||||||
|
self:T("Start = "..tostring(Start))
|
||||||
|
if Start == nil then return end
|
||||||
|
local filled = {}
|
||||||
|
local unfilled = {}
|
||||||
|
if ABTable then
|
||||||
|
unfilled = ABTable
|
||||||
|
else
|
||||||
|
for _name,_ in pairs(self.airbasetable) do
|
||||||
|
unfilled[_name] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
filled[Start] = true
|
||||||
|
unfilled[Start] = nil
|
||||||
|
local start = self:FindNeighborNodes(Start)
|
||||||
|
for _name,_ in pairs (start) do
|
||||||
|
if filled[_name] ~= true then
|
||||||
|
self:T("Flooding ".._name)
|
||||||
|
filled[_name] = true
|
||||||
|
unfilled[_name] = nil
|
||||||
|
self:_FloodNext(_name,filled,unfilled)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return filled, unfilled
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [INTERNAL] Internal helper function to check for islands, aka Floodtest
|
||||||
|
-- @param #STRATEGO self
|
||||||
|
-- @param #boolen connect If true, connect the two resulting islands at the shortest distance if necessary
|
||||||
|
-- @param #boolen draw If true, draw outer vertices of found node networks
|
||||||
|
-- @return #boolean Connected If true, all nodes are in one network
|
||||||
|
-- @return #table Network #table of node names in the network
|
||||||
|
-- @return #table Unconnected #table of node names **not** in the network
|
||||||
|
function STRATEGO:_FloodTest(connect,draw)
|
||||||
|
|
||||||
|
local function GetElastic(bases)
|
||||||
|
local vec2table = {}
|
||||||
|
for _name,_ in pairs(bases) do
|
||||||
|
local coord = self.airbasetable[_name].coord
|
||||||
|
local vec2 = coord:GetVec2()
|
||||||
|
table.insert(vec2table,vec2)
|
||||||
|
end
|
||||||
|
local zone = ZONE_ELASTIC:New("STRATEGO-Floodtest-"..math.random(1,10000),vec2table)
|
||||||
|
return zone
|
||||||
|
end
|
||||||
|
|
||||||
|
local function DrawElastic(filled,drawit)
|
||||||
|
local zone = GetElastic(filled)
|
||||||
|
if drawit then
|
||||||
|
zone:SetColor({1,1,1},1)
|
||||||
|
zone:SetDrawCoalition(-1)
|
||||||
|
zone:Update(1,true) -- draw zone
|
||||||
|
end
|
||||||
|
return zone
|
||||||
|
end
|
||||||
|
|
||||||
|
local _,_,weight,name = self:GetHighestWeightNodes()
|
||||||
|
local filled, unfilled = self:_FloodFill(name)
|
||||||
|
local allin = true
|
||||||
|
if table.length(unfilled) > 0 then
|
||||||
|
MESSAGE:New("There is at least one node island!",15,"STRATEGO"):ToAllIf(self.debug):ToLog()
|
||||||
|
allin = false
|
||||||
|
if self.debug == true then
|
||||||
|
local zone1 = DrawElastic(filled,draw)
|
||||||
|
local zone2 = DrawElastic(unfilled,draw)
|
||||||
|
local vertices1 = zone1:GetVerticiesVec2()
|
||||||
|
local vertices2 = zone2:GetVerticiesVec2()
|
||||||
|
-- get closest vertices
|
||||||
|
local corner1 = nil
|
||||||
|
local corner2 = nil
|
||||||
|
local mindist = math.huge
|
||||||
|
local found = false
|
||||||
|
for _,_edge in pairs(vertices1) do
|
||||||
|
for _,_edge2 in pairs(vertices2) do
|
||||||
|
local dist=UTILS.VecDist2D(_edge,_edge2)
|
||||||
|
if dist < mindist then
|
||||||
|
mindist = dist
|
||||||
|
corner1 = _edge
|
||||||
|
corner2 = _edge2
|
||||||
|
found = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if found then
|
||||||
|
local Corner = COORDINATE:NewFromVec2(corner1)
|
||||||
|
local Corner2 = COORDINATE:NewFromVec2(corner2)
|
||||||
|
Corner:LineToAll(Corner2,-1,{1,1,1},1,1,true,"Island2Island")
|
||||||
|
local cornername
|
||||||
|
local cornername2
|
||||||
|
for _name,_data in pairs(self.airbasetable) do
|
||||||
|
local zone = _data.zone
|
||||||
|
if zone:IsVec2InZone(corner1) then
|
||||||
|
cornername = _name
|
||||||
|
self:T("Corner1 = ".._name)
|
||||||
|
end
|
||||||
|
if zone:IsVec2InZone(corner2) then
|
||||||
|
cornername2 = _name
|
||||||
|
self:T("Corner2 = ".._name)
|
||||||
|
end
|
||||||
|
if cornername and cornername2 and connect == true then
|
||||||
|
self:AddRoutesManually(cornername,cornername2,Color,Linetype,self.debug)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return allin, filled, unfilled
|
||||||
|
end
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------------
|
||||||
--
|
--
|
||||||
-- End
|
-- End
|
||||||
|
|||||||
@@ -154,6 +154,14 @@ __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Route.lua' )
|
|||||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Account.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Account.lua' )
|
||||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Assist.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Assist.lua' )
|
||||||
|
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/ShapeBase.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Circle.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Cube.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Line.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Oval.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Polygon.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Triangle.lua' )
|
||||||
|
|
||||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/UserSound.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/UserSound.lua' )
|
||||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/SoundOutput.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/SoundOutput.lua' )
|
||||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/Radio.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/Radio.lua' )
|
||||||
|
|||||||
@@ -255,6 +255,7 @@
|
|||||||
-- @field #boolean skipperUturn U-turn on/off via menu.
|
-- @field #boolean skipperUturn U-turn on/off via menu.
|
||||||
-- @field #number skipperOffset Holding offset angle in degrees for Case II/III manual recoveries.
|
-- @field #number skipperOffset Holding offset angle in degrees for Case II/III manual recoveries.
|
||||||
-- @field #number skipperTime Recovery time in min for manual recovery.
|
-- @field #number skipperTime Recovery time in min for manual recovery.
|
||||||
|
-- @field #boolean intowindold If true, use old into wind calculation.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- Be the boss!
|
--- Be the boss!
|
||||||
@@ -2724,6 +2725,18 @@ function AIRBOSS:SetLSOCallInterval( TimeInterval )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set if old into wind calculation is used when carrier turns into the wind for a recovery.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
-- @param #boolean SwitchOn If `true` or `nil`, use old into wind calculation.
|
||||||
|
-- @return #AIRBOSS self
|
||||||
|
function AIRBOSS:SetIntoWindLegacy( SwitchOn )
|
||||||
|
if SwitchOn==nil then
|
||||||
|
SwitchOn=true
|
||||||
|
end
|
||||||
|
self.intowindold=SwitchOn
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Airboss is a rather nice guy and not strictly following the rules. Fore example, he does allow you into the landing pattern if you are not coming from the Marshal stack.
|
--- Airboss is a rather nice guy and not strictly following the rules. Fore example, he does allow you into the landing pattern if you are not coming from the Marshal stack.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @param #boolean Switch If true or nil, Airboss bends the rules a bit.
|
-- @param #boolean Switch If true or nil, Airboss bends the rules a bit.
|
||||||
@@ -3642,6 +3655,12 @@ function AIRBOSS:onafterStatus( From, Event, To )
|
|||||||
local pos = self:GetCoordinate()
|
local pos = self:GetCoordinate()
|
||||||
local speed = self.carrier:GetVelocityKNOTS()
|
local speed = self.carrier:GetVelocityKNOTS()
|
||||||
|
|
||||||
|
-- Update magnetic variation if we can get it from DCS.
|
||||||
|
if require then
|
||||||
|
self.magvar=pos:GetMagneticDeclination()
|
||||||
|
--env.info(string.format("FF magvar=%.1f", self.magvar))
|
||||||
|
end
|
||||||
|
|
||||||
-- Check water is ahead.
|
-- Check water is ahead.
|
||||||
local collision = false -- self:_CheckCollisionCoord(pos:Translate(self.collisiondist, hdg))
|
local collision = false -- self:_CheckCollisionCoord(pos:Translate(self.collisiondist, hdg))
|
||||||
|
|
||||||
@@ -5201,6 +5220,7 @@ function AIRBOSS:_InitVoiceOvers()
|
|||||||
TOMCAT = { file = "PILOT-Tomcat", suffix = "ogg", loud = false, subtitle = "", duration = 0.66, subduration = 5 },
|
TOMCAT = { file = "PILOT-Tomcat", suffix = "ogg", loud = false, subtitle = "", duration = 0.66, subduration = 5 },
|
||||||
HORNET = { file = "PILOT-Hornet", suffix = "ogg", loud = false, subtitle = "", duration = 0.56, subduration = 5 },
|
HORNET = { file = "PILOT-Hornet", suffix = "ogg", loud = false, subtitle = "", duration = 0.56, subduration = 5 },
|
||||||
VIKING = { file = "PILOT-Viking", suffix = "ogg", loud = false, subtitle = "", duration = 0.61, subduration = 5 },
|
VIKING = { file = "PILOT-Viking", suffix = "ogg", loud = false, subtitle = "", duration = 0.61, subduration = 5 },
|
||||||
|
GREYHOUND = { file = "PILOT-Greyhound", suffix = "ogg", loud = false, subtitle = "", duration = 0.61, subduration = 5 },
|
||||||
BALL = { file = "PILOT-Ball", suffix = "ogg", loud = false, subtitle = "", duration = 0.50, subduration = 5 },
|
BALL = { file = "PILOT-Ball", suffix = "ogg", loud = false, subtitle = "", duration = 0.50, subduration = 5 },
|
||||||
BINGOFUEL = { file = "PILOT-BingoFuel", suffix = "ogg", loud = false, subtitle = "", duration = 0.80 },
|
BINGOFUEL = { file = "PILOT-BingoFuel", suffix = "ogg", loud = false, subtitle = "", duration = 0.80 },
|
||||||
GASATDIVERT = { file = "PILOT-GasAtDivert", suffix = "ogg", loud = false, subtitle = "", duration = 1.80 },
|
GASATDIVERT = { file = "PILOT-GasAtDivert", suffix = "ogg", loud = false, subtitle = "", duration = 1.80 },
|
||||||
@@ -6475,7 +6495,7 @@ function AIRBOSS:_LandAI( flight )
|
|||||||
or flight.actype == AIRBOSS.AircraftCarrier.RHINOF
|
or flight.actype == AIRBOSS.AircraftCarrier.RHINOF
|
||||||
or flight.actype == AIRBOSS.AircraftCarrier.GROWLER then
|
or flight.actype == AIRBOSS.AircraftCarrier.GROWLER then
|
||||||
Speed = UTILS.KnotsToKmph( 200 )
|
Speed = UTILS.KnotsToKmph( 200 )
|
||||||
elseif flight.actype == AIRBOSS.AircraftCarrier.E2D then
|
elseif flight.actype == AIRBOSS.AircraftCarrier.E2D or flight.actype == AIRBOSS.AircraftCarrier.C2A then
|
||||||
Speed = UTILS.KnotsToKmph( 150 )
|
Speed = UTILS.KnotsToKmph( 150 )
|
||||||
elseif flight.actype == AIRBOSS.AircraftCarrier.F14A_AI or flight.actype == AIRBOSS.AircraftCarrier.F14A or flight.actype == AIRBOSS.AircraftCarrier.F14B then
|
elseif flight.actype == AIRBOSS.AircraftCarrier.F14A_AI or flight.actype == AIRBOSS.AircraftCarrier.F14A or flight.actype == AIRBOSS.AircraftCarrier.F14B then
|
||||||
Speed = UTILS.KnotsToKmph( 175 )
|
Speed = UTILS.KnotsToKmph( 175 )
|
||||||
@@ -11476,7 +11496,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 15 m.
|
-- @param #number alt Altitude ASL in meters. Default 18 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.
|
||||||
@@ -11548,10 +11568,31 @@ end
|
|||||||
|
|
||||||
--- Get true (or magnetic) heading of carrier into the wind. This accounts for the angled runway.
|
--- Get true (or magnetic) heading of carrier into the wind. This accounts for the angled runway.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
|
-- @param #number vdeck Desired wind velocity over deck in knots.
|
||||||
-- @param #boolean magnetic If true, calculate magnetic heading. By default true heading is returned.
|
-- @param #boolean magnetic If true, calculate magnetic heading. By default true heading is returned.
|
||||||
-- @param Core.Point#COORDINATE coord (Optional) Coordinate from which heading is calculated. Default is current carrier position.
|
-- @param Core.Point#COORDINATE coord (Optional) Coordinate from which heading is calculated. Default is current carrier position.
|
||||||
-- @return #number Carrier heading in degrees.
|
-- @return #number Carrier heading in degrees.
|
||||||
function AIRBOSS:GetHeadingIntoWind_old( magnetic, coord )
|
-- @return #number Carrier speed in knots to reach desired wind speed on deck.
|
||||||
|
function AIRBOSS:GetHeadingIntoWind(vdeck, magnetic, coord )
|
||||||
|
|
||||||
|
if self.intowindold then
|
||||||
|
--env.info("FF use OLD into wind")
|
||||||
|
return self:GetHeadingIntoWind_old(vdeck, magnetic, coord)
|
||||||
|
else
|
||||||
|
--env.info("FF use NEW into wind")
|
||||||
|
return self:GetHeadingIntoWind_new(vdeck, magnetic, coord)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get true (or magnetic) heading of carrier into the wind. This accounts for the angled runway.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
-- @param #number vdeck Desired wind velocity over deck in knots.
|
||||||
|
-- @param #boolean magnetic If true, calculate magnetic heading. By default true heading is returned.
|
||||||
|
-- @param Core.Point#COORDINATE coord (Optional) Coordinate from which heading is calculated. Default is current carrier position.
|
||||||
|
-- @return #number Carrier heading in degrees.
|
||||||
|
function AIRBOSS:GetHeadingIntoWind_old( vdeck, magnetic, coord )
|
||||||
|
|
||||||
local function adjustDegreesForWindSpeed(windSpeed)
|
local function adjustDegreesForWindSpeed(windSpeed)
|
||||||
local degreesAdjustment = 0
|
local degreesAdjustment = 0
|
||||||
@@ -11608,7 +11649,13 @@ function AIRBOSS:GetHeadingIntoWind_old( magnetic, coord )
|
|||||||
intowind = intowind + 360
|
intowind = intowind + 360
|
||||||
end
|
end
|
||||||
|
|
||||||
return intowind
|
-- Wind speed.
|
||||||
|
--local _, vwind = self:GetWind()
|
||||||
|
|
||||||
|
-- Speed of carrier in m/s but at least 4 knots.
|
||||||
|
local vtot = math.max(vdeck-UTILS.MpsToKnots(vwind), 4)
|
||||||
|
|
||||||
|
return intowind, vtot
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get true (or magnetic) heading of carrier into the wind. This accounts for the angled runway.
|
--- Get true (or magnetic) heading of carrier into the wind. This accounts for the angled runway.
|
||||||
@@ -11619,7 +11666,7 @@ end
|
|||||||
-- @param Core.Point#COORDINATE coord (Optional) Coordinate from which heading is calculated. Default is current carrier position.
|
-- @param Core.Point#COORDINATE coord (Optional) Coordinate from which heading is calculated. Default is current carrier position.
|
||||||
-- @return #number Carrier heading in degrees.
|
-- @return #number Carrier heading in degrees.
|
||||||
-- @return #number Carrier speed in knots to reach desired wind speed on deck.
|
-- @return #number Carrier speed in knots to reach desired wind speed on deck.
|
||||||
function AIRBOSS:GetHeadingIntoWind( vdeck, magnetic, coord )
|
function AIRBOSS:GetHeadingIntoWind_new( vdeck, magnetic, coord )
|
||||||
|
|
||||||
-- Default offset angle.
|
-- Default offset angle.
|
||||||
local Offset=self.carrierparam.rwyangle or 0
|
local Offset=self.carrierparam.rwyangle or 0
|
||||||
@@ -14280,6 +14327,8 @@ function AIRBOSS:_GetACNickname( actype )
|
|||||||
nickname = "Harrier"
|
nickname = "Harrier"
|
||||||
elseif actype == AIRBOSS.AircraftCarrier.E2D then
|
elseif actype == AIRBOSS.AircraftCarrier.E2D then
|
||||||
nickname = "Hawkeye"
|
nickname = "Hawkeye"
|
||||||
|
elseif actype == AIRBOSS.AircraftCarrier.C2A then
|
||||||
|
nickname = "Greyhound"
|
||||||
elseif actype == AIRBOSS.AircraftCarrier.F14A_AI or actype == AIRBOSS.AircraftCarrier.F14A or actype == AIRBOSS.AircraftCarrier.F14B then
|
elseif actype == AIRBOSS.AircraftCarrier.F14A_AI or actype == AIRBOSS.AircraftCarrier.F14A or actype == AIRBOSS.AircraftCarrier.F14B then
|
||||||
nickname = "Tomcat"
|
nickname = "Tomcat"
|
||||||
elseif actype == AIRBOSS.AircraftCarrier.FA18C or actype == AIRBOSS.AircraftCarrier.HORNET then
|
elseif actype == AIRBOSS.AircraftCarrier.FA18C or actype == AIRBOSS.AircraftCarrier.HORNET then
|
||||||
@@ -14317,32 +14366,55 @@ function AIRBOSS:_GetOnboardNumbers( group, playeronly )
|
|||||||
-- Debug text.
|
-- Debug text.
|
||||||
local text = string.format( "Onboard numbers of group %s:", groupname )
|
local text = string.format( "Onboard numbers of group %s:", groupname )
|
||||||
|
|
||||||
-- Units of template group.
|
local template=group:GetTemplate()
|
||||||
local units = group:GetTemplate().units
|
|
||||||
|
|
||||||
-- Get numbers.
|
|
||||||
local numbers = {}
|
local numbers = {}
|
||||||
for _, unit in pairs( units ) do
|
if template then
|
||||||
|
|
||||||
-- Onboard number and unit name.
|
-- Units of template group.
|
||||||
local n = tostring( unit.onboard_num )
|
local units = template.units
|
||||||
local name = unit.name
|
|
||||||
local skill = unit.skill or "Unknown"
|
|
||||||
|
|
||||||
-- Debug text.
|
-- Get numbers.
|
||||||
text = text .. string.format( "\n- unit %s: onboard #=%s skill=%s", name, n, tostring( skill ) )
|
for _, unit in pairs( units ) do
|
||||||
|
|
||||||
if playeronly and skill == "Client" or skill == "Player" then
|
-- Onboard number and unit name.
|
||||||
-- There can be only one player in the group, so we skip everything else.
|
local n = tostring( unit.onboard_num )
|
||||||
return n
|
local name = unit.name
|
||||||
|
local skill = unit.skill or "Unknown"
|
||||||
|
|
||||||
|
-- Debug text.
|
||||||
|
text = text .. string.format( "\n- unit %s: onboard #=%s skill=%s", name, n, tostring( skill ) )
|
||||||
|
|
||||||
|
if playeronly and skill == "Client" or skill == "Player" then
|
||||||
|
-- There can be only one player in the group, so we skip everything else.
|
||||||
|
return n
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Table entry.
|
||||||
|
numbers[name] = n
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Table entry.
|
-- Debug info.
|
||||||
numbers[name] = n
|
self:T2( self.lid .. text )
|
||||||
end
|
|
||||||
|
|
||||||
-- Debug info.
|
else
|
||||||
self:T2( self.lid .. text )
|
|
||||||
|
if playeronly then
|
||||||
|
return 101
|
||||||
|
else
|
||||||
|
|
||||||
|
local units=group:GetUnits()
|
||||||
|
|
||||||
|
for i,_unit in pairs(units) do
|
||||||
|
local name=_unit:GetName()
|
||||||
|
|
||||||
|
numbers[name]=100+i
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return numbers
|
return numbers
|
||||||
end
|
end
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -30,8 +30,8 @@
|
|||||||
-- @module Ops.CSAR
|
-- @module Ops.CSAR
|
||||||
-- @image OPS_CSAR.jpg
|
-- @image OPS_CSAR.jpg
|
||||||
|
|
||||||
-- Date: May 2023
|
---
|
||||||
-- Last: Update Dec 2024
|
-- Last Update April 2024
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
||||||
@@ -291,10 +291,12 @@ CSAR.AircraftType["UH-60L"] = 10
|
|||||||
CSAR.AircraftType["AH-64D_BLK_II"] = 2
|
CSAR.AircraftType["AH-64D_BLK_II"] = 2
|
||||||
CSAR.AircraftType["Bronco-OV-10A"] = 2
|
CSAR.AircraftType["Bronco-OV-10A"] = 2
|
||||||
CSAR.AircraftType["MH-60R"] = 10
|
CSAR.AircraftType["MH-60R"] = 10
|
||||||
|
CSAR.AircraftType["OH-6A"] = 2
|
||||||
|
CSAR.AircraftType["OH58D"] = 2
|
||||||
|
|
||||||
--- CSAR class version.
|
--- CSAR class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CSAR.version="1.0.20"
|
CSAR.version="1.0.24"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@@ -463,7 +465,7 @@ function CSAR:New(Coalition, Template, Alias)
|
|||||||
self.SRSModulation = radio.modulation.AM -- modulation
|
self.SRSModulation = radio.modulation.AM -- modulation
|
||||||
self.SRSport = 5002 -- port
|
self.SRSport = 5002 -- port
|
||||||
self.SRSCulture = "en-GB"
|
self.SRSCulture = "en-GB"
|
||||||
self.SRSVoice = nil
|
self.SRSVoice = MSRS.Voices.Google.Standard.en_GB_Standard_B
|
||||||
self.SRSGPathToCredentials = nil
|
self.SRSGPathToCredentials = nil
|
||||||
self.SRSVolume = 1.0 -- volume 0.0 to 1.0
|
self.SRSVolume = 1.0 -- volume 0.0 to 1.0
|
||||||
self.SRSGender = "male" -- male or female
|
self.SRSGender = "male" -- male or female
|
||||||
@@ -734,7 +736,7 @@ function CSAR:_SpawnPilotInField(country,point,frequency,wetfeet)
|
|||||||
:NewWithAlias(template,alias)
|
:NewWithAlias(template,alias)
|
||||||
:InitCoalition(coalition)
|
:InitCoalition(coalition)
|
||||||
:InitCountry(country)
|
:InitCountry(country)
|
||||||
:InitAIOnOff(pilotcacontrol)
|
--:InitAIOnOff(pilotcacontrol)
|
||||||
:InitDelayOff()
|
:InitDelayOff()
|
||||||
:SpawnFromCoordinate(point)
|
:SpawnFromCoordinate(point)
|
||||||
|
|
||||||
@@ -1190,7 +1192,7 @@ function CSAR:_EventHandler(EventData)
|
|||||||
|
|
||||||
if _place:GetCoalition() == self.coalition or _place:GetCoalition() == coalition.side.NEUTRAL then
|
if _place:GetCoalition() == self.coalition or _place:GetCoalition() == coalition.side.NEUTRAL then
|
||||||
self:__Landed(2,_event.IniUnitName, _place)
|
self:__Landed(2,_event.IniUnitName, _place)
|
||||||
self:_ScheduledSARFlight(_event.IniUnitName,_event.IniGroupName,true)
|
self:_ScheduledSARFlight(_event.IniUnitName,_event.IniGroupName,true,true)
|
||||||
else
|
else
|
||||||
self:T(string.format("Airfield %d, Unit %d", _place:GetCoalition(), _unit:GetCoalition()))
|
self:T(string.format("Airfield %d, Unit %d", _place:GetCoalition(), _unit:GetCoalition()))
|
||||||
end
|
end
|
||||||
@@ -1238,10 +1240,24 @@ function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage, _pla
|
|||||||
if not _nomessage then
|
if not _nomessage then
|
||||||
if _freq ~= 0 then --shagrat
|
if _freq ~= 0 then --shagrat
|
||||||
local _text = string.format("%s requests SAR at %s, beacon at %.2f KHz", _groupName, _coordinatesText, _freqk)--shagrat _groupName to prevent 'f15_Pilot_Parachute'
|
local _text = string.format("%s requests SAR at %s, beacon at %.2f KHz", _groupName, _coordinatesText, _freqk)--shagrat _groupName to prevent 'f15_Pilot_Parachute'
|
||||||
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
if self.coordtype ~= 2 then --not MGRS
|
||||||
|
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
||||||
|
else
|
||||||
|
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime,false,true)
|
||||||
|
local coordtext = UTILS.MGRSStringToSRSFriendly(_coordinatesText,true)
|
||||||
|
local _text = string.format("%s requests SAR at %s, beacon at %.2f kilo hertz", _groupName, coordtext, _freqk)
|
||||||
|
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime,true,false)
|
||||||
|
end
|
||||||
else --shagrat CASEVAC msg
|
else --shagrat CASEVAC msg
|
||||||
local _text = string.format("Pickup Zone at %s.", _coordinatesText )
|
local _text = string.format("Pickup Zone at %s.", _coordinatesText )
|
||||||
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
if self.coordtype ~= 2 then --not MGRS
|
||||||
|
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
||||||
|
else
|
||||||
|
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime,false,true)
|
||||||
|
local coordtext = UTILS.MGRSStringToSRSFriendly(_coordinatesText,true)
|
||||||
|
local _text = string.format("Pickup Zone at %s.", coordtext )
|
||||||
|
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime,true,false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1529,7 +1545,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
|||||||
local _reset = true
|
local _reset = true
|
||||||
|
|
||||||
if (_distance < 500) then
|
if (_distance < 500) then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo closer than 500m: ".._lookupKeyHeli)
|
||||||
if self.heliCloseMessage[_lookupKeyHeli] == nil then
|
if self.heliCloseMessage[_lookupKeyHeli] == nil then
|
||||||
if self.autosmoke == true then
|
if self.autosmoke == true then
|
||||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land or hover at the smoke.", self:_GetCustomCallSign(_heliName), _pilotName), self.messageTime,false,true)
|
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land or hover at the smoke.", self:_GetCustomCallSign(_heliName), _pilotName), self.messageTime,false,true)
|
||||||
@@ -1538,14 +1554,16 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
|||||||
end
|
end
|
||||||
self.heliCloseMessage[_lookupKeyHeli] = true
|
self.heliCloseMessage[_lookupKeyHeli] = true
|
||||||
end
|
end
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Checking landed vs Hover for ".._lookupKeyHeli)
|
||||||
-- have we landed close enough?
|
-- have we landed close enough?
|
||||||
if not _heliUnit:InAir() then
|
if not _heliUnit:InAir() then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo landed: ".._lookupKeyHeli)
|
||||||
if self.pilotRuntoExtractPoint == true then
|
if self.pilotRuntoExtractPoint == true then
|
||||||
if (_distance < self.extractDistance) then
|
if (_distance < self.extractDistance) then
|
||||||
local _time = self.landedStatus[_lookupKeyHeli]
|
local _time = self.landedStatus[_lookupKeyHeli]
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Check pilot running or arrived ".._lookupKeyHeli)
|
||||||
if _time == nil then
|
if _time == nil then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Pilot running not arrived yet ".._lookupKeyHeli)
|
||||||
self.landedStatus[_lookupKeyHeli] = math.floor( (_distance - self.loadDistance) / 3.6 )
|
self.landedStatus[_lookupKeyHeli] = math.floor( (_distance - self.loadDistance) / 3.6 )
|
||||||
_time = self.landedStatus[_lookupKeyHeli]
|
_time = self.landedStatus[_lookupKeyHeli]
|
||||||
_woundedGroup:OptionAlarmStateGreen()
|
_woundedGroup:OptionAlarmStateGreen()
|
||||||
@@ -1556,11 +1574,15 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
|||||||
self.landedStatus[_lookupKeyHeli] = _time
|
self.landedStatus[_lookupKeyHeli] = _time
|
||||||
end
|
end
|
||||||
--if _time <= 0 or _distance < self.loadDistance then
|
--if _time <= 0 or _distance < self.loadDistance then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Pilot close enough? ".._lookupKeyHeli)
|
||||||
if _distance < self.loadDistance + 5 or _distance <= 13 then
|
if _distance < self.loadDistance + 5 or _distance <= 13 then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Pilot close enough - YES ".._lookupKeyHeli)
|
||||||
if self.pilotmustopendoors and (self:_IsLoadingDoorOpen(_heliName) == false) then
|
if self.pilotmustopendoors and (self:_IsLoadingDoorOpen(_heliName) == false) then
|
||||||
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true, true)
|
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true, true)
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Door closed, try again next loop ".._lookupKeyHeli)
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Pick up Pilot ".._lookupKeyHeli)
|
||||||
self.landedStatus[_lookupKeyHeli] = nil
|
self.landedStatus[_lookupKeyHeli] = nil
|
||||||
self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName)
|
self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName)
|
||||||
return true
|
return true
|
||||||
@@ -1568,28 +1590,32 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo landed, pilot NOT set to run to helo ".._lookupKeyHeli)
|
||||||
if (_distance < self.loadDistance) then
|
if (_distance < self.loadDistance) then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo close enough, door check ".._lookupKeyHeli)
|
||||||
if self.pilotmustopendoors and (self:_IsLoadingDoorOpen(_heliName) == false) then
|
if self.pilotmustopendoors and (self:_IsLoadingDoorOpen(_heliName) == false) then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Door closed, try again next loop ".._lookupKeyHeli)
|
||||||
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true, true)
|
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true, true)
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Pick up Pilot ".._lookupKeyHeli)
|
||||||
self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName)
|
self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo hovering".._lookupKeyHeli)
|
||||||
local _unitsInHelicopter = self:_PilotsOnboard(_heliName)
|
local _unitsInHelicopter = self:_PilotsOnboard(_heliName)
|
||||||
local _maxUnits = self.AircraftType[_heliUnit:GetTypeName()]
|
local _maxUnits = self.AircraftType[_heliUnit:GetTypeName()]
|
||||||
if _maxUnits == nil then
|
if _maxUnits == nil then
|
||||||
_maxUnits = self.max_units
|
_maxUnits = self.max_units
|
||||||
end
|
end
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Check capacity and close enough for winching ".._lookupKeyHeli)
|
||||||
if _heliUnit:InAir() and _unitsInHelicopter + 1 <= _maxUnits then
|
if _heliUnit:InAir() and _unitsInHelicopter + 1 <= _maxUnits then
|
||||||
-- DONE - make variable
|
-- DONE - make variable
|
||||||
if _distance < self.rescuehoverdistance then
|
if _distance < self.rescuehoverdistance then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo hovering close enough ".._lookupKeyHeli)
|
||||||
--check height!
|
--check height!
|
||||||
local leaderheight = _woundedLeader:GetHeight()
|
local leaderheight = _woundedLeader:GetHeight()
|
||||||
if leaderheight < 0 then leaderheight = 0 end
|
if leaderheight < 0 then leaderheight = 0 end
|
||||||
@@ -1597,7 +1623,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
|||||||
|
|
||||||
-- DONE - make variable
|
-- DONE - make variable
|
||||||
if _height <= self.rescuehoverheight then
|
if _height <= self.rescuehoverheight then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo hovering low enough ".._lookupKeyHeli)
|
||||||
local _time = self.hoverStatus[_lookupKeyHeli]
|
local _time = self.hoverStatus[_lookupKeyHeli]
|
||||||
|
|
||||||
if _time == nil then
|
if _time == nil then
|
||||||
@@ -1607,22 +1633,28 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
|||||||
_time = self.hoverStatus[_lookupKeyHeli] - 10
|
_time = self.hoverStatus[_lookupKeyHeli] - 10
|
||||||
self.hoverStatus[_lookupKeyHeli] = _time
|
self.hoverStatus[_lookupKeyHeli] = _time
|
||||||
end
|
end
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Check hover timer ".._lookupKeyHeli)
|
||||||
if _time > 0 then
|
if _time > 0 then
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo hovering not long enough ".._lookupKeyHeli)
|
||||||
self:_DisplayMessageToSAR(_heliUnit, "Hovering above " .. _pilotName .. ". \n\nHold hover for " .. _time .. " seconds to winch them up. \n\nIf the countdown stops you\'re too far away!", self.messageTime, true)
|
self:_DisplayMessageToSAR(_heliUnit, "Hovering above " .. _pilotName .. ". \n\nHold hover for " .. _time .. " seconds to winch them up. \n\nIf the countdown stops you\'re too far away!", self.messageTime, true)
|
||||||
else
|
else
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo hovering long enough - door check ".._lookupKeyHeli)
|
||||||
if self.pilotmustopendoors and (self:_IsLoadingDoorOpen(_heliName) == false) then
|
if self.pilotmustopendoors and (self:_IsLoadingDoorOpen(_heliName) == false) then
|
||||||
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true, true)
|
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me in!", self.messageTime, true, true)
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Door closed, try again next loop ".._lookupKeyHeli)
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
self.hoverStatus[_lookupKeyHeli] = nil
|
self.hoverStatus[_lookupKeyHeli] = nil
|
||||||
self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName)
|
self:_PickupUnit(_heliUnit, _pilotName, _woundedGroup, _woundedGroupName)
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Pilot picked up ".._lookupKeyHeli)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
_reset = false
|
_reset = false
|
||||||
else
|
else
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Helo hovering too high ".._lookupKeyHeli)
|
||||||
self:_DisplayMessageToSAR(_heliUnit, "Too high to winch " .. _pilotName .. " \nReduce height and hover for 10 seconds!", self.messageTime, true,true)
|
self:_DisplayMessageToSAR(_heliUnit, "Too high to winch " .. _pilotName .. " \nReduce height and hover for 10 seconds!", self.messageTime, true,true)
|
||||||
|
self:T(self.lid .. "[Pickup Debug] Hovering too high, try again next loop ".._lookupKeyHeli)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1647,7 +1679,8 @@ end
|
|||||||
-- @param #string heliname Heli name
|
-- @param #string heliname Heli name
|
||||||
-- @param #string groupname Group name
|
-- @param #string groupname Group name
|
||||||
-- @param #boolean isairport If true, EVENT.Landing took place at an airport or FARP
|
-- @param #boolean isairport If true, EVENT.Landing took place at an airport or FARP
|
||||||
function CSAR:_ScheduledSARFlight(heliname,groupname, isairport)
|
-- @param #boolean noreschedule If true, do not try to reschedule this is distances are not ok (coming from landing event)
|
||||||
|
function CSAR:_ScheduledSARFlight(heliname,groupname, isairport, noreschedule)
|
||||||
self:T(self.lid .. " _ScheduledSARFlight")
|
self:T(self.lid .. " _ScheduledSARFlight")
|
||||||
self:T({heliname,groupname})
|
self:T({heliname,groupname})
|
||||||
local _heliUnit = self:_GetSARHeli(heliname)
|
local _heliUnit = self:_GetSARHeli(heliname)
|
||||||
@@ -1667,20 +1700,29 @@ function CSAR:_ScheduledSARFlight(heliname,groupname, isairport)
|
|||||||
local _dist = self:_GetClosestMASH(_heliUnit)
|
local _dist = self:_GetClosestMASH(_heliUnit)
|
||||||
|
|
||||||
if _dist == -1 then
|
if _dist == -1 then
|
||||||
return
|
self:T(self.lid.."[Drop off debug] Check distance to MASH for "..heliname.." Distance can not be determined!")
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:T(self.lid.."[Drop off debug] Check distance to MASH for "..heliname.." Distance km: "..math.floor(_dist/1000))
|
||||||
|
|
||||||
if ( _dist < self.FARPRescueDistance or isairport ) and _heliUnit:InAir() == false then
|
if ( _dist < self.FARPRescueDistance or isairport ) and _heliUnit:InAir() == false then
|
||||||
|
self:T(self.lid.."[Drop off debug] Distance ok, door check")
|
||||||
if self.pilotmustopendoors and self:_IsLoadingDoorOpen(heliname) == false then
|
if self.pilotmustopendoors and self:_IsLoadingDoorOpen(heliname) == false then
|
||||||
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me out!", self.messageTime, true, true)
|
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me out!", self.messageTime, true, true)
|
||||||
|
self:T(self.lid.."[Drop off debug] Door closed, try again next loop")
|
||||||
else
|
else
|
||||||
|
self:T(self.lid.."[Drop off debug] Rescued!")
|
||||||
self:_RescuePilots(_heliUnit)
|
self:_RescuePilots(_heliUnit)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--queue up
|
--queue up
|
||||||
self:__Returning(-5,heliname,_woundedGroupName, isairport)
|
if not noreschedule then
|
||||||
|
self:__Returning(5,heliname,_woundedGroupName, isairport)
|
||||||
|
self:ScheduleOnce(5,self._ScheduledSARFlight,self,heliname,groupname, isairport, noreschedule)
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1752,7 +1794,7 @@ function CSAR:_DisplayMessageToSAR(_unit, _text, _time, _clear, _speak, _overrid
|
|||||||
_text = string.gsub(_text,"nm"," nautical miles")
|
_text = string.gsub(_text,"nm"," nautical miles")
|
||||||
--self.msrs:SetVoice(self.SRSVoice)
|
--self.msrs:SetVoice(self.SRSVoice)
|
||||||
--self.SRSQueue:NewTransmission(_text,nil,self.msrs,nil,1)
|
--self.SRSQueue:NewTransmission(_text,nil,self.msrs,nil,1)
|
||||||
self:I("Voice = "..self.SRSVoice)
|
--self:I("Voice = "..self.SRSVoice)
|
||||||
self.SRSQueue:NewTransmission(_text,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,self.SRSVoice,volume,label,coord)
|
self.SRSQueue:NewTransmission(_text,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,self.SRSVoice,volume,label,coord)
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -1919,23 +1961,28 @@ end
|
|||||||
--- (Internal) Display info to all SAR groups.
|
--- (Internal) Display info to all SAR groups.
|
||||||
-- @param #CSAR self
|
-- @param #CSAR self
|
||||||
-- @param #string _message Message to display.
|
-- @param #string _message Message to display.
|
||||||
-- @param #number _side Coalition of message.
|
-- @param #number _side Coalition of message.
|
||||||
-- @param #number _messagetime How long to show.
|
-- @param #number _messagetime How long to show.
|
||||||
function CSAR:_DisplayToAllSAR(_message, _side, _messagetime)
|
-- @param #boolean ToSRS If true or nil, send to SRS TTS
|
||||||
|
-- @param #boolean ToScreen If true or nil, send to Screen
|
||||||
|
function CSAR:_DisplayToAllSAR(_message, _side, _messagetime,ToSRS,ToScreen)
|
||||||
self:T(self.lid .. " _DisplayToAllSAR")
|
self:T(self.lid .. " _DisplayToAllSAR")
|
||||||
local messagetime = _messagetime or self.messageTime
|
local messagetime = _messagetime or self.messageTime
|
||||||
if self.msrs then
|
self:T({_message,ToSRS=ToSRS,ToScreen=ToScreen})
|
||||||
|
if self.msrs and (ToSRS == true or ToSRS == nil) then
|
||||||
local voice = self.CSARVoice or MSRS.Voices.Google.Standard.en_GB_Standard_F
|
local voice = self.CSARVoice or MSRS.Voices.Google.Standard.en_GB_Standard_F
|
||||||
if self.msrs:GetProvider() == MSRS.Provider.WINDOWS then
|
if self.msrs:GetProvider() == MSRS.Provider.WINDOWS then
|
||||||
voice = self.CSARVoiceMS or MSRS.Voices.Microsoft.Hedda
|
voice = self.CSARVoiceMS or MSRS.Voices.Microsoft.Hedda
|
||||||
end
|
end
|
||||||
self:I("Voice = "..voice)
|
self:F("Voice = "..voice)
|
||||||
self.SRSQueue:NewTransmission(_message,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,voice,volume,label,self.coordinate)
|
self.SRSQueue:NewTransmission(_message,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,voice,volume,label,self.coordinate)
|
||||||
end
|
end
|
||||||
for _, _unitName in pairs(self.csarUnits) do
|
if ToScreen == true or ToScreen == nil then
|
||||||
local _unit = self:_GetSARHeli(_unitName)
|
for _, _unitName in pairs(self.csarUnits) do
|
||||||
if _unit and not self.suppressmessages then
|
local _unit = self:_GetSARHeli(_unitName)
|
||||||
self:_DisplayMessageToSAR(_unit, _message, _messagetime)
|
if _unit and not self.suppressmessages then
|
||||||
|
self:_DisplayMessageToSAR(_unit, _message, _messagetime)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -1981,7 +2028,7 @@ end
|
|||||||
--- (Internal) Determine distance to closest MASH.
|
--- (Internal) Determine distance to closest MASH.
|
||||||
-- @param #CSAR self
|
-- @param #CSAR self
|
||||||
-- @param Wrapper.Unit#UNIT _heli Helicopter #UNIT
|
-- @param Wrapper.Unit#UNIT _heli Helicopter #UNIT
|
||||||
-- @retunr
|
-- @return #CSAR self
|
||||||
function CSAR:_GetClosestMASH(_heli)
|
function CSAR:_GetClosestMASH(_heli)
|
||||||
self:T(self.lid .. " _GetClosestMASH")
|
self:T(self.lid .. " _GetClosestMASH")
|
||||||
local _mashset = self.mash -- Core.Set#SET_GROUP
|
local _mashset = self.mash -- Core.Set#SET_GROUP
|
||||||
@@ -2219,7 +2266,7 @@ function CSAR:_RefreshRadioBeacons()
|
|||||||
if self:_CountActiveDownedPilots() > 0 then
|
if self:_CountActiveDownedPilots() > 0 then
|
||||||
local PilotTable = self.downedPilots
|
local PilotTable = self.downedPilots
|
||||||
for _,_pilot in pairs (PilotTable) do
|
for _,_pilot in pairs (PilotTable) do
|
||||||
self:T({_pilot})
|
self:T({_pilot.name})
|
||||||
local pilot = _pilot -- #CSAR.DownedPilot
|
local pilot = _pilot -- #CSAR.DownedPilot
|
||||||
local group = pilot.group
|
local group = pilot.group
|
||||||
local frequency = pilot.frequency or 0 -- thanks to @Thrud
|
local frequency = pilot.frequency or 0 -- thanks to @Thrud
|
||||||
@@ -2501,7 +2548,7 @@ end
|
|||||||
-- @param #boolean IsAirport True if heli has landed on an AFB (from event land).
|
-- @param #boolean IsAirport True if heli has landed on an AFB (from event land).
|
||||||
function CSAR:onbeforeReturning(From, Event, To, Heliname, Woundedgroupname, IsAirPort)
|
function CSAR:onbeforeReturning(From, Event, To, Heliname, Woundedgroupname, IsAirPort)
|
||||||
self:T({From, Event, To, Heliname, Woundedgroupname})
|
self:T({From, Event, To, Heliname, Woundedgroupname})
|
||||||
self:_ScheduledSARFlight(Heliname,Woundedgroupname, IsAirPort)
|
--self:_ScheduledSARFlight(Heliname,Woundedgroupname, IsAirPort)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
-- @module Ops.CTLD
|
-- @module Ops.CTLD
|
||||||
-- @image OPS_CTLD.jpg
|
-- @image OPS_CTLD.jpg
|
||||||
|
|
||||||
-- Last Update March 2024
|
-- Last Update April 2024
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
@@ -1249,11 +1249,13 @@ CTLD.UnitTypeCapabilities = {
|
|||||||
["SH-60B"] = {type="SH-60B", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
["SH-60B"] = {type="SH-60B", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
||||||
["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200}, -- 2 ppl **outside** the helo
|
["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200}, -- 2 ppl **outside** the helo
|
||||||
["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
|
["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
|
||||||
|
["OH-6A"] = {type="OH-6A", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 7, cargoweightlimit = 550},
|
||||||
|
["OH58D"] = {type="OH58D", crates=false, troops=false, cratelimit = 0, trooplimit = 0, length = 14, cargoweightlimit = 400},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- CTLD class version.
|
--- CTLD class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CTLD.version="1.0.50"
|
CTLD.version="1.0.54"
|
||||||
|
|
||||||
--- Instantiate a new CTLD.
|
--- Instantiate a new CTLD.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
@@ -2240,7 +2242,9 @@ end
|
|||||||
local extractdistance = self.CrateDistance * self.ExtractFactor
|
local extractdistance = self.CrateDistance * self.ExtractFactor
|
||||||
for k,v in pairs(self.DroppedTroops) do
|
for k,v in pairs(self.DroppedTroops) do
|
||||||
local distance = self:_GetDistance(v:GetCoordinate(),unitcoord)
|
local distance = self:_GetDistance(v:GetCoordinate(),unitcoord)
|
||||||
if distance <= extractdistance and distance ~= -1 then
|
local TNow = timer.getTime()
|
||||||
|
local vtime = v.ExtractTime or TNow-310
|
||||||
|
if distance <= extractdistance and distance ~= -1 and (TNow - vtime > 300) then
|
||||||
nearestGroup = v
|
nearestGroup = v
|
||||||
nearestGroupIndex = k
|
nearestGroupIndex = k
|
||||||
nearestDistance = distance
|
nearestDistance = distance
|
||||||
@@ -2291,9 +2295,11 @@ end
|
|||||||
end
|
end
|
||||||
if troopsize + numberonboard > trooplimit then
|
if troopsize + numberonboard > trooplimit then
|
||||||
self:_SendMessage("Sorry, we\'re crammed already!", 10, false, Group)
|
self:_SendMessage("Sorry, we\'re crammed already!", 10, false, Group)
|
||||||
|
nearestGroup.ExtractTime = 0
|
||||||
--return self
|
--return self
|
||||||
else
|
else
|
||||||
self.CargoCounter = self.CargoCounter + 1
|
self.CargoCounter = self.CargoCounter + 1
|
||||||
|
nearestGroup.ExtractTime = timer.getTime()
|
||||||
local loadcargotype = CTLD_CARGO:New(self.CargoCounter, Cargotype.Name, Cargotype.Templates, Cargotype.CargoType, true, true, Cargotype.CratesNeeded,nil,nil,Cargotype.PerCrateMass)
|
local loadcargotype = CTLD_CARGO:New(self.CargoCounter, Cargotype.Name, Cargotype.Templates, Cargotype.CargoType, true, true, Cargotype.CratesNeeded,nil,nil,Cargotype.PerCrateMass)
|
||||||
self:T({cargotype=loadcargotype})
|
self:T({cargotype=loadcargotype})
|
||||||
local running = math.floor(nearestDistance / 4)+10 -- time run to helo plus boarding
|
local running = math.floor(nearestDistance / 4)+10 -- time run to helo plus boarding
|
||||||
@@ -3603,7 +3609,7 @@ function CTLD:_MoveGroupToZone(Group)
|
|||||||
local groupcoord = Group:GetCoordinate()
|
local groupcoord = Group:GetCoordinate()
|
||||||
-- Get closest zone of type
|
-- Get closest zone of type
|
||||||
local outcome, name, zone, distance = self:IsUnitInZone(Group,CTLD.CargoZoneType.MOVE)
|
local outcome, name, zone, distance = self:IsUnitInZone(Group,CTLD.CargoZoneType.MOVE)
|
||||||
if (distance <= self.movetroopsdistance) and zone then
|
if (distance <= self.movetroopsdistance) and outcome == true and zone~= nil then
|
||||||
-- yes, we can ;)
|
-- yes, we can ;)
|
||||||
local groupname = Group:GetName()
|
local groupname = Group:GetName()
|
||||||
local zonecoord = zone:GetRandomCoordinate(20,125) -- Core.Point#COORDINATE
|
local zonecoord = zone:GetRandomCoordinate(20,125) -- Core.Point#COORDINATE
|
||||||
@@ -4460,10 +4466,9 @@ function CTLD:IsUnitInZone(Unit,Zonetype)
|
|||||||
zonewidth = zoneradius
|
zonewidth = zoneradius
|
||||||
end
|
end
|
||||||
local distance = self:_GetDistance(zonecoord,unitcoord)
|
local distance = self:_GetDistance(zonecoord,unitcoord)
|
||||||
if zone:IsVec2InZone(unitVec2) and active then
|
self:T("Distance Zone: "..distance)
|
||||||
|
if (zone:IsVec2InZone(unitVec2) or Zonetype == CTLD.CargoZoneType.MOVE) and active == true and maxdist > distance then
|
||||||
outcome = true
|
outcome = true
|
||||||
end
|
|
||||||
if maxdist > distance then
|
|
||||||
maxdist = distance
|
maxdist = distance
|
||||||
zoneret = zone
|
zoneret = zone
|
||||||
zonenameret = zonename
|
zonenameret = zonename
|
||||||
|
|||||||
@@ -1078,6 +1078,13 @@ function CHIEF:SetStrategy(Strategy)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get current strategy.
|
||||||
|
-- @param #CHIEF self
|
||||||
|
-- @return #string Strategy.
|
||||||
|
function CHIEF:GetStrategy()
|
||||||
|
return self.strategy
|
||||||
|
end
|
||||||
|
|
||||||
--- Get defence condition.
|
--- Get defence condition.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
-- @param #string Current Defence condition. See @{#CHIEF.DEFCON}, e.g. `CHIEF.DEFCON.RED`.
|
-- @param #string Current Defence condition. See @{#CHIEF.DEFCON}, e.g. `CHIEF.DEFCON.RED`.
|
||||||
@@ -1456,7 +1463,7 @@ end
|
|||||||
--- Add a CAP zone. Flights will engage detected targets inside this zone.
|
--- Add a CAP zone. Flights will engage detected targets inside this zone.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
-- @param Core.Zone#ZONE Zone CAP Zone. Has to be a circular zone.
|
-- @param Core.Zone#ZONE Zone CAP Zone. Has to be a circular zone.
|
||||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
-- @param #number Altitude Orbit altitude in feet. Default is 12,000 feet.
|
||||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||||
@@ -1472,7 +1479,7 @@ end
|
|||||||
--- Add a GCI CAP.
|
--- Add a GCI CAP.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
-- @param Core.Zone#ZONE Zone Zone, where the flight orbits.
|
-- @param Core.Zone#ZONE Zone Zone, where the flight orbits.
|
||||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
-- @param #number Altitude Orbit altitude in feet. Default is 12,000 feet.
|
||||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||||
@@ -1499,7 +1506,7 @@ end
|
|||||||
--- Add an AWACS zone.
|
--- Add an AWACS zone.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
-- @param Core.Zone#ZONE Zone Zone.
|
-- @param Core.Zone#ZONE Zone Zone.
|
||||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
-- @param #number Altitude Orbit altitude in feet. Default is 12,000 feet.
|
||||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||||
@@ -1526,7 +1533,7 @@ end
|
|||||||
--- Add a refuelling tanker zone.
|
--- Add a refuelling tanker zone.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
-- @param Core.Zone#ZONE Zone Zone.
|
-- @param Core.Zone#ZONE Zone Zone.
|
||||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
-- @param #number Altitude Orbit altitude in feet. Default is 12,000 feet.
|
||||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||||
|
|||||||
@@ -505,6 +505,9 @@ end
|
|||||||
function COHORT:SetCallsign(Callsign, Index)
|
function COHORT:SetCallsign(Callsign, Index)
|
||||||
self.callsignName=Callsign
|
self.callsignName=Callsign
|
||||||
self.callsignIndex=Index
|
self.callsignIndex=Index
|
||||||
|
self.callsign={}
|
||||||
|
self.callsign.NumberSquad=Callsign
|
||||||
|
self.callsign.NumberGroup=Index
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -663,7 +663,7 @@ end
|
|||||||
--- Add a CAP zone.
|
--- Add a CAP zone.
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param Core.Zone#ZONE Zone CapZone Zone.
|
-- @param Core.Zone#ZONE Zone CapZone Zone.
|
||||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
-- @param #number Altitude Orbit altitude in feet. Default is 12,000 feet.
|
||||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||||
@@ -689,7 +689,7 @@ end
|
|||||||
--- Add a GCICAP zone.
|
--- Add a GCICAP zone.
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param Core.Zone#ZONE Zone CapZone Zone.
|
-- @param Core.Zone#ZONE Zone CapZone Zone.
|
||||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
-- @param #number Altitude Orbit altitude in feet. Default is 12,000 feet.
|
||||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||||
@@ -735,7 +735,7 @@ end
|
|||||||
--- Add an AWACS zone.
|
--- Add an AWACS zone.
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param Core.Zone#ZONE Zone Zone.
|
-- @param Core.Zone#ZONE Zone Zone.
|
||||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
-- @param #number Altitude Orbit altitude in feet. Default is 12,000 feet.
|
||||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||||
@@ -782,7 +782,7 @@ end
|
|||||||
--- Add a refuelling tanker zone.
|
--- Add a refuelling tanker zone.
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param Core.Zone#ZONE Zone Zone.
|
-- @param Core.Zone#ZONE Zone Zone.
|
||||||
-- @param #number Altitude Orbit altitude in feet. Default is 12,0000 feet.
|
-- @param #number Altitude Orbit altitude in feet. Default is 12,000 feet.
|
||||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||||
|
|||||||
@@ -62,6 +62,8 @@
|
|||||||
-- @field #number runwayrepairtime Time in seconds until runway will be repaired after it was destroyed. Default is 3600 sec (one hour).
|
-- @field #number runwayrepairtime Time in seconds until runway will be repaired after it was destroyed. Default is 3600 sec (one hour).
|
||||||
-- @field #boolean markerParking If `true`, occupied parking spots are marked.
|
-- @field #boolean markerParking If `true`, occupied parking spots are marked.
|
||||||
-- @field #boolean nosubs If `true`, SRS TTS is without subtitles.
|
-- @field #boolean nosubs If `true`, SRS TTS is without subtitles.
|
||||||
|
-- @field #number Nplayers Number of human players. Updated at each StatusUpdate call.
|
||||||
|
-- @field #boolean radioOnlyIfPlayers Activate to limit transmissions only if players are active at the airbase.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- **Ground Control**: Airliner X, Good news, you are clear to taxi to the active.
|
--- **Ground Control**: Airliner X, Good news, you are clear to taxi to the active.
|
||||||
@@ -272,6 +274,7 @@ FLIGHTCONTROL = {
|
|||||||
holdingpatterns = {},
|
holdingpatterns = {},
|
||||||
hpcounter = 0,
|
hpcounter = 0,
|
||||||
nosubs = false,
|
nosubs = false,
|
||||||
|
Nplayers = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Holding point. Contains holding stacks.
|
--- Holding point. Contains holding stacks.
|
||||||
@@ -329,7 +332,7 @@ FLIGHTCONTROL.FlightStatus={
|
|||||||
|
|
||||||
--- FlightControl class version.
|
--- FlightControl class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
FLIGHTCONTROL.version="0.7.5"
|
FLIGHTCONTROL.version="0.7.7"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -417,6 +420,9 @@ function FLIGHTCONTROL:New(AirbaseName, Frequency, Modulation, PathToSRS, Port,
|
|||||||
-- Init msrs queue.
|
-- Init msrs queue.
|
||||||
self.msrsqueue=MSRSQUEUE:New(self.alias)
|
self.msrsqueue=MSRSQUEUE:New(self.alias)
|
||||||
|
|
||||||
|
-- Set that transmission is only if alive players on the server.
|
||||||
|
self:SetTransmitOnlyWithPlayers(true)
|
||||||
|
|
||||||
-- Init msrs bases
|
-- Init msrs bases
|
||||||
local path = PathToSRS or MSRS.path
|
local path = PathToSRS or MSRS.path
|
||||||
local port = Port or MSRS.port or 5002
|
local port = Port or MSRS.port or 5002
|
||||||
@@ -571,6 +577,31 @@ function FLIGHTCONTROL:SetVerbosity(VerbosityLevel)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Limit radio transmissions only if human players are registered at the airbase.
|
||||||
|
-- This can be used to reduce TTS messages on heavy missions.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #boolean Switch If `true` or `nil` no transmission if there are no players. Use `false` enable TTS with no players.
|
||||||
|
-- @return #FLIGHTCONTROL self
|
||||||
|
function FLIGHTCONTROL:SetRadioOnlyIfPlayers(Switch)
|
||||||
|
if Switch==nil or Switch==true then
|
||||||
|
self.radioOnlyIfPlayers=true
|
||||||
|
else
|
||||||
|
self.radioOnlyIfPlayers=false
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set whether to only transmit TTS messages if there are players on the server.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #boolean Switch If `true`, only send TTS messages if there are alive Players. If `false` or `nil`, transmission are done also if no players are on the server.
|
||||||
|
-- @return #FLIGHTCONTROL self
|
||||||
|
function FLIGHTCONTROL:SetTransmitOnlyWithPlayers(Switch)
|
||||||
|
self.msrsqueue:SetTransmitOnlyWithPlayers(Switch)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set subtitles to appear on SRS TTS messages.
|
--- Set subtitles to appear on SRS TTS messages.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @return #FLIGHTCONTROL self
|
-- @return #FLIGHTCONTROL self
|
||||||
@@ -1063,9 +1094,10 @@ function FLIGHTCONTROL:onafterStatusUpdate()
|
|||||||
-- Check if runway was repaired.
|
-- Check if runway was repaired.
|
||||||
if self:IsRunwayOperational()==false then
|
if self:IsRunwayOperational()==false then
|
||||||
local Trepair=self:GetRunwayRepairtime()
|
local Trepair=self:GetRunwayRepairtime()
|
||||||
self:I(self.lid..string.format("Runway still destroyed! Will be repaired in %d sec", Trepair))
|
|
||||||
if Trepair==0 then
|
if Trepair==0 then
|
||||||
self:RunwayRepaired()
|
self:RunwayRepaired()
|
||||||
|
else
|
||||||
|
self:I(self.lid..string.format("Runway still destroyed! Will be repaired in %d sec", Trepair))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1835,7 +1867,7 @@ function FLIGHTCONTROL:_GetNextFightParking()
|
|||||||
local text="Parking flights:"
|
local text="Parking flights:"
|
||||||
for i,_flight in pairs(Qparking) do
|
for i,_flight in pairs(Qparking) do
|
||||||
local flight=_flight --Ops.FlightGroup#FLIGHTGROUP
|
local flight=_flight --Ops.FlightGroup#FLIGHTGROUP
|
||||||
text=text..string.format("\n[%d] %s [%s], state=%s [%s]: Tparking=%.1f sec", i, flight.groupname, flight.actype, flight:GetState(), self:GetFlightStatus(flight), flight:GetParkingTime())
|
text=text..string.format("\n[%d] %s [%s], state=%s [%s]: Tparking=%.1f sec", i, flight.groupname, tostring(flight.actype), flight:GetState(), self:GetFlightStatus(flight), flight:GetParkingTime())
|
||||||
end
|
end
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
end
|
end
|
||||||
@@ -2131,7 +2163,7 @@ function FLIGHTCONTROL:_InitParkingSpots()
|
|||||||
|
|
||||||
local isalive=unit:IsAlive()
|
local isalive=unit:IsAlive()
|
||||||
|
|
||||||
--env.info(string.format("FF parking spot %d is occupied by unit %s alive=%s", spot.TerminalID, unitname, tostring(isalive)))
|
self:T2(self.lid..string.format("FF parking spot %d is occupied by unit %s alive=%s", spot.TerminalID, unitname, tostring(isalive)))
|
||||||
|
|
||||||
if isalive then
|
if isalive then
|
||||||
|
|
||||||
@@ -4081,6 +4113,15 @@ function FLIGHTCONTROL:_CheckFlights()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Count number of players
|
||||||
|
self.Nplayers=0
|
||||||
|
for _,_flight in pairs(self.flights) do
|
||||||
|
local flight=_flight --Ops.FlightGroup#FLIGHTGROUP
|
||||||
|
if not flight.isAI then
|
||||||
|
self.Nplayers=self.Nplayers+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Check speeding.
|
-- Check speeding.
|
||||||
if self.speedLimitTaxi then
|
if self.speedLimitTaxi then
|
||||||
|
|
||||||
@@ -4313,6 +4354,11 @@ end
|
|||||||
-- @param #number Delay Delay in seconds before the text is transmitted. Default 0 sec.
|
-- @param #number Delay Delay in seconds before the text is transmitted. Default 0 sec.
|
||||||
function FLIGHTCONTROL:TransmissionTower(Text, Flight, Delay)
|
function FLIGHTCONTROL:TransmissionTower(Text, Flight, Delay)
|
||||||
|
|
||||||
|
if self.radioOnlyIfPlayers==true and self.Nplayers==0 then
|
||||||
|
self:T(self.lid.."No players ==> skipping TOWER radio transmission")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Spoken text.
|
-- Spoken text.
|
||||||
local text=self:_GetTextForSpeech(Text)
|
local text=self:_GetTextForSpeech(Text)
|
||||||
|
|
||||||
@@ -4344,6 +4390,12 @@ end
|
|||||||
-- @param #number Delay Delay in seconds before the text is transmitted. Default 0 sec.
|
-- @param #number Delay Delay in seconds before the text is transmitted. Default 0 sec.
|
||||||
function FLIGHTCONTROL:TransmissionPilot(Text, Flight, Delay)
|
function FLIGHTCONTROL:TransmissionPilot(Text, Flight, Delay)
|
||||||
|
|
||||||
|
if self.radioOnlyIfPlayers==true and self.Nplayers==0 then
|
||||||
|
self:T(self.lid.."No players ==> skipping PILOT radio transmission")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Get player data.
|
-- Get player data.
|
||||||
local playerData=Flight:_GetPlayerData()
|
local playerData=Flight:_GetPlayerData()
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
-- @field #boolean prohibitAB Disallow (true) or allow (false) AI to use the afterburner.
|
-- @field #boolean prohibitAB Disallow (true) or allow (false) AI to use the afterburner.
|
||||||
-- @field #boolean jettisonEmptyTanks Allow (true) or disallow (false) AI to jettison empty fuel tanks.
|
-- @field #boolean jettisonEmptyTanks Allow (true) or disallow (false) AI to jettison empty fuel tanks.
|
||||||
-- @field #boolean jettisonWeapons Allow (true) or disallow (false) AI to jettison weapons if in danger.
|
-- @field #boolean jettisonWeapons Allow (true) or disallow (false) AI to jettison weapons if in danger.
|
||||||
|
-- @field #number holdtime Time [s] flight is holding before going on final. Set to nil for indefinitely.
|
||||||
--
|
--
|
||||||
-- @extends Ops.OpsGroup#OPSGROUP
|
-- @extends Ops.OpsGroup#OPSGROUP
|
||||||
|
|
||||||
@@ -273,6 +274,7 @@ function FLIGHTGROUP:New(group)
|
|||||||
-- Holding flag.
|
-- Holding flag.
|
||||||
self.flaghold=USERFLAG:New(string.format("%s_FlagHold", self.groupname))
|
self.flaghold=USERFLAG:New(string.format("%s_FlagHold", self.groupname))
|
||||||
self.flaghold:Set(0)
|
self.flaghold:Set(0)
|
||||||
|
self.holdtime=2*60
|
||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
@@ -786,6 +788,7 @@ function FLIGHTGROUP:SetReadyForTakeoff(ReadyTO, Delay)
|
|||||||
if Delay and Delay>0 then
|
if Delay and Delay>0 then
|
||||||
self:ScheduleOnce(Delay, FLIGHTGROUP.SetReadyForTakeoff, self, ReadyTO, 0)
|
self:ScheduleOnce(Delay, FLIGHTGROUP.SetReadyForTakeoff, self, ReadyTO, 0)
|
||||||
else
|
else
|
||||||
|
self:T(self.lid.."Set Ready for Takeoff switch for flightcontrol")
|
||||||
self.isReadyTO=ReadyTO
|
self.isReadyTO=ReadyTO
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -1254,9 +1257,12 @@ function FLIGHTGROUP:Status()
|
|||||||
-- Check ammo status.
|
-- Check ammo status.
|
||||||
self:_CheckAmmoStatus()
|
self:_CheckAmmoStatus()
|
||||||
|
|
||||||
-- Check damage.
|
-- Check damage.
|
||||||
self:_CheckDamage()
|
self:_CheckDamage()
|
||||||
|
|
||||||
|
-- Check if stuck while taxiing.
|
||||||
|
self:_CheckStuck()
|
||||||
|
|
||||||
-- Get current mission (if any).
|
-- Get current mission (if any).
|
||||||
local mission=self:GetMissionCurrent()
|
local mission=self:GetMissionCurrent()
|
||||||
|
|
||||||
@@ -1624,6 +1630,9 @@ function FLIGHTGROUP:Status()
|
|||||||
if not mission then
|
if not mission then
|
||||||
self.Twaiting=nil
|
self.Twaiting=nil
|
||||||
self.dTwait=nil
|
self.dTwait=nil
|
||||||
|
|
||||||
|
-- Check if group is done.
|
||||||
|
-- TODO: Not sure why I introduced this here.
|
||||||
self:_CheckGroupDone()
|
self:_CheckGroupDone()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2097,7 +2106,7 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
|||||||
-- Debug info.
|
-- Debug info.
|
||||||
if self.verbose>=1 then
|
if self.verbose>=1 then
|
||||||
local text=string.format("Initialized Flight Group %s:\n", self.groupname)
|
local text=string.format("Initialized Flight Group %s:\n", self.groupname)
|
||||||
text=text..string.format("Unit type = %s\n", self.actype)
|
text=text..string.format("Unit type = %s\n", tostring(self.actype))
|
||||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedMax))
|
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedMax))
|
||||||
text=text..string.format("Range max = %.1f km\n", self.rangemax/1000)
|
text=text..string.format("Range max = %.1f km\n", self.rangemax/1000)
|
||||||
text=text..string.format("Ceiling = %.1f feet\n", UTILS.MetersToFeet(self.ceiling))
|
text=text..string.format("Ceiling = %.1f feet\n", UTILS.MetersToFeet(self.ceiling))
|
||||||
@@ -2136,6 +2145,10 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
|||||||
self.isDestroyed=false
|
self.isDestroyed=false
|
||||||
|
|
||||||
if self.isAI then
|
if self.isAI then
|
||||||
|
|
||||||
|
-- TODO: Could be that element is spawned UNCONTROLLED.
|
||||||
|
-- In that case, the commands are not yet used.
|
||||||
|
-- This should be shifted to something like after ACTIVATED
|
||||||
|
|
||||||
-- Set ROE.
|
-- Set ROE.
|
||||||
self:SwitchROE(self.option.ROE)
|
self:SwitchROE(self.option.ROE)
|
||||||
@@ -2175,7 +2188,7 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
|||||||
-- TODO: make this input.
|
-- TODO: make this input.
|
||||||
self:GetGroup():SetOption(AI.Option.Air.id.PROHIBIT_JETT, self.jettisonWeapons)
|
self:GetGroup():SetOption(AI.Option.Air.id.PROHIBIT_JETT, self.jettisonWeapons)
|
||||||
self:GetGroup():SetOption(AI.Option.Air.id.PROHIBIT_AB, self.prohibitAB) -- Does not seem to work. AI still used the after burner.
|
self:GetGroup():SetOption(AI.Option.Air.id.PROHIBIT_AB, self.prohibitAB) -- Does not seem to work. AI still used the after burner.
|
||||||
self:GetGroup():SetOption(AI.Option.Air.id.RTB_ON_BINGO, false)
|
self:GetGroup():SetOption(AI.Option.Air.id.RTB_ON_BINGO, false)
|
||||||
self:GetGroup():SetOption(AI.Option.Air.id.JETT_TANKS_IF_EMPTY, self.jettisonEmptyTanks)
|
self:GetGroup():SetOption(AI.Option.Air.id.JETT_TANKS_IF_EMPTY, self.jettisonEmptyTanks)
|
||||||
--self.group:SetOption(AI.Option.Air.id.RADAR_USING, AI.Option.Air.val.RADAR_USING.FOR_CONTINUOUS_SEARCH)
|
--self.group:SetOption(AI.Option.Air.id.RADAR_USING, AI.Option.Air.val.RADAR_USING.FOR_CONTINUOUS_SEARCH)
|
||||||
|
|
||||||
@@ -2737,6 +2750,7 @@ function FLIGHTGROUP:onafterOutOfMissilesAA(From, Event, To)
|
|||||||
if self.outofAAMrtb then
|
if self.outofAAMrtb then
|
||||||
-- Back to destination or home.
|
-- Back to destination or home.
|
||||||
local airbase=self.destbase or self.homebase
|
local airbase=self.destbase or self.homebase
|
||||||
|
self:T(self.lid.."Calling RTB in onafterOutOfMissilesAA")
|
||||||
self:__RTB(-5, airbase)
|
self:__RTB(-5, airbase)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2751,6 +2765,7 @@ function FLIGHTGROUP:onafterOutOfMissilesAG(From, Event, To)
|
|||||||
if self.outofAGMrtb then
|
if self.outofAGMrtb then
|
||||||
-- Back to destination or home.
|
-- Back to destination or home.
|
||||||
local airbase=self.destbase or self.homebase
|
local airbase=self.destbase or self.homebase
|
||||||
|
self:T(self.lid.."Calling RTB in onafterOutOfMissilesAG")
|
||||||
self:__RTB(-5, airbase)
|
self:__RTB(-5, airbase)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2789,6 +2804,11 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime)
|
|||||||
self:T(self.lid.."Engaging! Group NOT done...")
|
self:T(self.lid.."Engaging! Group NOT done...")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
-- Check if group is going for fuel.
|
||||||
|
if self:IsGoing4Fuel() then
|
||||||
|
self:T(self.lid.."Going for FUEL! Group NOT done...")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Number of tasks remaining.
|
-- Number of tasks remaining.
|
||||||
local nTasks=self:CountRemainingTasks()
|
local nTasks=self:CountRemainingTasks()
|
||||||
@@ -2840,8 +2860,8 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime)
|
|||||||
-- Number of remaining tasks/missions?
|
-- Number of remaining tasks/missions?
|
||||||
if nTasks==0 and nMissions==0 and nTransports==0 then
|
if nTasks==0 and nMissions==0 and nTransports==0 then
|
||||||
|
|
||||||
local destbase=self.destbase or self.homebase
|
local destbase=self.destbase or self.homebase --Wrapper.Airbase#AIRBASE
|
||||||
local destzone=self.destzone or self.homezone
|
local destzone=self.destzone or self.homezone --Wrapper.Airbase#AIRBASE
|
||||||
|
|
||||||
-- Send flight to destination.
|
-- Send flight to destination.
|
||||||
if waittime then
|
if waittime then
|
||||||
@@ -2852,8 +2872,11 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime)
|
|||||||
self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports AND parking at destination airbase ==> Arrived!")
|
self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports AND parking at destination airbase ==> Arrived!")
|
||||||
self:Arrived()
|
self:Arrived()
|
||||||
else
|
else
|
||||||
self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports ==> RTB!")
|
-- Only send RTB if current base is not yet the destination
|
||||||
self:__RTB(-0.1, destbase)
|
if self.currbase==nil or self.currbase.AirbaseName~=destbase.AirbaseName then
|
||||||
|
self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports ==> RTB!")
|
||||||
|
self:__RTB(-0.1, destbase)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif destzone then
|
elseif destzone then
|
||||||
self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports ==> RTZ!")
|
self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports ==> RTZ!")
|
||||||
@@ -2981,6 +3004,7 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Tsuspend and not allowed then
|
if Tsuspend and not allowed then
|
||||||
|
self:T(self.lid.."Calling RTB in onbeforeRTB")
|
||||||
self:__RTB(Tsuspend, airbase, SpeedTo, SpeedHold)
|
self:__RTB(Tsuspend, airbase, SpeedTo, SpeedHold)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3198,7 +3222,7 @@ function FLIGHTGROUP:_LandAtAirbase(airbase, SpeedTo, SpeedHold, SpeedLand)
|
|||||||
self.flaghold:Set(0)
|
self.flaghold:Set(0)
|
||||||
|
|
||||||
-- Set holding time.
|
-- Set holding time.
|
||||||
local holdtime=2*60
|
local holdtime=self.holdtime
|
||||||
if fc or self.airboss then
|
if fc or self.airboss then
|
||||||
holdtime=nil
|
holdtime=nil
|
||||||
end
|
end
|
||||||
@@ -3361,8 +3385,8 @@ function FLIGHTGROUP:onafterWait(From, Event, To, Duration, Altitude, Speed)
|
|||||||
-- Set time stamp.
|
-- Set time stamp.
|
||||||
self.Twaiting=timer.getAbsTime()
|
self.Twaiting=timer.getAbsTime()
|
||||||
|
|
||||||
-- Max waiting
|
-- Max waiting time in seconds.
|
||||||
self.dTwait=Duration
|
self.dTwait=Duration
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3400,6 +3424,9 @@ function FLIGHTGROUP:onafterRefuel(From, Event, To, Coordinate)
|
|||||||
local wp9=Coordinate:WaypointAir("BARO", COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, Speed, true, nil, DCSTasks, "Refuel")
|
local wp9=Coordinate:WaypointAir("BARO", COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, Speed, true, nil, DCSTasks, "Refuel")
|
||||||
|
|
||||||
self:Route({wp0, wp9}, 1)
|
self:Route({wp0, wp9}, 1)
|
||||||
|
|
||||||
|
-- Set RTB on Bingo option. Currently DCS does not execute the refueling task if RTB_ON_BINGO is set to "NO RTB ON BINGO"
|
||||||
|
self.group:SetOption(AI.Option.Air.id.RTB_ON_BINGO, true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3413,6 +3440,9 @@ function FLIGHTGROUP:onafterRefueled(From, Event, To)
|
|||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Flight group finished refuelling")
|
local text=string.format("Flight group finished refuelling")
|
||||||
self:T(self.lid..text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
|
-- Set RTB on Bingo option to "NO RTB ON BINGO"
|
||||||
|
self.group:SetOption(AI.Option.Air.id.RTB_ON_BINGO, false)
|
||||||
|
|
||||||
-- Check if flight is done.
|
-- Check if flight is done.
|
||||||
self:_CheckGroupDone(1)
|
self:_CheckGroupDone(1)
|
||||||
@@ -3661,6 +3691,7 @@ function FLIGHTGROUP:onafterFuelLow(From, Event, To)
|
|||||||
|
|
||||||
-- Send back to airbase.
|
-- Send back to airbase.
|
||||||
if airbase and self.fuellowrtb then
|
if airbase and self.fuellowrtb then
|
||||||
|
self:T(self.lid.."Calling RTB in onafterFuelLow")
|
||||||
self:RTB(airbase)
|
self:RTB(airbase)
|
||||||
--TODO: RTZ
|
--TODO: RTZ
|
||||||
end
|
end
|
||||||
@@ -3685,6 +3716,7 @@ function FLIGHTGROUP:onafterFuelCritical(From, Event, To)
|
|||||||
local airbase=self.destbase or self.homebase
|
local airbase=self.destbase or self.homebase
|
||||||
|
|
||||||
if airbase and self.fuelcriticalrtb and not self:IsGoing4Fuel() then
|
if airbase and self.fuelcriticalrtb and not self:IsGoing4Fuel() then
|
||||||
|
self:T(self.lid.."Calling RTB in onafterFuelCritical")
|
||||||
self:RTB(airbase)
|
self:RTB(airbase)
|
||||||
--TODO: RTZ
|
--TODO: RTZ
|
||||||
end
|
end
|
||||||
@@ -4832,6 +4864,87 @@ function FLIGHTGROUP:_GetTerminal(_attribute, _category)
|
|||||||
return _terminal
|
return _terminal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if group got stuck. This overwrites the OPSGROUP function.
|
||||||
|
-- Here we only check if stuck whilst taxiing.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #boolean Despawn If `true`, despawn group if stuck.
|
||||||
|
-- @return #number Time in seconds the group got stuck or nil if not stuck.
|
||||||
|
function FLIGHTGROUP:_CheckStuck(Despawn)
|
||||||
|
|
||||||
|
-- Cases we are not stuck.
|
||||||
|
if not self:IsTaxiing() then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Current time.
|
||||||
|
local Tnow=timer.getTime()
|
||||||
|
|
||||||
|
-- Expected speed in m/s.
|
||||||
|
local ExpectedSpeed=5
|
||||||
|
|
||||||
|
-- Current speed in m/s.
|
||||||
|
local speed=self:GetVelocity()
|
||||||
|
|
||||||
|
-- Check speed.
|
||||||
|
if speed<0.1 then
|
||||||
|
|
||||||
|
if ExpectedSpeed>0 and not self.stuckTimestamp then
|
||||||
|
self:T2(self.lid..string.format("WARNING: Group came to an unexpected standstill. Speed=%.1f<%.1f m/s expected", speed, ExpectedSpeed))
|
||||||
|
self.stuckTimestamp=Tnow
|
||||||
|
self.stuckVec3=self:GetVec3()
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- Moving (again).
|
||||||
|
self.stuckTimestamp=nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local holdtime=nil
|
||||||
|
|
||||||
|
-- Somehow we are not moving...
|
||||||
|
if self.stuckTimestamp then
|
||||||
|
|
||||||
|
-- Time we are holding.
|
||||||
|
holdtime=Tnow-self.stuckTimestamp
|
||||||
|
|
||||||
|
-- Trigger stuck event.
|
||||||
|
self:Stuck(holdtime)
|
||||||
|
|
||||||
|
if holdtime>=5*60 and holdtime<15*60 then
|
||||||
|
|
||||||
|
-- Debug warning.
|
||||||
|
self:T(self.lid..string.format("WARNING: Group came to an unexpected standstill. Speed=%.1f<%.1f m/s expected for %d sec", speed, ExpectedSpeed, holdtime))
|
||||||
|
|
||||||
|
elseif holdtime>=15*60 then
|
||||||
|
|
||||||
|
-- Debug warning.
|
||||||
|
self:T(self.lid..string.format("WARNING: Group came to an unexpected standstill. Speed=%.1f<%.1f m/s expected for %d sec", speed, ExpectedSpeed, holdtime))
|
||||||
|
|
||||||
|
-- Look for a current mission and cancel it as we do not seem to be able to perform it.
|
||||||
|
local mission=self:GetMissionCurrent()
|
||||||
|
|
||||||
|
if mission then
|
||||||
|
self:T(self.lid..string.format("WARNING: Cancelling mission %s [%s] due to being stuck", mission:GetName(), mission:GetType()))
|
||||||
|
self:MissionCancel(mission)
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.stuckDespawn then
|
||||||
|
if self.legion then
|
||||||
|
self:T(self.lid..string.format("Asset is returned to its legion after being stuck!"))
|
||||||
|
self:ReturnToLegion()
|
||||||
|
else
|
||||||
|
self:T(self.lid..string.format("Despawning group after being stuck!"))
|
||||||
|
self:Despawn()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return holdtime
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- OPTION FUNCTIONS
|
-- OPTION FUNCTIONS
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -117,6 +117,10 @@
|
|||||||
-- @field #string callsignAlias Callsign alias.
|
-- @field #string callsignAlias Callsign alias.
|
||||||
--
|
--
|
||||||
-- @field #OPSGROUP.Spot spot Laser and IR spot.
|
-- @field #OPSGROUP.Spot spot Laser and IR spot.
|
||||||
|
--
|
||||||
|
-- @field DCS#Vec3 stuckVec3 Position where the group got stuck.
|
||||||
|
-- @field #number stuckTimestamp Time stamp [sec], when the group got stuck.
|
||||||
|
-- @field #boolean stuckDespawn If `true`, group gets despawned after beeing stuck for a certain time.
|
||||||
--
|
--
|
||||||
-- @field #OPSGROUP.Ammo ammo Initial ammount of ammo.
|
-- @field #OPSGROUP.Ammo ammo Initial ammount of ammo.
|
||||||
-- @field #OPSGROUP.WeaponData weaponData Weapon data table with key=BitType.
|
-- @field #OPSGROUP.WeaponData weaponData Weapon data table with key=BitType.
|
||||||
@@ -597,7 +601,7 @@ function OPSGROUP:New(group)
|
|||||||
if units then
|
if units then
|
||||||
local masterunit=units[1] --Wrapper.Unit#UNIT
|
local masterunit=units[1] --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
if unit then
|
if masterunit then
|
||||||
-- Get Descriptors.
|
-- Get Descriptors.
|
||||||
self.descriptors=masterunit:GetDesc()
|
self.descriptors=masterunit:GetDesc()
|
||||||
|
|
||||||
@@ -676,10 +680,11 @@ function OPSGROUP:New(group)
|
|||||||
self:AddTransition("*", "UpdateRoute", "*") -- Update route of group.
|
self:AddTransition("*", "UpdateRoute", "*") -- Update route of group.
|
||||||
|
|
||||||
self:AddTransition("*", "PassingWaypoint", "*") -- Group passed a waypoint.
|
self:AddTransition("*", "PassingWaypoint", "*") -- Group passed a waypoint.
|
||||||
self:AddTransition("*", "PassedFinalWaypoint", "*") -- Group passed the waypoint.
|
self:AddTransition("*", "PassedFinalWaypoint", "*") -- Group passed the waypoint.
|
||||||
self:AddTransition("*", "GotoWaypoint", "*") -- Group switches to a specific waypoint.
|
self:AddTransition("*", "GotoWaypoint", "*") -- Group switches to a specific waypoint.
|
||||||
|
|
||||||
self:AddTransition("*", "Wait", "*") -- Group will wait for further orders.
|
self:AddTransition("*", "Wait", "*") -- Group will wait for further orders.
|
||||||
|
self:AddTransition("*", "Stuck", "*") -- Group got stuck.
|
||||||
|
|
||||||
self:AddTransition("*", "DetectedUnit", "*") -- Unit was detected (again) in this detection cycle.
|
self:AddTransition("*", "DetectedUnit", "*") -- Unit was detected (again) in this detection cycle.
|
||||||
self:AddTransition("*", "DetectedUnitNew", "*") -- Add a newly detected unit to the detected units set.
|
self:AddTransition("*", "DetectedUnitNew", "*") -- Add a newly detected unit to the detected units set.
|
||||||
@@ -1774,6 +1779,8 @@ function OPSGROUP:GetDCSUnit(UnitNumber)
|
|||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
local unit=DCSGroup:getUnit(UnitNumber or 1)
|
local unit=DCSGroup:getUnit(UnitNumber or 1)
|
||||||
return unit
|
return unit
|
||||||
|
else
|
||||||
|
self:E(self.lid..string.format("ERROR: DCS group does not exist! Cannot get unit"))
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1887,7 +1894,7 @@ end
|
|||||||
|
|
||||||
--- Get current velocity of the group.
|
--- Get current velocity of the group.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #string UnitName (Optional) Get heading of a specific unit of the group. Default is from the first existing unit in the group.
|
-- @param #string UnitName (Optional) Get velocity of a specific unit of the group. Default is from the first existing unit in the group.
|
||||||
-- @return #number Velocity in m/s.
|
-- @return #number Velocity in m/s.
|
||||||
function OPSGROUP:GetVelocity(UnitName)
|
function OPSGROUP:GetVelocity(UnitName)
|
||||||
|
|
||||||
@@ -2203,6 +2210,8 @@ function OPSGROUP:Destroy(Delay)
|
|||||||
if Delay and Delay>0 then
|
if Delay and Delay>0 then
|
||||||
self:ScheduleOnce(Delay, OPSGROUP.Destroy, self, 0)
|
self:ScheduleOnce(Delay, OPSGROUP.Destroy, self, 0)
|
||||||
else
|
else
|
||||||
|
|
||||||
|
self:T(self.lid.."Destroying group!")
|
||||||
|
|
||||||
-- Get all units.
|
-- Get all units.
|
||||||
local units=self:GetDCSUnits()
|
local units=self:GetDCSUnits()
|
||||||
@@ -3529,9 +3538,11 @@ function OPSGROUP:OnEventBirth(EventData)
|
|||||||
local element=self:GetElementByName(unitname)
|
local element=self:GetElementByName(unitname)
|
||||||
|
|
||||||
if element and element.status~=OPSGROUP.ElementStatus.SPAWNED then
|
if element and element.status~=OPSGROUP.ElementStatus.SPAWNED then
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("EVENT: Element %s born ==> spawned", unitname))
|
self:T(self.lid..string.format("EVENT: Element %s born ==> spawned", unitname))
|
||||||
|
|
||||||
|
self:T2(self.lid..string.format("DCS unit=%s isExist=%s", tostring(EventData.IniDCSUnit:getName()), tostring(EventData.IniDCSUnit:isExist()) ))
|
||||||
|
|
||||||
-- Set element to spawned state.
|
-- Set element to spawned state.
|
||||||
self:ElementSpawned(element)
|
self:ElementSpawned(element)
|
||||||
@@ -6673,6 +6684,7 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
local wpnext=self:GetWaypointNext()
|
local wpnext=self:GetWaypointNext()
|
||||||
if wpnext then
|
if wpnext then
|
||||||
self.speedWp=wpnext.speed
|
self.speedWp=wpnext.speed
|
||||||
|
self:T(self.lid..string.format("Expected/waypoint speed=%.1f m/s", self.speedWp))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -11388,6 +11400,7 @@ function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
|
|||||||
-- Expected speed to the first waypoint.
|
-- Expected speed to the first waypoint.
|
||||||
if i<=2 then
|
if i<=2 then
|
||||||
self.speedWp=wp.speed
|
self.speedWp=wp.speed
|
||||||
|
self:T(self.lid..string.format("Expected/waypoint speed=%.1f m/s", self.speedWp))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
@@ -12020,7 +12033,7 @@ function OPSGROUP:GetEPLRS()
|
|||||||
return self.option.EPLRS or self.optionDefault.EPLRS
|
return self.option.EPLRS or self.optionDefault.EPLRS
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the default EPLRS for the group.
|
--- Set the default emission state for the group.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #boolean OnOffSwitch If `true`, EPLRS is on by default. If `false` default EPLRS setting is off. If `nil`, default is on if group has EPLRS and off if it does not have a datalink.
|
-- @param #boolean OnOffSwitch If `true`, EPLRS is on by default. If `false` default EPLRS setting is off. If `nil`, default is on if group has EPLRS and off if it does not have a datalink.
|
||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
@@ -12029,7 +12042,7 @@ function OPSGROUP:SetDefaultEmission(OnOffSwitch)
|
|||||||
if OnOffSwitch==nil then
|
if OnOffSwitch==nil then
|
||||||
self.optionDefault.Emission=true
|
self.optionDefault.Emission=true
|
||||||
else
|
else
|
||||||
self.optionDefault.EPLRS=OnOffSwitch
|
self.optionDefault.Emission=OnOffSwitch
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
-- ===
|
-- ===
|
||||||
-- @module Ops.PlayerTask
|
-- @module Ops.PlayerTask
|
||||||
-- @image OPS_PlayerTask.jpg
|
-- @image OPS_PlayerTask.jpg
|
||||||
-- @date Last Update Feb 2024
|
-- @date Last Update May 2024
|
||||||
|
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -1213,6 +1213,9 @@ do
|
|||||||
-- AIRDEFENSE = "Airdefense",
|
-- AIRDEFENSE = "Airdefense",
|
||||||
-- SAM = "SAM",
|
-- SAM = "SAM",
|
||||||
-- GROUP = "Group",
|
-- GROUP = "Group",
|
||||||
|
-- ELEVATION = "\nTarget Elevation: %s %s",
|
||||||
|
-- METER = "meter",
|
||||||
|
-- FEET = "feet",
|
||||||
-- },
|
-- },
|
||||||
--
|
--
|
||||||
-- e.g.
|
-- e.g.
|
||||||
@@ -1367,7 +1370,7 @@ PLAYERTASKCONTROLLER.Type = {
|
|||||||
AUFTRAG.Type.PRECISIONBOMBING = "Precision Bombing"
|
AUFTRAG.Type.PRECISIONBOMBING = "Precision Bombing"
|
||||||
AUFTRAG.Type.CTLD = "Combat Transport"
|
AUFTRAG.Type.CTLD = "Combat Transport"
|
||||||
AUFTRAG.Type.CSAR = "Combat Rescue"
|
AUFTRAG.Type.CSAR = "Combat Rescue"
|
||||||
|
AUFTRAG.Type.CONQUER = "Conquer"
|
||||||
---
|
---
|
||||||
-- @type Scores
|
-- @type Scores
|
||||||
PLAYERTASKCONTROLLER.Scores = {
|
PLAYERTASKCONTROLLER.Scores = {
|
||||||
@@ -1380,7 +1383,8 @@ PLAYERTASKCONTROLLER.Scores = {
|
|||||||
[AUFTRAG.Type.BAI] = 100,
|
[AUFTRAG.Type.BAI] = 100,
|
||||||
[AUFTRAG.Type.SEAD] = 100,
|
[AUFTRAG.Type.SEAD] = 100,
|
||||||
[AUFTRAG.Type.BOMBING] = 100,
|
[AUFTRAG.Type.BOMBING] = 100,
|
||||||
[AUFTRAG.Type.BOMBRUNWAY] = 100,
|
[AUFTRAG.Type.BOMBRUNWAY] = 100,
|
||||||
|
[AUFTRAG.Type.CONQUER] = 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -1419,6 +1423,9 @@ PLAYERTASKCONTROLLER.Messages = {
|
|||||||
THREATMEDIUM = "medium",
|
THREATMEDIUM = "medium",
|
||||||
THREATLOW = "low",
|
THREATLOW = "low",
|
||||||
THREATTEXT = "%s\nThreat: %s\nTargets left: %d\nCoord: %s",
|
THREATTEXT = "%s\nThreat: %s\nTargets left: %d\nCoord: %s",
|
||||||
|
ELEVATION = "\nTarget Elevation: %s %s",
|
||||||
|
METER = "meter",
|
||||||
|
FEET = "feet",
|
||||||
THREATTEXTTTS = "%s, %s. Target information for %s. Threat level %s. Targets left %d. Target location %s.",
|
THREATTEXTTTS = "%s, %s. Target information for %s. Threat level %s. Targets left %d. Target location %s.",
|
||||||
MARKTASK = "%s, %s, copy, task %03d location marked on map!",
|
MARKTASK = "%s, %s, copy, task %03d location marked on map!",
|
||||||
SMOKETASK = "%s, %s, copy, task %03d location smoked!",
|
SMOKETASK = "%s, %s, copy, task %03d location smoked!",
|
||||||
@@ -1499,6 +1506,9 @@ PLAYERTASKCONTROLLER.Messages = {
|
|||||||
THREATMEDIUM = "mittel",
|
THREATMEDIUM = "mittel",
|
||||||
THREATLOW = "niedrig",
|
THREATLOW = "niedrig",
|
||||||
THREATTEXT = "%s\nGefahrstufe: %s\nZiele: %d\nKoord: %s",
|
THREATTEXT = "%s\nGefahrstufe: %s\nZiele: %d\nKoord: %s",
|
||||||
|
ELEVATION = "\nZiel Höhe: %s %s",
|
||||||
|
METER = "Meter",
|
||||||
|
FEET = "Fuss",
|
||||||
THREATTEXTTTS = "%s, %s. Zielinformation zu %s. Gefahrstufe %s. Ziele %d. Zielposition %s.",
|
THREATTEXTTTS = "%s, %s. Zielinformation zu %s. Gefahrstufe %s. Ziele %d. Zielposition %s.",
|
||||||
MARKTASK = "%s, %s, verstanden, Zielposition %03d auf der Karte markiert!",
|
MARKTASK = "%s, %s, verstanden, Zielposition %03d auf der Karte markiert!",
|
||||||
SMOKETASK = "%s, %s, verstanden, Zielposition %03d mit Rauch markiert!",
|
SMOKETASK = "%s, %s, verstanden, Zielposition %03d mit Rauch markiert!",
|
||||||
@@ -1561,7 +1571,7 @@ PLAYERTASKCONTROLLER.Messages = {
|
|||||||
|
|
||||||
--- PLAYERTASK class version.
|
--- PLAYERTASK class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
PLAYERTASKCONTROLLER.version="0.1.65"
|
PLAYERTASKCONTROLLER.version="0.1.66"
|
||||||
|
|
||||||
--- Create and run a new TASKCONTROLLER instance.
|
--- Create and run a new TASKCONTROLLER instance.
|
||||||
-- @param #PLAYERTASKCONTROLLER self
|
-- @param #PLAYERTASKCONTROLLER self
|
||||||
@@ -2113,10 +2123,12 @@ function PLAYERTASKCONTROLLER:_GetPlayerName(Client)
|
|||||||
local ttsplayername = nil
|
local ttsplayername = nil
|
||||||
if not self.customcallsigns[playername] then
|
if not self.customcallsigns[playername] then
|
||||||
local playergroup = Client:GetGroup()
|
local playergroup = Client:GetGroup()
|
||||||
ttsplayername = playergroup:GetCustomCallSign(self.ShortCallsign,self.Keepnumber,self.CallsignTranslations)
|
if playergroup ~= nil then
|
||||||
local newplayername = self:_GetTextForSpeech(ttsplayername)
|
ttsplayername = playergroup:GetCustomCallSign(self.ShortCallsign,self.Keepnumber,self.CallsignTranslations)
|
||||||
self.customcallsigns[playername] = newplayername
|
local newplayername = self:_GetTextForSpeech(ttsplayername)
|
||||||
ttsplayername = newplayername
|
self.customcallsigns[playername] = newplayername
|
||||||
|
ttsplayername = newplayername
|
||||||
|
end
|
||||||
else
|
else
|
||||||
ttsplayername = self.customcallsigns[playername]
|
ttsplayername = self.customcallsigns[playername]
|
||||||
end
|
end
|
||||||
@@ -3182,7 +3194,8 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Task, Group, Client)
|
|||||||
local ttsname = self.gettext:GetEntry("TASKNAMETTS",self.locale)
|
local ttsname = self.gettext:GetEntry("TASKNAMETTS",self.locale)
|
||||||
local taskname = string.format(tname,task.Type,task.PlayerTaskNr)
|
local taskname = string.format(tname,task.Type,task.PlayerTaskNr)
|
||||||
local ttstaskname = string.format(ttsname,task.TTSType,task.PlayerTaskNr)
|
local ttstaskname = string.format(ttsname,task.TTSType,task.PlayerTaskNr)
|
||||||
local Coordinate = task.Target:GetCoordinate() or COORDINATE:New(0,0,0)
|
local Coordinate = task.Target:GetCoordinate() or COORDINATE:New(0,0,0) -- Core.Point#COORDINATE
|
||||||
|
local Elevation = Coordinate:GetLandHeight() or 0 -- meters
|
||||||
local CoordText = ""
|
local CoordText = ""
|
||||||
local CoordTextLLDM = nil
|
local CoordTextLLDM = nil
|
||||||
if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then
|
if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then
|
||||||
@@ -3207,6 +3220,17 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Task, Group, Client)
|
|||||||
local ThreatGraph = "[" .. string.rep( "■", ThreatLevel ) .. string.rep( "□", 10 - ThreatLevel ) .. "]: "..ThreatLevel
|
local ThreatGraph = "[" .. string.rep( "■", ThreatLevel ) .. string.rep( "□", 10 - ThreatLevel ) .. "]: "..ThreatLevel
|
||||||
local ThreatLocaleText = self.gettext:GetEntry("THREATTEXT",self.locale)
|
local ThreatLocaleText = self.gettext:GetEntry("THREATTEXT",self.locale)
|
||||||
text = string.format(ThreatLocaleText, taskname, ThreatGraph, targets, CoordText)
|
text = string.format(ThreatLocaleText, taskname, ThreatGraph, targets, CoordText)
|
||||||
|
local settings = _DATABASE:GetPlayerSettings(playername) or _SETTINGS -- Core.Settings#SETTINGS
|
||||||
|
local elevationmeasure = self.gettext:GetEntry("FEET",self.locale)
|
||||||
|
if settings:IsMetric() then
|
||||||
|
elevationmeasure = self.gettext:GetEntry("METER",self.locale)
|
||||||
|
--Elevation = math.floor(UTILS.MetersToFeet(Elevation))
|
||||||
|
else
|
||||||
|
Elevation = math.floor(UTILS.MetersToFeet(Elevation))
|
||||||
|
end
|
||||||
|
-- ELEVATION = "\nTarget Elevation: %s %s",
|
||||||
|
local elev = self.gettext:GetEntry("ELEVATION",self.locale)
|
||||||
|
text = text .. string.format(elev,tostring(math.floor(Elevation)),elevationmeasure)
|
||||||
-- Prec bombing
|
-- Prec bombing
|
||||||
if task.Type == AUFTRAG.Type.PRECISIONBOMBING and self.precisionbombing then
|
if task.Type == AUFTRAG.Type.PRECISIONBOMBING and self.precisionbombing then
|
||||||
if self.LasingDrone and self.LasingDrone.playertask then
|
if self.LasingDrone and self.LasingDrone.playertask then
|
||||||
|
|||||||
260
Moose Development/Moose/Shapes/Circle.lua
Normal file
260
Moose Development/Moose/Shapes/Circle.lua
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
--
|
||||||
|
--
|
||||||
|
-- ### Author: **nielsvaes/coconutcockpit**
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Shapes.CIRCLE
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- CIRCLE class.
|
||||||
|
-- @type CIRCLE
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #number Radius Radius of the circle
|
||||||
|
|
||||||
|
--- *It's NOT hip to be square* -- Someone, somewhere, probably
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # CIRCLE
|
||||||
|
-- CIRCLEs can be fetched from the drawings in the Mission Editor
|
||||||
|
|
||||||
|
---
|
||||||
|
-- This class has some of the standard CIRCLE functions you'd expect. One function of interest is CIRCLE:PointInSector() that you can use if a point is
|
||||||
|
-- within a certain sector (pizza slice) of a circle. This can be useful for many things, including rudimentary, "radar-like" searches from a unit.
|
||||||
|
--
|
||||||
|
-- CIRCLE class with properties and methods for handling circles.
|
||||||
|
-- @field #CIRCLE
|
||||||
|
CIRCLE = {
|
||||||
|
ClassName = "CIRCLE",
|
||||||
|
Radius = nil,
|
||||||
|
}
|
||||||
|
--- Finds a circle on the map by its name. The circle must have been added in the Mission Editor
|
||||||
|
-- @param #string shape_name Name of the circle to find
|
||||||
|
-- @return #CIRCLE The found circle, or nil if not found
|
||||||
|
function CIRCLE:FindOnMap(shape_name)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:FindOnMap(shape_name))
|
||||||
|
for _, layer in pairs(env.mission.drawings.layers) do
|
||||||
|
for _, object in pairs(layer["objects"]) do
|
||||||
|
if string.find(object["name"], shape_name, 1, true) then
|
||||||
|
if object["polygonMode"] == "circle" then
|
||||||
|
self.Radius = object["radius"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Finds a circle by its name in the database.
|
||||||
|
-- @param #string shape_name Name of the circle to find
|
||||||
|
-- @return #CIRCLE The found circle, or nil if not found
|
||||||
|
function CIRCLE:Find(shape_name)
|
||||||
|
return _DATABASE:FindShape(shape_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Creates a new circle from a center point and a radius.
|
||||||
|
-- @param #table vec2 The center point of the circle
|
||||||
|
-- @param #number radius The radius of the circle
|
||||||
|
-- @return #CIRCLE The new circle
|
||||||
|
function CIRCLE:New(vec2, radius)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:New())
|
||||||
|
self.CenterVec2 = vec2
|
||||||
|
self.Radius = radius
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the radius of the circle.
|
||||||
|
-- @return #number The radius of the circle
|
||||||
|
function CIRCLE:GetRadius()
|
||||||
|
return self.Radius
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a point is contained within the circle.
|
||||||
|
-- @param #table point The point to check
|
||||||
|
-- @return #bool True if the point is contained, false otherwise
|
||||||
|
function CIRCLE:ContainsPoint(point)
|
||||||
|
if ((point.x - self.CenterVec2.x) ^ 2 + (point.y - self.CenterVec2.y) ^ 2) ^ 0.5 <= self.Radius then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a point is contained within a sector of the circle. The start and end sector need to be clockwise
|
||||||
|
-- @param #table point The point to check
|
||||||
|
-- @param #table sector_start The start point of the sector
|
||||||
|
-- @param #table sector_end The end point of the sector
|
||||||
|
-- @param #table center The center point of the sector
|
||||||
|
-- @param #number radius The radius of the sector
|
||||||
|
-- @return #bool True if the point is contained, false otherwise
|
||||||
|
function CIRCLE:PointInSector(point, sector_start, sector_end, center, radius)
|
||||||
|
center = center or self.CenterVec2
|
||||||
|
radius = radius or self.Radius
|
||||||
|
|
||||||
|
local function are_clockwise(v1, v2)
|
||||||
|
return -v1.x * v2.y + v1.y * v2.x > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function is_in_radius(rp)
|
||||||
|
return rp.x * rp.x + rp.y * rp.y <= radius ^ 2
|
||||||
|
end
|
||||||
|
|
||||||
|
local rel_pt = {
|
||||||
|
x = point.x - center.x,
|
||||||
|
y = point.y - center.y
|
||||||
|
}
|
||||||
|
|
||||||
|
local rel_sector_start = {
|
||||||
|
x = sector_start.x - center.x,
|
||||||
|
y = sector_start.y - center.y,
|
||||||
|
}
|
||||||
|
|
||||||
|
local rel_sector_end = {
|
||||||
|
x = sector_end.x - center.x,
|
||||||
|
y = sector_end.y - center.y,
|
||||||
|
}
|
||||||
|
|
||||||
|
return not are_clockwise(rel_sector_start, rel_pt) and
|
||||||
|
are_clockwise(rel_sector_end, rel_pt) and
|
||||||
|
is_in_radius(rel_pt, radius)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a unit is contained within a sector of the circle. The start and end sector need to be clockwise
|
||||||
|
-- @param #string unit_name The name of the unit to check
|
||||||
|
-- @param #table sector_start The start point of the sector
|
||||||
|
-- @param #table sector_end The end point of the sector
|
||||||
|
-- @param #table center The center point of the sector
|
||||||
|
-- @param #number radius The radius of the sector
|
||||||
|
-- @return #bool True if the unit is contained, false otherwise
|
||||||
|
function CIRCLE:UnitInSector(unit_name, sector_start, sector_end, center, radius)
|
||||||
|
center = center or self.CenterVec2
|
||||||
|
radius = radius or self.Radius
|
||||||
|
|
||||||
|
if self:PointInSector(UNIT:FindByName(unit_name):GetVec2(), sector_start, sector_end, center, radius) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if any unit of a group is contained within a sector of the circle. The start and end sector need to be clockwise
|
||||||
|
-- @param #string group_name The name of the group to check
|
||||||
|
-- @param #table sector_start The start point of the sector
|
||||||
|
-- @param #table sector_end The end point of the sector
|
||||||
|
-- @param #table center The center point of the sector
|
||||||
|
-- @param #number radius The radius of the sector
|
||||||
|
-- @return #bool True if any unit of the group is contained, false otherwise
|
||||||
|
function CIRCLE:AnyOfGroupInSector(group_name, sector_start, sector_end, center, radius)
|
||||||
|
center = center or self.CenterVec2
|
||||||
|
radius = radius or self.Radius
|
||||||
|
|
||||||
|
for _, unit in pairs(GROUP:FindByName(group_name):GetUnits()) do
|
||||||
|
if self:PointInSector(unit:GetVec2(), sector_start, sector_end, center, radius) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if all units of a group are contained within a sector of the circle. The start and end sector need to be clockwise
|
||||||
|
-- @param #string group_name The name of the group to check
|
||||||
|
-- @param #table sector_start The start point of the sector
|
||||||
|
-- @param #table sector_end The end point of the sector
|
||||||
|
-- @param #table center The center point of the sector
|
||||||
|
-- @param #number radius The radius of the sector
|
||||||
|
-- @return #bool True if all units of the group are contained, false otherwise
|
||||||
|
function CIRCLE:AllOfGroupInSector(group_name, sector_start, sector_end, center, radius)
|
||||||
|
center = center or self.CenterVec2
|
||||||
|
radius = radius or self.Radius
|
||||||
|
|
||||||
|
for _, unit in pairs(GROUP:FindByName(group_name):GetUnits()) do
|
||||||
|
if not self:PointInSector(unit:GetVec2(), sector_start, sector_end, center, radius) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a unit is contained within a radius of the circle.
|
||||||
|
-- @param #string unit_name The name of the unit to check
|
||||||
|
-- @param #table center The center point of the radius
|
||||||
|
-- @param #number radius The radius to check
|
||||||
|
-- @return #bool True if the unit is contained, false otherwise
|
||||||
|
function CIRCLE:UnitInRadius(unit_name, center, radius)
|
||||||
|
center = center or self.CenterVec2
|
||||||
|
radius = radius or self.Radius
|
||||||
|
|
||||||
|
if UTILS.IsInRadius(center, UNIT:FindByName(unit_name):GetVec2(), radius) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if any unit of a group is contained within a radius of the circle.
|
||||||
|
-- @param #string group_name The name of the group to check
|
||||||
|
-- @param #table center The center point of the radius
|
||||||
|
-- @param #number radius The radius to check
|
||||||
|
-- @return #bool True if any unit of the group is contained, false otherwise
|
||||||
|
function CIRCLE:AnyOfGroupInRadius(group_name, center, radius)
|
||||||
|
center = center or self.CenterVec2
|
||||||
|
radius = radius or self.Radius
|
||||||
|
|
||||||
|
for _, unit in pairs(GROUP:FindByName(group_name):GetUnits()) do
|
||||||
|
if UTILS.IsInRadius(center, unit:GetVec2(), radius) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if all units of a group are contained within a radius of the circle.
|
||||||
|
-- @param #string group_name The name of the group to check
|
||||||
|
-- @param #table center The center point of the radius
|
||||||
|
-- @param #number radius The radius to check
|
||||||
|
-- @return #bool True if all units of the group are contained, false otherwise
|
||||||
|
function CIRCLE:AllOfGroupInRadius(group_name, center, radius)
|
||||||
|
center = center or self.CenterVec2
|
||||||
|
radius = radius or self.Radius
|
||||||
|
|
||||||
|
for _, unit in pairs(GROUP:FindByName(group_name):GetUnits()) do
|
||||||
|
if not UTILS.IsInRadius(center, unit:GetVec2(), radius) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns a random Vec2 within the circle.
|
||||||
|
-- @return #table The random Vec2
|
||||||
|
function CIRCLE:GetRandomVec2()
|
||||||
|
local angle = math.random() * 2 * math.pi
|
||||||
|
|
||||||
|
local rx = math.random(0, self.Radius) * math.cos(angle) + self.CenterVec2.x
|
||||||
|
local ry = math.random(0, self.Radius) * math.sin(angle) + self.CenterVec2.y
|
||||||
|
|
||||||
|
return {x=rx, y=ry}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns a random Vec2 on the border of the circle.
|
||||||
|
-- @return #table The random Vec2
|
||||||
|
function CIRCLE:GetRandomVec2OnBorder()
|
||||||
|
local angle = math.random() * 2 * math.pi
|
||||||
|
|
||||||
|
local rx = self.Radius * math.cos(angle) + self.CenterVec2.x
|
||||||
|
local ry = self.Radius * math.sin(angle) + self.CenterVec2.y
|
||||||
|
|
||||||
|
return {x=rx, y=ry}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculates the bounding box of the circle. The bounding box is the smallest rectangle that contains the circle.
|
||||||
|
-- @return #table The bounding box of the circle
|
||||||
|
function CIRCLE:GetBoundingBox()
|
||||||
|
local min_x = self.CenterVec2.x - self.Radius
|
||||||
|
local min_y = self.CenterVec2.y - self.Radius
|
||||||
|
local max_x = self.CenterVec2.x + self.Radius
|
||||||
|
local max_y = self.CenterVec2.y + self.Radius
|
||||||
|
|
||||||
|
return {
|
||||||
|
{x=min_x, y=min_x}, {x=max_x, y=min_y}, {x=max_x, y=max_y}, {x=min_x, y=max_y}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
85
Moose Development/Moose/Shapes/Cube.lua
Normal file
85
Moose Development/Moose/Shapes/Cube.lua
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
---
|
||||||
|
--
|
||||||
|
-- ### Author: **nielsvaes/coconutcockpit**
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Shapes.CUBE
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- LINE class.
|
||||||
|
-- @type CUBE
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #number Points points of the line
|
||||||
|
-- @field #number Coords coordinates of the line
|
||||||
|
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @field #CUBE
|
||||||
|
CUBE = {
|
||||||
|
ClassName = "CUBE",
|
||||||
|
Points = {},
|
||||||
|
Coords = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Points need to be added in the following order:
|
||||||
|
--- p1 -> p4 make up the front face of the cube
|
||||||
|
--- p5 -> p8 make up the back face of the cube
|
||||||
|
--- p1 connects to p5
|
||||||
|
--- p2 connects to p6
|
||||||
|
--- p3 connects to p7
|
||||||
|
--- p4 connects to p8
|
||||||
|
---
|
||||||
|
--- 8-----------7
|
||||||
|
--- /| /|
|
||||||
|
--- / | / |
|
||||||
|
--- 4--+--------3 |
|
||||||
|
--- | | | |
|
||||||
|
--- | | | |
|
||||||
|
--- | | | |
|
||||||
|
--- | 5--------+--6
|
||||||
|
--- | / | /
|
||||||
|
--- |/ |/
|
||||||
|
--- 1-----------2
|
||||||
|
---
|
||||||
|
function CUBE:New(p1, p2, p3, p4, p5, p6, p7, p8)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE)
|
||||||
|
self.Points = {p1, p2, p3, p4, p5, p6, p7, p8}
|
||||||
|
for _, point in spairs(self.Points) do
|
||||||
|
table.insert(self.Coords, COORDINATE:NewFromVec3(point))
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function CUBE:GetCenter()
|
||||||
|
local center = { x=0, y=0, z=0 }
|
||||||
|
for _, point in pairs(self.Points) do
|
||||||
|
center.x = center.x + point.x
|
||||||
|
center.y = center.y + point.y
|
||||||
|
center.z = center.z + point.z
|
||||||
|
end
|
||||||
|
|
||||||
|
center.x = center.x / 8
|
||||||
|
center.y = center.y / 8
|
||||||
|
center.z = center.z / 8
|
||||||
|
return center
|
||||||
|
end
|
||||||
|
|
||||||
|
function CUBE:ContainsPoint(point, cube_points)
|
||||||
|
cube_points = cube_points or self.Points
|
||||||
|
local min_x, min_y, min_z = math.huge, math.huge, math.huge
|
||||||
|
local max_x, max_y, max_z = -math.huge, -math.huge, -math.huge
|
||||||
|
|
||||||
|
-- Find the minimum and maximum x, y, and z values of the cube points
|
||||||
|
for _, p in ipairs(cube_points) do
|
||||||
|
if p.x < min_x then min_x = p.x end
|
||||||
|
if p.y < min_y then min_y = p.y end
|
||||||
|
if p.z < min_z then min_z = p.z end
|
||||||
|
if p.x > max_x then max_x = p.x end
|
||||||
|
if p.y > max_y then max_y = p.y end
|
||||||
|
if p.z > max_z then max_z = p.z end
|
||||||
|
end
|
||||||
|
|
||||||
|
return point.x >= min_x and point.x <= max_x and point.y >= min_y and point.y <= max_y and point.z >= min_z and point.z <= max_z
|
||||||
|
end
|
||||||
333
Moose Development/Moose/Shapes/Line.lua
Normal file
333
Moose Development/Moose/Shapes/Line.lua
Normal file
@@ -0,0 +1,333 @@
|
|||||||
|
---
|
||||||
|
--
|
||||||
|
-- ### Author: **nielsvaes/coconutcockpit**
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Shapes.LINE
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- LINE class.
|
||||||
|
-- @type LINE
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #number Points points of the line
|
||||||
|
-- @field #number Coords coordinates of the line
|
||||||
|
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @field #LINE
|
||||||
|
LINE = {
|
||||||
|
ClassName = "LINE",
|
||||||
|
Points = {},
|
||||||
|
Coords = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Finds a line on the map by its name. The line must be drawn in the Mission Editor
|
||||||
|
-- @param #string line_name Name of the line to find
|
||||||
|
-- @return #LINE The found line, or nil if not found
|
||||||
|
function LINE:FindOnMap(line_name)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:FindOnMap(line_name))
|
||||||
|
|
||||||
|
for _, layer in pairs(env.mission.drawings.layers) do
|
||||||
|
for _, object in pairs(layer["objects"]) do
|
||||||
|
if object["name"] == line_name then
|
||||||
|
if object["primitiveType"] == "Line" then
|
||||||
|
for _, point in UTILS.spairs(object["points"]) do
|
||||||
|
local p = {x = object["mapX"] + point["x"],
|
||||||
|
y = object["mapY"] + point["y"] }
|
||||||
|
local coord = COORDINATE:NewFromVec2(p)
|
||||||
|
table.insert(self.Points, p)
|
||||||
|
table.insert(self.Coords, coord)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:I(#self.Points)
|
||||||
|
if #self.Points == 0 then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
self.MarkIDs = {}
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Finds a line by its name in the database.
|
||||||
|
-- @param #string shape_name Name of the line to find
|
||||||
|
-- @return #LINE The found line, or nil if not found
|
||||||
|
function LINE:Find(shape_name)
|
||||||
|
return _DATABASE:FindShape(shape_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Creates a new line from two points.
|
||||||
|
-- @param #table vec2 The first point of the line
|
||||||
|
-- @param #number radius The second point of the line
|
||||||
|
-- @return #LINE The new line
|
||||||
|
function LINE:New(...)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:New())
|
||||||
|
self.Points = {...}
|
||||||
|
self:I(self.Points)
|
||||||
|
for _, point in UTILS.spairs(self.Points) do
|
||||||
|
table.insert(self.Coords, COORDINATE:NewFromVec2(point))
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Creates a new line from a circle.
|
||||||
|
-- @param #table center_point center point of the circle
|
||||||
|
-- @param #number radius radius of the circle, half length of the line
|
||||||
|
-- @param #number angle_degrees degrees the line will form from center point
|
||||||
|
-- @return #LINE The new line
|
||||||
|
function LINE:NewFromCircle(center_point, radius, angle_degrees)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:New())
|
||||||
|
self.CenterVec2 = center_point
|
||||||
|
local angleRadians = math.rad(angle_degrees)
|
||||||
|
|
||||||
|
local point1 = {
|
||||||
|
x = center_point.x + radius * math.cos(angleRadians),
|
||||||
|
y = center_point.y + radius * math.sin(angleRadians)
|
||||||
|
}
|
||||||
|
|
||||||
|
local point2 = {
|
||||||
|
x = center_point.x + radius * math.cos(angleRadians + math.pi),
|
||||||
|
y = center_point.y + radius * math.sin(angleRadians + math.pi)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, point in pairs{point1, point2} do
|
||||||
|
table.insert(self.Points, point)
|
||||||
|
table.insert(self.Coords, COORDINATE:NewFromVec2(point))
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the coordinates of the line.
|
||||||
|
-- @return #table The coordinates of the line
|
||||||
|
function LINE:Coordinates()
|
||||||
|
return self.Coords
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the start coordinate of the line. The start coordinate is the first point of the line.
|
||||||
|
-- @return #COORDINATE The start coordinate of the line
|
||||||
|
function LINE:GetStartCoordinate()
|
||||||
|
return self.Coords[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the end coordinate of the line. The end coordinate is the last point of the line.
|
||||||
|
-- @return #COORDINATE The end coordinate of the line
|
||||||
|
function LINE:GetEndCoordinate()
|
||||||
|
return self.Coords[#self.Coords]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the start point of the line. The start point is the first point of the line.
|
||||||
|
-- @return #table The start point of the line
|
||||||
|
function LINE:GetStartPoint()
|
||||||
|
return self.Points[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the end point of the line. The end point is the last point of the line.
|
||||||
|
-- @return #table The end point of the line
|
||||||
|
function LINE:GetEndPoint()
|
||||||
|
return self.Points[#self.Points]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the length of the line.
|
||||||
|
-- @return #number The length of the line
|
||||||
|
function LINE:GetLength()
|
||||||
|
local total_length = 0
|
||||||
|
for i=1, #self.Points - 1 do
|
||||||
|
local x1, y1 = self.Points[i]["x"], self.Points[i]["y"]
|
||||||
|
local x2, y2 = self.Points[i+1]["x"], self.Points[i+1]["y"]
|
||||||
|
local segment_length = math.sqrt((x2 - x1)^2 + (y2 - y1)^2)
|
||||||
|
total_length = total_length + segment_length
|
||||||
|
end
|
||||||
|
return total_length
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns a random point on the line.
|
||||||
|
-- @param #table points (optional) The points of the line or 2 other points if you're just using the LINE class without an object of it
|
||||||
|
-- @return #table The random point
|
||||||
|
function LINE:GetRandomPoint(points)
|
||||||
|
points = points or self.Points
|
||||||
|
local rand = math.random() -- 0->1
|
||||||
|
|
||||||
|
local random_x = points[1].x + rand * (points[2].x - points[1].x)
|
||||||
|
local random_y = points[1].y + rand * (points[2].y - points[1].y)
|
||||||
|
|
||||||
|
return { x= random_x, y= random_y }
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the heading of the line.
|
||||||
|
-- @param #table points (optional) The points of the line or 2 other points if you're just using the LINE class without an object of it
|
||||||
|
-- @return #number The heading of the line
|
||||||
|
function LINE:GetHeading(points)
|
||||||
|
points = points or self.Points
|
||||||
|
|
||||||
|
local angle = math.atan2(points[2].y - points[1].y, points[2].x - points[1].x)
|
||||||
|
|
||||||
|
angle = math.deg(angle)
|
||||||
|
if angle < 0 then
|
||||||
|
angle = angle + 360
|
||||||
|
end
|
||||||
|
|
||||||
|
return angle
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return each part of the line as a new line
|
||||||
|
-- @return #table The points
|
||||||
|
function LINE:GetIndividualParts()
|
||||||
|
local parts = {}
|
||||||
|
if #self.Points == 2 then
|
||||||
|
parts = {self}
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1, #self.Points -1 do
|
||||||
|
local p1 = self.Points[i]
|
||||||
|
local p2 = self.Points[i % #self.Points + 1]
|
||||||
|
table.add(parts, LINE:New(p1, p2))
|
||||||
|
end
|
||||||
|
|
||||||
|
return parts
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets a number of points in between the start and end points of the line.
|
||||||
|
-- @param #number amount The number of points to get
|
||||||
|
-- @param #table start_point (Optional) The start point of the line, defaults to the object's start point
|
||||||
|
-- @param #table end_point (Optional) The end point of the line, defaults to the object's end point
|
||||||
|
-- @return #table The points
|
||||||
|
function LINE:GetPointsInbetween(amount, start_point, end_point)
|
||||||
|
start_point = start_point or self:GetStartPoint()
|
||||||
|
end_point = end_point or self:GetEndPoint()
|
||||||
|
if amount == 0 then return {start_point, end_point} end
|
||||||
|
|
||||||
|
amount = amount + 1
|
||||||
|
local points = {}
|
||||||
|
|
||||||
|
local difference = { x = end_point.x - start_point.x, y = end_point.y - start_point.y }
|
||||||
|
local divided = { x = difference.x / amount, y = difference.y / amount }
|
||||||
|
|
||||||
|
for j=0, amount do
|
||||||
|
local part_pos = {x = divided.x * j, y = divided.y * j}
|
||||||
|
-- add part_pos vector to the start point so the new point is placed along in the line
|
||||||
|
local point = {x = start_point.x + part_pos.x, y = start_point.y + part_pos.y}
|
||||||
|
table.insert(points, point)
|
||||||
|
end
|
||||||
|
return points
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets a number of points in between the start and end points of the line.
|
||||||
|
-- @param #number amount The number of points to get
|
||||||
|
-- @param #table start_point (Optional) The start point of the line, defaults to the object's start point
|
||||||
|
-- @param #table end_point (Optional) The end point of the line, defaults to the object's end point
|
||||||
|
-- @return #table The points
|
||||||
|
function LINE:GetCoordinatesInBetween(amount, start_point, end_point)
|
||||||
|
local coords = {}
|
||||||
|
for _, pt in pairs(self:GetPointsInbetween(amount, start_point, end_point)) do
|
||||||
|
table.add(coords, COORDINATE:NewFromVec2(pt))
|
||||||
|
end
|
||||||
|
return coords
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function LINE:GetRandomPoint(start_point, end_point)
|
||||||
|
start_point = start_point or self:GetStartPoint()
|
||||||
|
end_point = end_point or self:GetEndPoint()
|
||||||
|
|
||||||
|
local fraction = math.random()
|
||||||
|
|
||||||
|
local difference = { x = end_point.x - start_point.x, y = end_point.y - start_point.y }
|
||||||
|
local part_pos = {x = difference.x * fraction, y = difference.y * fraction}
|
||||||
|
local random_point = { x = start_point.x + part_pos.x, y = start_point.y + part_pos.y}
|
||||||
|
|
||||||
|
return random_point
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function LINE:GetRandomCoordinate(start_point, end_point)
|
||||||
|
start_point = start_point or self:GetStartPoint()
|
||||||
|
end_point = end_point or self:GetEndPoint()
|
||||||
|
|
||||||
|
return COORDINATE:NewFromVec2(self:GetRandomPoint(start_point, end_point))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Gets a number of points on a sine wave between the start and end points of the line.
|
||||||
|
-- @param #number amount The number of points to get
|
||||||
|
-- @param #table start_point (Optional) The start point of the line, defaults to the object's start point
|
||||||
|
-- @param #table end_point (Optional) The end point of the line, defaults to the object's end point
|
||||||
|
-- @param #number frequency (Optional) The frequency of the sine wave, default 1
|
||||||
|
-- @param #number phase (Optional) The phase of the sine wave, default 0
|
||||||
|
-- @param #number amplitude (Optional) The amplitude of the sine wave, default 100
|
||||||
|
-- @return #table The points
|
||||||
|
function LINE:GetPointsBetweenAsSineWave(amount, start_point, end_point, frequency, phase, amplitude)
|
||||||
|
amount = amount or 20
|
||||||
|
start_point = start_point or self:GetStartPoint()
|
||||||
|
end_point = end_point or self:GetEndPoint()
|
||||||
|
frequency = frequency or 1 -- number of cycles per unit of x
|
||||||
|
phase = phase or 0 -- offset in radians
|
||||||
|
amplitude = amplitude or 100 -- maximum height of the wave
|
||||||
|
|
||||||
|
local points = {}
|
||||||
|
|
||||||
|
-- Returns the y-coordinate of the sine wave at x
|
||||||
|
local function sine_wave(x)
|
||||||
|
return amplitude * math.sin(2 * math.pi * frequency * (x - start_point.x) + phase)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Plot x-amount of points on the sine wave between point_01 and point_02
|
||||||
|
local x = start_point.x
|
||||||
|
local step = (end_point.x - start_point.x) / 20
|
||||||
|
for _=1, amount do
|
||||||
|
local y = sine_wave(x)
|
||||||
|
x = x + step
|
||||||
|
table.add(points, {x=x, y=y})
|
||||||
|
end
|
||||||
|
return points
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculates the bounding box of the line. The bounding box is the smallest rectangle that contains the line.
|
||||||
|
-- @return #table The bounding box of the line
|
||||||
|
function LINE:GetBoundingBox()
|
||||||
|
local min_x, min_y, max_x, max_y = self.Points[1].x, self.Points[1].y, self.Points[2].x, self.Points[2].y
|
||||||
|
|
||||||
|
for i = 2, #self.Points do
|
||||||
|
local x, y = self.Points[i].x, self.Points[i].y
|
||||||
|
|
||||||
|
if x < min_x then
|
||||||
|
min_x = x
|
||||||
|
end
|
||||||
|
if y < min_y then
|
||||||
|
min_y = y
|
||||||
|
end
|
||||||
|
if x > max_x then
|
||||||
|
max_x = x
|
||||||
|
end
|
||||||
|
if y > max_y then
|
||||||
|
max_y = y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return {
|
||||||
|
{x=min_x, y=min_x}, {x=max_x, y=min_y}, {x=max_x, y=max_y}, {x=min_x, y=max_y}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Draws the line on the map.
|
||||||
|
-- @param #table points The points of the line
|
||||||
|
function LINE:Draw()
|
||||||
|
for i=1, #self.Coords -1 do
|
||||||
|
local c1 = self.Coords[i]
|
||||||
|
local c2 = self.Coords[i % #self.Coords + 1]
|
||||||
|
table.add(self.MarkIDs, c1:LineToAll(c2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Removes the drawing of the line from the map.
|
||||||
|
function LINE:RemoveDraw()
|
||||||
|
for _, mark_id in pairs(self.MarkIDs) do
|
||||||
|
UTILS.RemoveMark(mark_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
213
Moose Development/Moose/Shapes/Oval.lua
Normal file
213
Moose Development/Moose/Shapes/Oval.lua
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
---
|
||||||
|
--
|
||||||
|
-- ### Author: **nielsvaes/coconutcockpit**
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Shapes.OVAL
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- OVAL class.
|
||||||
|
-- @type OVAL
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #number MajorAxis The major axis (radius) of the oval
|
||||||
|
-- @field #number MinorAxis The minor axis (radius) of the oval
|
||||||
|
-- @field #number Angle The angle the oval is rotated on
|
||||||
|
|
||||||
|
--- *The little man removed his hat, what an egg shaped head he had* -- Agatha Christie
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # OVAL
|
||||||
|
-- OVALs can be fetched from the drawings in the Mission Editor
|
||||||
|
--
|
||||||
|
-- The major and minor axes define how elongated the shape of an oval is. This class has some basic functions that the other SHAPE classes have as well.
|
||||||
|
-- Since it's not possible to draw the shape of an oval while the mission is running, right now the draw function draws 2 cicles. One with the major axis and one with
|
||||||
|
-- the minor axis. It then draws a diamond shape on an angle where the corners touch the major and minor axes to give an indication of what the oval actually
|
||||||
|
-- looks like.
|
||||||
|
--
|
||||||
|
-- Using ovals can be handy to find an area on the ground that is actually an intersection of a cone and a plane. So imagine you're faking the view cone of
|
||||||
|
-- a targeting pod and
|
||||||
|
|
||||||
|
--- OVAL class with properties and methods for handling ovals.
|
||||||
|
-- @field #OVAL
|
||||||
|
OVAL = {
|
||||||
|
ClassName = "OVAL",
|
||||||
|
MajorAxis = nil,
|
||||||
|
MinorAxis = nil,
|
||||||
|
Angle = 0,
|
||||||
|
DrawPoly=nil
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Finds an oval on the map by its name. The oval must be drawn on the map.
|
||||||
|
-- @param #string shape_name Name of the oval to find
|
||||||
|
-- @return #OVAL The found oval, or nil if not found
|
||||||
|
function OVAL:FindOnMap(shape_name)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:FindOnMap(shape_name))
|
||||||
|
for _, layer in pairs(env.mission.drawings.layers) do
|
||||||
|
for _, object in pairs(layer["objects"]) do
|
||||||
|
if string.find(object["name"], shape_name, 1, true) then
|
||||||
|
if object["polygonMode"] == "oval" then
|
||||||
|
self.CenterVec2 = { x = object["mapX"], y = object["mapY"] }
|
||||||
|
self.MajorAxis = object["r1"]
|
||||||
|
self.MinorAxis = object["r2"]
|
||||||
|
self.Angle = object["angle"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Finds an oval by its name in the database.
|
||||||
|
-- @param #string shape_name Name of the oval to find
|
||||||
|
-- @return #OVAL The found oval, or nil if not found
|
||||||
|
function OVAL:Find(shape_name)
|
||||||
|
return _DATABASE:FindShape(shape_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Creates a new oval from a center point, major axis, minor axis, and angle.
|
||||||
|
-- @param #table vec2 The center point of the oval
|
||||||
|
-- @param #number major_axis The major axis of the oval
|
||||||
|
-- @param #number minor_axis The minor axis of the oval
|
||||||
|
-- @param #number angle The angle of the oval
|
||||||
|
-- @return #OVAL The new oval
|
||||||
|
function OVAL:New(vec2, major_axis, minor_axis, angle)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:New())
|
||||||
|
self.CenterVec2 = vec2
|
||||||
|
self.MajorAxis = major_axis
|
||||||
|
self.MinorAxis = minor_axis
|
||||||
|
self.Angle = angle or 0
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the major axis of the oval.
|
||||||
|
-- @return #number The major axis of the oval
|
||||||
|
function OVAL:GetMajorAxis()
|
||||||
|
return self.MajorAxis
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the minor axis of the oval.
|
||||||
|
-- @return #number The minor axis of the oval
|
||||||
|
function OVAL:GetMinorAxis()
|
||||||
|
return self.MinorAxis
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the angle of the oval.
|
||||||
|
-- @return #number The angle of the oval
|
||||||
|
function OVAL:GetAngle()
|
||||||
|
return self.Angle
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Sets the major axis of the oval.
|
||||||
|
-- @param #number value The new major axis
|
||||||
|
function OVAL:SetMajorAxis(value)
|
||||||
|
self.MajorAxis = value
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Sets the minor axis of the oval.
|
||||||
|
-- @param #number value The new minor axis
|
||||||
|
function OVAL:SetMinorAxis(value)
|
||||||
|
self.MinorAxis = value
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Sets the angle of the oval.
|
||||||
|
-- @param #number value The new angle
|
||||||
|
function OVAL:SetAngle(value)
|
||||||
|
self.Angle = value
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a point is contained within the oval.
|
||||||
|
-- @param #table point The point to check
|
||||||
|
-- @return #bool True if the point is contained, false otherwise
|
||||||
|
function OVAL:ContainsPoint(point)
|
||||||
|
local cos, sin = math.cos, math.sin
|
||||||
|
local dx = point.x - self.CenterVec2.x
|
||||||
|
local dy = point.y - self.CenterVec2.y
|
||||||
|
local rx = dx * cos(self.Angle) + dy * sin(self.Angle)
|
||||||
|
local ry = -dx * sin(self.Angle) + dy * cos(self.Angle)
|
||||||
|
return rx * rx / (self.MajorAxis * self.MajorAxis) + ry * ry / (self.MinorAxis * self.MinorAxis) <= 1
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns a random Vec2 within the oval.
|
||||||
|
-- @return #table The random Vec2
|
||||||
|
function OVAL:GetRandomVec2()
|
||||||
|
local theta = math.rad(self.Angle)
|
||||||
|
|
||||||
|
local random_point = math.sqrt(math.random()) --> uniformly
|
||||||
|
--local random_point = math.random() --> more clumped around center
|
||||||
|
local phi = math.random() * 2 * math.pi
|
||||||
|
local x_c = random_point * math.cos(phi)
|
||||||
|
local y_c = random_point * math.sin(phi)
|
||||||
|
local x_e = x_c * self.MajorAxis
|
||||||
|
local y_e = y_c * self.MinorAxis
|
||||||
|
local rx = (x_e * math.cos(theta) - y_e * math.sin(theta)) + self.CenterVec2.x
|
||||||
|
local ry = (x_e * math.sin(theta) + y_e * math.cos(theta)) + self.CenterVec2.y
|
||||||
|
|
||||||
|
return {x=rx, y=ry}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculates the bounding box of the oval. The bounding box is the smallest rectangle that contains the oval.
|
||||||
|
-- @return #table The bounding box of the oval
|
||||||
|
function OVAL:GetBoundingBox()
|
||||||
|
local min_x = self.CenterVec2.x - self.MajorAxis
|
||||||
|
local min_y = self.CenterVec2.y - self.MinorAxis
|
||||||
|
local max_x = self.CenterVec2.x + self.MajorAxis
|
||||||
|
local max_y = self.CenterVec2.y + self.MinorAxis
|
||||||
|
|
||||||
|
return {
|
||||||
|
{x=min_x, y=min_x}, {x=max_x, y=min_y}, {x=max_x, y=max_y}, {x=min_x, y=max_y}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Draws the oval on the map, for debugging
|
||||||
|
-- @param #number angle (Optional) The angle of the oval. If nil will use self.Angle
|
||||||
|
function OVAL:Draw()
|
||||||
|
--for pt in pairs(self:PointsOnEdge(20)) do
|
||||||
|
-- COORDINATE:NewFromVec2(pt)
|
||||||
|
--end
|
||||||
|
|
||||||
|
self.DrawPoly = POLYGON:NewFromPoints(self:PointsOnEdge(20))
|
||||||
|
self.DrawPoly:Draw(true)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---- TODO: draw a better shape using line segments
|
||||||
|
--angle = angle or self.Angle
|
||||||
|
--local coor = self:GetCenterCoordinate()
|
||||||
|
--
|
||||||
|
--table.add(self.MarkIDs, coor:CircleToAll(self.MajorAxis))
|
||||||
|
--table.add(self.MarkIDs, coor:CircleToAll(self.MinorAxis))
|
||||||
|
--table.add(self.MarkIDs, coor:LineToAll(coor:Translate(self.MajorAxis, self.Angle)))
|
||||||
|
--
|
||||||
|
--local pt_1 = coor:Translate(self.MajorAxis, self.Angle)
|
||||||
|
--local pt_2 = coor:Translate(self.MinorAxis, self.Angle - 90)
|
||||||
|
--local pt_3 = coor:Translate(self.MajorAxis, self.Angle - 180)
|
||||||
|
--local pt_4 = coor:Translate(self.MinorAxis, self.Angle - 270)
|
||||||
|
--table.add(self.MarkIDs, pt_1:QuadToAll(pt_2, pt_3, pt_4), -1, {0, 1, 0}, 1, {0, 1, 0})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Removes the drawing of the oval from the map
|
||||||
|
function OVAL:RemoveDraw()
|
||||||
|
self.DrawPoly:RemoveDraw()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function OVAL:PointsOnEdge(num_points)
|
||||||
|
num_points = num_points or 20
|
||||||
|
local points = {}
|
||||||
|
local dtheta = 2 * math.pi / num_points
|
||||||
|
|
||||||
|
for i = 0, num_points - 1 do
|
||||||
|
local theta = i * dtheta
|
||||||
|
local x = self.CenterVec2.x + self.MajorAxis * math.cos(theta) * math.cos(self.Angle) - self.MinorAxis * math.sin(theta) * math.sin(self.Angle)
|
||||||
|
local y = self.CenterVec2.y + self.MajorAxis * math.cos(theta) * math.sin(self.Angle) + self.MinorAxis * math.sin(theta) * math.cos(self.Angle)
|
||||||
|
table.insert(points, {x = x, y = y})
|
||||||
|
end
|
||||||
|
|
||||||
|
return points
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
458
Moose Development/Moose/Shapes/Polygon.lua
Normal file
458
Moose Development/Moose/Shapes/Polygon.lua
Normal file
@@ -0,0 +1,458 @@
|
|||||||
|
---
|
||||||
|
--
|
||||||
|
-- ### Author: **nielsvaes/coconutcockpit**
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Shapes.POLYGON
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- POLYGON class.
|
||||||
|
-- @type POLYGON
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #table Points List of 3D points defining the shape, this will be assigned automatically if you're passing in a drawing from the Mission Editor
|
||||||
|
-- @field #table Coords List of COORDINATE defining the path, this will be assigned automatically if you're passing in a drawing from the Mission Editor
|
||||||
|
-- @field #table MarkIDs List any MARKIDs this class use, this will be assigned automatically if you're passing in a drawing from the Mission Editor
|
||||||
|
-- @field #table Triangles List of TRIANGLEs that make up the shape of the POLYGON after being triangulated
|
||||||
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
--- *Polygons are fashionable at the moment* -- Trip Hawkins
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # POLYGON
|
||||||
|
-- POLYGONs can be fetched from the drawings in the Mission Editor if the drawing is:
|
||||||
|
-- * A closed shape made with line segments
|
||||||
|
-- * A closed shape made with a freehand line
|
||||||
|
-- * A freehand drawn polygon
|
||||||
|
-- * A rect
|
||||||
|
-- Use the POLYGON:FindOnMap() of POLYGON:Find() functions for this. You can also create a non existing polygon in memory using the POLYGON:New() function. Pass in a
|
||||||
|
-- any number of Vec2s into this function to define the shape of the polygon you want.
|
||||||
|
--
|
||||||
|
-- You can draw very intricate and complex polygons in the Mission Editor to avoid (or include) map objects. You can then generate random points within this complex
|
||||||
|
-- shape for spawning groups or checking positions.
|
||||||
|
--
|
||||||
|
-- When a POLYGON is made, it's automatically triangulated. The resulting triangles are stored in POLYGON.Triangles. This also immeadiately saves the surface area
|
||||||
|
-- of the POLYGON. Because the POLYGON is triangulated, it's possible to generate random points within this POLYGON without having to use a trial and error method to see if
|
||||||
|
-- the point is contained within the shape.
|
||||||
|
-- Using POLYGON:GetRandomVec2() will result in a truly, non-biased, random Vec2 within the shape. You'll want to use this function most. There's also POLYGON:GetRandomNonWeightedVec2
|
||||||
|
-- which ignores the size of the triangles in the polygon to pick a random points. This will result in more points clumping together in parts of the polygon where the triangles are
|
||||||
|
-- the smallest.
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @field #POLYGON
|
||||||
|
POLYGON = {
|
||||||
|
ClassName = "POLYGON",
|
||||||
|
Points = {},
|
||||||
|
Coords = {},
|
||||||
|
Triangles = {},
|
||||||
|
SurfaceArea = 0,
|
||||||
|
TriangleMarkIDs = {},
|
||||||
|
OutlineMarkIDs = {},
|
||||||
|
Angle = nil, -- for arrows
|
||||||
|
Heading = nil -- for arrows
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Finds a polygon on the map by its name. The polygon must be added in the mission editor.
|
||||||
|
-- @param #string shape_name Name of the polygon to find
|
||||||
|
-- @return #POLYGON The found polygon, or nil if not found
|
||||||
|
function POLYGON:FindOnMap(shape_name)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:FindOnMap(shape_name))
|
||||||
|
|
||||||
|
for _, layer in pairs(env.mission.drawings.layers) do
|
||||||
|
for _, object in pairs(layer["objects"]) do
|
||||||
|
if object["name"] == shape_name then
|
||||||
|
if (object["primitiveType"] == "Line" and object["closed"] == true) or (object["polygonMode"] == "free") then
|
||||||
|
for _, point in UTILS.spairs(object["points"]) do
|
||||||
|
local p = {x = object["mapX"] + point["x"],
|
||||||
|
y = object["mapY"] + point["y"] }
|
||||||
|
local coord = COORDINATE:NewFromVec2(p)
|
||||||
|
self.Points[#self.Points + 1] = p
|
||||||
|
self.Coords[#self.Coords + 1] = coord
|
||||||
|
end
|
||||||
|
elseif object["polygonMode"] == "rect" then
|
||||||
|
local angle = object["angle"]
|
||||||
|
local half_width = object["width"] / 2
|
||||||
|
local half_height = object["height"] / 2
|
||||||
|
|
||||||
|
local p1 = UTILS.RotatePointAroundPivot({ x = self.CenterVec2.x - half_height, y = self.CenterVec2.y + half_width }, self.CenterVec2, angle)
|
||||||
|
local p2 = UTILS.RotatePointAroundPivot({ x = self.CenterVec2.x + half_height, y = self.CenterVec2.y + half_width }, self.CenterVec2, angle)
|
||||||
|
local p3 = UTILS.RotatePointAroundPivot({ x = self.CenterVec2.x + half_height, y = self.CenterVec2.y - half_width }, self.CenterVec2, angle)
|
||||||
|
local p4 = UTILS.RotatePointAroundPivot({ x = self.CenterVec2.x - half_height, y = self.CenterVec2.y - half_width }, self.CenterVec2, angle)
|
||||||
|
|
||||||
|
self.Points = {p1, p2, p3, p4}
|
||||||
|
for _, point in pairs(self.Points) do
|
||||||
|
self.Coords[#self.Coords + 1] = COORDINATE:NewFromVec2(point)
|
||||||
|
end
|
||||||
|
elseif object["polygonMode"] == "arrow" then
|
||||||
|
for _, point in UTILS.spairs(object["points"]) do
|
||||||
|
local p = {x = object["mapX"] + point["x"],
|
||||||
|
y = object["mapY"] + point["y"] }
|
||||||
|
local coord = COORDINATE:NewFromVec2(p)
|
||||||
|
self.Points[#self.Points + 1] = p
|
||||||
|
self.Coords[#self.Coords + 1] = coord
|
||||||
|
end
|
||||||
|
self.Angle = object["angle"]
|
||||||
|
self.Heading = UTILS.ClampAngle(self.Angle + 90)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #self.Points == 0 then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
self.CenterVec2 = self:GetCentroid()
|
||||||
|
self.Triangles = self:Triangulate()
|
||||||
|
self.SurfaceArea = self:__CalculateSurfaceArea()
|
||||||
|
|
||||||
|
self.TriangleMarkIDs = {}
|
||||||
|
self.OutlineMarkIDs = {}
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Creates a polygon from a zone. The zone must be defined in the mission.
|
||||||
|
-- @param #string zone_name Name of the zone
|
||||||
|
-- @return #POLYGON The polygon created from the zone, or nil if the zone is not found
|
||||||
|
function POLYGON:FromZone(zone_name)
|
||||||
|
for _, zone in pairs(env.mission.triggers.zones) do
|
||||||
|
if zone["name"] == zone_name then
|
||||||
|
return POLYGON:New(unpack(zone["verticies"] or {}))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Finds a polygon by its name in the database.
|
||||||
|
-- @param #string shape_name Name of the polygon to find
|
||||||
|
-- @return #POLYGON The found polygon, or nil if not found
|
||||||
|
function POLYGON:Find(shape_name)
|
||||||
|
return _DATABASE:FindShape(shape_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Creates a new polygon from a list of points. Each point is a table with 'x' and 'y' fields.
|
||||||
|
-- @param #table ... Points of the polygon
|
||||||
|
-- @return #POLYGON The new polygon
|
||||||
|
function POLYGON:New(...)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:New())
|
||||||
|
|
||||||
|
self.Points = {...}
|
||||||
|
self.Coords = {}
|
||||||
|
for _, point in UTILS.spairs(self.Points) do
|
||||||
|
table.insert(self.Coords, COORDINATE:NewFromVec2(point))
|
||||||
|
end
|
||||||
|
self.Triangles = self:Triangulate()
|
||||||
|
self.SurfaceArea = self:__CalculateSurfaceArea()
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculates the centroid of the polygon. The centroid is the average of the 'x' and 'y' coordinates of the points.
|
||||||
|
-- @return #table The centroid of the polygon
|
||||||
|
function POLYGON:GetCentroid()
|
||||||
|
local function sum(t)
|
||||||
|
local total = 0
|
||||||
|
for _, value in pairs(t) do
|
||||||
|
total = total + value
|
||||||
|
end
|
||||||
|
return total
|
||||||
|
end
|
||||||
|
|
||||||
|
local x_values = {}
|
||||||
|
local y_values = {}
|
||||||
|
local length = table.length(self.Points)
|
||||||
|
|
||||||
|
for _, point in pairs(self.Points) do
|
||||||
|
table.insert(x_values, point.x)
|
||||||
|
table.insert(y_values, point.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
local x = sum(x_values) / length
|
||||||
|
local y = sum(y_values) / length
|
||||||
|
|
||||||
|
return {
|
||||||
|
["x"] = x,
|
||||||
|
["y"] = y
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the coordinates of the polygon. Each coordinate is a COORDINATE object.
|
||||||
|
-- @return #table The coordinates of the polygon
|
||||||
|
function POLYGON:GetCoordinates()
|
||||||
|
return self.Coords
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the start coordinate of the polygon. The start coordinate is the first point of the polygon.
|
||||||
|
-- @return #COORDINATE The start coordinate of the polygon
|
||||||
|
function POLYGON:GetStartCoordinate()
|
||||||
|
return self.Coords[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the end coordinate of the polygon. The end coordinate is the last point of the polygon.
|
||||||
|
-- @return #COORDINATE The end coordinate of the polygon
|
||||||
|
function POLYGON:GetEndCoordinate()
|
||||||
|
return self.Coords[#self.Coords]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the start point of the polygon. The start point is the first point of the polygon.
|
||||||
|
-- @return #table The start point of the polygon
|
||||||
|
function POLYGON:GetStartPoint()
|
||||||
|
return self.Points[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the end point of the polygon. The end point is the last point of the polygon.
|
||||||
|
-- @return #table The end point of the polygon
|
||||||
|
function POLYGON:GetEndPoint()
|
||||||
|
return self.Points[#self.Points]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the points of the polygon. Each point is a table with 'x' and 'y' fields.
|
||||||
|
-- @return #table The points of the polygon
|
||||||
|
function POLYGON:GetPoints()
|
||||||
|
return self.Points
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculates the surface area of the polygon. The surface area is the sum of the areas of the triangles that make up the polygon.
|
||||||
|
-- @return #number The surface area of the polygon
|
||||||
|
function POLYGON:GetSurfaceArea()
|
||||||
|
return self.SurfaceArea
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculates the bounding box of the polygon. The bounding box is the smallest rectangle that contains the polygon.
|
||||||
|
-- @return #table The bounding box of the polygon
|
||||||
|
function POLYGON:GetBoundingBox()
|
||||||
|
local min_x, min_y, max_x, max_y = self.Points[1].x, self.Points[1].y, self.Points[1].x, self.Points[1].y
|
||||||
|
|
||||||
|
for i = 2, #self.Points do
|
||||||
|
local x, y = self.Points[i].x, self.Points[i].y
|
||||||
|
|
||||||
|
if x < min_x then
|
||||||
|
min_x = x
|
||||||
|
end
|
||||||
|
if y < min_y then
|
||||||
|
min_y = y
|
||||||
|
end
|
||||||
|
if x > max_x then
|
||||||
|
max_x = x
|
||||||
|
end
|
||||||
|
if y > max_y then
|
||||||
|
max_y = y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return {
|
||||||
|
{x=min_x, y=min_x}, {x=max_x, y=min_y}, {x=max_x, y=max_y}, {x=min_x, y=max_y}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Triangulates the polygon. The polygon is divided into triangles.
|
||||||
|
-- @param #table points (optional) Points of the polygon or other points if you're just using the POLYGON class without an object of it
|
||||||
|
-- @return #table The triangles of the polygon
|
||||||
|
function POLYGON:Triangulate(points)
|
||||||
|
points = points or self.Points
|
||||||
|
local triangles = {}
|
||||||
|
|
||||||
|
local function get_orientation(shape_points)
|
||||||
|
local sum = 0
|
||||||
|
for i = 1, #shape_points do
|
||||||
|
local j = i % #shape_points + 1
|
||||||
|
sum = sum + (shape_points[j].x - shape_points[i].x) * (shape_points[j].y + shape_points[i].y)
|
||||||
|
end
|
||||||
|
return sum >= 0 and "clockwise" or "counter-clockwise" -- sum >= 0, return "clockwise", else return "counter-clockwise"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ensure_clockwise(shape_points)
|
||||||
|
local orientation = get_orientation(shape_points)
|
||||||
|
if orientation == "counter-clockwise" then
|
||||||
|
-- Reverse the order of shape_points so they're clockwise
|
||||||
|
local reversed = {}
|
||||||
|
for i = #shape_points, 1, -1 do
|
||||||
|
table.insert(reversed, shape_points[i])
|
||||||
|
end
|
||||||
|
return reversed
|
||||||
|
end
|
||||||
|
return shape_points
|
||||||
|
end
|
||||||
|
|
||||||
|
local function is_clockwise(p1, p2, p3)
|
||||||
|
local cross_product = (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x)
|
||||||
|
return cross_product < 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function divide_recursively(shape_points)
|
||||||
|
if #shape_points == 3 then
|
||||||
|
table.insert(triangles, TRIANGLE:New(shape_points[1], shape_points[2], shape_points[3]))
|
||||||
|
elseif #shape_points > 3 then -- find an ear -> a triangle with no other points inside it
|
||||||
|
for i, p1 in ipairs(shape_points) do
|
||||||
|
local p2 = shape_points[(i % #shape_points) + 1]
|
||||||
|
local p3 = shape_points[(i + 1) % #shape_points + 1]
|
||||||
|
local triangle = TRIANGLE:New(p1, p2, p3)
|
||||||
|
local is_ear = true
|
||||||
|
|
||||||
|
if not is_clockwise(p1, p2, p3) then
|
||||||
|
is_ear = false
|
||||||
|
else
|
||||||
|
for _, point in ipairs(shape_points) do
|
||||||
|
if point ~= p1 and point ~= p2 and point ~= p3 and triangle:ContainsPoint(point) then
|
||||||
|
is_ear = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if is_ear then
|
||||||
|
-- Check if any point in the original polygon is inside the ear triangle
|
||||||
|
local is_valid_triangle = true
|
||||||
|
for _, point in ipairs(points) do
|
||||||
|
if point ~= p1 and point ~= p2 and point ~= p3 and triangle:ContainsPoint(point) then
|
||||||
|
is_valid_triangle = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if is_valid_triangle then
|
||||||
|
table.insert(triangles, triangle)
|
||||||
|
local remaining_points = {}
|
||||||
|
for j, point in ipairs(shape_points) do
|
||||||
|
if point ~= p2 then
|
||||||
|
table.insert(remaining_points, point)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
divide_recursively(remaining_points)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
points = ensure_clockwise(points)
|
||||||
|
divide_recursively(points)
|
||||||
|
return triangles
|
||||||
|
end
|
||||||
|
|
||||||
|
function POLYGON:CovarianceMatrix()
|
||||||
|
local cx, cy = self:GetCentroid()
|
||||||
|
local covXX, covYY, covXY = 0, 0, 0
|
||||||
|
for _, p in ipairs(self.points) do
|
||||||
|
covXX = covXX + (p.x - cx)^2
|
||||||
|
covYY = covYY + (p.y - cy)^2
|
||||||
|
covXY = covXY + (p.x - cx) * (p.y - cy)
|
||||||
|
end
|
||||||
|
covXX = covXX / (#self.points - 1)
|
||||||
|
covYY = covYY / (#self.points - 1)
|
||||||
|
covXY = covXY / (#self.points - 1)
|
||||||
|
return covXX, covYY, covXY
|
||||||
|
end
|
||||||
|
|
||||||
|
function POLYGON:Direction()
|
||||||
|
local covXX, covYY, covXY = self:CovarianceMatrix()
|
||||||
|
-- Simplified calculation for the largest eigenvector's direction
|
||||||
|
local theta = 0.5 * math.atan2(2 * covXY, covXX - covYY)
|
||||||
|
return math.cos(theta), math.sin(theta)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns a random Vec2 within the polygon. The Vec2 is weighted by the areas of the triangles that make up the polygon.
|
||||||
|
-- @return #table The random Vec2
|
||||||
|
function POLYGON:GetRandomVec2()
|
||||||
|
local weights = {}
|
||||||
|
for _, triangle in pairs(self.Triangles) do
|
||||||
|
weights[triangle] = triangle.SurfaceArea / self.SurfaceArea
|
||||||
|
end
|
||||||
|
|
||||||
|
local random_weight = math.random()
|
||||||
|
local accumulated_weight = 0
|
||||||
|
for triangle, weight in pairs(weights) do
|
||||||
|
accumulated_weight = accumulated_weight + weight
|
||||||
|
if accumulated_weight >= random_weight then
|
||||||
|
return triangle:GetRandomVec2()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns a random non-weighted Vec2 within the polygon. The Vec2 is chosen from one of the triangles that make up the polygon.
|
||||||
|
-- @return #table The random non-weighted Vec2
|
||||||
|
function POLYGON:GetRandomNonWeightedVec2()
|
||||||
|
return self.Triangles[math.random(1, #self.Triangles)]:GetRandomVec2()
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a point is contained within the polygon. The point is a table with 'x' and 'y' fields.
|
||||||
|
-- @param #table point The point to check
|
||||||
|
-- @param #table points (optional) Points of the polygon or other points if you're just using the POLYGON class without an object of it
|
||||||
|
-- @return #bool True if the point is contained, false otherwise
|
||||||
|
function POLYGON:ContainsPoint(point, polygon_points)
|
||||||
|
local x = point.x
|
||||||
|
local y = point.y
|
||||||
|
|
||||||
|
polygon_points = polygon_points or self.Points
|
||||||
|
|
||||||
|
local counter = 0
|
||||||
|
local num_points = #polygon_points
|
||||||
|
for current_index = 1, num_points do
|
||||||
|
local next_index = (current_index % num_points) + 1
|
||||||
|
local current_x, current_y = polygon_points[current_index].x, polygon_points[current_index].y
|
||||||
|
local next_x, next_y = polygon_points[next_index].x, polygon_points[next_index].y
|
||||||
|
if ((current_y > y) ~= (next_y > y)) and (x < (next_x - current_x) * (y - current_y) / (next_y - current_y) + current_x) then
|
||||||
|
counter = counter + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return counter % 2 == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Draws the polygon on the map. The polygon can be drawn with or without inner triangles. This is just for debugging
|
||||||
|
-- @param #bool include_inner_triangles Whether to include inner triangles in the drawing
|
||||||
|
function POLYGON:Draw(include_inner_triangles)
|
||||||
|
include_inner_triangles = include_inner_triangles or false
|
||||||
|
for i=1, #self.Coords do
|
||||||
|
local c1 = self.Coords[i]
|
||||||
|
local c2 = self.Coords[i % #self.Coords + 1]
|
||||||
|
table.add(self.OutlineMarkIDs, c1:LineToAll(c2))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if include_inner_triangles then
|
||||||
|
for _, triangle in ipairs(self.Triangles) do
|
||||||
|
triangle:Draw()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Removes the drawing of the polygon from the map.
|
||||||
|
function POLYGON:RemoveDraw()
|
||||||
|
for _, triangle in pairs(self.Triangles) do
|
||||||
|
triangle:RemoveDraw()
|
||||||
|
end
|
||||||
|
for _, mark_id in pairs(self.OutlineMarkIDs) do
|
||||||
|
UTILS.RemoveMark(mark_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Calculates the surface area of the polygon. The surface area is the sum of the areas of the triangles that make up the polygon.
|
||||||
|
-- @return #number The surface area of the polygon
|
||||||
|
function POLYGON:__CalculateSurfaceArea()
|
||||||
|
local area = 0
|
||||||
|
for _, triangle in pairs(self.Triangles) do
|
||||||
|
area = area + triangle.SurfaceArea
|
||||||
|
end
|
||||||
|
return area
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
214
Moose Development/Moose/Shapes/ShapeBase.lua
Normal file
214
Moose Development/Moose/Shapes/ShapeBase.lua
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
--- **Shapes** - Class that serves as the base shapes drawn in the Mission Editor
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- ### Author: **nielsvaes/coconutcockpit**
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Shapes.SHAPE_BASE
|
||||||
|
-- @image CORE_Pathline.png
|
||||||
|
|
||||||
|
|
||||||
|
--- SHAPE_BASE class.
|
||||||
|
-- @type SHAPE_BASE
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #string Name Name of the shape
|
||||||
|
-- @field #table CenterVec2 Vec2 of the center of the shape, this will be assigned automatically
|
||||||
|
-- @field #table Points List of 3D points defining the shape, this will be assigned automatically
|
||||||
|
-- @field #table Coords List of COORDINATE defining the path, this will be assigned automatically
|
||||||
|
-- @field #table MarkIDs List any MARKIDs this class use, this will be assigned automatically
|
||||||
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
--- *I'm in love with the shape of you -- Ed Sheeran
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # SHAPE_BASE
|
||||||
|
-- The class serves as the base class to deal with these shapes using MOOSE. You should never use this class on its own,
|
||||||
|
-- rather use:
|
||||||
|
-- CIRCLE
|
||||||
|
-- LINE
|
||||||
|
-- OVAL
|
||||||
|
-- POLYGON
|
||||||
|
-- TRIANGLE (although this one's a bit special as well)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- The idea is that anything you draw on the map in the Mission Editor can be turned in a shape to work with in MOOSE.
|
||||||
|
-- This is the base class that all other shape classes are built on. There are some shared functions, most of which are overridden in the derived classes
|
||||||
|
--
|
||||||
|
-- @field #SHAPE_BASE
|
||||||
|
SHAPE_BASE = {
|
||||||
|
ClassName = "SHAPE_BASE",
|
||||||
|
Name = "",
|
||||||
|
CenterVec2 = nil,
|
||||||
|
Points = {},
|
||||||
|
Coords = {},
|
||||||
|
MarkIDs = {},
|
||||||
|
ColorString = "",
|
||||||
|
ColorRGBA = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Creates a new instance of SHAPE_BASE.
|
||||||
|
-- @return #SHAPE_BASE The new instance
|
||||||
|
function SHAPE_BASE:New()
|
||||||
|
local self = BASE:Inherit(self, BASE:New())
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Finds a shape on the map by its name.
|
||||||
|
-- @param #string shape_name Name of the shape to find
|
||||||
|
-- @return #SHAPE_BASE The found shape
|
||||||
|
function SHAPE_BASE:FindOnMap(shape_name)
|
||||||
|
local self = BASE:Inherit(self, BASE:New())
|
||||||
|
|
||||||
|
local found = false
|
||||||
|
|
||||||
|
for _, layer in pairs(env.mission.drawings.layers) do
|
||||||
|
for _, object in pairs(layer["objects"]) do
|
||||||
|
if object["name"] == shape_name then
|
||||||
|
self.Name = object["name"]
|
||||||
|
self.CenterVec2 = { x = object["mapX"], y = object["mapY"] }
|
||||||
|
self.ColorString = object["colorString"]
|
||||||
|
self.ColorRGBA = UTILS.HexToRGBA(self.ColorString)
|
||||||
|
found = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not found then
|
||||||
|
self:E("Can't find a shape with name " .. shape_name)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function SHAPE_BASE:GetAllShapes(filter)
|
||||||
|
filter = filter or ""
|
||||||
|
local return_shapes = {}
|
||||||
|
for _, layer in pairs(env.mission.drawings.layers) do
|
||||||
|
for _, object in pairs(layer["objects"]) do
|
||||||
|
if string.contains(object["name"], filter) then
|
||||||
|
table.add(return_shapes, object)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return return_shapes
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Offsets the shape to a new position.
|
||||||
|
-- @param #table new_vec2 The new position
|
||||||
|
function SHAPE_BASE:Offset(new_vec2)
|
||||||
|
local offset_vec2 = UTILS.Vec2Subtract(new_vec2, self.CenterVec2)
|
||||||
|
self.CenterVec2 = new_vec2
|
||||||
|
if self.ClassName == "POLYGON" then
|
||||||
|
for _, point in pairs(self.Points) do
|
||||||
|
point.x = point.x + offset_vec2.x
|
||||||
|
point.y = point.y + offset_vec2.y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the name of the shape.
|
||||||
|
-- @return #string The name of the shape
|
||||||
|
function SHAPE_BASE:GetName()
|
||||||
|
return self.Name
|
||||||
|
end
|
||||||
|
|
||||||
|
function SHAPE_BASE:GetColorString()
|
||||||
|
return self.ColorString
|
||||||
|
end
|
||||||
|
|
||||||
|
function SHAPE_BASE:GetColorRGBA()
|
||||||
|
return self.ColorRGBA
|
||||||
|
end
|
||||||
|
|
||||||
|
function SHAPE_BASE:GetColorRed()
|
||||||
|
return self.ColorRGBA.R
|
||||||
|
end
|
||||||
|
|
||||||
|
function SHAPE_BASE:GetColorGreen()
|
||||||
|
return self.ColorRGBA.G
|
||||||
|
end
|
||||||
|
|
||||||
|
function SHAPE_BASE:GetColorBlue()
|
||||||
|
return self.ColorRGBA.B
|
||||||
|
end
|
||||||
|
|
||||||
|
function SHAPE_BASE:GetColorAlpha()
|
||||||
|
return self.ColorRGBA.A
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the center position of the shape.
|
||||||
|
-- @return #table The center position
|
||||||
|
function SHAPE_BASE:GetCenterVec2()
|
||||||
|
return self.CenterVec2
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the center coordinate of the shape.
|
||||||
|
-- @return #COORDINATE The center coordinate
|
||||||
|
function SHAPE_BASE:GetCenterCoordinate()
|
||||||
|
return COORDINATE:NewFromVec2(self.CenterVec2)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the coordinate of the shape.
|
||||||
|
-- @return #COORDINATE The coordinate
|
||||||
|
function SHAPE_BASE:GetCoordinate()
|
||||||
|
return self:GetCenterCoordinate()
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a point is contained within the shape.
|
||||||
|
-- @param #table _ The point to check
|
||||||
|
-- @return #bool True if the point is contained, false otherwise
|
||||||
|
function SHAPE_BASE:ContainsPoint(_)
|
||||||
|
self:E("This needs to be set in the derived class")
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a unit is contained within the shape.
|
||||||
|
-- @param #string unit_name The name of the unit to check
|
||||||
|
-- @return #bool True if the unit is contained, false otherwise
|
||||||
|
function SHAPE_BASE:ContainsUnit(unit_name)
|
||||||
|
local unit = UNIT:FindByName(unit_name)
|
||||||
|
|
||||||
|
if unit == nil or not unit:IsAlive() then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if self:ContainsPoint(unit:GetVec2()) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if any unit of a group is contained within the shape.
|
||||||
|
-- @param #string group_name The name of the group to check
|
||||||
|
-- @return #bool True if any unit of the group is contained, false otherwise
|
||||||
|
function SHAPE_BASE:ContainsAnyOfGroup(group_name)
|
||||||
|
local group = GROUP:FindByName(group_name)
|
||||||
|
|
||||||
|
if group == nil or not group:IsAlive() then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, unit in pairs(group:GetUnits()) do
|
||||||
|
if self:ContainsPoint(unit:GetVec2()) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if all units of a group are contained within the shape.
|
||||||
|
-- @param #string group_name The name of the group to check
|
||||||
|
-- @return #bool True if all units of the group are contained, false otherwise
|
||||||
|
function SHAPE_BASE:ContainsAllOfGroup(group_name)
|
||||||
|
local group = GROUP:FindByName(group_name)
|
||||||
|
|
||||||
|
if group == nil or not group:IsAlive() then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, unit in pairs(group:GetUnits()) do
|
||||||
|
if not self:ContainsPoint(unit:GetVec2()) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
101
Moose Development/Moose/Shapes/Triangle.lua
Normal file
101
Moose Development/Moose/Shapes/Triangle.lua
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
--- TRIANGLE class with properties and methods for handling triangles. This class is mostly used by the POLYGON class, but you can use it on its own as well
|
||||||
|
--
|
||||||
|
-- ### Author: **nielsvaes/coconutcockpit**
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
-- @module Shapes.TRIANGLE
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- LINE class.
|
||||||
|
-- @type CUBE
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #number Points points of the line
|
||||||
|
-- @field #number Coords coordinates of the line
|
||||||
|
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @field #TRIANGLE
|
||||||
|
TRIANGLE = {
|
||||||
|
ClassName = "TRIANGLE",
|
||||||
|
Points = {},
|
||||||
|
Coords = {},
|
||||||
|
SurfaceArea = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Creates a new triangle from three points. The points need to be given as Vec2s
|
||||||
|
-- @param #table p1 The first point of the triangle
|
||||||
|
-- @param #table p2 The second point of the triangle
|
||||||
|
-- @param #table p3 The third point of the triangle
|
||||||
|
-- @return #TRIANGLE The new triangle
|
||||||
|
function TRIANGLE:New(p1, p2, p3)
|
||||||
|
local self = BASE:Inherit(self, SHAPE_BASE:New())
|
||||||
|
self.Points = {p1, p2, p3}
|
||||||
|
|
||||||
|
local center_x = (p1.x + p2.x + p3.x) / 3
|
||||||
|
local center_y = (p1.y + p2.y + p3.y) / 3
|
||||||
|
self.CenterVec2 = {x=center_x, y=center_y}
|
||||||
|
|
||||||
|
for _, pt in pairs({p1, p2, p3}) do
|
||||||
|
table.add(self.Coords, COORDINATE:NewFromVec2(pt))
|
||||||
|
end
|
||||||
|
|
||||||
|
self.SurfaceArea = math.abs((p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y)) * 0.5
|
||||||
|
|
||||||
|
self.MarkIDs = {}
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a point is contained within the triangle.
|
||||||
|
-- @param #table pt The point to check
|
||||||
|
-- @param #table points (optional) The points of the triangle, or 3 other points if you're just using the TRIANGLE class without an object of it
|
||||||
|
-- @return #bool True if the point is contained, false otherwise
|
||||||
|
function TRIANGLE:ContainsPoint(pt, points)
|
||||||
|
points = points or self.Points
|
||||||
|
|
||||||
|
local function sign(p1, p2, p3)
|
||||||
|
return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
local d1 = sign(pt, self.Points[1], self.Points[2])
|
||||||
|
local d2 = sign(pt, self.Points[2], self.Points[3])
|
||||||
|
local d3 = sign(pt, self.Points[3], self.Points[1])
|
||||||
|
|
||||||
|
local has_neg = (d1 < 0) or (d2 < 0) or (d3 < 0)
|
||||||
|
local has_pos = (d1 > 0) or (d2 > 0) or (d3 > 0)
|
||||||
|
|
||||||
|
return not (has_neg and has_pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns a random Vec2 within the triangle.
|
||||||
|
-- @param #table points The points of the triangle, or 3 other points if you're just using the TRIANGLE class without an object of it
|
||||||
|
-- @return #table The random Vec2
|
||||||
|
function TRIANGLE:GetRandomVec2(points)
|
||||||
|
points = points or self.Points
|
||||||
|
local pt = {math.random(), math.random()}
|
||||||
|
table.sort(pt)
|
||||||
|
local s = pt[1]
|
||||||
|
local t = pt[2] - pt[1]
|
||||||
|
local u = 1 - pt[2]
|
||||||
|
|
||||||
|
return {x = s * points[1].x + t * points[2].x + u * points[3].x,
|
||||||
|
y = s * points[1].y + t * points[2].y + u * points[3].y}
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Draws the triangle on the map, just for debugging
|
||||||
|
function TRIANGLE:Draw()
|
||||||
|
for i=1, #self.Coords do
|
||||||
|
local c1 = self.Coords[i]
|
||||||
|
local c2 = self.Coords[i % #self.Coords + 1]
|
||||||
|
table.add(self.MarkIDs, c1:LineToAll(c2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Removes the drawing of the triangle from the map.
|
||||||
|
function TRIANGLE:RemoveDraw()
|
||||||
|
for _, mark_id in pairs(self.MarkIDs) do
|
||||||
|
UTILS.RemoveMark(mark_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -175,19 +175,19 @@ do -- TASK_A2G
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Core.Set#SET_UNIT TargetSetUnit The set of targets.
|
-- @param Core.Set#SET_UNIT TargetSetUnit The set of targets.
|
||||||
function TASK_A2G:SetTargetSetUnit( TargetSetUnit )
|
function TASK_A2G:SetTargetSetUnit( TargetSetUnit )
|
||||||
|
|
||||||
self.TargetSetUnit = TargetSetUnit
|
self.TargetSetUnit = TargetSetUnit
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
function TASK_A2G:GetPlannedMenuText()
|
function TASK_A2G:GetPlannedMenuText()
|
||||||
return self:GetStateString() .. " - " .. self:GetTaskName() .. " ( " .. self.TargetSetUnit:GetUnitTypesText() .. " )"
|
return self:GetStateString() .. " - " .. self:GetTaskName() .. " ( " .. self.TargetSetUnit:GetUnitTypesText() .. " )"
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Core.Point#COORDINATE RendezVousCoordinate The Coordinate object referencing to the 2D point where the RendezVous point is located on the map.
|
-- @param Core.Point#COORDINATE RendezVousCoordinate The Coordinate object referencing to the 2D point where the RendezVous point is located on the map.
|
||||||
-- @param #number RendezVousRange The RendezVousRange that defines when the player is considered to have arrived at the RendezVous point.
|
-- @param #number RendezVousRange The RendezVousRange that defines when the player is considered to have arrived at the RendezVous point.
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
@@ -200,7 +200,7 @@ do -- TASK_A2G
|
|||||||
ActRouteRendezVous:SetRange( RendezVousRange )
|
ActRouteRendezVous:SetRange( RendezVousRange )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @return Core.Point#COORDINATE The Coordinate object referencing to the 2D point where the RendezVous point is located on the map.
|
-- @return Core.Point#COORDINATE The Coordinate object referencing to the 2D point where the RendezVous point is located on the map.
|
||||||
-- @return #number The RendezVousRange that defines when the player is considered to have arrived at the RendezVous point.
|
-- @return #number The RendezVousRange that defines when the player is considered to have arrived at the RendezVous point.
|
||||||
@@ -212,7 +212,7 @@ do -- TASK_A2G
|
|||||||
return ActRouteRendezVous:GetCoordinate(), ActRouteRendezVous:GetRange()
|
return ActRouteRendezVous:GetCoordinate(), ActRouteRendezVous:GetRange()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Core.Zone#ZONE_BASE RendezVousZone The Zone object where the RendezVous is located on the map.
|
-- @param Core.Zone#ZONE_BASE RendezVousZone The Zone object where the RendezVous is located on the map.
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
function TASK_A2G:SetRendezVousZone( RendezVousZone, TaskUnit )
|
function TASK_A2G:SetRendezVousZone( RendezVousZone, TaskUnit )
|
||||||
@@ -223,7 +223,7 @@ do -- TASK_A2G
|
|||||||
ActRouteRendezVous:SetZone( RendezVousZone )
|
ActRouteRendezVous:SetZone( RendezVousZone )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @return Core.Zone#ZONE_BASE The Zone object where the RendezVous is located on the map.
|
-- @return Core.Zone#ZONE_BASE The Zone object where the RendezVous is located on the map.
|
||||||
function TASK_A2G:GetRendezVousZone( TaskUnit )
|
function TASK_A2G:GetRendezVousZone( TaskUnit )
|
||||||
@@ -234,7 +234,7 @@ do -- TASK_A2G
|
|||||||
return ActRouteRendezVous:GetZone()
|
return ActRouteRendezVous:GetZone()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Core.Point#COORDINATE TargetCoordinate The Coordinate object where the Target is located on the map.
|
-- @param Core.Point#COORDINATE TargetCoordinate The Coordinate object where the Target is located on the map.
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
function TASK_A2G:SetTargetCoordinate( TargetCoordinate, TaskUnit )
|
function TASK_A2G:SetTargetCoordinate( TargetCoordinate, TaskUnit )
|
||||||
@@ -245,7 +245,7 @@ do -- TASK_A2G
|
|||||||
ActRouteTarget:SetCoordinate( TargetCoordinate )
|
ActRouteTarget:SetCoordinate( TargetCoordinate )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @return Core.Point#COORDINATE The Coordinate object where the Target is located on the map.
|
-- @return Core.Point#COORDINATE The Coordinate object where the Target is located on the map.
|
||||||
function TASK_A2G:GetTargetCoordinate( TaskUnit )
|
function TASK_A2G:GetTargetCoordinate( TaskUnit )
|
||||||
@@ -256,7 +256,7 @@ do -- TASK_A2G
|
|||||||
return ActRouteTarget:GetCoordinate()
|
return ActRouteTarget:GetCoordinate()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Core.Zone#ZONE_BASE TargetZone The Zone object where the Target is located on the map.
|
-- @param Core.Zone#ZONE_BASE TargetZone The Zone object where the Target is located on the map.
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
function TASK_A2G:SetTargetZone( TargetZone, TaskUnit )
|
function TASK_A2G:SetTargetZone( TargetZone, TaskUnit )
|
||||||
@@ -267,7 +267,7 @@ do -- TASK_A2G
|
|||||||
ActRouteTarget:SetZone( TargetZone )
|
ActRouteTarget:SetZone( TargetZone )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @return Core.Zone#ZONE_BASE The Zone object where the Target is located on the map.
|
-- @return Core.Zone#ZONE_BASE The Zone object where the Target is located on the map.
|
||||||
function TASK_A2G:GetTargetZone( TaskUnit )
|
function TASK_A2G:GetTargetZone( TaskUnit )
|
||||||
@@ -280,7 +280,7 @@ do -- TASK_A2G
|
|||||||
|
|
||||||
function TASK_A2G:SetGoalTotal()
|
function TASK_A2G:SetGoalTotal()
|
||||||
|
|
||||||
self.GoalTotal = self.TargetSetUnit:Count()
|
self.GoalTotal = self.TargetSetUnit:CountAlive()
|
||||||
end
|
end
|
||||||
|
|
||||||
function TASK_A2G:GetGoalTotal()
|
function TASK_A2G:GetGoalTotal()
|
||||||
@@ -304,14 +304,14 @@ do -- TASK_A2G
|
|||||||
function TASK_A2G:onafterGoal( TaskUnit, From, Event, To )
|
function TASK_A2G:onafterGoal( TaskUnit, From, Event, To )
|
||||||
local TargetSetUnit = self.TargetSetUnit -- Core.Set#SET_UNIT
|
local TargetSetUnit = self.TargetSetUnit -- Core.Set#SET_UNIT
|
||||||
|
|
||||||
if TargetSetUnit:Count() == 0 then
|
if TargetSetUnit:CountAlive() == 0 then
|
||||||
self:Success()
|
self:Success()
|
||||||
end
|
end
|
||||||
|
|
||||||
self:__Goal( -10 )
|
self:__Goal( -10 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #TASK_A2G self
|
-- @param #TASK_A2G self
|
||||||
function TASK_A2G:UpdateTaskInfo( DetectedItem )
|
function TASK_A2G:UpdateTaskInfo( DetectedItem )
|
||||||
|
|
||||||
if self:IsStatePlanned() or self:IsStateAssigned() then
|
if self:IsStatePlanned() or self:IsStateAssigned() then
|
||||||
@@ -328,7 +328,7 @@ do -- TASK_A2G
|
|||||||
self.TaskInfo:AddThreat( ThreatText, ThreatLevel, 10, "MOD", true )
|
self.TaskInfo:AddThreat( ThreatText, ThreatLevel, 10, "MOD", true )
|
||||||
|
|
||||||
if self.Detection then
|
if self.Detection then
|
||||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
local DetectedItemsCount = self.TargetSetUnit:CountAlive()
|
||||||
local ReportTypes = REPORT:New()
|
local ReportTypes = REPORT:New()
|
||||||
local TargetTypes = {}
|
local TargetTypes = {}
|
||||||
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||||
@@ -341,7 +341,7 @@ do -- TASK_A2G
|
|||||||
self.TaskInfo:AddTargetCount( DetectedItemsCount, 11, "O", true )
|
self.TaskInfo:AddTargetCount( DetectedItemsCount, 11, "O", true )
|
||||||
self.TaskInfo:AddTargets( DetectedItemsCount, ReportTypes:Text( ", " ), 20, "D", true )
|
self.TaskInfo:AddTargets( DetectedItemsCount, ReportTypes:Text( ", " ), 20, "D", true )
|
||||||
else
|
else
|
||||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
local DetectedItemsCount = self.TargetSetUnit:CountAlive()
|
||||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||||
self.TaskInfo:AddTargetCount( DetectedItemsCount, 11, "O", true )
|
self.TaskInfo:AddTargetCount( DetectedItemsCount, 11, "O", true )
|
||||||
self.TaskInfo:AddTargets( DetectedItemsCount, DetectedItemsTypes, 20, "D", true )
|
self.TaskInfo:AddTargets( DetectedItemsCount, DetectedItemsTypes, 20, "D", true )
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ BIGSMOKEPRESET = {
|
|||||||
-- @field #string MarianaIslands Mariana Islands map.
|
-- @field #string MarianaIslands Mariana Islands map.
|
||||||
-- @field #string Falklands South Atlantic map.
|
-- @field #string Falklands South Atlantic map.
|
||||||
-- @field #string Sinai Sinai map.
|
-- @field #string Sinai Sinai map.
|
||||||
|
-- @field #string Kola Kola map.
|
||||||
DCSMAP = {
|
DCSMAP = {
|
||||||
Caucasus="Caucasus",
|
Caucasus="Caucasus",
|
||||||
NTTR="Nevada",
|
NTTR="Nevada",
|
||||||
@@ -64,7 +65,8 @@ DCSMAP = {
|
|||||||
Syria="Syria",
|
Syria="Syria",
|
||||||
MarianaIslands="MarianaIslands",
|
MarianaIslands="MarianaIslands",
|
||||||
Falklands="Falklands",
|
Falklands="Falklands",
|
||||||
Sinai="SinaiMap"
|
Sinai="SinaiMap",
|
||||||
|
Kola="Kola"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ CALLSIGN={
|
|||||||
Shell=3,
|
Shell=3,
|
||||||
Navy_One=4,
|
Navy_One=4,
|
||||||
Mauler=5,
|
Mauler=5,
|
||||||
Bloodhound=6,
|
Bloodhound=6,
|
||||||
},
|
},
|
||||||
-- JTAC
|
-- JTAC
|
||||||
JTAC={
|
JTAC={
|
||||||
@@ -416,7 +418,7 @@ function UTILS._OneLineSerialize(tbl)
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
tbl_str[#tbl_str + 1] = '}'
|
tbl_str[#tbl_str + 1] = '}'
|
||||||
return table.concat(tbl_str)
|
return table.concat(tbl_str)
|
||||||
else
|
else
|
||||||
@@ -433,7 +435,7 @@ UTILS.BasicSerialize = function(s)
|
|||||||
if ((type(s) == 'number') or (type(s) == 'boolean') or (type(s) == 'function') or (type(s) == 'userdata') ) then
|
if ((type(s) == 'number') or (type(s) == 'boolean') or (type(s) == 'function') or (type(s) == 'userdata') ) then
|
||||||
return tostring(s)
|
return tostring(s)
|
||||||
elseif type(s) == "table" then
|
elseif type(s) == "table" then
|
||||||
return UTILS._OneLineSerialize(s)
|
return UTILS._OneLineSerialize(s)
|
||||||
elseif type(s) == 'string' then
|
elseif type(s) == 'string' then
|
||||||
s = string.format('(%s)', s)
|
s = string.format('(%s)', s)
|
||||||
return s
|
return s
|
||||||
@@ -562,15 +564,15 @@ end
|
|||||||
-- @param #string fname File name.
|
-- @param #string fname File name.
|
||||||
function UTILS.Gdump(fname)
|
function UTILS.Gdump(fname)
|
||||||
if lfs and io then
|
if lfs and io then
|
||||||
|
|
||||||
local fdir = lfs.writedir() .. [[Logs\]] .. fname
|
local fdir = lfs.writedir() .. [[Logs\]] .. fname
|
||||||
|
|
||||||
local f = io.open(fdir, 'w')
|
local f = io.open(fdir, 'w')
|
||||||
|
|
||||||
f:write(UTILS.TableShow(_G))
|
f:write(UTILS.TableShow(_G))
|
||||||
|
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
env.info(string.format('Wrote debug data to $1', fdir))
|
env.info(string.format('Wrote debug data to $1', fdir))
|
||||||
else
|
else
|
||||||
env.error("WARNING: lfs and/or io not de-sanitized - cannot dump _G!")
|
env.error("WARNING: lfs and/or io not de-sanitized - cannot dump _G!")
|
||||||
@@ -867,17 +869,17 @@ UTILS.tostringLLM2KData = function( lat, lon, acc)
|
|||||||
-- degrees, decimal minutes.
|
-- degrees, decimal minutes.
|
||||||
latMin = UTILS.Round(latMin, acc)
|
latMin = UTILS.Round(latMin, acc)
|
||||||
lonMin = UTILS.Round(lonMin, acc)
|
lonMin = UTILS.Round(lonMin, acc)
|
||||||
|
|
||||||
if latMin == 60 then
|
if latMin == 60 then
|
||||||
latMin = 0
|
latMin = 0
|
||||||
latDeg = latDeg + 1
|
latDeg = latDeg + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if lonMin == 60 then
|
if lonMin == 60 then
|
||||||
lonMin = 0
|
lonMin = 0
|
||||||
lonDeg = lonDeg + 1
|
lonDeg = lonDeg + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local minFrmtStr -- create the formatting string for the minutes place
|
local minFrmtStr -- create the formatting string for the minutes place
|
||||||
if acc <= 0 then -- no decimal place.
|
if acc <= 0 then -- no decimal place.
|
||||||
minFrmtStr = '%02d'
|
minFrmtStr = '%02d'
|
||||||
@@ -885,7 +887,7 @@ UTILS.tostringLLM2KData = function( lat, lon, acc)
|
|||||||
local width = 3 + acc -- 01.310 - that's a width of 6, for example.
|
local width = 3 + acc -- 01.310 - that's a width of 6, for example.
|
||||||
minFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
|
minFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 024 23'N or 024 23.123'N
|
-- 024 23'N or 024 23.123'N
|
||||||
return latHemi..string.format('%02d:', latDeg) .. string.format(minFrmtStr, latMin), lonHemi..string.format('%02d:', lonDeg) .. string.format(minFrmtStr, lonMin)
|
return latHemi..string.format('%02d:', latDeg) .. string.format(minFrmtStr, latMin), lonHemi..string.format('%02d:', lonDeg) .. string.format(minFrmtStr, lonMin)
|
||||||
|
|
||||||
@@ -897,9 +899,9 @@ UTILS.tostringMGRS = function(MGRS, acc) --R2.1
|
|||||||
if acc <= 0 then
|
if acc <= 0 then
|
||||||
return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph
|
return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph
|
||||||
else
|
else
|
||||||
|
|
||||||
if acc > 5 then acc = 5 end
|
if acc > 5 then acc = 5 end
|
||||||
|
|
||||||
-- Test if Easting/Northing have less than 4 digits.
|
-- Test if Easting/Northing have less than 4 digits.
|
||||||
--MGRS.Easting=123 -- should be 00123
|
--MGRS.Easting=123 -- should be 00123
|
||||||
--MGRS.Northing=5432 -- should be 05432
|
--MGRS.Northing=5432 -- should be 05432
|
||||||
@@ -1382,7 +1384,7 @@ end
|
|||||||
function UTILS.VecDist2D(a, b)
|
function UTILS.VecDist2D(a, b)
|
||||||
|
|
||||||
local d = math.huge
|
local d = math.huge
|
||||||
|
|
||||||
if (not a) or (not b) then return d end
|
if (not a) or (not b) then return d end
|
||||||
|
|
||||||
local c={x=b.x-a.x, y=b.y-a.y}
|
local c={x=b.x-a.x, y=b.y-a.y}
|
||||||
@@ -1398,12 +1400,12 @@ end
|
|||||||
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||||
-- @return #number Distance between the vectors.
|
-- @return #number Distance between the vectors.
|
||||||
function UTILS.VecDist3D(a, b)
|
function UTILS.VecDist3D(a, b)
|
||||||
|
|
||||||
|
|
||||||
local d = math.huge
|
local d = math.huge
|
||||||
|
|
||||||
if (not a) or (not b) then return d end
|
if (not a) or (not b) then return d end
|
||||||
|
|
||||||
local c={x=b.x-a.x, y=b.y-a.y, z=b.z-a.z}
|
local c={x=b.x-a.x, y=b.y-a.y, z=b.z-a.z}
|
||||||
|
|
||||||
d=math.sqrt(UTILS.VecDot(c, c))
|
d=math.sqrt(UTILS.VecDot(c, c))
|
||||||
@@ -1703,6 +1705,7 @@ end
|
|||||||
-- * Mariana Islands +2 (East)
|
-- * Mariana Islands +2 (East)
|
||||||
-- * Falklands +12 (East) - note there's a LOT of deviation across the map, as we're closer to the South Pole
|
-- * Falklands +12 (East) - note there's a LOT of deviation across the map, as we're closer to the South Pole
|
||||||
-- * Sinai +4.8 (East)
|
-- * Sinai +4.8 (East)
|
||||||
|
-- * Kola +15 (East) - not there is a lot of deviation across the map (-1° to +24°), as we are close to the North pole
|
||||||
-- @param #string map (Optional) Map for which the declination is returned. Default is from env.mission.theatre
|
-- @param #string map (Optional) Map for which the declination is returned. Default is from env.mission.theatre
|
||||||
-- @return #number Declination in degrees.
|
-- @return #number Declination in degrees.
|
||||||
function UTILS.GetMagneticDeclination(map)
|
function UTILS.GetMagneticDeclination(map)
|
||||||
@@ -1729,6 +1732,8 @@ function UTILS.GetMagneticDeclination(map)
|
|||||||
declination=12
|
declination=12
|
||||||
elseif map==DCSMAP.Sinai then
|
elseif map==DCSMAP.Sinai then
|
||||||
declination=4.8
|
declination=4.8
|
||||||
|
elseif map==DCSMAP.Kola then
|
||||||
|
declination=15
|
||||||
else
|
else
|
||||||
declination=0
|
declination=0
|
||||||
end
|
end
|
||||||
@@ -1796,7 +1801,7 @@ function UTILS.GetCoalitionEnemy(Coalition, Neutral)
|
|||||||
|
|
||||||
local Coalitions={}
|
local Coalitions={}
|
||||||
if Coalition then
|
if Coalition then
|
||||||
if Coalition==coalition.side.RED then
|
if Coalition==coalition.side.RED then
|
||||||
Coalitions={coalition.side.BLUE}
|
Coalitions={coalition.side.BLUE}
|
||||||
elseif Coalition==coalition.side.BLUE then
|
elseif Coalition==coalition.side.BLUE then
|
||||||
Coalitions={coalition.side.RED}
|
Coalitions={coalition.side.RED}
|
||||||
@@ -1804,7 +1809,7 @@ function UTILS.GetCoalitionEnemy(Coalition, Neutral)
|
|||||||
Coalitions={coalition.side.RED, coalition.side.BLUE}
|
Coalitions={coalition.side.RED, coalition.side.BLUE}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Neutral then
|
if Neutral then
|
||||||
table.insert(Coalitions, coalition.side.NEUTRAL)
|
table.insert(Coalitions, coalition.side.NEUTRAL)
|
||||||
end
|
end
|
||||||
@@ -1835,17 +1840,17 @@ end
|
|||||||
-- @param #number Typename The type name.
|
-- @param #number Typename The type name.
|
||||||
-- @return #string The Reporting name or "Bogey".
|
-- @return #string The Reporting name or "Bogey".
|
||||||
function UTILS.GetReportingName(Typename)
|
function UTILS.GetReportingName(Typename)
|
||||||
|
|
||||||
local typename = string.lower(Typename)
|
local typename = string.lower(Typename)
|
||||||
|
|
||||||
for name, value in pairs(ENUMS.ReportingName.NATO) do
|
for name, value in pairs(ENUMS.ReportingName.NATO) do
|
||||||
local svalue = string.lower(value)
|
local svalue = string.lower(value)
|
||||||
if string.find(typename,svalue,1,true) then
|
if string.find(typename,svalue,1,true) then
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return "Bogey"
|
return "Bogey"
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the callsign name from its enumerator value
|
--- Get the callsign name from its enumerator value
|
||||||
@@ -1876,49 +1881,49 @@ function UTILS.GetCallsignName(Callsign)
|
|||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, value in pairs(CALLSIGN.B1B) do
|
for name, value in pairs(CALLSIGN.B1B) do
|
||||||
if value==Callsign then
|
if value==Callsign then
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, value in pairs(CALLSIGN.B52) do
|
for name, value in pairs(CALLSIGN.B52) do
|
||||||
if value==Callsign then
|
if value==Callsign then
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, value in pairs(CALLSIGN.F15E) do
|
for name, value in pairs(CALLSIGN.F15E) do
|
||||||
if value==Callsign then
|
if value==Callsign then
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, value in pairs(CALLSIGN.F16) do
|
for name, value in pairs(CALLSIGN.F16) do
|
||||||
if value==Callsign then
|
if value==Callsign then
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, value in pairs(CALLSIGN.F18) do
|
for name, value in pairs(CALLSIGN.F18) do
|
||||||
if value==Callsign then
|
if value==Callsign then
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, value in pairs(CALLSIGN.FARP) do
|
for name, value in pairs(CALLSIGN.FARP) do
|
||||||
if value==Callsign then
|
if value==Callsign then
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, value in pairs(CALLSIGN.TransportAircraft) do
|
for name, value in pairs(CALLSIGN.TransportAircraft) do
|
||||||
if value==Callsign then
|
if value==Callsign then
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return "Ghostrider"
|
return "Ghostrider"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1945,7 +1950,9 @@ function UTILS.GMTToLocalTimeDifference()
|
|||||||
elseif theatre==DCSMAP.Falklands then
|
elseif theatre==DCSMAP.Falklands then
|
||||||
return -3 -- Fireland is UTC-3 hours.
|
return -3 -- Fireland is UTC-3 hours.
|
||||||
elseif theatre==DCSMAP.Sinai then
|
elseif theatre==DCSMAP.Sinai then
|
||||||
return 2 -- Currently map is +2 but should be +3 (DCS bug?)
|
return 2 -- Currently map is +2 but should be +3 (DCS bug?)
|
||||||
|
elseif theatre==DCSMAP.Kola then
|
||||||
|
return 3 -- Currently map is +2 but should be +3 (DCS bug?)
|
||||||
else
|
else
|
||||||
BASE:E(string.format("ERROR: Unknown Map %s in UTILS.GMTToLocal function. Returning 0", tostring(theatre)))
|
BASE:E(string.format("ERROR: Unknown Map %s in UTILS.GMTToLocal function. Returning 0", tostring(theatre)))
|
||||||
return 0
|
return 0
|
||||||
@@ -2150,19 +2157,19 @@ function UTILS.GetRandomTableElement(t, replace)
|
|||||||
BASE:I("Error in ShuffleTable: Missing or wrong type of Argument")
|
BASE:I("Error in ShuffleTable: Missing or wrong type of Argument")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
math.random()
|
math.random()
|
||||||
math.random()
|
math.random()
|
||||||
math.random()
|
math.random()
|
||||||
|
|
||||||
local r=math.random(#t)
|
local r=math.random(#t)
|
||||||
|
|
||||||
local element=t[r]
|
local element=t[r]
|
||||||
|
|
||||||
if not replace then
|
if not replace then
|
||||||
table.remove(t, r)
|
table.remove(t, r)
|
||||||
end
|
end
|
||||||
|
|
||||||
return element
|
return element
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2191,7 +2198,7 @@ function UTILS.IsLoadingDoorOpen( unit_name )
|
|||||||
BASE:T(unit_name .. " a side door is open ")
|
BASE:T(unit_name .. " a side door is open ")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if string.find(type_name, "SA342" ) and (unit:getDrawArgumentValue(34) == 1) then
|
if string.find(type_name, "SA342" ) and (unit:getDrawArgumentValue(34) == 1) then
|
||||||
BASE:T(unit_name .. " front door(s) are open or doors removed")
|
BASE:T(unit_name .. " front door(s) are open or doors removed")
|
||||||
return true
|
return true
|
||||||
@@ -2216,7 +2223,7 @@ function UTILS.IsLoadingDoorOpen( unit_name )
|
|||||||
BASE:T(unit_name .. " door is open")
|
BASE:T(unit_name .. " door is open")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if type_name == "UH-60L" and (unit:getDrawArgumentValue(401) == 1 or unit:getDrawArgumentValue(402) == 1) then
|
if type_name == "UH-60L" and (unit:getDrawArgumentValue(401) == 1 or unit:getDrawArgumentValue(402) == 1) then
|
||||||
BASE:T(unit_name .. " cargo door is open")
|
BASE:T(unit_name .. " cargo door is open")
|
||||||
return true
|
return true
|
||||||
@@ -2226,22 +2233,27 @@ function UTILS.IsLoadingDoorOpen( unit_name )
|
|||||||
BASE:T(unit_name .. " front door(s) are open")
|
BASE:T(unit_name .. " front door(s) are open")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if type_name == "AH-64D_BLK_II" then
|
if type_name == "AH-64D_BLK_II" then
|
||||||
BASE:T(unit_name .. " front door(s) are open")
|
BASE:T(unit_name .. " front door(s) are open")
|
||||||
return true -- no doors on this one ;)
|
return true -- no doors on this one ;)
|
||||||
end
|
end
|
||||||
|
|
||||||
if type_name == "Bronco-OV-10A" then
|
if type_name == "Bronco-OV-10A" then
|
||||||
BASE:T(unit_name .. " front door(s) are open")
|
BASE:T(unit_name .. " front door(s) are open")
|
||||||
return true -- no doors on this one ;)
|
return true -- no doors on this one ;)
|
||||||
end
|
end
|
||||||
|
|
||||||
if type_name == "MH-60R" and (unit:getDrawArgumentValue(403) > 0 or unit:getDrawArgumentValue(403) == -1) then
|
if type_name == "MH-60R" and (unit:getDrawArgumentValue(403) > 0 or unit:getDrawArgumentValue(403) == -1) then
|
||||||
BASE:T(unit_name .. " cargo door is open")
|
BASE:T(unit_name .. " cargo door is open")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if type_name == " OH-58D" and (unit:getDrawArgumentValue(35) > 0 or unit:getDrawArgumentValue(421) == -1) then
|
||||||
|
BASE:T(unit_name .. " cargo door is open")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
end -- nil
|
end -- nil
|
||||||
@@ -2350,7 +2362,7 @@ function UTILS.GenerateUHFrequencies(Start,End)
|
|||||||
|
|
||||||
local FreeUHFFrequencies = {}
|
local FreeUHFFrequencies = {}
|
||||||
local _start = 220000000
|
local _start = 220000000
|
||||||
|
|
||||||
if not Start then
|
if not Start then
|
||||||
while _start < 399000000 do
|
while _start < 399000000 do
|
||||||
if _start ~= 243000000 then
|
if _start ~= 243000000 then
|
||||||
@@ -2361,7 +2373,7 @@ function UTILS.GenerateUHFrequencies(Start,End)
|
|||||||
else
|
else
|
||||||
local myend = End*1000000 or 399000000
|
local myend = End*1000000 or 399000000
|
||||||
local mystart = Start*1000000 or 220000000
|
local mystart = Start*1000000 or 220000000
|
||||||
|
|
||||||
while _start < 399000000 do
|
while _start < 399000000 do
|
||||||
if _start ~= 243000000 and (_start < mystart or _start > myend) then
|
if _start ~= 243000000 and (_start < mystart or _start > myend) then
|
||||||
print(_start)
|
print(_start)
|
||||||
@@ -2369,10 +2381,10 @@ function UTILS.GenerateUHFrequencies(Start,End)
|
|||||||
end
|
end
|
||||||
_start = _start + 500000
|
_start = _start + 500000
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return FreeUHFFrequencies
|
return FreeUHFFrequencies
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2413,7 +2425,7 @@ function UTILS.GenerateLaserCodes()
|
|||||||
return jtacGeneratedLaserCodes
|
return jtacGeneratedLaserCodes
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Ensure the passed object is a table.
|
--- Ensure the passed object is a table.
|
||||||
-- @param #table Object The object that should be a table.
|
-- @param #table Object The object that should be a table.
|
||||||
-- @param #boolean ReturnNil If `true`, return `#nil` if `Object` is nil. Otherwise an empty table `{}` is returned.
|
-- @param #boolean ReturnNil If `true`, return `#nil` if `Object` is nil. Otherwise an empty table `{}` is returned.
|
||||||
-- @return #table The object that now certainly *is* a table.
|
-- @return #table The object that now certainly *is* a table.
|
||||||
@@ -2425,11 +2437,11 @@ function UTILS.EnsureTable(Object, ReturnNil)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if ReturnNil then
|
if ReturnNil then
|
||||||
return nil
|
return nil
|
||||||
else
|
else
|
||||||
Object={}
|
Object={}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Object
|
return Object
|
||||||
@@ -2441,30 +2453,30 @@ end
|
|||||||
-- @param #table Data The LUA data structure to save. This will be e.g. a table of text lines with an \\n at the end of each line.
|
-- @param #table Data The LUA data structure to save. This will be e.g. a table of text lines with an \\n at the end of each line.
|
||||||
-- @return #boolean outcome True if saving is possible, else false.
|
-- @return #boolean outcome True if saving is possible, else false.
|
||||||
function UTILS.SaveToFile(Path,Filename,Data)
|
function UTILS.SaveToFile(Path,Filename,Data)
|
||||||
-- Thanks to @FunkyFranky
|
-- Thanks to @FunkyFranky
|
||||||
-- Check io module is available.
|
-- Check io module is available.
|
||||||
if not io then
|
if not io then
|
||||||
BASE:E("ERROR: io not desanitized. Can't save current file.")
|
BASE:E("ERROR: io not desanitized. Can't save current file.")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check default path.
|
-- Check default path.
|
||||||
if Path==nil and not lfs then
|
if Path==nil and not lfs then
|
||||||
BASE:E("WARNING: lfs not desanitized. File will be saved in DCS installation root directory rather than your \"Saved Games\\DCS\" folder.")
|
BASE:E("WARNING: lfs not desanitized. File will be saved in DCS installation root directory rather than your \"Saved Games\\DCS\" folder.")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set path or default.
|
-- Set path or default.
|
||||||
local path = nil
|
local path = nil
|
||||||
if lfs then
|
if lfs then
|
||||||
path=Path or lfs.writedir()
|
path=Path or lfs.writedir()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set file name.
|
-- Set file name.
|
||||||
local filename=Filename
|
local filename=Filename
|
||||||
if path~=nil then
|
if path~=nil then
|
||||||
filename=path.."\\"..filename
|
filename=path.."\\"..filename
|
||||||
end
|
end
|
||||||
|
|
||||||
-- write
|
-- write
|
||||||
local f = assert(io.open(filename, "wb"))
|
local f = assert(io.open(filename, "wb"))
|
||||||
f:write(Data)
|
f:write(Data)
|
||||||
@@ -2472,43 +2484,43 @@ function UTILS.SaveToFile(Path,Filename,Data)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Function to save an object to a file
|
--- Function to load an object from a file.
|
||||||
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
|
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
|
||||||
-- @param #string Filename The name of the file.
|
-- @param #string Filename The name of the file.
|
||||||
-- @return #boolean outcome True if reading is possible and successful, else false.
|
-- @return #boolean outcome True if reading is possible and successful, else false.
|
||||||
-- @return #table data The data read from the filesystem (table of lines of text). Each line is one single #string!
|
-- @return #table data The data read from the filesystem (table of lines of text). Each line is one single #string!
|
||||||
function UTILS.LoadFromFile(Path,Filename)
|
function UTILS.LoadFromFile(Path,Filename)
|
||||||
-- Thanks to @FunkyFranky
|
-- Thanks to @FunkyFranky
|
||||||
-- Check io module is available.
|
-- Check io module is available.
|
||||||
if not io then
|
if not io then
|
||||||
BASE:E("ERROR: io not desanitized. Can't save current state.")
|
BASE:E("ERROR: io not desanitized. Can't save current state.")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check default path.
|
-- Check default path.
|
||||||
if Path==nil and not lfs then
|
if Path==nil and not lfs then
|
||||||
BASE:E("WARNING: lfs not desanitized. Loading will look into your DCS installation root directory rather than your \"Saved Games\\DCS\" folder.")
|
BASE:E("WARNING: lfs not desanitized. Loading will look into your DCS installation root directory rather than your \"Saved Games\\DCS\" folder.")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set path or default.
|
-- Set path or default.
|
||||||
local path = nil
|
local path = nil
|
||||||
if lfs then
|
if lfs then
|
||||||
path=Path or lfs.writedir()
|
path=Path or lfs.writedir()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set file name.
|
-- Set file name.
|
||||||
local filename=Filename
|
local filename=Filename
|
||||||
if path~=nil then
|
if path~=nil then
|
||||||
filename=path.."\\"..filename
|
filename=path.."\\"..filename
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if file exists.
|
-- Check if file exists.
|
||||||
local exists=UTILS.CheckFileExists(Path,Filename)
|
local exists=UTILS.CheckFileExists(Path,Filename)
|
||||||
if not exists then
|
if not exists then
|
||||||
BASE:I(string.format("ERROR: File %s does not exist!",filename))
|
BASE:I(string.format("ERROR: File %s does not exist!",filename))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- read
|
-- read
|
||||||
local file=assert(io.open(filename, "rb"))
|
local file=assert(io.open(filename, "rb"))
|
||||||
local loadeddata = {}
|
local loadeddata = {}
|
||||||
@@ -2535,30 +2547,30 @@ function UTILS.CheckFileExists(Path,Filename)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check io module is available.
|
-- Check io module is available.
|
||||||
if not io then
|
if not io then
|
||||||
BASE:E("ERROR: io not desanitized.")
|
BASE:E("ERROR: io not desanitized.")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check default path.
|
-- Check default path.
|
||||||
if Path==nil and not lfs then
|
if Path==nil and not lfs then
|
||||||
BASE:E("WARNING: lfs not desanitized. Loading will look into your DCS installation root directory rather than your \"Saved Games\\DCS\" folder.")
|
BASE:E("WARNING: lfs not desanitized. Loading will look into your DCS installation root directory rather than your \"Saved Games\\DCS\" folder.")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set path or default.
|
-- Set path or default.
|
||||||
local path = nil
|
local path = nil
|
||||||
if lfs then
|
if lfs then
|
||||||
path=Path or lfs.writedir()
|
path=Path or lfs.writedir()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set file name.
|
-- Set file name.
|
||||||
local filename=Filename
|
local filename=Filename
|
||||||
if path~=nil then
|
if path~=nil then
|
||||||
filename=path.."\\"..filename
|
filename=path.."\\"..filename
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if file exists.
|
-- Check if file exists.
|
||||||
local exists=_fileexists(filename)
|
local exists=_fileexists(filename)
|
||||||
if not exists then
|
if not exists then
|
||||||
@@ -2595,7 +2607,7 @@ end
|
|||||||
-- @return #boolean outcome True if saving is successful, else false.
|
-- @return #boolean outcome True if saving is successful, else false.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- We will go through the list and find the corresponding group and save the current group size (0 when dead).
|
-- We will go through the list and find the corresponding group and save the current group size (0 when dead).
|
||||||
-- These groups are supposed to be put on the map in the ME and have *not* moved (e.g. stationary SAM sites).
|
-- These groups are supposed to be put on the map in the ME and have *not* moved (e.g. stationary SAM sites).
|
||||||
-- Position is still saved for your usage.
|
-- Position is still saved for your usage.
|
||||||
-- The idea is to reduce the number of units when reloading the data again to restart the saved mission.
|
-- The idea is to reduce the number of units when reloading the data again to restart the saved mission.
|
||||||
-- The data will be a simple comma separated list of groupname and size, with one header line.
|
-- The data will be a simple comma separated list of groupname and size, with one header line.
|
||||||
@@ -2634,12 +2646,12 @@ end
|
|||||||
-- @return #boolean outcome True if saving is successful, else false.
|
-- @return #boolean outcome True if saving is successful, else false.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- We will go through the set and find the corresponding group and save the current group size and current position.
|
-- We will go through the set and find the corresponding group and save the current group size and current position.
|
||||||
-- The idea is to respawn the groups **spawned during an earlier run of the mission** at the given location and reduce
|
-- The idea is to respawn the groups **spawned during an earlier run of the mission** at the given location and reduce
|
||||||
-- the number of units in the group when reloading the data again to restart the saved mission. Note that *dead* groups
|
-- the number of units in the group when reloading the data again to restart the saved mission. Note that *dead* groups
|
||||||
-- cannot be covered with this.
|
-- cannot be covered with this.
|
||||||
-- **Note** Do NOT use dashes or hashes in group template names (-,#)!
|
-- **Note** Do NOT use dashes or hashes in group template names (-,#)!
|
||||||
-- The data will be a simple comma separated list of groupname and size, with one header line.
|
-- The data will be a simple comma separated list of groupname and size, with one header line.
|
||||||
-- The current task/waypoint/etc cannot be restored.
|
-- The current task/waypoint/etc cannot be restored.
|
||||||
function UTILS.SaveSetOfGroups(Set,Path,Filename,Structured)
|
function UTILS.SaveSetOfGroups(Set,Path,Filename,Structured)
|
||||||
local filename = Filename or "SetOfGroups"
|
local filename = Filename or "SetOfGroups"
|
||||||
local data = "--Save SET of groups: "..Filename .."\n"
|
local data = "--Save SET of groups: "..Filename .."\n"
|
||||||
@@ -2649,9 +2661,12 @@ function UTILS.SaveSetOfGroups(Set,Path,Filename,Structured)
|
|||||||
if group and group:IsAlive() then
|
if group and group:IsAlive() then
|
||||||
local name = group:GetName()
|
local name = group:GetName()
|
||||||
local template = string.gsub(name,"-(.+)$","")
|
local template = string.gsub(name,"-(.+)$","")
|
||||||
|
if string.find(name,"AID") then
|
||||||
|
template = string.gsub(name,"(.AID.%d+$","")
|
||||||
|
end
|
||||||
if string.find(template,"#") then
|
if string.find(template,"#") then
|
||||||
template = string.gsub(name,"#(%d+)$","")
|
template = string.gsub(name,"#(%d+)$","")
|
||||||
end
|
end
|
||||||
local units = group:CountAliveUnits()
|
local units = group:CountAliveUnits()
|
||||||
local position = group:GetVec3()
|
local position = group:GetVec3()
|
||||||
if Structured then
|
if Structured then
|
||||||
@@ -2663,7 +2678,7 @@ function UTILS.SaveSetOfGroups(Set,Path,Filename,Structured)
|
|||||||
data = string.format("%s%s,%s,%d,%d,%d,%d,%s\n",data,name,template,units,position.x,position.y,position.z,strucdata)
|
data = string.format("%s%s,%s,%d,%d,%d,%d,%s\n",data,name,template,units,position.x,position.y,position.z,strucdata)
|
||||||
else
|
else
|
||||||
data = string.format("%s%s,%s,%d,%d,%d,%d\n",data,name,template,units,position.x,position.y,position.z)
|
data = string.format("%s%s,%s,%d,%d,%d,%d\n",data,name,template,units,position.x,position.y,position.z)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- save the data
|
-- save the data
|
||||||
@@ -2734,16 +2749,16 @@ end
|
|||||||
-- @return #table Table of data objects (tables) containing groupname, coordinate and group object. Returns nil when file cannot be read.
|
-- @return #table Table of data objects (tables) containing groupname, coordinate and group object. Returns nil when file cannot be read.
|
||||||
-- @return #table When using Cinematic: table of names of smoke and fire objects, so they can be extinguished with `COORDINATE.StopBigSmokeAndFire( name )`
|
-- @return #table When using Cinematic: table of names of smoke and fire objects, so they can be extinguished with `COORDINATE.StopBigSmokeAndFire( name )`
|
||||||
function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce,Structured,Cinematic,Effect,Density)
|
function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce,Structured,Cinematic,Effect,Density)
|
||||||
|
|
||||||
local fires = {}
|
local fires = {}
|
||||||
|
|
||||||
local function Smokers(name,coord,effect,density)
|
local function Smokers(name,coord,effect,density)
|
||||||
local eff = math.random(8)
|
local eff = math.random(8)
|
||||||
if type(effect) == "number" then eff = effect end
|
if type(effect) == "number" then eff = effect end
|
||||||
coord:BigSmokeAndFire(eff,density,name)
|
coord:BigSmokeAndFire(eff,density,name)
|
||||||
table.insert(fires,name)
|
table.insert(fires,name)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Cruncher(group,typename,anzahl)
|
local function Cruncher(group,typename,anzahl)
|
||||||
local units = group:GetUnits()
|
local units = group:GetUnits()
|
||||||
local reduced = 0
|
local reduced = 0
|
||||||
@@ -2761,7 +2776,7 @@ function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce,Structured,Cinema
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local reduce = true
|
local reduce = true
|
||||||
if Reduce == false then reduce = false end
|
if Reduce == false then reduce = false end
|
||||||
local filename = Filename or "StateListofGroups"
|
local filename = Filename or "StateListofGroups"
|
||||||
@@ -2803,13 +2818,13 @@ function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce,Structured,Cinema
|
|||||||
end
|
end
|
||||||
local reduce = false
|
local reduce = false
|
||||||
if loadednumber < _number then reduce = true end
|
if loadednumber < _number then reduce = true end
|
||||||
|
|
||||||
--BASE:I(string.format("Looking at: %s | Original number: %d | Loaded number: %d | Reduce: %s",_name,_number,loadednumber,tostring(reduce)))
|
--BASE:I(string.format("Looking at: %s | Original number: %d | Loaded number: %d | Reduce: %s",_name,_number,loadednumber,tostring(reduce)))
|
||||||
|
|
||||||
if reduce then
|
if reduce then
|
||||||
Cruncher(actualgroup,_name,_number-loadednumber)
|
Cruncher(actualgroup,_name,_number-loadednumber)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local reduction = actualgroup:CountAliveUnits() - size
|
local reduction = actualgroup:CountAliveUnits() - size
|
||||||
@@ -2824,7 +2839,7 @@ function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce,Structured,Cinema
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(datatable,data)
|
table.insert(datatable,data)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -2839,11 +2854,11 @@ end
|
|||||||
-- @param #boolean Cinematic (Optional, needs Structured=true) If true, place a fire/smoke effect on the dead static position.
|
-- @param #boolean Cinematic (Optional, needs Structured=true) If true, place a fire/smoke effect on the dead static position.
|
||||||
-- @param #number Effect (Optional for Cinematic) What effect to use. Defaults to a random effect. Smoke presets are: 1=small smoke and fire, 2=medium smoke and fire, 3=large smoke and fire, 4=huge smoke and fire, 5=small smoke, 6=medium smoke, 7=large smoke, 8=huge smoke.
|
-- @param #number Effect (Optional for Cinematic) What effect to use. Defaults to a random effect. Smoke presets are: 1=small smoke and fire, 2=medium smoke and fire, 3=large smoke and fire, 4=huge smoke and fire, 5=small smoke, 6=medium smoke, 7=large smoke, 8=huge smoke.
|
||||||
-- @param #number Density (Optional for Cinematic) What smoke density to use, can be 0 to 1. Defaults to 0.5.
|
-- @param #number Density (Optional for Cinematic) What smoke density to use, can be 0 to 1. Defaults to 0.5.
|
||||||
-- @return Core.Set#SET_GROUP Set of GROUP objects.
|
-- @return Core.Set#SET_GROUP Set of GROUP objects.
|
||||||
-- Returns nil when file cannot be read. Returns a table of data entries if Spawn is false: `{ groupname=groupname, size=size, coordinate=coordinate, template=template }`
|
-- Returns nil when file cannot be read. Returns a table of data entries if Spawn is false: `{ groupname=groupname, size=size, coordinate=coordinate, template=template }`
|
||||||
-- @return #table When using Cinematic: table of names of smoke and fire objects, so they can be extinguished with `COORDINATE.StopBigSmokeAndFire( name )`
|
-- @return #table When using Cinematic: table of names of smoke and fire objects, so they can be extinguished with `COORDINATE.StopBigSmokeAndFire( name )`
|
||||||
function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,Density)
|
function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,Density)
|
||||||
|
|
||||||
local fires = {}
|
local fires = {}
|
||||||
local usedtemplates = {}
|
local usedtemplates = {}
|
||||||
local spawn = true
|
local spawn = true
|
||||||
@@ -2851,14 +2866,14 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,D
|
|||||||
local filename = Filename or "SetOfGroups"
|
local filename = Filename or "SetOfGroups"
|
||||||
local setdata = SET_GROUP:New()
|
local setdata = SET_GROUP:New()
|
||||||
local datatable = {}
|
local datatable = {}
|
||||||
|
|
||||||
local function Smokers(name,coord,effect,density)
|
local function Smokers(name,coord,effect,density)
|
||||||
local eff = math.random(8)
|
local eff = math.random(8)
|
||||||
if type(effect) == "number" then eff = effect end
|
if type(effect) == "number" then eff = effect end
|
||||||
coord:BigSmokeAndFire(eff,density,name)
|
coord:BigSmokeAndFire(eff,density,name)
|
||||||
table.insert(fires,name)
|
table.insert(fires,name)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Cruncher(group,typename,anzahl)
|
local function Cruncher(group,typename,anzahl)
|
||||||
local units = group:GetUnits()
|
local units = group:GetUnits()
|
||||||
local reduced = 0
|
local reduced = 0
|
||||||
@@ -2876,7 +2891,7 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,D
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function PostSpawn(args)
|
local function PostSpawn(args)
|
||||||
local spwndgrp = args[1]
|
local spwndgrp = args[1]
|
||||||
local size = args[2]
|
local size = args[2]
|
||||||
@@ -2886,16 +2901,16 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,D
|
|||||||
local actualsize = spwndgrp:CountAliveUnits()
|
local actualsize = spwndgrp:CountAliveUnits()
|
||||||
if actualsize > size then
|
if actualsize > size then
|
||||||
if Structured and structure then
|
if Structured and structure then
|
||||||
|
|
||||||
local loadedstructure = {}
|
local loadedstructure = {}
|
||||||
local strcset = UTILS.Split(structure,";")
|
local strcset = UTILS.Split(structure,";")
|
||||||
for _,_data in pairs(strcset) do
|
for _,_data in pairs(strcset) do
|
||||||
local datasplit = UTILS.Split(_data,"==")
|
local datasplit = UTILS.Split(_data,"==")
|
||||||
loadedstructure[datasplit[1]] = tonumber(datasplit[2])
|
loadedstructure[datasplit[1]] = tonumber(datasplit[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
local originalstructure = UTILS.GetCountPerTypeName(spwndgrp)
|
local originalstructure = UTILS.GetCountPerTypeName(spwndgrp)
|
||||||
|
|
||||||
for _name,_number in pairs(originalstructure) do
|
for _name,_number in pairs(originalstructure) do
|
||||||
local loadednumber = 0
|
local loadednumber = 0
|
||||||
if loadedstructure[_name] then
|
if loadedstructure[_name] then
|
||||||
@@ -2903,11 +2918,11 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,D
|
|||||||
end
|
end
|
||||||
local reduce = false
|
local reduce = false
|
||||||
if loadednumber < _number then reduce = true end
|
if loadednumber < _number then reduce = true end
|
||||||
|
|
||||||
if reduce then
|
if reduce then
|
||||||
Cruncher(spwndgrp,_name,_number-loadednumber)
|
Cruncher(spwndgrp,_name,_number-loadednumber)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local reduction = actualsize-size
|
local reduction = actualsize-size
|
||||||
@@ -2920,16 +2935,16 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,D
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function MultiUse(Data)
|
local function MultiUse(Data)
|
||||||
local template = Data.template
|
local template = Data.template
|
||||||
if template and usedtemplates[template] and usedtemplates[template].used and usedtemplates[template].used > 1 then
|
if template and usedtemplates[template] and usedtemplates[template].used and usedtemplates[template].used > 1 then
|
||||||
-- multispawn
|
-- multispawn
|
||||||
if not usedtemplates[template].done then
|
if not usedtemplates[template].done then
|
||||||
local spwnd = 0
|
local spwnd = 0
|
||||||
local spawngrp = SPAWN:New(template)
|
local spawngrp = SPAWN:New(template)
|
||||||
spawngrp:InitLimit(0,usedtemplates[template].used)
|
spawngrp:InitLimit(0,usedtemplates[template].used)
|
||||||
for _,_entry in pairs(usedtemplates[template].data) do
|
for _,_entry in pairs(usedtemplates[template].data) do
|
||||||
spwnd = spwnd + 1
|
spwnd = spwnd + 1
|
||||||
local sgrp=spawngrp:SpawnFromCoordinate(_entry.coordinate,spwnd)
|
local sgrp=spawngrp:SpawnFromCoordinate(_entry.coordinate,spwnd)
|
||||||
BASE:ScheduleOnce(0.5,PostSpawn,{sgrp,_entry.size,_entry.structure})
|
BASE:ScheduleOnce(0.5,PostSpawn,{sgrp,_entry.size,_entry.structure})
|
||||||
@@ -2941,7 +2956,7 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,D
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--BASE:I("Spawn = "..tostring(spawn))
|
--BASE:I("Spawn = "..tostring(spawn))
|
||||||
if UTILS.CheckFileExists(Path,filename) then
|
if UTILS.CheckFileExists(Path,filename) then
|
||||||
local outcome,loadeddata = UTILS.LoadFromFile(Path,Filename)
|
local outcome,loadeddata = UTILS.LoadFromFile(Path,Filename)
|
||||||
@@ -2975,13 +2990,13 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn,Structured,Cinematic,Effect,D
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _id,_entry in pairs (datatable) do
|
for _id,_entry in pairs (datatable) do
|
||||||
if spawn and not MultiUse(_entry) and _entry.size > 0 then
|
if spawn and not MultiUse(_entry) and _entry.size > 0 then
|
||||||
local group = SPAWN:New(_entry.template)
|
local group = SPAWN:New(_entry.template)
|
||||||
local sgrp=group:SpawnFromCoordinate(_entry.coordinate)
|
local sgrp=group:SpawnFromCoordinate(_entry.coordinate)
|
||||||
BASE:ScheduleOnce(0.5,PostSpawn,{sgrp,_entry.size,_entry.structure})
|
BASE:ScheduleOnce(0.5,PostSpawn,{sgrp,_entry.size,_entry.structure})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -3010,7 +3025,7 @@ function UTILS.LoadSetOfStatics(Path,Filename)
|
|||||||
if StaticObject then
|
if StaticObject then
|
||||||
datatable:AddObject(StaticObject)
|
datatable:AddObject(StaticObject)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -3026,7 +3041,7 @@ end
|
|||||||
-- @param #number Effect (Optional for Cinematic) What effect to use. Defaults to a random effect. Smoke presets are: 1=small smoke and fire, 2=medium smoke and fire, 3=large smoke and fire, 4=huge smoke and fire, 5=small smoke, 6=medium smoke, 7=large smoke, 8=huge smoke.
|
-- @param #number Effect (Optional for Cinematic) What effect to use. Defaults to a random effect. Smoke presets are: 1=small smoke and fire, 2=medium smoke and fire, 3=large smoke and fire, 4=huge smoke and fire, 5=small smoke, 6=medium smoke, 7=large smoke, 8=huge smoke.
|
||||||
-- @param #number Density (Optional for Cinematic) What smoke density to use, can be 0 to 1. Defaults to 0.5.
|
-- @param #number Density (Optional for Cinematic) What smoke density to use, can be 0 to 1. Defaults to 0.5.
|
||||||
-- @return #table Table of data objects (tables) containing staticname, size (0=dead else 1), coordinate and the static object. Dead objects will have coordinate points `{x=0,y=0,z=0}`
|
-- @return #table Table of data objects (tables) containing staticname, size (0=dead else 1), coordinate and the static object. Dead objects will have coordinate points `{x=0,y=0,z=0}`
|
||||||
-- @return #table When using Cinematic: table of names of smoke and fire objects, so they can be extinguished with `COORDINATE.StopBigSmokeAndFire( name )`
|
-- @return #table When using Cinematic: table of names of smoke and fire objects, so they can be extinguished with `COORDINATE.StopBigSmokeAndFire( name )`
|
||||||
-- Returns nil when file cannot be read.
|
-- Returns nil when file cannot be read.
|
||||||
function UTILS.LoadStationaryListOfStatics(Path,Filename,Reduce,Dead,Cinematic,Effect,Density)
|
function UTILS.LoadStationaryListOfStatics(Path,Filename,Reduce,Dead,Cinematic,Effect,Density)
|
||||||
local fires = {}
|
local fires = {}
|
||||||
@@ -3062,7 +3077,7 @@ function UTILS.LoadStationaryListOfStatics(Path,Filename,Reduce,Dead,Cinematic,E
|
|||||||
if Cinematic then
|
if Cinematic then
|
||||||
local effect = math.random(8)
|
local effect = math.random(8)
|
||||||
if type(Effect) == "number" then
|
if type(Effect) == "number" then
|
||||||
effect = Effect
|
effect = Effect
|
||||||
end
|
end
|
||||||
coord:BigSmokeAndFire(effect,Density,staticname)
|
coord:BigSmokeAndFire(effect,Density,staticname)
|
||||||
table.insert(fires,staticname)
|
table.insert(fires,staticname)
|
||||||
@@ -3072,7 +3087,7 @@ function UTILS.LoadStationaryListOfStatics(Path,Filename,Reduce,Dead,Cinematic,E
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -3120,10 +3135,10 @@ function UTILS.ToStringBRAANATO(FromGrp,ToGrp)
|
|||||||
if aspect == "" then
|
if aspect == "" then
|
||||||
BRAANATO = string.format("%s, BRA, %03d, %d miles, Angels %d, Track %s",GroupWords,bearing, rangeNM, alt, track)
|
BRAANATO = string.format("%s, BRA, %03d, %d miles, Angels %d, Track %s",GroupWords,bearing, rangeNM, alt, track)
|
||||||
else
|
else
|
||||||
BRAANATO = string.format("%s, BRAA, %03d, %d miles, Angels %d, %s, Track %s",GroupWords, bearing, rangeNM, alt, aspect, track)
|
BRAANATO = string.format("%s, BRAA, %03d, %d miles, Angels %d, %s, Track %s",GroupWords, bearing, rangeNM, alt, aspect, track)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return BRAANATO
|
return BRAANATO
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if an object is contained in a table.
|
--- Check if an object is contained in a table.
|
||||||
@@ -3168,7 +3183,7 @@ function UTILS.IsAnyInTable(Table, Objects, Key)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -3184,30 +3199,30 @@ end
|
|||||||
-- @param #table Color Color of the line in RGB, e.g. {1,0,0} for red
|
-- @param #table Color Color of the line in RGB, e.g. {1,0,0} for red
|
||||||
-- @param #number Alpha Transparency factor, between 0.1 and 1
|
-- @param #number Alpha Transparency factor, between 0.1 and 1
|
||||||
-- @param #number LineType Line type to be used, line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
-- @param #number LineType Line type to be used, 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
|
-- @param #boolean ReadOnly
|
||||||
function UTILS.PlotRacetrack(Coordinate, Altitude, Speed, Heading, Leg, Coalition, Color, Alpha, LineType, ReadOnly)
|
function UTILS.PlotRacetrack(Coordinate, Altitude, Speed, Heading, Leg, Coalition, Color, Alpha, LineType, ReadOnly)
|
||||||
local fix_coordinate = Coordinate
|
local fix_coordinate = Coordinate
|
||||||
local altitude = Altitude
|
local altitude = Altitude
|
||||||
local speed = Speed or 350
|
local speed = Speed or 350
|
||||||
local heading = Heading or 270
|
local heading = Heading or 270
|
||||||
local leg_distance = Leg or 10
|
local leg_distance = Leg or 10
|
||||||
|
|
||||||
local coalition = Coalition or -1
|
local coalition = Coalition or -1
|
||||||
local color = Color or {1,0,0}
|
local color = Color or {1,0,0}
|
||||||
local alpha = Alpha or 1
|
local alpha = Alpha or 1
|
||||||
local lineType = LineType or 1
|
local lineType = LineType or 1
|
||||||
|
|
||||||
|
|
||||||
speed = UTILS.IasToTas(speed, UTILS.FeetToMeters(altitude), oatcorr)
|
speed = UTILS.IasToTas(speed, UTILS.FeetToMeters(altitude), oatcorr)
|
||||||
|
|
||||||
local turn_radius = 0.0211 * speed -3.01
|
local turn_radius = 0.0211 * speed -3.01
|
||||||
|
|
||||||
local point_two = fix_coordinate:Translate(UTILS.NMToMeters(leg_distance), heading, true, false)
|
local point_two = fix_coordinate:Translate(UTILS.NMToMeters(leg_distance), heading, true, false)
|
||||||
local point_three = point_two:Translate(UTILS.NMToMeters(turn_radius)*2, heading - 90, true, false)
|
local point_three = point_two:Translate(UTILS.NMToMeters(turn_radius)*2, heading - 90, true, false)
|
||||||
local point_four = fix_coordinate:Translate(UTILS.NMToMeters(turn_radius)*2, heading - 90, true, false)
|
local point_four = fix_coordinate:Translate(UTILS.NMToMeters(turn_radius)*2, heading - 90, true, false)
|
||||||
local circle_center_fix_four = point_two:Translate(UTILS.NMToMeters(turn_radius), heading - 90, true, false)
|
local circle_center_fix_four = point_two:Translate(UTILS.NMToMeters(turn_radius), heading - 90, true, false)
|
||||||
local circle_center_two_three = fix_coordinate:Translate(UTILS.NMToMeters(turn_radius), heading - 90, true, false)
|
local circle_center_two_three = fix_coordinate:Translate(UTILS.NMToMeters(turn_radius), heading - 90, true, false)
|
||||||
|
|
||||||
|
|
||||||
fix_coordinate:LineToAll(point_two, coalition, color, alpha, lineType)
|
fix_coordinate:LineToAll(point_two, coalition, color, alpha, lineType)
|
||||||
point_four:LineToAll(point_three, coalition, color, alpha, lineType)
|
point_four:LineToAll(point_three, coalition, color, alpha, lineType)
|
||||||
@@ -3513,6 +3528,25 @@ function string.contains(str, value)
|
|||||||
return string.match(str, value)
|
return string.match(str, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Moves an object from one table to another
|
||||||
|
-- @param #obj object to move
|
||||||
|
-- @param #from_table table to move from
|
||||||
|
-- @param #to_table table to move to
|
||||||
|
function table.move_object(obj, from_table, to_table)
|
||||||
|
local index
|
||||||
|
for i, v in pairs(from_table) do
|
||||||
|
if v == obj then
|
||||||
|
index = i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if index then
|
||||||
|
local moved = table.remove(from_table, index)
|
||||||
|
table.insert_unique(to_table, moved)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Given tbl is a indexed table ({"hello", "dcs", "world"}), checks if element exists in the table.
|
--- Given tbl is a indexed table ({"hello", "dcs", "world"}), checks if element exists in the table.
|
||||||
--- The table can be made up out of complex tables or values as well
|
--- The table can be made up out of complex tables or values as well
|
||||||
-- @param #table tbl
|
-- @param #table tbl
|
||||||
@@ -3731,6 +3765,25 @@ function UTILS.OctalToDecimal(Number)
|
|||||||
return tonumber(Number,8)
|
return tonumber(Number,8)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- HexToRGBA
|
||||||
|
-- @param hex_string table
|
||||||
|
-- @return #table R, G, B, A
|
||||||
|
function UTILS.HexToRGBA(hex_string)
|
||||||
|
local hexNumber = tonumber(string.sub(hex_string, 3), 16) -- convert the string to a number
|
||||||
|
-- extract RGBA components
|
||||||
|
local alpha = hexNumber % 256
|
||||||
|
hexNumber = (hexNumber - alpha) / 256
|
||||||
|
local blue = hexNumber % 256
|
||||||
|
hexNumber = (hexNumber - blue) / 256
|
||||||
|
local green = hexNumber % 256
|
||||||
|
hexNumber = (hexNumber - green) / 256
|
||||||
|
local red = hexNumber % 256
|
||||||
|
|
||||||
|
return {R = red, G = green, B = blue, A = alpha}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Function to save the position of a set of #OPSGROUP (ARMYGROUP) objects.
|
--- Function to save the position of a set of #OPSGROUP (ARMYGROUP) objects.
|
||||||
-- @param Core.Set#SET_OPSGROUP Set of ops objects to save
|
-- @param Core.Set#SET_OPSGROUP Set of ops objects to save
|
||||||
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
|
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
|
||||||
@@ -3768,7 +3821,7 @@ function UTILS.SaveSetOfOpsGroups(Set,Path,Filename,Structured)
|
|||||||
data = string.format("%s%s,%s,%s,%s,%d,%d,%d,%d,%s\n",data,name,legion,template,alttemplate,units,position.x,position.y,position.z,strucdata)
|
data = string.format("%s%s,%s,%s,%s,%d,%d,%d,%d,%s\n",data,name,legion,template,alttemplate,units,position.x,position.y,position.z,strucdata)
|
||||||
else
|
else
|
||||||
data = string.format("%s%s,%s,%s,%s,%d,%d,%d,%d\n",data,name,legion,template,alttemplate,units,position.x,position.y,position.z)
|
data = string.format("%s%s,%s,%s,%s,%d,%d,%d,%d\n",data,name,legion,template,alttemplate,units,position.x,position.y,position.z)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- save the data
|
-- save the data
|
||||||
@@ -3780,12 +3833,12 @@ end
|
|||||||
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
|
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
|
||||||
-- @param #string Filename The name of the file.
|
-- @param #string Filename The name of the file.
|
||||||
-- @return #table Returns a table of data entries: `{ groupname=groupname, size=size, coordinate=coordinate, template=template, structure=structure, legion=legion, alttemplate=alttemplate }`
|
-- @return #table Returns a table of data entries: `{ groupname=groupname, size=size, coordinate=coordinate, template=template, structure=structure, legion=legion, alttemplate=alttemplate }`
|
||||||
-- Returns nil when the file cannot be read.
|
-- Returns nil when the file cannot be read.
|
||||||
function UTILS.LoadSetOfOpsGroups(Path,Filename)
|
function UTILS.LoadSetOfOpsGroups(Path,Filename)
|
||||||
|
|
||||||
local filename = Filename or "SetOfGroups"
|
local filename = Filename or "SetOfGroups"
|
||||||
local datatable = {}
|
local datatable = {}
|
||||||
|
|
||||||
if UTILS.CheckFileExists(Path,filename) then
|
if UTILS.CheckFileExists(Path,filename) then
|
||||||
local outcome,loadeddata = UTILS.LoadFromFile(Path,Filename)
|
local outcome,loadeddata = UTILS.LoadFromFile(Path,Filename)
|
||||||
-- remove header
|
-- remove header
|
||||||
@@ -3820,20 +3873,20 @@ end
|
|||||||
-- @param #number tgtHdg The absolute heading from the reference object to the target object/point in 0-360
|
-- @param #number tgtHdg The absolute heading from the reference object to the target object/point in 0-360
|
||||||
-- @return #string text Text in clock heading such as "4 O'CLOCK"
|
-- @return #string text Text in clock heading such as "4 O'CLOCK"
|
||||||
-- @usage Display the range and clock distance of a BTR in relation to REAPER 1-1's heading:
|
-- @usage Display the range and clock distance of a BTR in relation to REAPER 1-1's heading:
|
||||||
--
|
--
|
||||||
-- myUnit = UNIT:FindByName( "REAPER 1-1" )
|
-- myUnit = UNIT:FindByName( "REAPER 1-1" )
|
||||||
-- myTarget = GROUP:FindByName( "BTR-1" )
|
-- myTarget = GROUP:FindByName( "BTR-1" )
|
||||||
--
|
--
|
||||||
-- coordUnit = myUnit:GetCoordinate()
|
-- coordUnit = myUnit:GetCoordinate()
|
||||||
-- coordTarget = myTarget:GetCoordinate()
|
-- coordTarget = myTarget:GetCoordinate()
|
||||||
--
|
--
|
||||||
-- hdgUnit = myUnit:GetHeading()
|
-- hdgUnit = myUnit:GetHeading()
|
||||||
-- hdgTarget = coordUnit:HeadingTo( coordTarget )
|
-- hdgTarget = coordUnit:HeadingTo( coordTarget )
|
||||||
-- distTarget = coordUnit:Get3DDistance( coordTarget )
|
-- distTarget = coordUnit:Get3DDistance( coordTarget )
|
||||||
--
|
--
|
||||||
-- clockString = UTILS.ClockHeadingString( hdgUnit, hdgTarget )
|
-- clockString = UTILS.ClockHeadingString( hdgUnit, hdgTarget )
|
||||||
--
|
--
|
||||||
-- -- Will show this message to REAPER 1-1 in-game: Contact BTR at 3 o'clock for 1134m!
|
-- -- Will show this message to REAPER 1-1 in-game: Contact BTR at 3 o'clock for 1134m!
|
||||||
-- MESSAGE:New("Contact BTR at " .. clockString .. " for " .. distTarget .. "m!):ToUnit( myUnit )
|
-- MESSAGE:New("Contact BTR at " .. clockString .. " for " .. distTarget .. "m!):ToUnit( myUnit )
|
||||||
function UTILS.ClockHeadingString(refHdg,tgtHdg)
|
function UTILS.ClockHeadingString(refHdg,tgtHdg)
|
||||||
local relativeAngle = tgtHdg - refHdg
|
local relativeAngle = tgtHdg - refHdg
|
||||||
@@ -3843,3 +3896,46 @@ function UTILS.ClockHeadingString(refHdg,tgtHdg)
|
|||||||
local clockPos = math.ceil((relativeAngle % 360) / 30)
|
local clockPos = math.ceil((relativeAngle % 360) / 30)
|
||||||
return clockPos.." o'clock"
|
return clockPos.." o'clock"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get a NATO abbreviated MGRS text for SRS use, optionally with prosody slow tag
|
||||||
|
-- @param #string Text The input string, e.g. "MGRS 4Q FJ 12345 67890"
|
||||||
|
-- @param #boolean Slow Optional - add slow tags
|
||||||
|
-- @return #string Output for (Slow) spelling in SRS TTS e.g. "MGRS;<prosody rate="slow">4;Quebec;Foxtrot;Juliett;1;2;3;4;5;6;7;8;niner;zero;</prosody>"
|
||||||
|
function UTILS.MGRSStringToSRSFriendly(Text,Slow)
|
||||||
|
local Text = string.gsub(Text,"MGRS ","")
|
||||||
|
Text = string.gsub(Text,"%s+","")
|
||||||
|
Text = string.gsub(Text,"([%a%d])","%1;") -- "0;5;1;"
|
||||||
|
Text = string.gsub(Text,"A","Alpha")
|
||||||
|
Text = string.gsub(Text,"B","Bravo")
|
||||||
|
Text = string.gsub(Text,"C","Charlie")
|
||||||
|
Text = string.gsub(Text,"D","Delta")
|
||||||
|
Text = string.gsub(Text,"E","Echo")
|
||||||
|
Text = string.gsub(Text,"F","Foxtrot")
|
||||||
|
Text = string.gsub(Text,"G","Golf")
|
||||||
|
Text = string.gsub(Text,"H","Hotel")
|
||||||
|
Text = string.gsub(Text,"I","India")
|
||||||
|
Text = string.gsub(Text,"J","Juliett")
|
||||||
|
Text = string.gsub(Text,"K","Kilo")
|
||||||
|
Text = string.gsub(Text,"L","Lima")
|
||||||
|
Text = string.gsub(Text,"M","Mike")
|
||||||
|
Text = string.gsub(Text,"N","November")
|
||||||
|
Text = string.gsub(Text,"O","Oscar")
|
||||||
|
Text = string.gsub(Text,"P","Papa")
|
||||||
|
Text = string.gsub(Text,"Q","Quebec")
|
||||||
|
Text = string.gsub(Text,"R","Romeo")
|
||||||
|
Text = string.gsub(Text,"S","Sierra")
|
||||||
|
Text = string.gsub(Text,"T","Tango")
|
||||||
|
Text = string.gsub(Text,"U","Uniform")
|
||||||
|
Text = string.gsub(Text,"V","Victor")
|
||||||
|
Text = string.gsub(Text,"W","Whiskey")
|
||||||
|
Text = string.gsub(Text,"X","Xray")
|
||||||
|
Text = string.gsub(Text,"Y","Yankee")
|
||||||
|
Text = string.gsub(Text,"Z","Zulu")
|
||||||
|
Text = string.gsub(Text,"0","zero")
|
||||||
|
Text = string.gsub(Text,"9","niner")
|
||||||
|
if Slow then
|
||||||
|
Text = '<prosody rate="slow">'..Text..'</prosody>'
|
||||||
|
end
|
||||||
|
Text = "MGRS;"..Text
|
||||||
|
return Text
|
||||||
|
end
|
||||||
|
|||||||
@@ -720,6 +720,39 @@ AIRBASE.Sinai = {
|
|||||||
["Wadi_al_Jandali"] = "Wadi al Jandali",
|
["Wadi_al_Jandali"] = "Wadi al Jandali",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Airbases of the Kola map
|
||||||
|
--
|
||||||
|
-- * AIRBASE.Kola.Banak
|
||||||
|
-- * AIRBASE.Kola.Bas_100
|
||||||
|
-- * AIRBASE.Kola.Bodo
|
||||||
|
-- * AIRBASE.Kola.Jokkmokk
|
||||||
|
-- * AIRBASE.Kola.Kalixfors
|
||||||
|
-- * AIRBASE.Kola.Kemi_Tornio
|
||||||
|
-- * AIRBASE.Kola.Kiruna
|
||||||
|
-- * AIRBASE.Kola.Monchegorsk
|
||||||
|
-- * AIRBASE.Kola.Murmansk_International
|
||||||
|
-- * AIRBASE.Kola.Olenya
|
||||||
|
-- * AIRBASE.Kola.Rovaniemi
|
||||||
|
-- * AIRBASE.Kola.Severomorsk_1
|
||||||
|
-- * AIRBASE.Kola.Severomorsk_3
|
||||||
|
--
|
||||||
|
-- @field Kola
|
||||||
|
AIRBASE.Kola = {
|
||||||
|
["Banak"] = "Banak",
|
||||||
|
["Bas_100"] = "Bas 100",
|
||||||
|
["Bodo"] = "Bodo",
|
||||||
|
["Jokkmokk"] = "Jokkmokk",
|
||||||
|
["Kalixfors"] = "Kalixfors",
|
||||||
|
["Kemi_Tornio"] = "Kemi Tornio",
|
||||||
|
["Kiruna"] = "Kiruna",
|
||||||
|
["Monchegorsk"] = "Monchegorsk",
|
||||||
|
["Murmansk_International"] = "Murmansk International",
|
||||||
|
["Olenya"] = "Olenya",
|
||||||
|
["Rovaniemi"] = "Rovaniemi",
|
||||||
|
["Severomorsk_1"] = "Severomorsk-1",
|
||||||
|
["Severomorsk_3"] = "Severomorsk-3",
|
||||||
|
}
|
||||||
|
|
||||||
--- AIRBASE.ParkingSpot ".Coordinate, ".TerminalID", ".TerminalType", ".TOAC", ".Free", ".TerminalID0", ".DistToRwy".
|
--- AIRBASE.ParkingSpot ".Coordinate, ".TerminalID", ".TerminalType", ".TOAC", ".Free", ".TerminalID0", ".DistToRwy".
|
||||||
-- @type AIRBASE.ParkingSpot
|
-- @type AIRBASE.ParkingSpot
|
||||||
-- @field Core.Point#COORDINATE Coordinate Coordinate of the parking spot.
|
-- @field Core.Point#COORDINATE Coordinate Coordinate of the parking spot.
|
||||||
@@ -760,11 +793,13 @@ AIRBASE.Sinai = {
|
|||||||
-- @field #number OpenMedOrBig 176: Combines OpenMed and OpenBig spots.
|
-- @field #number OpenMedOrBig 176: Combines OpenMed and OpenBig spots.
|
||||||
-- @field #number HelicopterUsable 216: Combines HelicopterOnly, OpenMed and OpenBig.
|
-- @field #number HelicopterUsable 216: Combines HelicopterOnly, OpenMed and OpenBig.
|
||||||
-- @field #number FighterAircraft 244: Combines Shelter. OpenMed and OpenBig spots. So effectively all spots usable by fixed wing aircraft.
|
-- @field #number FighterAircraft 244: Combines Shelter. OpenMed and OpenBig spots. So effectively all spots usable by fixed wing aircraft.
|
||||||
|
-- @field #number SmallSizeFigher 100: Tight spots for smaller type fixed wing aircraft, like the F-16. Example of these spots: 04, 05, 06 on Muwaffaq_Salti. A Viper sized plane can spawn here, but an A-10 or Strike Eagle can't
|
||||||
AIRBASE.TerminalType = {
|
AIRBASE.TerminalType = {
|
||||||
Runway=16,
|
Runway=16,
|
||||||
HelicopterOnly=40,
|
HelicopterOnly=40,
|
||||||
Shelter=68,
|
Shelter=68,
|
||||||
OpenMed=72,
|
OpenMed=72,
|
||||||
|
SmallSizeFighter=100,
|
||||||
OpenBig=104,
|
OpenBig=104,
|
||||||
OpenMedOrBig=176,
|
OpenMedOrBig=176,
|
||||||
HelicopterUsable=216,
|
HelicopterUsable=216,
|
||||||
@@ -1494,7 +1529,7 @@ function AIRBASE:GetFreeParkingSpotsTable(termtype, allowTOAC)
|
|||||||
-- Put coordinates of free spots into table.
|
-- Put coordinates of free spots into table.
|
||||||
local freespots={}
|
local freespots={}
|
||||||
for _,_spot in pairs(parkingfree) do
|
for _,_spot in pairs(parkingfree) do
|
||||||
if AIRBASE._CheckTerminalType(_spot.Term_Type, termtype) and _spot.Term_Index>0 then
|
if AIRBASE._CheckTerminalType(_spot.Term_Type, termtype) then -- and _spot.Term_Index>0 then --Not sure why I had this in. But caused problems now for a Gas platform where a valid spot was not included!
|
||||||
if (allowTOAC and allowTOAC==true) or _spot.TO_AC==false then
|
if (allowTOAC and allowTOAC==true) or _spot.TO_AC==false then
|
||||||
|
|
||||||
local spot=self:_GetParkingSpotByID(_spot.Term_Index)
|
local spot=self:_GetParkingSpotByID(_spot.Term_Index)
|
||||||
@@ -1841,7 +1876,7 @@ function AIRBASE._CheckTerminalType(Term_Type, termtype)
|
|||||||
match=true
|
match=true
|
||||||
end
|
end
|
||||||
elseif termtype==AIRBASE.TerminalType.FighterAircraft then
|
elseif termtype==AIRBASE.TerminalType.FighterAircraft then
|
||||||
if Term_Type==AIRBASE.TerminalType.OpenMed or Term_Type==AIRBASE.TerminalType.OpenBig or Term_Type==AIRBASE.TerminalType.Shelter then
|
if Term_Type==AIRBASE.TerminalType.OpenMed or Term_Type==AIRBASE.TerminalType.OpenBig or Term_Type==AIRBASE.TerminalType.Shelter or Term_Type==AIRBASE.TerminalType.SmallSizeFighter then
|
||||||
match=true
|
match=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -359,12 +359,15 @@ end
|
|||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return DCS#Group The DCS Group.
|
-- @return DCS#Group The DCS Group.
|
||||||
function GROUP:GetDCSObject()
|
function GROUP:GetDCSObject()
|
||||||
|
|
||||||
|
-- Get DCS group.
|
||||||
local DCSGroup = Group.getByName( self.GroupName )
|
local DCSGroup = Group.getByName( self.GroupName )
|
||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
return DCSGroup
|
return DCSGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:T2(string.format("ERROR: Could not get DCS group object of group %s because DCS object could not be found!", tostring(self.GroupName)))
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1187,13 +1190,12 @@ 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 Units = self:GetUnits() or {}
|
local Units = self:GetUnits() or {}
|
||||||
|
|
||||||
for _,_unit in pairs(Units) do
|
for _,_unit in pairs(Units) do
|
||||||
local FirstUnit = _unit -- Wrapper.Unit#UNIT
|
local FirstUnit = _unit -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
if FirstUnit then
|
if FirstUnit and FirstUnit:IsAlive() then
|
||||||
|
|
||||||
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
|
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
|
||||||
|
|
||||||
@@ -1205,6 +1207,24 @@ function GROUP:GetCoordinate()
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- no luck, try the API way
|
||||||
|
|
||||||
|
local DCSGroup = Group.getByName(self.GroupName)
|
||||||
|
if DCSGroup then
|
||||||
|
local DCSUnits = DCSGroup:getUnits() or {}
|
||||||
|
for _,_unit in pairs(DCSUnits) do
|
||||||
|
if Object.isExist(_unit) then
|
||||||
|
local position = _unit:getPosition()
|
||||||
|
local point = position.p ~= nil and position.p or _unit:GetPoint()
|
||||||
|
if point then
|
||||||
|
--self:I(point)
|
||||||
|
local coord = COORDINATE:NewFromVec3(point)
|
||||||
|
return coord
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
BASE:E( { "Cannot GetCoordinate", Group = self, Alive = self:IsAlive() } )
|
BASE:E( { "Cannot GetCoordinate", Group = self, Alive = self:IsAlive() } )
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1758,10 +1778,14 @@ end
|
|||||||
|
|
||||||
--- Returns the group template from the global _DATABASE object (an instance of @{Core.Database#DATABASE}).
|
--- Returns the group template from the global _DATABASE object (an instance of @{Core.Database#DATABASE}).
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return #table
|
-- @return #table Template table.
|
||||||
function GROUP:GetTemplate()
|
function GROUP:GetTemplate()
|
||||||
local GroupName = self:GetName()
|
local GroupName = self:GetName()
|
||||||
return UTILS.DeepCopy( _DATABASE:GetGroupTemplate( GroupName ) )
|
local template=_DATABASE:GetGroupTemplate( GroupName )
|
||||||
|
if template then
|
||||||
|
return UTILS.DeepCopy( template )
|
||||||
|
end
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the group template route.points[] (the waypoints) from the global _DATABASE object (an instance of @{Core.Database#DATABASE}).
|
--- Returns the group template route.points[] (the waypoints) from the global _DATABASE object (an instance of @{Core.Database#DATABASE}).
|
||||||
|
|||||||
@@ -723,7 +723,7 @@ end
|
|||||||
--- Converts a JSON string to a lua value.
|
--- Converts a JSON string to a lua value.
|
||||||
-- @param #string Json Anything JSON
|
-- @param #string Json Anything JSON
|
||||||
-- @return #table Lua
|
-- @return #table Lua
|
||||||
function NET.Lua2Json(Json)
|
function NET.Json2Lua(Json)
|
||||||
return net.json2lua(Json)
|
return net.json2lua(Json)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
-- @field #number coalition Coalition ID.
|
-- @field #number coalition Coalition ID.
|
||||||
-- @field #number country Country ID.
|
-- @field #number country Country ID.
|
||||||
-- @field DCS#Desc desc Descriptor table.
|
-- @field DCS#Desc desc Descriptor table.
|
||||||
|
-- @field DCS#Desc guidance Missile guidance descriptor.
|
||||||
-- @field DCS#Unit launcher Launcher DCS unit.
|
-- @field DCS#Unit launcher Launcher DCS unit.
|
||||||
-- @field Wrapper.Unit#UNIT launcherUnit Launcher Unit.
|
-- @field Wrapper.Unit#UNIT launcherUnit Launcher Unit.
|
||||||
-- @field #string launcherName Name of launcher unit.
|
-- @field #string launcherName Name of launcher unit.
|
||||||
@@ -196,6 +197,9 @@ function WEAPON:New(WeaponObject)
|
|||||||
|
|
||||||
if self:IsMissile() and self.desc.missileCategory then
|
if self:IsMissile() and self.desc.missileCategory then
|
||||||
self.categoryMissile=self.desc.missileCategory
|
self.categoryMissile=self.desc.missileCategory
|
||||||
|
if self.desc.guidance then
|
||||||
|
self.guidance = self.desc.guidance
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get type name.
|
-- Get type name.
|
||||||
@@ -667,6 +671,26 @@ function WEAPON:IsTorpedo()
|
|||||||
return self.category==Weapon.Category.TORPEDO
|
return self.category==Weapon.Category.TORPEDO
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if weapon is a Fox One missile (Radar Semi-Active).
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @return #boolean If `true`, is a Fox One.
|
||||||
|
function WEAPON:IsFoxOne()
|
||||||
|
return self.guidance==Weapon.GuidanceType.RADAR_SEMI_ACTIVE
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if weapon is a Fox Two missile (IR guided).
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @return #boolean If `true`, is a Fox Two.
|
||||||
|
function WEAPON:IsFoxTwo()
|
||||||
|
return self.guidance==Weapon.GuidanceType.IR
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if weapon is a Fox Three missile (Radar Active).
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @return #boolean If `true`, is a Fox Three.
|
||||||
|
function WEAPON:IsFoxThree()
|
||||||
|
return self.guidance==Weapon.GuidanceType.RADAR_ACTIVE
|
||||||
|
end
|
||||||
|
|
||||||
--- Destroy the weapon object.
|
--- Destroy the weapon object.
|
||||||
-- @param #WEAPON self
|
-- @param #WEAPON self
|
||||||
|
|||||||
Reference in New Issue
Block a user