mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Compare commits
289 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6de09a0ca | ||
|
|
4668132b37 | ||
|
|
ceb77e2837 | ||
|
|
137f0251fb | ||
|
|
16dc3860f7 | ||
|
|
333ed629bb | ||
|
|
c87e91d845 | ||
|
|
778ae1b8e5 | ||
|
|
6df4fffafd | ||
|
|
783e29f189 | ||
|
|
af39a3ae9c | ||
|
|
c985d40ca0 | ||
|
|
90b588420f | ||
|
|
3a0d2a5c51 | ||
|
|
07a76ced88 | ||
|
|
a3805118a0 | ||
|
|
2e6957984f | ||
|
|
433a66d530 | ||
|
|
7d3ad15f39 | ||
|
|
d0728afee7 | ||
|
|
01330bf00c | ||
|
|
01de638b8e | ||
|
|
3e8c7ad1df | ||
|
|
22c6a03161 | ||
|
|
dd8b2caa24 | ||
|
|
1e4cfd473c | ||
|
|
044fb66ca0 | ||
|
|
cc17027a7a | ||
|
|
fc52e06318 | ||
|
|
27d36f3e0d | ||
|
|
d3419d218a | ||
|
|
f9dcc9d95c | ||
|
|
a0b49fbd67 | ||
|
|
ae213c4cf1 | ||
|
|
8dea86b921 | ||
|
|
44003a8fda | ||
|
|
b883bb1e62 | ||
|
|
db35a67bd7 | ||
|
|
bc5946c76e | ||
|
|
3d7172fdf7 | ||
|
|
28411d2093 | ||
|
|
26deaca166 | ||
|
|
95baed1aac | ||
|
|
3b364c7650 | ||
|
|
2a4e242eb2 | ||
|
|
8b2237d183 | ||
|
|
abc26b1e5c | ||
|
|
b761078c18 | ||
|
|
616690391c | ||
|
|
465c395294 | ||
|
|
73bddddba4 | ||
|
|
9a3effd063 | ||
|
|
b9bd8d88a9 | ||
|
|
18fd587ab0 | ||
|
|
ba14330281 | ||
|
|
2eb4118d56 | ||
|
|
dcc15afb89 | ||
|
|
67b43e2c68 | ||
|
|
2ad111dd50 | ||
|
|
ac42b56b8e | ||
|
|
874fa7ad69 | ||
|
|
70c29de695 | ||
|
|
b263cddc07 | ||
|
|
613d33d731 | ||
|
|
50298e4109 | ||
|
|
244abe2bbb | ||
|
|
378e76e45b | ||
|
|
241b31fcec | ||
|
|
3dd069d7d6 | ||
|
|
aca4e4d7ca | ||
|
|
2f81fcb0c0 | ||
|
|
8cf11de774 | ||
|
|
176bd0eb8b | ||
|
|
10edd2f9d0 | ||
|
|
11acb578f6 | ||
|
|
4d8abe7f57 | ||
|
|
ab14fbd11c | ||
|
|
cb61177252 | ||
|
|
1e15509001 | ||
|
|
bfa8719ec3 | ||
|
|
3652376d42 | ||
|
|
3953f0e7fc | ||
|
|
5621579b5e | ||
|
|
57ce6bcec2 | ||
|
|
71b5492903 | ||
|
|
d64dadd9a9 | ||
|
|
0f30f3b1a0 | ||
|
|
51911d3292 | ||
|
|
bff60bdb69 | ||
|
|
aac3f64638 | ||
|
|
74c19f1058 | ||
|
|
1cbdafda65 | ||
|
|
595b9132e8 | ||
|
|
45aebff48e | ||
|
|
f2e22579ed | ||
|
|
1f9725530f | ||
|
|
c85f575888 | ||
|
|
5eef138507 | ||
|
|
14d6085b69 | ||
|
|
ced01a993d | ||
|
|
02e59b23c5 | ||
|
|
4c2a89ee29 | ||
|
|
e8c75b8795 | ||
|
|
2ce9f26e26 | ||
|
|
30819dad72 | ||
|
|
2eeca4451c | ||
|
|
27ea85ea57 | ||
|
|
0faa0036ee | ||
|
|
f859522052 | ||
|
|
5a772ad05e | ||
|
|
51f134538d | ||
|
|
0ee7a38c61 | ||
|
|
15dd2cf735 | ||
|
|
e895642157 | ||
|
|
154026fbf8 | ||
|
|
7dcff7ec9c | ||
|
|
67e52120d4 | ||
|
|
4b84d227f0 | ||
|
|
86e13df303 | ||
|
|
2e167358bb | ||
|
|
48dba742ad | ||
|
|
531132e8a7 | ||
|
|
7464406a17 | ||
|
|
0ddf8762c2 | ||
|
|
d984a1b142 | ||
|
|
748aa131e4 | ||
|
|
33bd928076 | ||
|
|
0b3fc515e0 | ||
|
|
581138b5bc | ||
|
|
08f2c29014 | ||
|
|
dcd4d0ab62 | ||
|
|
bb07e1935e | ||
|
|
088436c5ce | ||
|
|
797bf0047b | ||
|
|
f29d055ca3 | ||
|
|
1468641563 | ||
|
|
8b08942c4d | ||
|
|
eb84ad3cee | ||
|
|
91a34ac4d8 | ||
|
|
28c8d99878 | ||
|
|
4fda8cc5fb | ||
|
|
4ac583e434 | ||
|
|
fa762fe0fc | ||
|
|
aca5846209 | ||
|
|
4fd7d7cba9 | ||
|
|
9280a1224d | ||
|
|
fce7b07014 | ||
|
|
4696569f83 | ||
|
|
84230e2360 | ||
|
|
ca9913e38b | ||
|
|
ff951c69d9 | ||
|
|
f2f7c88299 | ||
|
|
f5d6d31b10 | ||
|
|
9b95e71d75 | ||
|
|
db6dc7b77e | ||
|
|
4c81333a0a | ||
|
|
79b1f1615f | ||
|
|
47f010cb28 | ||
|
|
d14b7e8f4c | ||
|
|
d9748ef147 | ||
|
|
64d7946c06 | ||
|
|
b052fc6243 | ||
|
|
8385b1d21a | ||
|
|
d4f4465b0a | ||
|
|
5fe77956cb | ||
|
|
d640acc7cc | ||
|
|
8dcd22f18c | ||
|
|
2d086a62f0 | ||
|
|
47ad2499d4 | ||
|
|
5d510807c9 | ||
|
|
5ba8f9e0e8 | ||
|
|
0338fd5d33 | ||
|
|
ea2175bba8 | ||
|
|
0835022c5c | ||
|
|
f306361317 | ||
|
|
0347e42fc7 | ||
|
|
9cc32ff8dc | ||
|
|
b052d99349 | ||
|
|
4fe1318e7c | ||
|
|
6ffe69484c | ||
|
|
501ab70992 | ||
|
|
6ac46addf0 | ||
|
|
3bdf4b4c76 | ||
|
|
46f70dd8a6 | ||
|
|
aeac2eb3d7 | ||
|
|
e83c8c3ee0 | ||
|
|
d65042c640 | ||
|
|
c72cdd8f0b | ||
|
|
7e2f8771b5 | ||
|
|
3ccfcdbd0f | ||
|
|
16f3dcbbb4 | ||
|
|
f6f3189504 | ||
|
|
071554bfc5 | ||
|
|
1527b53c76 | ||
|
|
bbc7f7e14c | ||
|
|
b9830a8437 | ||
|
|
caaee4f551 | ||
|
|
5f7115f4fe | ||
|
|
9ec92a8fca | ||
|
|
7cc040c234 | ||
|
|
9227ba9ecd | ||
|
|
e7fb073bab | ||
|
|
f86b3505b2 | ||
|
|
e89b921f3e | ||
|
|
0d18ce086c | ||
|
|
8fb126682f | ||
|
|
ebe486c69a | ||
|
|
702ec75935 | ||
|
|
465ec216ea | ||
|
|
d803b51e84 | ||
|
|
53f89fd42c | ||
|
|
c72f109553 | ||
|
|
92e03522db | ||
|
|
9716162739 | ||
|
|
4eea8fcadd | ||
|
|
0ae9be49da | ||
|
|
bda4efc634 | ||
|
|
e84e16f58b | ||
|
|
55ffe37a79 | ||
|
|
68548f4581 | ||
|
|
8382eb9cd8 | ||
|
|
f837e9dec7 | ||
|
|
230d9d82bf | ||
|
|
c089e56060 | ||
|
|
87f1a5ed0d | ||
|
|
d2d6fac7df | ||
|
|
bc3f9ed7c0 | ||
|
|
0f4162a9a9 | ||
|
|
6b270916c4 | ||
|
|
b3a006096c | ||
|
|
6903e252d2 | ||
|
|
ff6704f123 | ||
|
|
c770f4cb68 | ||
|
|
9ce1d360d6 | ||
|
|
6f473faa92 | ||
|
|
dd37a42470 | ||
|
|
88e1bbd60d | ||
|
|
e078e48853 | ||
|
|
fac7a5fdc6 | ||
|
|
49191fb144 | ||
|
|
f739062463 | ||
|
|
c22304f2b0 | ||
|
|
c97d2ecaba | ||
|
|
89a9d1d0a4 | ||
|
|
cf7d41cd7f | ||
|
|
afe542cc63 | ||
|
|
89a902fd57 | ||
|
|
ae604fd847 | ||
|
|
4b8d120f20 | ||
|
|
c489a88106 | ||
|
|
641707f37b | ||
|
|
67924c894d | ||
|
|
7c8f212b03 | ||
|
|
85c73cb0a5 | ||
|
|
1b1f8e0d2c | ||
|
|
f87126f22c | ||
|
|
b635490e47 | ||
|
|
cac7b39823 | ||
|
|
af3c579a03 | ||
|
|
a508c63279 | ||
|
|
427a11bd0f | ||
|
|
6f3133d48c | ||
|
|
aa7f26ac79 | ||
|
|
084caad5d7 | ||
|
|
343bf05c2c | ||
|
|
3e40d72e25 | ||
|
|
1c1daa4ebe | ||
|
|
fdcda6e5f3 | ||
|
|
a50dde7f2b | ||
|
|
1fb4cb1c4f | ||
|
|
cd0f854f41 | ||
|
|
52c2401d93 | ||
|
|
02a87d9fe0 | ||
|
|
12d68a41ca | ||
|
|
6c4a64601f | ||
|
|
434f985e77 | ||
|
|
ba1dcfcdba | ||
|
|
b346dabdf8 | ||
|
|
1376a16812 | ||
|
|
4267314260 | ||
|
|
b5110c8554 | ||
|
|
1f1d1e4f2f | ||
|
|
522eb8b256 | ||
|
|
b662ecc76b | ||
|
|
6dd69eb6db | ||
|
|
1b6aeff005 | ||
|
|
4287774d9f | ||
|
|
6bba2fec0b | ||
|
|
5d2656d679 |
9
.github/workflows/build-includes.yml
vendored
9
.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
|
||||||
@@ -95,10 +96,6 @@ jobs:
|
|||||||
export COMMIT_TIME=$(git show -s --format=%cd ${{ github.sha }} --date=iso-strict)
|
export COMMIT_TIME=$(git show -s --format=%cd ${{ github.sha }} --date=iso-strict)
|
||||||
lua5.3 "./Moose Setup/Moose_Create.lua" D "$COMMIT_TIME-${{ github.sha }}" "./Moose Development/Moose" "./Moose Setup" "./build/result/Moose_Include_Dynamic"
|
lua5.3 "./Moose Setup/Moose_Create.lua" D "$COMMIT_TIME-${{ github.sha }}" "./Moose Development/Moose" "./Moose Setup" "./build/result/Moose_Include_Dynamic"
|
||||||
|
|
||||||
- name: Run LuaSrcDiet
|
|
||||||
run: |
|
|
||||||
luasrcdiet --basic --opt-emptylines ./build/result/Moose_Include_Static/Moose.lua -o ./build/result/Moose_Include_Static/Moose_.lua
|
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# Run LuaCheck
|
# Run LuaCheck
|
||||||
#########################################################################
|
#########################################################################
|
||||||
@@ -108,6 +105,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
luacheck --std=lua51c --config=.luacheckrc -gurasqq "Moose Development/Moose"
|
luacheck --std=lua51c --config=.luacheckrc -gurasqq "Moose Development/Moose"
|
||||||
|
|
||||||
|
- name: Run LuaSrcDiet
|
||||||
|
run: |
|
||||||
|
luasrcdiet --basic --opt-emptylines ./build/result/Moose_Include_Static/Moose.lua -o ./build/result/Moose_Include_Static/Moose_.lua
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# Push to MOOSE_INCLUDE
|
# Push to MOOSE_INCLUDE
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|||||||
12
.github/workflows/gh-pages.yml
vendored
12
.github/workflows/gh-pages.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Setup Ruby
|
- name: Setup Ruby
|
||||||
uses: ruby/setup-ruby@v1
|
uses: ruby/setup-ruby@v1
|
||||||
with:
|
with:
|
||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
working-directory: docs/
|
working-directory: docs/
|
||||||
- name: Setup Pages
|
- name: Setup Pages
|
||||||
id: pages
|
id: pages
|
||||||
uses: actions/configure-pages@v3
|
uses: actions/configure-pages@v4
|
||||||
- name: Build with Jekyll
|
- name: Build with Jekyll
|
||||||
# Outputs to the './_site' directory by default
|
# Outputs to the './_site' directory by default
|
||||||
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
|
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
|
||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
working-directory: docs/
|
working-directory: docs/
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
# Automatically uploads an artifact from the './_site' directory by default
|
# Automatically uploads an artifact from the './_site' directory by default
|
||||||
uses: actions/upload-pages-artifact@v1
|
uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: docs/_site/
|
path: docs/_site/
|
||||||
|
|
||||||
@@ -66,13 +66,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v1
|
uses: actions/deploy-pages@v4
|
||||||
|
|
||||||
check:
|
check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: deploy
|
needs: deploy
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
- run: npm install linkinator
|
- run: npm install linkinator
|
||||||
- run: npx linkinator https://flightcontrol-master.github.io/MOOSE/ --verbosity error --timeout 5000 --recurse --skip "(java.com)"
|
- run: npx linkinator https://flightcontrol-master.github.io/MOOSE/ --verbosity error --timeout 5000 --recurse --skip "(java.com)" --retry-errors --retry-errors-count 3 --retry-errors-jitter
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -221,6 +221,9 @@ pip-log.txt
|
|||||||
#Goodsync
|
#Goodsync
|
||||||
_gsdata_/
|
_gsdata_/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
.idea
|
||||||
|
|
||||||
#GITHUB
|
#GITHUB
|
||||||
Moose Test Missions/MOOSE_Test_Template.miz
|
Moose Test Missions/MOOSE_Test_Template.miz
|
||||||
Moose Development/Moose/.vscode/launch.json
|
Moose Development/Moose/.vscode/launch.json
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [AID-A2A - AI A2A Dispatching](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching/AID-A2A%20-%20AI%20A2A%20Dispatching)
|
-- [AID-A2A - AI A2A Dispatching](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2A_Dispatcher)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -310,7 +310,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- Use the method @{#AI_A2A_DISPATCHER.SetEngageRadius}() to set a specific Engage Radius.
|
-- Use the method @{#AI_A2A_DISPATCHER.SetEngageRadius}() to set a specific Engage Radius.
|
||||||
-- **The Engage Radius is defined for ALL squadrons which are operational.**
|
-- **The Engage Radius is defined for ALL squadrons which are operational.**
|
||||||
--
|
--
|
||||||
-- Demonstration Mission: [AID-019 - AI_A2A - Engage Range Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching/AID-A2A%20-%20AI%20A2A%20Dispatching/AID-A2A-019%20-%20Engage%20Range%20Test)
|
-- Demonstration Mission: [AID-019 - AI_A2A - Engage Range Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2A_Dispatcher/AID-A2A-019%20-%20Engage%20Range%20Test)
|
||||||
--
|
--
|
||||||
-- In this example an Engage Radius is set to various values.
|
-- In this example an Engage Radius is set to various values.
|
||||||
--
|
--
|
||||||
@@ -333,7 +333,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- Use the method @{#AI_A2A_DISPATCHER.SetGciRadius}() to set a specific controlled ground intercept radius.
|
-- Use the method @{#AI_A2A_DISPATCHER.SetGciRadius}() to set a specific controlled ground intercept radius.
|
||||||
-- **The Ground Controlled Intercept radius is defined for ALL squadrons which are operational.**
|
-- **The Ground Controlled Intercept radius is defined for ALL squadrons which are operational.**
|
||||||
--
|
--
|
||||||
-- Demonstration Mission: [AID-013 - AI_A2A - Intercept Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching/AID-A2A%20-%20AI%20A2A%20Dispatching/AID-A2A-013%20-%20Intercept%20Test)
|
-- Demonstration Mission: [AID-013 - AI_A2A - Intercept Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2A_Dispatcher/AID-A2A-013%20-%20Intercept%20Test)
|
||||||
--
|
--
|
||||||
-- In these examples, the Gci Radius is set to various values:
|
-- In these examples, the Gci Radius is set to various values:
|
||||||
--
|
--
|
||||||
@@ -366,7 +366,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- it makes it easier sometimes for the mission maker to envisage where the red and blue territories roughly are.
|
-- it makes it easier sometimes for the mission maker to envisage where the red and blue territories roughly are.
|
||||||
-- In a hot war the borders are effectively defined by the ground based radar coverage of a coalition.
|
-- In a hot war the borders are effectively defined by the ground based radar coverage of a coalition.
|
||||||
--
|
--
|
||||||
-- Demonstration Mission: [AID-009 - AI_A2A - Border Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching/AID-A2A%20-%20AI%20A2A%20Dispatching/AID-A2A-009%20-%20Border%20Test)
|
-- Demonstration Mission: [AID-009 - AI_A2A - Border Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2A_Dispatcher/AID-A2A-009%20-%20Border%20Test)
|
||||||
--
|
--
|
||||||
-- In this example a border is set for the CCCP A2A dispatcher:
|
-- In this example a border is set for the CCCP A2A dispatcher:
|
||||||
--
|
--
|
||||||
@@ -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
|
||||||
@@ -1233,7 +1233,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
--
|
--
|
||||||
-- **Use the method @{#AI_A2A_DISPATCHER.SetEngageRadius}() to modify the default Engage Radius for ALL squadrons.**
|
-- **Use the method @{#AI_A2A_DISPATCHER.SetEngageRadius}() to modify the default Engage Radius for ALL squadrons.**
|
||||||
--
|
--
|
||||||
-- Demonstration Mission: [AID-019 - AI_A2A - Engage Range Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching/AID-A2A%20-%20AI%20A2A%20Dispatching/AID-A2A-019%20-%20Engage%20Range%20Test)
|
-- Demonstration Mission: [AID-019 - AI_A2A - Engage Range Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2A_Dispatcher/AID-A2A-019%20-%20Engage%20Range%20Test)
|
||||||
--
|
--
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
-- @param #number EngageRadius (Optional, Default = 100000) The radius to report friendlies near the target.
|
-- @param #number EngageRadius (Optional, Default = 100000) The radius to report friendlies near the target.
|
||||||
@@ -1283,7 +1283,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- Use the method @{#AI_A2A_DISPATCHER.SetGciRadius}() to set a specific controlled ground intercept radius.
|
-- Use the method @{#AI_A2A_DISPATCHER.SetGciRadius}() to set a specific controlled ground intercept radius.
|
||||||
-- **The Ground Controlled Intercept radius is defined for ALL squadrons which are operational.**
|
-- **The Ground Controlled Intercept radius is defined for ALL squadrons which are operational.**
|
||||||
--
|
--
|
||||||
-- Demonstration Mission: [AID-013 - AI_A2A - Intercept Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching/AID-A2A%20-%20AI%20A2A%20Dispatching/AID-A2A-013%20-%20Intercept%20Test)
|
-- Demonstration Mission: [AID-013 - AI_A2A - Intercept Test](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2A_Dispatcher/AID-A2A-013%20-%20Intercept%20Test)
|
||||||
--
|
--
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
-- @param #number GciRadius (Optional, Default = 200000) The radius to ground control intercept detected targets from the nearest airbase.
|
-- @param #number GciRadius (Optional, Default = 200000) The radius to ground control intercept detected targets from the nearest airbase.
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -3257,7 +3257,8 @@ do -- AI_A2A_DISPATCHER
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2A_DISPATCHER self
|
--- AI_A2A_Fsm:onafterHome
|
||||||
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
function AI_A2A_Fsm:onafterHome( Defender, From, Event, To, Action )
|
function AI_A2A_Fsm:onafterHome( Defender, From, Event, To, Action )
|
||||||
if Defender and Defender:IsAlive() then
|
if Defender and Defender:IsAlive() then
|
||||||
self:F( { "CAP Home", Defender:GetName() } )
|
self:F( { "CAP Home", Defender:GetName() } )
|
||||||
@@ -3505,7 +3506,8 @@ do -- AI_A2A_DISPATCHER
|
|||||||
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2A_DISPATCHER self
|
--- function Fsm:onafterLostControl
|
||||||
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
function Fsm:onafterLostControl( Defender, From, Event, To )
|
function Fsm:onafterLostControl( Defender, From, Event, To )
|
||||||
self:F( { "GCI LostControl", Defender:GetName() } )
|
self:F( { "GCI LostControl", Defender:GetName() } )
|
||||||
self:GetParent( self ).onafterHome( self, Defender, From, Event, To )
|
self:GetParent( self ).onafterHome( self, Defender, From, Event, To )
|
||||||
@@ -3518,7 +3520,8 @@ do -- AI_A2A_DISPATCHER
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2A_DISPATCHER self
|
--- function Fsm:onafterHome
|
||||||
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
function Fsm:onafterHome( DefenderGroup, From, Event, To, Action )
|
function Fsm:onafterHome( DefenderGroup, From, Event, To, Action )
|
||||||
self:F( { "GCI Home", DefenderGroup:GetName() } )
|
self:F( { "GCI Home", DefenderGroup:GetName() } )
|
||||||
self:GetParent( self ).onafterHome( self, DefenderGroup, From, Event, To )
|
self:GetParent( self ).onafterHome( self, DefenderGroup, From, Event, To )
|
||||||
@@ -3949,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.
|
||||||
@@ -3959,7 +3962,7 @@ do
|
|||||||
--
|
--
|
||||||
-- # Demo Missions
|
-- # Demo Missions
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching/AID-A2A%20-%20AI%20A2A%20Dispatching)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2A_Dispatcher)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -4319,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
|
||||||
@@ -4351,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()
|
||||||
@@ -4365,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
|
||||||
@@ -4373,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
|
||||||
@@ -4381,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
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [AID-A2G - AI A2G Dispatching](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching/AID-A2G%20-%20AI%20A2G%20Dispatching)
|
-- [AID-A2G - AI A2G Dispatching](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2G_Dispatcher)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -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 )
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [AID-AIR - AI AIR Dispatching](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AID%20-%20AI%20Dispatching)
|
-- [AI_A2A_Dispatcher](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_A2A_Dispatcher)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/BAI%20-%20Battlefield%20Air%20Interdiction)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_BAI)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AIB%20-%20AI%20Balancing)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_Balancer)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -168,7 +168,8 @@ function AI_BALANCER:ReturnToHomeAirbase( ReturnThresholdRange )
|
|||||||
self.ReturnThresholdRange = ReturnThresholdRange
|
self.ReturnThresholdRange = ReturnThresholdRange
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_BALANCER self
|
--- AI_BALANCER:onenterSpawning
|
||||||
|
-- @param #AI_BALANCER self
|
||||||
-- @param Core.Set#SET_GROUP SetGroup
|
-- @param Core.Set#SET_GROUP SetGroup
|
||||||
-- @param #string ClientName
|
-- @param #string ClientName
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
@@ -190,7 +191,8 @@ function AI_BALANCER:onenterSpawning( SetGroup, From, Event, To, ClientName )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_BALANCER self
|
--- AI_BALANCER:onenterDestroying
|
||||||
|
-- @param #AI_BALANCER self
|
||||||
-- @param Core.Set#SET_GROUP SetGroup
|
-- @param Core.Set#SET_GROUP SetGroup
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_BALANCER:onenterDestroying( SetGroup, From, Event, To, ClientName, AIGroup )
|
function AI_BALANCER:onenterDestroying( SetGroup, From, Event, To, ClientName, AIGroup )
|
||||||
@@ -233,15 +235,16 @@ function AI_BALANCER:onenterReturning( SetGroup, From, Event, To, AIGroup )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- AI_BALANCER:onenterMonitoring
|
||||||
--- @param #AI_BALANCER self
|
-- @param #AI_BALANCER self
|
||||||
function AI_BALANCER:onenterMonitoring( SetGroup )
|
function AI_BALANCER:onenterMonitoring( SetGroup )
|
||||||
|
|
||||||
self:T2( { self.SetClient:Count() } )
|
self:T2( { self.SetClient:Count() } )
|
||||||
--self.SetClient:Flush()
|
--self.SetClient:Flush()
|
||||||
|
|
||||||
self.SetClient:ForEachClient(
|
self.SetClient:ForEachClient(
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
--- SetClient:ForEachClient
|
||||||
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
function( Client )
|
function( Client )
|
||||||
self:T3(Client.ClientName)
|
self:T3(Client.ClientName)
|
||||||
|
|
||||||
@@ -264,7 +267,8 @@ function AI_BALANCER:onenterMonitoring( SetGroup )
|
|||||||
self:T2( RangeZone )
|
self:T2( RangeZone )
|
||||||
|
|
||||||
_DATABASE:ForEachPlayerUnit(
|
_DATABASE:ForEachPlayerUnit(
|
||||||
--- @param Wrapper.Unit#UNIT RangeTestUnit
|
--- Nameless function
|
||||||
|
-- @param Wrapper.Unit#UNIT RangeTestUnit
|
||||||
function( RangeTestUnit, RangeZone, AIGroup, PlayerInRange )
|
function( RangeTestUnit, RangeZone, AIGroup, PlayerInRange )
|
||||||
self:T2( { PlayerInRange, RangeTestUnit.UnitName, RangeZone.ZoneName } )
|
self:T2( { PlayerInRange, RangeTestUnit.UnitName, RangeZone.ZoneName } )
|
||||||
if RangeTestUnit:IsInZone( RangeZone ) == true then
|
if RangeTestUnit:IsInZone( RangeZone ) == true then
|
||||||
@@ -276,7 +280,8 @@ function AI_BALANCER:onenterMonitoring( SetGroup )
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
--- @param Core.Zone#ZONE_RADIUS RangeZone
|
--- Nameless function
|
||||||
|
-- @param Core.Zone#ZONE_RADIUS RangeZone
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function( RangeZone, AIGroup, PlayerInRange )
|
function( RangeZone, AIGroup, PlayerInRange )
|
||||||
if PlayerInRange.Value == false then
|
if PlayerInRange.Value == false then
|
||||||
@@ -307,6 +312,3 @@ function AI_BALANCER:onenterMonitoring( SetGroup )
|
|||||||
|
|
||||||
self:__Monitor( 10 )
|
self:__Monitor( 10 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/CAP%20-%20Combat%20Air%20Patrol)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_CAP)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/CAS%20-%20Close%20Air%20Support)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_CAS)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
--
|
--
|
||||||
-- Test missions can be located on the main GITHUB site.
|
-- Test missions can be located on the main GITHUB site.
|
||||||
--
|
--
|
||||||
-- [FlightControl-Master/MOOSE_MISSIONS/AID - AI Dispatching/AID-CGO - AI Cargo Dispatching/](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/AID%20-%20AI%20Dispatching/AID-CGO%20-%20AI%20Cargo%20Dispatching)
|
-- [FlightControl-Master/MOOSE_MISSIONS/AID - AI Dispatching/AID-CGO - AI Cargo Dispatching/](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_Cargo_Dispatcher)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -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.
|
||||||
@@ -583,10 +583,12 @@ AI_CARGO_DISPATCHER = {
|
|||||||
PickupCargo = {}
|
PickupCargo = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @field #list
|
--- List of AI_Cargo
|
||||||
|
-- @field #list
|
||||||
AI_CARGO_DISPATCHER.AI_Cargo = {}
|
AI_CARGO_DISPATCHER.AI_Cargo = {}
|
||||||
|
|
||||||
--- @field #list
|
--- List of PickupCargo
|
||||||
|
-- @field #list
|
||||||
AI_CARGO_DISPATCHER.PickupCargo = {}
|
AI_CARGO_DISPATCHER.PickupCargo = {}
|
||||||
|
|
||||||
|
|
||||||
@@ -1159,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
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ESC%20-%20Escorting)
|
-- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_Escort)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -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 )
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ESC%20-%20Escorting)
|
-- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_Escort)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/FOR%20-%20AI%20Group%20Formation)
|
-- ## Additional Material:
|
||||||
--
|
--
|
||||||
-- ===
|
-- * **Demo Missions:** [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_Formation)
|
||||||
--
|
-- * **YouTube videos:** [Playlist](https://www.youtube.com/playlist?list=PL7ZUrU4zZUl0bFIJ9jIdYM22uaWmIN4oz)
|
||||||
-- ### [YouTube Playlist](https://www.youtube.com/playlist?list=PL7ZUrU4zZUl0bFIJ9jIdYM22uaWmIN4oz)
|
-- * **Guides:** None
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/PAT%20-%20Patrolling)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_Patrol)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -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 )
|
||||||
|
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ CARGOS = {}
|
|||||||
|
|
||||||
do -- CARGO
|
do -- CARGO
|
||||||
|
|
||||||
--- @type CARGO
|
-- @type CARGO
|
||||||
-- @extends Core.Fsm#FSM_PROCESS
|
-- @extends Core.Fsm#FSM_PROCESS
|
||||||
-- @field #string Type A string defining the type of the cargo. eg. Engineers, Equipment, Screwdrivers.
|
-- @field #string Type A string defining the type of the cargo. eg. Engineers, Equipment, Screwdrivers.
|
||||||
-- @field #string Name A string defining the name of the cargo. The name is the unique identifier of the cargo.
|
-- @field #string Name A string defining the name of the cargo. The name is the unique identifier of the cargo.
|
||||||
@@ -433,7 +433,7 @@ do -- CARGO
|
|||||||
Reported = {},
|
Reported = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @type CARGO.CargoObjects
|
-- @type CARGO.CargoObjects
|
||||||
-- @map < #string, Wrapper.Positionable#POSITIONABLE > The alive POSITIONABLE objects representing the the cargo.
|
-- @map < #string, Wrapper.Positionable#POSITIONABLE > The alive POSITIONABLE objects representing the the cargo.
|
||||||
|
|
||||||
--- CARGO Constructor. This class is an abstract class and should not be instantiated.
|
--- CARGO Constructor. This class is an abstract class and should not be instantiated.
|
||||||
@@ -447,7 +447,7 @@ do -- CARGO
|
|||||||
function CARGO:New( Type, Name, Weight, LoadRadius, NearRadius ) --R2.1
|
function CARGO:New( Type, Name, Weight, LoadRadius, NearRadius ) --R2.1
|
||||||
|
|
||||||
local self = BASE:Inherit( self, FSM:New() ) -- #CARGO
|
local self = BASE:Inherit( self, FSM:New() ) -- #CARGO
|
||||||
self:F( { Type, Name, Weight, LoadRadius, NearRadius } )
|
self:T( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||||
|
|
||||||
self:SetStartState( "UnLoaded" )
|
self:SetStartState( "UnLoaded" )
|
||||||
self:AddTransition( { "UnLoaded", "Boarding" }, "Board", "Boarding" )
|
self:AddTransition( { "UnLoaded", "Boarding" }, "Board", "Boarding" )
|
||||||
@@ -711,7 +711,7 @@ do -- CARGO
|
|||||||
-- @param #CARGO self
|
-- @param #CARGO self
|
||||||
-- @return #CARGO
|
-- @return #CARGO
|
||||||
function CARGO:Spawn( PointVec2 )
|
function CARGO:Spawn( PointVec2 )
|
||||||
self:F()
|
self:T()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -812,7 +812,7 @@ do -- CARGO
|
|||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
-- @return #boolean true if the CargoGroup is within the loading radius.
|
-- @return #boolean true if the CargoGroup is within the loading radius.
|
||||||
function CARGO:IsInLoadRadius( Coordinate )
|
function CARGO:IsInLoadRadius( Coordinate )
|
||||||
self:F( { Coordinate, LoadRadius = self.LoadRadius } )
|
self:T( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||||
|
|
||||||
local Distance = 0
|
local Distance = 0
|
||||||
if self:IsUnLoaded() then
|
if self:IsUnLoaded() then
|
||||||
@@ -832,7 +832,7 @@ do -- CARGO
|
|||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
-- @return #boolean true if the Cargo can report itself.
|
-- @return #boolean true if the Cargo can report itself.
|
||||||
function CARGO:IsInReportRadius( Coordinate )
|
function CARGO:IsInReportRadius( Coordinate )
|
||||||
self:F( { Coordinate } )
|
self:T( { Coordinate } )
|
||||||
|
|
||||||
local Distance = 0
|
local Distance = 0
|
||||||
if self:IsUnLoaded() then
|
if self:IsUnLoaded() then
|
||||||
@@ -853,23 +853,23 @@ do -- CARGO
|
|||||||
-- @param #number NearRadius The radius when the cargo will board the Carrier (to avoid collision).
|
-- @param #number NearRadius The radius when the cargo will board the Carrier (to avoid collision).
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function CARGO:IsNear( Coordinate, NearRadius )
|
function CARGO:IsNear( Coordinate, NearRadius )
|
||||||
--self:F( { PointVec2 = PointVec2, NearRadius = NearRadius } )
|
--self:T( { PointVec2 = PointVec2, NearRadius = NearRadius } )
|
||||||
|
|
||||||
if self.CargoObject:IsAlive() then
|
if self.CargoObject:IsAlive() then
|
||||||
--local Distance = PointVec2:Get2DDistance( self.CargoObject:GetPointVec2() )
|
--local Distance = PointVec2:Get2DDistance( self.CargoObject:GetPointVec2() )
|
||||||
--self:F( { CargoObjectName = self.CargoObject:GetName() } )
|
--self:T( { CargoObjectName = self.CargoObject:GetName() } )
|
||||||
--self:F( { CargoObjectVec2 = self.CargoObject:GetVec2() } )
|
--self:T( { CargoObjectVec2 = self.CargoObject:GetVec2() } )
|
||||||
--self:F( { PointVec2 = PointVec2:GetVec2() } )
|
--self:T( { PointVec2 = PointVec2:GetVec2() } )
|
||||||
local Distance = Coordinate:Get2DDistance( self.CargoObject:GetCoordinate() )
|
local Distance = Coordinate:Get2DDistance( self.CargoObject:GetCoordinate() )
|
||||||
--self:F( { Distance = Distance, NearRadius = NearRadius or "nil" } )
|
--self:T( { Distance = Distance, NearRadius = NearRadius or "nil" } )
|
||||||
|
|
||||||
if Distance <= NearRadius then
|
if Distance <= NearRadius then
|
||||||
--self:F( { PointVec2 = PointVec2, NearRadius = NearRadius, IsNear = true } )
|
--self:T( { PointVec2 = PointVec2, NearRadius = NearRadius, IsNear = true } )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--self:F( { PointVec2 = PointVec2, NearRadius = NearRadius, IsNear = false } )
|
--self:T( { PointVec2 = PointVec2, NearRadius = NearRadius, IsNear = false } )
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -878,12 +878,12 @@ do -- CARGO
|
|||||||
-- @param Core.Zone#ZONE_BASE Zone
|
-- @param Core.Zone#ZONE_BASE Zone
|
||||||
-- @return #boolean **true** if cargo is in the Zone, **false** if cargo is not in the Zone.
|
-- @return #boolean **true** if cargo is in the Zone, **false** if cargo is not in the Zone.
|
||||||
function CARGO:IsInZone( Zone )
|
function CARGO:IsInZone( Zone )
|
||||||
--self:F( { Zone } )
|
--self:T( { Zone } )
|
||||||
|
|
||||||
if self:IsLoaded() then
|
if self:IsLoaded() then
|
||||||
return Zone:IsPointVec2InZone( self.CargoCarrier:GetPointVec2() )
|
return Zone:IsPointVec2InZone( self.CargoCarrier:GetPointVec2() )
|
||||||
else
|
else
|
||||||
--self:F( { Size = self.CargoObject:GetSize(), Units = self.CargoObject:GetUnits() } )
|
--self:T( { Size = self.CargoObject:GetSize(), Units = self.CargoObject:GetUnits() } )
|
||||||
if self.CargoObject:GetSize() ~= 0 then
|
if self.CargoObject:GetSize() ~= 0 then
|
||||||
return Zone:IsPointVec2InZone( self.CargoObject:GetPointVec2() )
|
return Zone:IsPointVec2InZone( self.CargoObject:GetPointVec2() )
|
||||||
else
|
else
|
||||||
@@ -1034,7 +1034,7 @@ end -- CARGO
|
|||||||
|
|
||||||
do -- CARGO_REPRESENTABLE
|
do -- CARGO_REPRESENTABLE
|
||||||
|
|
||||||
--- @type CARGO_REPRESENTABLE
|
-- @type CARGO_REPRESENTABLE
|
||||||
-- @extends #CARGO
|
-- @extends #CARGO
|
||||||
-- @field test
|
-- @field test
|
||||||
|
|
||||||
@@ -1056,7 +1056,7 @@ do -- CARGO_REPRESENTABLE
|
|||||||
|
|
||||||
-- Inherit CARGO.
|
-- Inherit CARGO.
|
||||||
local self = BASE:Inherit( self, CARGO:New( Type, Name, 0, LoadRadius, NearRadius ) ) -- #CARGO_REPRESENTABLE
|
local self = BASE:Inherit( self, CARGO:New( Type, Name, 0, LoadRadius, NearRadius ) ) -- #CARGO_REPRESENTABLE
|
||||||
self:F( { Type, Name, LoadRadius, NearRadius } )
|
self:T( { Type, Name, LoadRadius, NearRadius } )
|
||||||
|
|
||||||
-- Descriptors.
|
-- Descriptors.
|
||||||
local Desc=CargoObject:GetDesc()
|
local Desc=CargoObject:GetDesc()
|
||||||
@@ -1086,7 +1086,7 @@ do -- CARGO_REPRESENTABLE
|
|||||||
function CARGO_REPRESENTABLE:Destroy()
|
function CARGO_REPRESENTABLE:Destroy()
|
||||||
|
|
||||||
-- Cargo objects are deleted from the _DATABASE and SET_CARGO objects.
|
-- Cargo objects are deleted from the _DATABASE and SET_CARGO objects.
|
||||||
self:F( { CargoName = self:GetName() } )
|
self:T( { CargoName = self:GetName() } )
|
||||||
--_EVENTDISPATCHER:CreateEventDeleteCargo( self )
|
--_EVENTDISPATCHER:CreateEventDeleteCargo( self )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -1123,12 +1123,12 @@ do -- CARGO_REPRESENTABLE
|
|||||||
CoordinateZone:Scan( { Object.Category.UNIT } )
|
CoordinateZone:Scan( { Object.Category.UNIT } )
|
||||||
for _, DCSUnit in pairs( CoordinateZone:GetScannedUnits() ) do
|
for _, DCSUnit in pairs( CoordinateZone:GetScannedUnits() ) do
|
||||||
local NearUnit = UNIT:Find( DCSUnit )
|
local NearUnit = UNIT:Find( DCSUnit )
|
||||||
self:F({NearUnit=NearUnit})
|
self:T({NearUnit=NearUnit})
|
||||||
local NearUnitCoalition = NearUnit:GetCoalition()
|
local NearUnitCoalition = NearUnit:GetCoalition()
|
||||||
local CargoCoalition = self:GetCoalition()
|
local CargoCoalition = self:GetCoalition()
|
||||||
if NearUnitCoalition == CargoCoalition then
|
if NearUnitCoalition == CargoCoalition then
|
||||||
local Attributes = NearUnit:GetDesc()
|
local Attributes = NearUnit:GetDesc()
|
||||||
self:F({Desc=Attributes})
|
self:T({Desc=Attributes})
|
||||||
if NearUnit:HasAttribute( "Trucks" ) then
|
if NearUnit:HasAttribute( "Trucks" ) then
|
||||||
MESSAGE:New( Message, 20, NearUnit:GetCallsign() .. " reporting - Cargo " .. self:GetName() ):ToGroup( TaskGroup )
|
MESSAGE:New( Message, 20, NearUnit:GetCallsign() .. " reporting - Cargo " .. self:GetName() ):ToGroup( TaskGroup )
|
||||||
break
|
break
|
||||||
@@ -1142,7 +1142,7 @@ end -- CARGO_REPRESENTABLE
|
|||||||
|
|
||||||
do -- CARGO_REPORTABLE
|
do -- CARGO_REPORTABLE
|
||||||
|
|
||||||
--- @type CARGO_REPORTABLE
|
-- @type CARGO_REPORTABLE
|
||||||
-- @extends #CARGO
|
-- @extends #CARGO
|
||||||
CARGO_REPORTABLE = {
|
CARGO_REPORTABLE = {
|
||||||
ClassName = "CARGO_REPORTABLE"
|
ClassName = "CARGO_REPORTABLE"
|
||||||
@@ -1158,7 +1158,7 @@ do -- CARGO_REPORTABLE
|
|||||||
-- @return #CARGO_REPORTABLE
|
-- @return #CARGO_REPORTABLE
|
||||||
function CARGO_REPORTABLE:New( Type, Name, Weight, LoadRadius, NearRadius )
|
function CARGO_REPORTABLE:New( Type, Name, Weight, LoadRadius, NearRadius )
|
||||||
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight, LoadRadius, NearRadius ) ) -- #CARGO_REPORTABLE
|
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight, LoadRadius, NearRadius ) ) -- #CARGO_REPORTABLE
|
||||||
self:F( { Type, Name, Weight, LoadRadius, NearRadius } )
|
self:T( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -1178,7 +1178,7 @@ end
|
|||||||
|
|
||||||
do -- CARGO_PACKAGE
|
do -- CARGO_PACKAGE
|
||||||
|
|
||||||
--- @type CARGO_PACKAGE
|
-- @type CARGO_PACKAGE
|
||||||
-- @extends #CARGO_REPRESENTABLE
|
-- @extends #CARGO_REPRESENTABLE
|
||||||
CARGO_PACKAGE = {
|
CARGO_PACKAGE = {
|
||||||
ClassName = "CARGO_PACKAGE"
|
ClassName = "CARGO_PACKAGE"
|
||||||
@@ -1195,7 +1195,7 @@ do -- CARGO_PACKAGE
|
|||||||
-- @return #CARGO_PACKAGE
|
-- @return #CARGO_PACKAGE
|
||||||
function CARGO_PACKAGE:New( CargoCarrier, Type, Name, Weight, LoadRadius, NearRadius )
|
function CARGO_PACKAGE:New( CargoCarrier, Type, Name, Weight, LoadRadius, NearRadius )
|
||||||
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoCarrier, Type, Name, Weight, LoadRadius, NearRadius ) ) -- #CARGO_PACKAGE
|
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoCarrier, Type, Name, Weight, LoadRadius, NearRadius ) ) -- #CARGO_PACKAGE
|
||||||
self:F( { Type, Name, Weight, LoadRadius, NearRadius } )
|
self:T( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||||
|
|
||||||
self:T( CargoCarrier )
|
self:T( CargoCarrier )
|
||||||
self.CargoCarrier = CargoCarrier
|
self.CargoCarrier = CargoCarrier
|
||||||
@@ -1213,7 +1213,7 @@ end
|
|||||||
-- @param #number BoardDistance
|
-- @param #number BoardDistance
|
||||||
-- @param #number Angle
|
-- @param #number Angle
|
||||||
function CARGO_PACKAGE:onafterOnBoard( From, Event, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
|
function CARGO_PACKAGE:onafterOnBoard( From, Event, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
|
||||||
self:F()
|
self:T()
|
||||||
|
|
||||||
self.CargoInAir = self.CargoCarrier:InAir()
|
self.CargoInAir = self.CargoCarrier:InAir()
|
||||||
|
|
||||||
@@ -1246,7 +1246,7 @@ end
|
|||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function CARGO_PACKAGE:IsNear( CargoCarrier )
|
function CARGO_PACKAGE:IsNear( CargoCarrier )
|
||||||
self:F()
|
self:T()
|
||||||
|
|
||||||
local CargoCarrierPoint = CargoCarrier:GetCoordinate()
|
local CargoCarrierPoint = CargoCarrier:GetCoordinate()
|
||||||
|
|
||||||
@@ -1271,7 +1271,7 @@ end
|
|||||||
-- @param #number LoadDistance
|
-- @param #number LoadDistance
|
||||||
-- @param #number Angle
|
-- @param #number Angle
|
||||||
function CARGO_PACKAGE:onafterOnBoarded( From, Event, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
|
function CARGO_PACKAGE:onafterOnBoarded( From, Event, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
|
||||||
self:F()
|
self:T()
|
||||||
|
|
||||||
if self:IsNear( CargoCarrier ) then
|
if self:IsNear( CargoCarrier ) then
|
||||||
self:__Load( 1, CargoCarrier, Speed, LoadDistance, Angle )
|
self:__Load( 1, CargoCarrier, Speed, LoadDistance, Angle )
|
||||||
@@ -1292,7 +1292,7 @@ end
|
|||||||
-- @param #number Radius
|
-- @param #number Radius
|
||||||
-- @param #number Angle
|
-- @param #number Angle
|
||||||
function CARGO_PACKAGE:onafterUnBoard( From, Event, To, CargoCarrier, Speed, UnLoadDistance, UnBoardDistance, Radius, Angle )
|
function CARGO_PACKAGE:onafterUnBoard( From, Event, To, CargoCarrier, Speed, UnLoadDistance, UnBoardDistance, Radius, Angle )
|
||||||
self:F()
|
self:T()
|
||||||
|
|
||||||
self.CargoInAir = self.CargoCarrier:InAir()
|
self.CargoInAir = self.CargoCarrier:InAir()
|
||||||
|
|
||||||
@@ -1331,7 +1331,7 @@ end
|
|||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
-- @param #number Speed
|
-- @param #number Speed
|
||||||
function CARGO_PACKAGE:onafterUnBoarded( From, Event, To, CargoCarrier, Speed )
|
function CARGO_PACKAGE:onafterUnBoarded( From, Event, To, CargoCarrier, Speed )
|
||||||
self:F()
|
self:T()
|
||||||
|
|
||||||
if self:IsNear( CargoCarrier ) then
|
if self:IsNear( CargoCarrier ) then
|
||||||
self:__UnLoad( 1, CargoCarrier, Speed )
|
self:__UnLoad( 1, CargoCarrier, Speed )
|
||||||
@@ -1350,7 +1350,7 @@ end
|
|||||||
-- @param #number LoadDistance
|
-- @param #number LoadDistance
|
||||||
-- @param #number Angle
|
-- @param #number Angle
|
||||||
function CARGO_PACKAGE:onafterLoad( From, Event, To, CargoCarrier, Speed, LoadDistance, Angle )
|
function CARGO_PACKAGE:onafterLoad( From, Event, To, CargoCarrier, Speed, LoadDistance, Angle )
|
||||||
self:F()
|
self:T()
|
||||||
|
|
||||||
self.CargoCarrier = CargoCarrier
|
self.CargoCarrier = CargoCarrier
|
||||||
|
|
||||||
@@ -1378,7 +1378,7 @@ end
|
|||||||
-- @param #number Distance
|
-- @param #number Distance
|
||||||
-- @param #number Angle
|
-- @param #number Angle
|
||||||
function CARGO_PACKAGE:onafterUnLoad( From, Event, To, CargoCarrier, Speed, Distance, Angle )
|
function CARGO_PACKAGE:onafterUnLoad( From, Event, To, CargoCarrier, Speed, Distance, Angle )
|
||||||
self:F()
|
self:T()
|
||||||
|
|
||||||
local StartPointVec2 = self.CargoCarrier:GetPointVec2()
|
local StartPointVec2 = self.CargoCarrier:GetPointVec2()
|
||||||
local CargoCarrierHeading = self.CargoCarrier:GetHeading() -- Get Heading of object in degrees.
|
local CargoCarrierHeading = self.CargoCarrier:GetHeading() -- Get Heading of object in degrees.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ do -- CARGO_CRATE
|
|||||||
-- @return #CARGO_CRATE
|
-- @return #CARGO_CRATE
|
||||||
function CARGO_CRATE:New( CargoStatic, Type, Name, LoadRadius, NearRadius )
|
function CARGO_CRATE:New( CargoStatic, Type, Name, LoadRadius, NearRadius )
|
||||||
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoStatic, Type, Name, nil, LoadRadius, NearRadius ) ) -- #CARGO_CRATE
|
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoStatic, Type, Name, nil, LoadRadius, NearRadius ) ) -- #CARGO_CRATE
|
||||||
self:F( { Type, Name, NearRadius } )
|
self:T( { Type, Name, NearRadius } )
|
||||||
|
|
||||||
self.CargoObject = CargoStatic -- Wrapper.Static#STATIC
|
self.CargoObject = CargoStatic -- Wrapper.Static#STATIC
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ do -- CARGO_CRATE
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#POINT_VEC2
|
-- @param Core.Point#POINT_VEC2
|
||||||
function CARGO_CRATE:onenterUnLoaded( From, Event, To, ToPointVec2 )
|
function CARGO_CRATE:onenterUnLoaded( From, Event, To, ToPointVec2 )
|
||||||
--self:F( { ToPointVec2, From, Event, To } )
|
--self:T( { ToPointVec2, From, Event, To } )
|
||||||
|
|
||||||
local Angle = 180
|
local Angle = 180
|
||||||
local Speed = 10
|
local Speed = 10
|
||||||
@@ -153,7 +153,7 @@ do -- CARGO_CRATE
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
function CARGO_CRATE:onenterLoaded( From, Event, To, CargoCarrier )
|
function CARGO_CRATE:onenterLoaded( From, Event, To, CargoCarrier )
|
||||||
--self:F( { From, Event, To, CargoCarrier } )
|
--self:T( { From, Event, To, CargoCarrier } )
|
||||||
|
|
||||||
self.CargoCarrier = CargoCarrier
|
self.CargoCarrier = CargoCarrier
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ do -- CARGO_CRATE
|
|||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
-- @return #boolean true if the Cargo Crate is within the report radius.
|
-- @return #boolean true if the Cargo Crate is within the report radius.
|
||||||
function CARGO_CRATE:IsInReportRadius( Coordinate )
|
function CARGO_CRATE:IsInReportRadius( Coordinate )
|
||||||
--self:F( { Coordinate, LoadRadius = self.LoadRadius } )
|
--self:T( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||||
|
|
||||||
local Distance = 0
|
local Distance = 0
|
||||||
if self:IsUnLoaded() then
|
if self:IsUnLoaded() then
|
||||||
@@ -210,7 +210,7 @@ do -- CARGO_CRATE
|
|||||||
-- @param Core.Point#Coordinate Coordinate
|
-- @param Core.Point#Coordinate Coordinate
|
||||||
-- @return #boolean true if the Cargo Crate is within the loading radius.
|
-- @return #boolean true if the Cargo Crate is within the loading radius.
|
||||||
function CARGO_CRATE:IsInLoadRadius( Coordinate )
|
function CARGO_CRATE:IsInLoadRadius( Coordinate )
|
||||||
--self:F( { Coordinate, LoadRadius = self.NearRadius } )
|
--self:T( { Coordinate, LoadRadius = self.NearRadius } )
|
||||||
|
|
||||||
local Distance = 0
|
local Distance = 0
|
||||||
if self:IsUnLoaded() then
|
if self:IsUnLoaded() then
|
||||||
@@ -231,7 +231,7 @@ do -- CARGO_CRATE
|
|||||||
-- @return Core.Point#COORDINATE The current Coordinate of the first Cargo of the CargoGroup.
|
-- @return Core.Point#COORDINATE The current Coordinate of the first Cargo of the CargoGroup.
|
||||||
-- @return #nil There is no valid Cargo in the CargoGroup.
|
-- @return #nil There is no valid Cargo in the CargoGroup.
|
||||||
function CARGO_CRATE:GetCoordinate()
|
function CARGO_CRATE:GetCoordinate()
|
||||||
--self:F()
|
--self:T()
|
||||||
|
|
||||||
return self.CargoObject:GetCoordinate()
|
return self.CargoObject:GetCoordinate()
|
||||||
end
|
end
|
||||||
@@ -261,7 +261,7 @@ do -- CARGO_CRATE
|
|||||||
-- @param #CARGO_CRATE self
|
-- @param #CARGO_CRATE self
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
function CARGO_CRATE:RouteTo( Coordinate )
|
function CARGO_CRATE:RouteTo( Coordinate )
|
||||||
self:F( {Coordinate = Coordinate } )
|
self:T( {Coordinate = Coordinate } )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -274,7 +274,7 @@ do -- CARGO_CRATE
|
|||||||
-- @return #boolean The Cargo is near to the Carrier.
|
-- @return #boolean The Cargo is near to the Carrier.
|
||||||
-- @return #nil The Cargo is not near to the Carrier.
|
-- @return #nil The Cargo is not near to the Carrier.
|
||||||
function CARGO_CRATE:IsNear( CargoCarrier, NearRadius )
|
function CARGO_CRATE:IsNear( CargoCarrier, NearRadius )
|
||||||
self:F( {NearRadius = NearRadius } )
|
self:T( {NearRadius = NearRadius } )
|
||||||
|
|
||||||
return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius )
|
return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius )
|
||||||
end
|
end
|
||||||
@@ -283,7 +283,7 @@ do -- CARGO_CRATE
|
|||||||
-- @param #CARGO_CRATE self
|
-- @param #CARGO_CRATE self
|
||||||
function CARGO_CRATE:Respawn()
|
function CARGO_CRATE:Respawn()
|
||||||
|
|
||||||
self:F( { "Respawning crate " .. self:GetName() } )
|
self:T( { "Respawning crate " .. self:GetName() } )
|
||||||
|
|
||||||
|
|
||||||
-- Respawn the group...
|
-- Respawn the group...
|
||||||
@@ -300,7 +300,7 @@ do -- CARGO_CRATE
|
|||||||
-- @param #CARGO_CRATE self
|
-- @param #CARGO_CRATE self
|
||||||
function CARGO_CRATE:onafterReset()
|
function CARGO_CRATE:onafterReset()
|
||||||
|
|
||||||
self:F( { "Reset crate " .. self:GetName() } )
|
self:T( { "Reset crate " .. self:GetName() } )
|
||||||
|
|
||||||
|
|
||||||
-- Respawn the group...
|
-- Respawn the group...
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ do -- CARGO_GROUP
|
|||||||
|
|
||||||
-- Inherit CAROG_REPORTABLE
|
-- Inherit CAROG_REPORTABLE
|
||||||
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( Type, Name, 0, LoadRadius, NearRadius ) ) -- #CARGO_GROUP
|
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( Type, Name, 0, LoadRadius, NearRadius ) ) -- #CARGO_GROUP
|
||||||
self:F( { Type, Name, LoadRadius } )
|
self:T( { Type, Name, LoadRadius } )
|
||||||
|
|
||||||
self.CargoSet = SET_CARGO:New()
|
self.CargoSet = SET_CARGO:New()
|
||||||
self.CargoGroup = CargoGroup
|
self.CargoGroup = CargoGroup
|
||||||
@@ -146,7 +146,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
function CARGO_GROUP:Respawn()
|
function CARGO_GROUP:Respawn()
|
||||||
|
|
||||||
self:F( { "Respawning" } )
|
self:T( { "Respawning" } )
|
||||||
|
|
||||||
for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do
|
for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do
|
||||||
local Cargo = CargoData -- Cargo.Cargo#CARGO
|
local Cargo = CargoData -- Cargo.Cargo#CARGO
|
||||||
@@ -227,7 +227,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
function CARGO_GROUP:Regroup()
|
function CARGO_GROUP:Regroup()
|
||||||
|
|
||||||
self:F("Regroup")
|
self:T("Regroup")
|
||||||
|
|
||||||
if self.Grouped == false then
|
if self.Grouped == false then
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ do -- CARGO_GROUP
|
|||||||
for CargoUnitName, CargoUnit in pairs( self.CargoSet:GetSet() ) do
|
for CargoUnitName, CargoUnit in pairs( self.CargoSet:GetSet() ) do
|
||||||
local CargoUnit = CargoUnit -- Cargo.CargoUnit#CARGO_UNIT
|
local CargoUnit = CargoUnit -- Cargo.CargoUnit#CARGO_UNIT
|
||||||
|
|
||||||
self:F( { CargoUnit:GetName(), UnLoaded = CargoUnit:IsUnLoaded() } )
|
self:T( { CargoUnit:GetName(), UnLoaded = CargoUnit:IsUnLoaded() } )
|
||||||
|
|
||||||
if CargoUnit:IsUnLoaded() then
|
if CargoUnit:IsUnLoaded() then
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ do -- CARGO_GROUP
|
|||||||
-- Then we register the new group in the database
|
-- Then we register the new group in the database
|
||||||
self.CargoGroup = GROUP:NewTemplate( GroupTemplate, GroupTemplate.CoalitionID, GroupTemplate.CategoryID, GroupTemplate.CountryID )
|
self.CargoGroup = GROUP:NewTemplate( GroupTemplate, GroupTemplate.CoalitionID, GroupTemplate.CategoryID, GroupTemplate.CountryID )
|
||||||
|
|
||||||
self:F( { "Regroup", GroupTemplate } )
|
self:T( { "Regroup", GroupTemplate } )
|
||||||
|
|
||||||
-- Now we spawn the new group based on the template created.
|
-- Now we spawn the new group based on the template created.
|
||||||
self.CargoObject = _DATABASE:Spawn( GroupTemplate )
|
self.CargoObject = _DATABASE:Spawn( GroupTemplate )
|
||||||
@@ -271,7 +271,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function CARGO_GROUP:OnEventCargoDead( EventData )
|
function CARGO_GROUP:OnEventCargoDead( EventData )
|
||||||
|
|
||||||
self:E(EventData)
|
self:T(EventData)
|
||||||
|
|
||||||
local Destroyed = false
|
local Destroyed = false
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ do -- CARGO_GROUP
|
|||||||
|
|
||||||
if Destroyed then
|
if Destroyed then
|
||||||
self:Destroyed()
|
self:Destroyed()
|
||||||
self:E( { "Cargo group destroyed" } )
|
self:T( { "Cargo group destroyed" } )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -309,14 +309,14 @@ do -- CARGO_GROUP
|
|||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onafterBoard( From, Event, To, CargoCarrier, NearRadius, ... )
|
function CARGO_GROUP:onafterBoard( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||||
self:F( { CargoCarrier.UnitName, From, Event, To, NearRadius = NearRadius } )
|
self:T( { CargoCarrier.UnitName, From, Event, To, NearRadius = NearRadius } )
|
||||||
|
|
||||||
NearRadius = NearRadius or self.NearRadius
|
NearRadius = NearRadius or self.NearRadius
|
||||||
|
|
||||||
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
|
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
|
||||||
self.CargoSet:ForEach(
|
self.CargoSet:ForEach(
|
||||||
function( Cargo, ... )
|
function( Cargo, ... )
|
||||||
self:F( { "Board Unit", Cargo:GetName( ), Cargo:IsDestroyed(), Cargo.CargoObject:IsAlive() } )
|
self:T( { "Board Unit", Cargo:GetName( ), Cargo:IsDestroyed(), Cargo.CargoObject:IsAlive() } )
|
||||||
local CargoGroup = Cargo.CargoObject --Wrapper.Group#GROUP
|
local CargoGroup = Cargo.CargoObject --Wrapper.Group#GROUP
|
||||||
CargoGroup:OptionAlarmStateGreen()
|
CargoGroup:OptionAlarmStateGreen()
|
||||||
Cargo:__Board( 1, CargoCarrier, NearRadius, ... )
|
Cargo:__Board( 1, CargoCarrier, NearRadius, ... )
|
||||||
@@ -334,7 +334,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
function CARGO_GROUP:onafterLoad( From, Event, To, CargoCarrier, ... )
|
function CARGO_GROUP:onafterLoad( From, Event, To, CargoCarrier, ... )
|
||||||
--self:F( { From, Event, To, CargoCarrier, ...} )
|
--self:T( { From, Event, To, CargoCarrier, ...} )
|
||||||
|
|
||||||
if From == "UnLoaded" then
|
if From == "UnLoaded" then
|
||||||
-- For each Cargo object within the CARGO_GROUP, load each cargo to the CargoCarrier.
|
-- For each Cargo object within the CARGO_GROUP, load each cargo to the CargoCarrier.
|
||||||
@@ -359,7 +359,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
function CARGO_GROUP:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||||
--self:F( { CargoCarrier.UnitName, From, Event, To } )
|
--self:T( { CargoCarrier.UnitName, From, Event, To } )
|
||||||
|
|
||||||
local Boarded = true
|
local Boarded = true
|
||||||
local Cancelled = false
|
local Cancelled = false
|
||||||
@@ -393,7 +393,7 @@ do -- CARGO_GROUP
|
|||||||
if not Boarded then
|
if not Boarded then
|
||||||
self:__Boarding( -5, CargoCarrier, NearRadius, ... )
|
self:__Boarding( -5, CargoCarrier, NearRadius, ... )
|
||||||
else
|
else
|
||||||
self:F("Group Cargo is loaded")
|
self:T("Group Cargo is loaded")
|
||||||
self:__Load( 1, CargoCarrier, ... )
|
self:__Load( 1, CargoCarrier, ... )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -413,7 +413,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onafterUnBoard( From, Event, To, ToPointVec2, NearRadius, ... )
|
function CARGO_GROUP:onafterUnBoard( From, Event, To, ToPointVec2, NearRadius, ... )
|
||||||
self:F( {From, Event, To, ToPointVec2, NearRadius } )
|
self:T( {From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
NearRadius = NearRadius or 25
|
NearRadius = NearRadius or 25
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
|
function CARGO_GROUP:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
|
||||||
--self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
--self:T( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
--local NearRadius = NearRadius or 25
|
--local NearRadius = NearRadius or 25
|
||||||
|
|
||||||
@@ -493,7 +493,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
function CARGO_GROUP:onafterUnLoad( From, Event, To, ToPointVec2, ... )
|
function CARGO_GROUP:onafterUnLoad( From, Event, To, ToPointVec2, ... )
|
||||||
--self:F( { From, Event, To, ToPointVec2 } )
|
--self:T( { From, Event, To, ToPointVec2 } )
|
||||||
|
|
||||||
if From == "Loaded" then
|
if From == "Loaded" then
|
||||||
|
|
||||||
@@ -611,7 +611,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
function CARGO_GROUP:RouteTo( Coordinate )
|
function CARGO_GROUP:RouteTo( Coordinate )
|
||||||
--self:F( {Coordinate = Coordinate } )
|
--self:T( {Coordinate = Coordinate } )
|
||||||
|
|
||||||
-- For each Cargo within the CargoSet, route each object to the Coordinate
|
-- For each Cargo within the CargoSet, route each object to the Coordinate
|
||||||
self.CargoSet:ForEach(
|
self.CargoSet:ForEach(
|
||||||
@@ -629,13 +629,13 @@ do -- CARGO_GROUP
|
|||||||
-- @param #number NearRadius
|
-- @param #number NearRadius
|
||||||
-- @return #boolean The Cargo is near to the Carrier or #nil if the Cargo is not near to the Carrier.
|
-- @return #boolean The Cargo is near to the Carrier or #nil if the Cargo is not near to the Carrier.
|
||||||
function CARGO_GROUP:IsNear( CargoCarrier, NearRadius )
|
function CARGO_GROUP:IsNear( CargoCarrier, NearRadius )
|
||||||
self:F( {NearRadius = NearRadius } )
|
self:T( {NearRadius = NearRadius } )
|
||||||
|
|
||||||
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||||
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
||||||
if Cargo:IsAlive() then
|
if Cargo:IsAlive() then
|
||||||
if Cargo:IsNear( CargoCarrier:GetCoordinate(), NearRadius ) then
|
if Cargo:IsNear( CargoCarrier:GetCoordinate(), NearRadius ) then
|
||||||
self:F( "Near" )
|
self:T( "Near" )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -649,7 +649,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
-- @return #boolean true if the Cargo Group is within the load radius.
|
-- @return #boolean true if the Cargo Group is within the load radius.
|
||||||
function CARGO_GROUP:IsInLoadRadius( Coordinate )
|
function CARGO_GROUP:IsInLoadRadius( Coordinate )
|
||||||
--self:F( { Coordinate } )
|
--self:T( { Coordinate } )
|
||||||
|
|
||||||
local Cargo = self:GetFirstAlive() -- Cargo.Cargo#CARGO
|
local Cargo = self:GetFirstAlive() -- Cargo.Cargo#CARGO
|
||||||
|
|
||||||
@@ -669,7 +669,7 @@ do -- CARGO_GROUP
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
self:F( { Distance = Distance, LoadRadius = self.LoadRadius } )
|
self:T( { Distance = Distance, LoadRadius = self.LoadRadius } )
|
||||||
if Distance <= self.LoadRadius then
|
if Distance <= self.LoadRadius then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
@@ -687,12 +687,12 @@ do -- CARGO_GROUP
|
|||||||
-- @param Core.Point#Coordinate Coordinate
|
-- @param Core.Point#Coordinate Coordinate
|
||||||
-- @return #boolean true if the Cargo Group is within the report radius.
|
-- @return #boolean true if the Cargo Group is within the report radius.
|
||||||
function CARGO_GROUP:IsInReportRadius( Coordinate )
|
function CARGO_GROUP:IsInReportRadius( Coordinate )
|
||||||
--self:F( { Coordinate } )
|
--self:T( { Coordinate } )
|
||||||
|
|
||||||
local Cargo = self:GetFirstAlive() -- Cargo.Cargo#CARGO
|
local Cargo = self:GetFirstAlive() -- Cargo.Cargo#CARGO
|
||||||
|
|
||||||
if Cargo then
|
if Cargo then
|
||||||
self:F( { Cargo } )
|
self:T( { Cargo } )
|
||||||
local Distance = 0
|
local Distance = 0
|
||||||
if Cargo:IsUnLoaded() then
|
if Cargo:IsUnLoaded() then
|
||||||
Distance = Coordinate:Get2DDistance( Cargo.CargoObject:GetCoordinate() )
|
Distance = Coordinate:Get2DDistance( Cargo.CargoObject:GetCoordinate() )
|
||||||
@@ -738,7 +738,7 @@ do -- CARGO_GROUP
|
|||||||
-- @return #boolean **true** if the first element of the CargoGroup is in the Zone
|
-- @return #boolean **true** if the first element of the CargoGroup is in the Zone
|
||||||
-- @return #boolean **false** if there is no element of the CargoGroup in the Zone.
|
-- @return #boolean **false** if there is no element of the CargoGroup in the Zone.
|
||||||
function CARGO_GROUP:IsInZone( Zone )
|
function CARGO_GROUP:IsInZone( Zone )
|
||||||
--self:F( { Zone } )
|
--self:T( { Zone } )
|
||||||
|
|
||||||
local Cargo = self.CargoSet:GetFirst() -- Cargo.Cargo#CARGO
|
local Cargo = self.CargoSet:GetFirst() -- Cargo.Cargo#CARGO
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @return #CARGO_SLINGLOAD
|
-- @return #CARGO_SLINGLOAD
|
||||||
function CARGO_SLINGLOAD:New( CargoStatic, Type, Name, LoadRadius, NearRadius )
|
function CARGO_SLINGLOAD:New( CargoStatic, Type, Name, LoadRadius, NearRadius )
|
||||||
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoStatic, Type, Name, nil, LoadRadius, NearRadius ) ) -- #CARGO_SLINGLOAD
|
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoStatic, Type, Name, nil, LoadRadius, NearRadius ) ) -- #CARGO_SLINGLOAD
|
||||||
self:F( { Type, Name, NearRadius } )
|
self:T( { Type, Name, NearRadius } )
|
||||||
|
|
||||||
self.CargoObject = CargoStatic
|
self.CargoObject = CargoStatic
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
-- @return #boolean true if the Cargo Crate is within the report radius.
|
-- @return #boolean true if the Cargo Crate is within the report radius.
|
||||||
function CARGO_SLINGLOAD:IsInReportRadius( Coordinate )
|
function CARGO_SLINGLOAD:IsInReportRadius( Coordinate )
|
||||||
--self:F( { Coordinate, LoadRadius = self.LoadRadius } )
|
--self:T( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||||
|
|
||||||
local Distance = 0
|
local Distance = 0
|
||||||
if self:IsUnLoaded() then
|
if self:IsUnLoaded() then
|
||||||
@@ -149,7 +149,7 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
-- @return #boolean true if the Cargo Slingload is within the loading radius.
|
-- @return #boolean true if the Cargo Slingload is within the loading radius.
|
||||||
function CARGO_SLINGLOAD:IsInLoadRadius( Coordinate )
|
function CARGO_SLINGLOAD:IsInLoadRadius( Coordinate )
|
||||||
--self:F( { Coordinate } )
|
--self:T( { Coordinate } )
|
||||||
|
|
||||||
local Distance = 0
|
local Distance = 0
|
||||||
if self:IsUnLoaded() then
|
if self:IsUnLoaded() then
|
||||||
@@ -169,7 +169,7 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @return Core.Point#COORDINATE The current Coordinate of the first Cargo of the CargoGroup.
|
-- @return Core.Point#COORDINATE The current Coordinate of the first Cargo of the CargoGroup.
|
||||||
-- @return #nil There is no valid Cargo in the CargoGroup.
|
-- @return #nil There is no valid Cargo in the CargoGroup.
|
||||||
function CARGO_SLINGLOAD:GetCoordinate()
|
function CARGO_SLINGLOAD:GetCoordinate()
|
||||||
--self:F()
|
--self:T()
|
||||||
|
|
||||||
return self.CargoObject:GetCoordinate()
|
return self.CargoObject:GetCoordinate()
|
||||||
end
|
end
|
||||||
@@ -199,7 +199,7 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @param #CARGO_SLINGLOAD self
|
-- @param #CARGO_SLINGLOAD self
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
function CARGO_SLINGLOAD:RouteTo( Coordinate )
|
function CARGO_SLINGLOAD:RouteTo( Coordinate )
|
||||||
--self:F( {Coordinate = Coordinate } )
|
--self:T( {Coordinate = Coordinate } )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @return #boolean The Cargo is near to the Carrier.
|
-- @return #boolean The Cargo is near to the Carrier.
|
||||||
-- @return #nil The Cargo is not near to the Carrier.
|
-- @return #nil The Cargo is not near to the Carrier.
|
||||||
function CARGO_SLINGLOAD:IsNear( CargoCarrier, NearRadius )
|
function CARGO_SLINGLOAD:IsNear( CargoCarrier, NearRadius )
|
||||||
--self:F( {NearRadius = NearRadius } )
|
--self:T( {NearRadius = NearRadius } )
|
||||||
|
|
||||||
return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius )
|
return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius )
|
||||||
end
|
end
|
||||||
@@ -222,7 +222,7 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @param #CARGO_SLINGLOAD self
|
-- @param #CARGO_SLINGLOAD self
|
||||||
function CARGO_SLINGLOAD:Respawn()
|
function CARGO_SLINGLOAD:Respawn()
|
||||||
|
|
||||||
--self:F( { "Respawning slingload " .. self:GetName() } )
|
--self:T( { "Respawning slingload " .. self:GetName() } )
|
||||||
|
|
||||||
|
|
||||||
-- Respawn the group...
|
-- Respawn the group...
|
||||||
@@ -239,7 +239,7 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @param #CARGO_SLINGLOAD self
|
-- @param #CARGO_SLINGLOAD self
|
||||||
function CARGO_SLINGLOAD:onafterReset()
|
function CARGO_SLINGLOAD:onafterReset()
|
||||||
|
|
||||||
--self:F( { "Reset slingload " .. self:GetName() } )
|
--self:T( { "Reset slingload " .. self:GetName() } )
|
||||||
|
|
||||||
|
|
||||||
-- Respawn the group...
|
-- Respawn the group...
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
-- @param #number NearRadius (optional) Defaut 25 m.
|
-- @param #number NearRadius (optional) Defaut 25 m.
|
||||||
function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||||
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
self:T( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
local Angle = 180
|
local Angle = 180
|
||||||
local Speed = 60
|
local Speed = 60
|
||||||
@@ -114,7 +114,7 @@ do -- CARGO_UNIT
|
|||||||
else
|
else
|
||||||
self.CargoObject:ReSpawnAt( FromPointVec2, CargoDeployHeading )
|
self.CargoObject:ReSpawnAt( FromPointVec2, CargoDeployHeading )
|
||||||
end
|
end
|
||||||
self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
|
self:T( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
|
||||||
self.CargoCarrier = nil
|
self.CargoCarrier = nil
|
||||||
|
|
||||||
local Points = {}
|
local Points = {}
|
||||||
@@ -148,7 +148,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
-- @param #number NearRadius (optional) Defaut 100 m.
|
-- @param #number NearRadius (optional) Defaut 100 m.
|
||||||
function CARGO_UNIT:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
function CARGO_UNIT:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||||
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
self:T( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
local Angle = 180
|
local Angle = 180
|
||||||
local Speed = 10
|
local Speed = 10
|
||||||
@@ -174,7 +174,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
-- @param #number NearRadius (optional) Defaut 100 m.
|
-- @param #number NearRadius (optional) Defaut 100 m.
|
||||||
function CARGO_UNIT:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
function CARGO_UNIT:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||||
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
self:T( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
self.CargoInAir = self.CargoObject:InAir()
|
self.CargoInAir = self.CargoObject:InAir()
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#POINT_VEC2
|
-- @param Core.Point#POINT_VEC2
|
||||||
function CARGO_UNIT:onenterUnLoaded( From, Event, To, ToPointVec2 )
|
function CARGO_UNIT:onenterUnLoaded( From, Event, To, ToPointVec2 )
|
||||||
self:F( { ToPointVec2, From, Event, To } )
|
self:T( { ToPointVec2, From, Event, To } )
|
||||||
|
|
||||||
local Angle = 180
|
local Angle = 180
|
||||||
local Speed = 10
|
local Speed = 10
|
||||||
@@ -236,7 +236,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param Wrapper.Group#GROUP CargoCarrier
|
-- @param Wrapper.Group#GROUP CargoCarrier
|
||||||
-- @param #number NearRadius
|
-- @param #number NearRadius
|
||||||
function CARGO_UNIT:onafterBoard( From, Event, To, CargoCarrier, NearRadius, ... )
|
function CARGO_UNIT:onafterBoard( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||||
self:F( { From, Event, To, CargoCarrier, NearRadius = NearRadius } )
|
self:T( { From, Event, To, CargoCarrier, NearRadius = NearRadius } )
|
||||||
|
|
||||||
self.CargoInAir = self.CargoObject:InAir()
|
self.CargoInAir = self.CargoObject:InAir()
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ do -- CARGO_UNIT
|
|||||||
local MaxSpeed = Desc.speedMaxOffRoad
|
local MaxSpeed = Desc.speedMaxOffRoad
|
||||||
local TypeName = Desc.typeName
|
local TypeName = Desc.typeName
|
||||||
|
|
||||||
--self:F({Unit=self.CargoObject:GetName()})
|
--self:T({Unit=self.CargoObject:GetName()})
|
||||||
|
|
||||||
-- A cargo unit can only be boarded if it is not dead
|
-- A cargo unit can only be boarded if it is not dead
|
||||||
|
|
||||||
@@ -298,9 +298,9 @@ do -- CARGO_UNIT
|
|||||||
-- @param Wrapper.Client#CLIENT CargoCarrier
|
-- @param Wrapper.Client#CLIENT CargoCarrier
|
||||||
-- @param #number NearRadius Default 25 m.
|
-- @param #number NearRadius Default 25 m.
|
||||||
function CARGO_UNIT:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
function CARGO_UNIT:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||||
self:F( { From, Event, To, CargoCarrier:GetName(), NearRadius = NearRadius } )
|
self:T( { From, Event, To, CargoCarrier:GetName(), NearRadius = NearRadius } )
|
||||||
|
|
||||||
self:F( { IsAlive=self.CargoObject:IsAlive() } )
|
self:T( { IsAlive=self.CargoObject:IsAlive() } )
|
||||||
|
|
||||||
if CargoCarrier and CargoCarrier:IsAlive() then -- and self.CargoObject and self.CargoObject:IsAlive() then
|
if CargoCarrier and CargoCarrier:IsAlive() then -- and self.CargoObject and self.CargoObject:IsAlive() then
|
||||||
if (CargoCarrier:IsAir() and not CargoCarrier:InAir()) or true then
|
if (CargoCarrier:IsAir() and not CargoCarrier:InAir()) or true then
|
||||||
@@ -321,7 +321,7 @@ do -- CARGO_UNIT
|
|||||||
local Angle = 180
|
local Angle = 180
|
||||||
local Distance = 0
|
local Distance = 0
|
||||||
|
|
||||||
--self:F({Unit=self.CargoObject:GetName()})
|
--self:T({Unit=self.CargoObject:GetName()})
|
||||||
|
|
||||||
local CargoCarrierPointVec2 = CargoCarrier:GetPointVec2()
|
local CargoCarrierPointVec2 = CargoCarrier:GetPointVec2()
|
||||||
local CargoCarrierHeading = CargoCarrier:GetHeading() -- Get Heading of object in degrees.
|
local CargoCarrierHeading = CargoCarrier:GetHeading() -- Get Heading of object in degrees.
|
||||||
@@ -348,7 +348,7 @@ do -- CARGO_UNIT
|
|||||||
self.CargoObject:SetCommand( self.CargoObject:CommandStopRoute( true ) )
|
self.CargoObject:SetCommand( self.CargoObject:CommandStopRoute( true ) )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E("Something is wrong")
|
self:T("Something is wrong")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -361,11 +361,11 @@ do -- CARGO_UNIT
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
function CARGO_UNIT:onenterLoaded( From, Event, To, CargoCarrier )
|
function CARGO_UNIT:onenterLoaded( From, Event, To, CargoCarrier )
|
||||||
self:F( { From, Event, To, CargoCarrier } )
|
self:T( { From, Event, To, CargoCarrier } )
|
||||||
|
|
||||||
self.CargoCarrier = CargoCarrier
|
self.CargoCarrier = CargoCarrier
|
||||||
|
|
||||||
--self:F({Unit=self.CargoObject:GetName()})
|
--self:T({Unit=self.CargoObject:GetName()})
|
||||||
|
|
||||||
-- Only destroy the CargoObject if there is a CargoObject (packages don't have CargoObjects).
|
-- Only destroy the CargoObject if there is a CargoObject (packages don't have CargoObjects).
|
||||||
if self.CargoObject then
|
if self.CargoObject then
|
||||||
|
|||||||
@@ -1144,6 +1144,19 @@ function BASE:TraceClassMethod( Class, Method )
|
|||||||
self:I( "Tracing method " .. Method .. " of class " .. Class )
|
self:I( "Tracing method " .. Method .. " of class " .. Class )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (Internal) Serialize arguments
|
||||||
|
-- @param #BASE self
|
||||||
|
-- @param #table Arguments
|
||||||
|
-- @return #string Text
|
||||||
|
function BASE:_Serialize(Arguments)
|
||||||
|
local text = UTILS.PrintTableToLog({Arguments}, 0, true)
|
||||||
|
text = string.gsub(text,"(\n+)","")
|
||||||
|
text = string.gsub(text,"%(%(","%(")
|
||||||
|
text = string.gsub(text,"%)%)","%)")
|
||||||
|
text = string.gsub(text,"(%s+)"," ")
|
||||||
|
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.
|
||||||
@@ -1168,7 +1181,7 @@ function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
|
|||||||
if DebugInfoFrom then
|
if DebugInfoFrom then
|
||||||
LineFrom = DebugInfoFrom.currentline
|
LineFrom = DebugInfoFrom.currentline
|
||||||
end
|
end
|
||||||
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "F", self.ClassName, self.ClassID, Function, UTILS.BasicSerialize( Arguments ) ) )
|
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "F", self.ClassName, self.ClassID, Function, BASE:_Serialize(Arguments) ) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1242,7 +1255,7 @@ function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
|
|||||||
if DebugInfoFrom then
|
if DebugInfoFrom then
|
||||||
LineFrom = DebugInfoFrom.currentline
|
LineFrom = DebugInfoFrom.currentline
|
||||||
end
|
end
|
||||||
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s", LineCurrent, LineFrom, "T", self.ClassName, self.ClassID, UTILS.BasicSerialize( Arguments ) ) )
|
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s", LineCurrent, LineFrom, "T", self.ClassName, self.ClassID, BASE:_Serialize(Arguments) ) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1314,7 +1327,7 @@ function BASE:E( Arguments )
|
|||||||
|
|
||||||
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, UTILS.BasicSerialize( Arguments ) ) )
|
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, UTILS.BasicSerialize( Arguments ) ) )
|
||||||
else
|
else
|
||||||
env.info( string.format( "%1s:%30s%05d(%s)", "E", self.ClassName, self.ClassID, UTILS.BasicSerialize( Arguments ) ) )
|
env.info( string.format( "%1s:%30s%05d(%s)", "E", self.ClassName, self.ClassID, BASE:_Serialize(Arguments) ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1341,39 +1354,8 @@ function BASE:I( Arguments )
|
|||||||
|
|
||||||
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "I", self.ClassName, self.ClassID, Function, UTILS.BasicSerialize( Arguments ) ) )
|
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "I", self.ClassName, self.ClassID, Function, UTILS.BasicSerialize( Arguments ) ) )
|
||||||
else
|
else
|
||||||
env.info( string.format( "%1s:%30s%05d(%s)", "I", self.ClassName, self.ClassID, UTILS.BasicSerialize( Arguments ) ) )
|
env.info( string.format( "%1s:%30s%05d(%s)", "I", self.ClassName, self.ClassID, BASE:_Serialize(Arguments)) )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- old stuff
|
|
||||||
|
|
||||||
-- function BASE:_Destructor()
|
|
||||||
-- --self:E("_Destructor")
|
|
||||||
--
|
|
||||||
-- --self:EventRemoveAll()
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- THIS IS WHY WE NEED LUA 5.2 ...
|
|
||||||
-- function BASE:_SetDestructor()
|
|
||||||
--
|
|
||||||
-- -- TODO: Okay, this is really technical...
|
|
||||||
-- -- When you set a proxy to a table to catch __gc, weak tables don't behave like weak...
|
|
||||||
-- -- Therefore, I am parking this logic until I've properly discussed all this with the community.
|
|
||||||
--
|
|
||||||
-- local proxy = newproxy(true)
|
|
||||||
-- local proxyMeta = getmetatable(proxy)
|
|
||||||
--
|
|
||||||
-- proxyMeta.__gc = function ()
|
|
||||||
-- env.info("In __gc for " .. self:GetClassNameAndID() )
|
|
||||||
-- if self._Destructor then
|
|
||||||
-- self:_Destructor()
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- -- keep the userdata from newproxy reachable until the object
|
|
||||||
-- -- table is about to be garbage-collected - then the __gc hook
|
|
||||||
-- -- will be invoked and the destructor called
|
|
||||||
-- rawset( self, '__proxy', proxy )
|
|
||||||
--
|
|
||||||
-- end
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Core/Beacon)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
-- ### Authors: Hugues "Grey_Echo" Bousquet, funkyfranky
|
-- ### Authors: Hugues "Grey_Echo" Bousquet, funkyfranky
|
||||||
--
|
--
|
||||||
-- @module Core.Beacon
|
-- @module Core.Beacon
|
||||||
@@ -34,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.
|
||||||
@@ -286,6 +292,7 @@ end
|
|||||||
-- myBeacon:AATACAN(20, "TEXACO", true) -- Activate the beacon
|
-- myBeacon:AATACAN(20, "TEXACO", true) -- Activate the beacon
|
||||||
function BEACON:AATACAN(TACANChannel, Message, Bearing, BeaconDuration)
|
function BEACON:AATACAN(TACANChannel, Message, Bearing, BeaconDuration)
|
||||||
self:F({TACANChannel, Message, Bearing, BeaconDuration})
|
self:F({TACANChannel, Message, Bearing, BeaconDuration})
|
||||||
|
self:E("This method is DEPRECATED! Please use ActivateTACAN() instead.")
|
||||||
|
|
||||||
local IsValid = true
|
local IsValid = true
|
||||||
|
|
||||||
@@ -380,6 +387,8 @@ function BEACON:RadioBeacon(FileName, Frequency, Modulation, Power, BeaconDurati
|
|||||||
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
|
||||||
@@ -390,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
|
||||||
@@ -416,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,
|
||||||
@@ -425,6 +436,7 @@ function BEACON:RadioBeacon(FileName, Frequency, Modulation, Power, BeaconDurati
|
|||||||
end, {}, BeaconDuration)
|
end, {}, BeaconDuration)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Stops the Radio Beacon
|
--- Stops the Radio Beacon
|
||||||
@@ -433,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
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
-- @field #table Templates Templates: Units, Groups, Statics, ClientsByName, ClientsByID.
|
-- @field #table Templates Templates: Units, Groups, Statics, ClientsByName, ClientsByID.
|
||||||
-- @field #table CLIENTS Clients.
|
-- @field #table CLIENTS Clients.
|
||||||
-- @field #table STORAGES DCS warehouse storages.
|
-- @field #table STORAGES DCS warehouse storages.
|
||||||
|
-- @field #table STNS Used Link16 octal numbers for F16/15/18/AWACS planes.
|
||||||
|
-- @field #table SADL Used Link16 octal numbers for A10/C-II planes.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- Contains collections of wrapper objects defined within MOOSE that reflect objects within the simulator.
|
--- Contains collections of wrapper objects defined within MOOSE that reflect objects within the simulator.
|
||||||
@@ -93,6 +95,8 @@ DATABASE = {
|
|||||||
OPSZONES = {},
|
OPSZONES = {},
|
||||||
PATHLINES = {},
|
PATHLINES = {},
|
||||||
STORAGES = {},
|
STORAGES = {},
|
||||||
|
STNS={},
|
||||||
|
SADL={},
|
||||||
}
|
}
|
||||||
|
|
||||||
local _DATABASECoalition =
|
local _DATABASECoalition =
|
||||||
@@ -489,8 +493,30 @@ do -- Zones and Pathlines
|
|||||||
-- Create new polygon zone.
|
-- Create new polygon zone.
|
||||||
local Zone=ZONE_POLYGON:NewFromPointsArray(ZoneName, points)
|
local Zone=ZONE_POLYGON:NewFromPointsArray(ZoneName, points)
|
||||||
|
|
||||||
|
--Zone.DrawID = objectID
|
||||||
|
|
||||||
-- Set color.
|
-- Set color.
|
||||||
Zone:SetColor({1, 0, 0}, 0.15)
|
Zone:SetColor({1, 0, 0}, 0.15)
|
||||||
|
Zone:SetFillColor({1, 0, 0}, 0.15)
|
||||||
|
|
||||||
|
if objectData.colorString then
|
||||||
|
-- eg colorString = 0xff0000ff
|
||||||
|
local color = string.gsub(objectData.colorString,"^0x","")
|
||||||
|
local r = tonumber(string.sub(color,1,2),16)/255
|
||||||
|
local g = tonumber(string.sub(color,3,4),16)/255
|
||||||
|
local b = tonumber(string.sub(color,5,6),16)/255
|
||||||
|
local a = tonumber(string.sub(color,7,8),16)/255
|
||||||
|
Zone:SetColor({r, g, b}, a)
|
||||||
|
end
|
||||||
|
if objectData.fillColorString then
|
||||||
|
-- eg fillColorString = 0xff00004b
|
||||||
|
local color = string.gsub(objectData.colorString,"^0x","")
|
||||||
|
local r = tonumber(string.sub(color,1,2),16)/255
|
||||||
|
local g = tonumber(string.sub(color,3,4),16)/255
|
||||||
|
local b = tonumber(string.sub(color,5,6),16)/255
|
||||||
|
local a = tonumber(string.sub(color,7,8),16)/255
|
||||||
|
Zone:SetFillColor({r, g, b}, a)
|
||||||
|
end
|
||||||
|
|
||||||
-- Store in DB.
|
-- Store in DB.
|
||||||
self.ZONENAMES[ZoneName] = ZoneName
|
self.ZONENAMES[ZoneName] = ZoneName
|
||||||
@@ -533,6 +559,25 @@ do -- Zones and Pathlines
|
|||||||
-- Set color.
|
-- Set color.
|
||||||
Zone:SetColor({1, 0, 0}, 0.15)
|
Zone:SetColor({1, 0, 0}, 0.15)
|
||||||
|
|
||||||
|
if objectData.colorString then
|
||||||
|
-- eg colorString = 0xff0000ff
|
||||||
|
local color = string.gsub(objectData.colorString,"^0x","")
|
||||||
|
local r = tonumber(string.sub(color,1,2),16)/255
|
||||||
|
local g = tonumber(string.sub(color,3,4),16)/255
|
||||||
|
local b = tonumber(string.sub(color,5,6),16)/255
|
||||||
|
local a = tonumber(string.sub(color,7,8),16)/255
|
||||||
|
Zone:SetColor({r, g, b}, a)
|
||||||
|
end
|
||||||
|
if objectData.fillColorString then
|
||||||
|
-- eg fillColorString = 0xff00004b
|
||||||
|
local color = string.gsub(objectData.colorString,"^0x","")
|
||||||
|
local r = tonumber(string.sub(color,1,2),16)/255
|
||||||
|
local g = tonumber(string.sub(color,3,4),16)/255
|
||||||
|
local b = tonumber(string.sub(color,5,6),16)/255
|
||||||
|
local a = tonumber(string.sub(color,7,8),16)/255
|
||||||
|
Zone:SetFillColor({r, g, b}, a)
|
||||||
|
end
|
||||||
|
|
||||||
-- Store in DB.
|
-- Store in DB.
|
||||||
self.ZONENAMES[ZoneName] = ZoneName
|
self.ZONENAMES[ZoneName] = ZoneName
|
||||||
|
|
||||||
@@ -756,7 +801,7 @@ end -- cargo
|
|||||||
|
|
||||||
--- Finds a CLIENT based on the ClientName.
|
--- Finds a CLIENT based on the ClientName.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string ClientName
|
-- @param #string ClientName - Note this is the UNIT name of the client!
|
||||||
-- @return Wrapper.Client#CLIENT The found CLIENT.
|
-- @return Wrapper.Client#CLIENT The found CLIENT.
|
||||||
function DATABASE:FindClient( ClientName )
|
function DATABASE:FindClient( ClientName )
|
||||||
|
|
||||||
@@ -887,7 +932,7 @@ function DATABASE:Spawn( SpawnTemplate )
|
|||||||
SpawnTemplate.CountryID = nil
|
SpawnTemplate.CountryID = nil
|
||||||
SpawnTemplate.CategoryID = nil
|
SpawnTemplate.CategoryID = nil
|
||||||
|
|
||||||
self:_RegisterGroupTemplate( SpawnTemplate, SpawnCoalitionID, SpawnCategoryID, SpawnCountryID )
|
self:_RegisterGroupTemplate( SpawnTemplate, SpawnCoalitionID, SpawnCategoryID, SpawnCountryID, SpawnTemplate.name )
|
||||||
|
|
||||||
self:T3( SpawnTemplate )
|
self:T3( SpawnTemplate )
|
||||||
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
||||||
@@ -989,6 +1034,27 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, Category
|
|||||||
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if UnitTemplate.AddPropAircraft then
|
||||||
|
if UnitTemplate.AddPropAircraft.STN_L16 then
|
||||||
|
local stn = UTILS.OctalToDecimal(UnitTemplate.AddPropAircraft.STN_L16)
|
||||||
|
if stn == nil or stn < 1 then
|
||||||
|
self:E("WARNING: Invalid STN "..tostring(UnitTemplate.AddPropAircraft.STN_L16).." for ".. UnitTemplate.name)
|
||||||
|
else
|
||||||
|
self.STNS[stn] = UnitTemplate.name
|
||||||
|
self:I("Register STN "..tostring(UnitTemplate.AddPropAircraft.STN_L16).." for ".. UnitTemplate.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if UnitTemplate.AddPropAircraft.SADL_TN then
|
||||||
|
local sadl = UTILS.OctalToDecimal(UnitTemplate.AddPropAircraft.SADL_TN)
|
||||||
|
if sadl == nil or sadl < 1 then
|
||||||
|
self:E("WARNING: Invalid SADL "..tostring(UnitTemplate.AddPropAircraft.SADL_TN).." for ".. UnitTemplate.name)
|
||||||
|
else
|
||||||
|
self.SADL[sadl] = UnitTemplate.name
|
||||||
|
self:I("Register SADL "..tostring(UnitTemplate.AddPropAircraft.SADL_TN).." for ".. UnitTemplate.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
UnitNames[#UnitNames+1] = self.Templates.Units[UnitTemplate.name].UnitName
|
UnitNames[#UnitNames+1] = self.Templates.Units[UnitTemplate.name].UnitName
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1002,6 +1068,80 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, Category
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get next (consecutive) free STN as octal number.
|
||||||
|
-- @param #DATABASE self
|
||||||
|
-- @param #number octal Starting octal.
|
||||||
|
-- @param #string unitname Name of the associated unit.
|
||||||
|
-- @return #number Octal
|
||||||
|
function DATABASE:GetNextSTN(octal,unitname)
|
||||||
|
local first = UTILS.OctalToDecimal(octal) or 0
|
||||||
|
if self.STNS[first] == unitname then return octal end
|
||||||
|
local nextoctal = 77777
|
||||||
|
local found = false
|
||||||
|
if 32767-first < 10 then
|
||||||
|
first = 0
|
||||||
|
end
|
||||||
|
for i=first+1,32767 do
|
||||||
|
if self.STNS[i] == nil then
|
||||||
|
found = true
|
||||||
|
nextoctal = UTILS.DecimalToOctal(i)
|
||||||
|
self.STNS[i] = unitname
|
||||||
|
self:T("Register STN "..tostring(nextoctal).." for ".. unitname)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not found then
|
||||||
|
self:E(string.format("WARNING: No next free STN past %05d found!",octal))
|
||||||
|
-- cleanup
|
||||||
|
local NewSTNS = {}
|
||||||
|
for _id,_name in pairs(self.STNS) do
|
||||||
|
if self.UNITS[_name] ~= nil then
|
||||||
|
NewSTNS[_id] = _name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.STNS = nil
|
||||||
|
self.STNS = NewSTNS
|
||||||
|
end
|
||||||
|
return nextoctal
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get next (consecutive) free SADL as octal number.
|
||||||
|
-- @param #DATABASE self
|
||||||
|
-- @param #number octal Starting octal.
|
||||||
|
-- @param #string unitname Name of the associated unit.
|
||||||
|
-- @return #number Octal
|
||||||
|
function DATABASE:GetNextSADL(octal,unitname)
|
||||||
|
local first = UTILS.OctalToDecimal(octal) or 0
|
||||||
|
if self.SADL[first] == unitname then return octal end
|
||||||
|
local nextoctal = 7777
|
||||||
|
local found = false
|
||||||
|
if 4095-first < 10 then
|
||||||
|
first = 0
|
||||||
|
end
|
||||||
|
for i=first+1,4095 do
|
||||||
|
if self.STNS[i] == nil then
|
||||||
|
found = true
|
||||||
|
nextoctal = UTILS.DecimalToOctal(i)
|
||||||
|
self.SADL[i] = unitname
|
||||||
|
self:T("Register SADL "..tostring(nextoctal).." for ".. unitname)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not found then
|
||||||
|
self:E(string.format("WARNING: No next free SADL past %04d found!",octal))
|
||||||
|
-- cleanup
|
||||||
|
local NewSTNS = {}
|
||||||
|
for _id,_name in pairs(self.SADL) do
|
||||||
|
if self.UNITS[_name] ~= nil then
|
||||||
|
NewSTNS[_id] = _name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.SADL = nil
|
||||||
|
self.SADL = NewSTNS
|
||||||
|
end
|
||||||
|
return nextoctal
|
||||||
|
end
|
||||||
|
|
||||||
--- Get group template.
|
--- Get group template.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string GroupName Group name.
|
-- @param #string GroupName Group name.
|
||||||
@@ -1303,8 +1443,16 @@ function DATABASE:_RegisterAirbase(airbase)
|
|||||||
-- Unique ID.
|
-- Unique ID.
|
||||||
local airbaseUID=airbase:GetID(true)
|
local airbaseUID=airbase:GetID(true)
|
||||||
|
|
||||||
|
local typename = airbase:GetTypeName()
|
||||||
|
|
||||||
|
local category = airbase.category
|
||||||
|
|
||||||
|
if category == Airbase.Category.SHIP and typename == "FARP_SINGLE_01" then
|
||||||
|
category = Airbase.Category.HELIPAD
|
||||||
|
end
|
||||||
|
|
||||||
-- Debug output.
|
-- Debug output.
|
||||||
local text=string.format("Register %s: %s (UID=%d), Runways=%d, Parking=%d [", AIRBASE.CategoryName[airbase.category], tostring(DCSAirbaseName), airbaseUID, #airbase.runways, airbase.NparkingTotal)
|
local text=string.format("Register %s: %s (UID=%d), Runways=%d, Parking=%d [", AIRBASE.CategoryName[category], tostring(DCSAirbaseName), airbaseUID, #airbase.runways, airbase.NparkingTotal)
|
||||||
for _,terminalType in pairs(AIRBASE.TerminalType) do
|
for _,terminalType in pairs(AIRBASE.TerminalType) do
|
||||||
if airbase.NparkingTerminal and airbase.NparkingTerminal[terminalType] then
|
if airbase.NparkingTerminal and airbase.NparkingTerminal[terminalType] then
|
||||||
text=text..string.format("%d=%d ", terminalType, airbase.NparkingTerminal[terminalType])
|
text=text..string.format("%d=%d ", terminalType, airbase.NparkingTerminal[terminalType])
|
||||||
@@ -1537,7 +1685,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
|
||||||
|
|
||||||
@@ -1852,7 +2000,7 @@ end
|
|||||||
|
|
||||||
--- Add a flight control to the data base.
|
--- Add a flight control to the data base.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param Ops.FlightControl#FLIGHTCONTROL flightcontrol
|
-- @param OPS.FlightControl#FLIGHTCONTROL flightcontrol
|
||||||
function DATABASE:AddFlightControl(flightcontrol)
|
function DATABASE:AddFlightControl(flightcontrol)
|
||||||
self:F2( { flightcontrol } )
|
self:F2( { flightcontrol } )
|
||||||
self.FLIGHTCONTROLS[flightcontrol.airbasename]=flightcontrol
|
self.FLIGHTCONTROLS[flightcontrol.airbasename]=flightcontrol
|
||||||
@@ -1861,7 +2009,7 @@ end
|
|||||||
--- Get a flight control object from the data base.
|
--- Get a flight control object from the data base.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string airbasename Name of the associated airbase.
|
-- @param #string airbasename Name of the associated airbase.
|
||||||
-- @return Ops.FlightControl#FLIGHTCONTROL The FLIGHTCONTROL object.s
|
-- @return OPS.FlightControl#FLIGHTCONTROL The FLIGHTCONTROL object.s
|
||||||
function DATABASE:GetFlightControl(airbasename)
|
function DATABASE:GetFlightControl(airbasename)
|
||||||
return self.FLIGHTCONTROLS[airbasename]
|
return self.FLIGHTCONTROLS[airbasename]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -261,6 +261,15 @@ EVENTS = {
|
|||||||
SimulationStart = world.event.S_EVENT_SIMULATION_START or -1,
|
SimulationStart = world.event.S_EVENT_SIMULATION_START or -1,
|
||||||
WeaponRearm = world.event.S_EVENT_WEAPON_REARM or -1,
|
WeaponRearm = world.event.S_EVENT_WEAPON_REARM or -1,
|
||||||
WeaponDrop = world.event.S_EVENT_WEAPON_DROP or -1,
|
WeaponDrop = world.event.S_EVENT_WEAPON_DROP or -1,
|
||||||
|
-- Added with DCS 2.9.0
|
||||||
|
UnitTaskTimeout = world.event.S_EVENT_UNIT_TASK_TIMEOUT or -1,
|
||||||
|
UnitTaskStage = world.event.S_EVENT_UNIT_TASK_STAGE or -1,
|
||||||
|
MacSubtaskScore = world.event.S_EVENT_MAC_SUBTASK_SCORE or -1,
|
||||||
|
MacExtraScore = world.event.S_EVENT_MAC_EXTRA_SCORE or -1,
|
||||||
|
MissionRestart = world.event.S_EVENT_MISSION_RESTART or -1,
|
||||||
|
MissionWinner = world.event.S_EVENT_MISSION_WINNER or -1,
|
||||||
|
PostponedTakeoff = world.event.S_EVENT_POSTPONED_TAKEOFF or -1,
|
||||||
|
PostponedLand = world.event.S_EVENT_POSTPONED_LAND or -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- The Event structure
|
--- The Event structure
|
||||||
@@ -636,6 +645,55 @@ local _EVENTMETA = {
|
|||||||
Event = "OnEventWeaponDrop",
|
Event = "OnEventWeaponDrop",
|
||||||
Text = "S_EVENT_WEAPON_DROP"
|
Text = "S_EVENT_WEAPON_DROP"
|
||||||
},
|
},
|
||||||
|
-- DCS 2.9
|
||||||
|
[EVENTS.UnitTaskTimeout] = {
|
||||||
|
Order = 1,
|
||||||
|
Side = "I",
|
||||||
|
Event = "OnEventUnitTaskTimeout",
|
||||||
|
Text = "S_EVENT_UNIT_TASK_TIMEOUT "
|
||||||
|
},
|
||||||
|
[EVENTS.UnitTaskStage] = {
|
||||||
|
Order = 1,
|
||||||
|
Side = "I",
|
||||||
|
Event = "OnEventUnitTaskStage",
|
||||||
|
Text = "S_EVENT_UNIT_TASK_STAGE "
|
||||||
|
},
|
||||||
|
[EVENTS.MacSubtaskScore] = {
|
||||||
|
Order = 1,
|
||||||
|
Side = "I",
|
||||||
|
Event = "OnEventMacSubtaskScore",
|
||||||
|
Text = "S_EVENT_MAC_SUBTASK_SCORE"
|
||||||
|
},
|
||||||
|
[EVENTS.MacExtraScore] = {
|
||||||
|
Order = 1,
|
||||||
|
Side = "I",
|
||||||
|
Event = "OnEventMacExtraScore",
|
||||||
|
Text = "S_EVENT_MAC_EXTRA_SCOREP"
|
||||||
|
},
|
||||||
|
[EVENTS.MissionRestart] = {
|
||||||
|
Order = 1,
|
||||||
|
Side = "I",
|
||||||
|
Event = "OnEventMissionRestart",
|
||||||
|
Text = "S_EVENT_MISSION_RESTART"
|
||||||
|
},
|
||||||
|
[EVENTS.MissionWinner] = {
|
||||||
|
Order = 1,
|
||||||
|
Side = "I",
|
||||||
|
Event = "OnEventMissionWinner",
|
||||||
|
Text = "S_EVENT_MISSION_WINNER"
|
||||||
|
},
|
||||||
|
[EVENTS.PostponedTakeoff] = {
|
||||||
|
Order = 1,
|
||||||
|
Side = "I",
|
||||||
|
Event = "OnEventPostponedTakeoff",
|
||||||
|
Text = "S_EVENT_POSTPONED_TAKEOFF"
|
||||||
|
},
|
||||||
|
[EVENTS.PostponedLand] = {
|
||||||
|
Order = 1,
|
||||||
|
Side = "I",
|
||||||
|
Event = "OnEventPostponedLand",
|
||||||
|
Text = "S_EVENT_POSTPONED_LAND"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- The Events structure
|
--- The Events structure
|
||||||
@@ -1243,13 +1301,16 @@ 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()
|
||||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
-- Workaround for borked target info on cruise missiles
|
||||||
Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName, false )
|
if Event.TgtDCSUnitName and Event.TgtDCSUnitName ~= "" then
|
||||||
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName, false )
|
||||||
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
||||||
|
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
||||||
|
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Event.TgtDCSUnitName = string.format("No target object for Event ID %s", tostring(Event.id))
|
Event.TgtDCSUnitName = string.format("No target object for Event ID %s", tostring(Event.id))
|
||||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
@@ -1287,7 +1348,8 @@ function EVENT:onEvent( Event )
|
|||||||
Event.Weapon = Event.weapon
|
Event.Weapon = Event.weapon
|
||||||
Event.WeaponName = Event.Weapon:getTypeName()
|
Event.WeaponName = Event.Weapon:getTypeName()
|
||||||
Event.WeaponUNIT = CLIENT:Find( Event.Weapon, '', true ) -- Sometimes, the weapon is a player unit!
|
Event.WeaponUNIT = CLIENT:Find( Event.Weapon, '', true ) -- Sometimes, the weapon is a player unit!
|
||||||
Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName()
|
Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon.getPlayerName and Event.Weapon:getPlayerName()
|
||||||
|
--Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName()
|
||||||
Event.WeaponCoalition = Event.WeaponUNIT and Event.Weapon:getCoalition()
|
Event.WeaponCoalition = Event.WeaponUNIT and Event.Weapon:getCoalition()
|
||||||
Event.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category
|
Event.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category
|
||||||
Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName()
|
Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName()
|
||||||
@@ -1316,6 +1378,7 @@ function EVENT:onEvent( Event )
|
|||||||
Event.MarkCoordinate=COORDINATE:NewFromVec3(Event.pos)
|
Event.MarkCoordinate=COORDINATE:NewFromVec3(Event.pos)
|
||||||
Event.MarkText=Event.text
|
Event.MarkText=Event.text
|
||||||
Event.MarkCoalition=Event.coalition
|
Event.MarkCoalition=Event.coalition
|
||||||
|
Event.IniCoalition=Event.coalition
|
||||||
Event.MarkGroupID = Event.groupID
|
Event.MarkGroupID = Event.groupID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ do -- FSM
|
|||||||
--
|
--
|
||||||
-- ### Linear Transition Example
|
-- ### Linear Transition Example
|
||||||
--
|
--
|
||||||
-- This example is fully implemented in the MOOSE test mission on GITHUB: [FSM-100 - Transition Explanation](https://github.com/FlightControl-Master/MOOSE_MISSIONS/blob/master/FSM%20-%20Finite%20State%20Machine/FSM-100%20-%20Transition%20Explanation/FSM-100%20-%20Transition%20Explanation.lua)
|
-- This example is fully implemented in the MOOSE test mission on GitHub: [FSM-100 - Transition Explanation](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Core/FSM/FSM-100%20-%20Transition%20Explanation)
|
||||||
--
|
--
|
||||||
-- It models a unit standing still near Batumi, and flaring every 5 seconds while switching between a Green flare and a Red flare.
|
-- It models a unit standing still near Batumi, and flaring every 5 seconds while switching between a Green flare and a Red flare.
|
||||||
-- The purpose of this example is not to show how exciting flaring is, but it demonstrates how a Linear Transition FSM can be build.
|
-- The purpose of this example is not to show how exciting flaring is, but it demonstrates how a Linear Transition FSM can be build.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
-- ### Author: **Applevangelist**
|
-- ### Author: **Applevangelist**
|
||||||
--
|
--
|
||||||
-- Date: 5 May 2021
|
-- Date: 5 May 2021
|
||||||
-- Last Update: Feb 2023
|
-- Last Update: Mar 2023
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
---
|
---
|
||||||
@@ -50,7 +50,7 @@ MARKEROPS_BASE = {
|
|||||||
ClassName = "MARKEROPS",
|
ClassName = "MARKEROPS",
|
||||||
Tag = "mytag",
|
Tag = "mytag",
|
||||||
Keywords = {},
|
Keywords = {},
|
||||||
version = "0.1.1",
|
version = "0.1.3",
|
||||||
debug = false,
|
debug = false,
|
||||||
Casesensitive = true,
|
Casesensitive = true,
|
||||||
}
|
}
|
||||||
@@ -114,6 +114,8 @@ function MARKEROPS_BASE:New(Tagname,Keywords,Casesensitive)
|
|||||||
-- @param #string Text The text on the marker
|
-- @param #string Text The text on the marker
|
||||||
-- @param #table Keywords Table of matching keywords found in the Event text
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
-- @param #number MarkerID Id of this marker
|
||||||
|
-- @param #number CoalitionNumber Coalition of the marker creator
|
||||||
|
|
||||||
--- On after "MarkChanged" event. Triggered when a Marker is changed on the F10 map.
|
--- On after "MarkChanged" event. Triggered when a Marker is changed on the F10 map.
|
||||||
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkChanged
|
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkChanged
|
||||||
@@ -124,7 +126,8 @@ function MARKEROPS_BASE:New(Tagname,Keywords,Casesensitive)
|
|||||||
-- @param #string Text The text on the marker
|
-- @param #string Text The text on the marker
|
||||||
-- @param #table Keywords Table of matching keywords found in the Event text
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
-- @param #number idx DCS Marker ID
|
-- @param #number MarkerID Id of this marker
|
||||||
|
-- @param #number CoalitionNumber Coalition of the marker creator
|
||||||
|
|
||||||
--- On after "MarkDeleted" event. Triggered when a Marker is deleted from the F10 map.
|
--- On after "MarkDeleted" event. Triggered when a Marker is deleted from the F10 map.
|
||||||
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkDeleted
|
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkDeleted
|
||||||
@@ -133,7 +136,7 @@ function MARKEROPS_BASE:New(Tagname,Keywords,Casesensitive)
|
|||||||
-- @param #string Event The Event called
|
-- @param #string Event The Event called
|
||||||
-- @param #string To The To state
|
-- @param #string To The To state
|
||||||
|
|
||||||
--- "Stop" trigger. Used to stop the function an unhandle events
|
--- "Stop" trigger. Used to stop the function an unhandle events
|
||||||
-- @function [parent=#MARKEROPS_BASE] Stop
|
-- @function [parent=#MARKEROPS_BASE] Stop
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -155,29 +158,30 @@ function MARKEROPS_BASE:OnEventMark(Event)
|
|||||||
local text = tostring(Event.text)
|
local text = tostring(Event.text)
|
||||||
local m = MESSAGE:New(string.format("Mark added at %s with text: %s",coordtext,text),10,"Info",false):ToAll()
|
local m = MESSAGE:New(string.format("Mark added at %s with text: %s",coordtext,text),10,"Info",false):ToAll()
|
||||||
end
|
end
|
||||||
|
local coalition = Event.MarkCoalition
|
||||||
-- decision
|
-- decision
|
||||||
if Event.id==world.event.S_EVENT_MARK_ADDED then
|
if Event.id==world.event.S_EVENT_MARK_ADDED then
|
||||||
self:T({event="S_EVENT_MARK_ADDED", carrier=self.groupname, vec3=Event.pos})
|
self:T({event="S_EVENT_MARK_ADDED", carrier=Event.IniGroupName, vec3=Event.pos})
|
||||||
-- Handle event
|
-- Handle event
|
||||||
local Eventtext = tostring(Event.text)
|
local Eventtext = tostring(Event.text)
|
||||||
if Eventtext~=nil then
|
if Eventtext~=nil then
|
||||||
if self:_MatchTag(Eventtext) then
|
if self:_MatchTag(Eventtext) then
|
||||||
local matchtable = self:_MatchKeywords(Eventtext)
|
local matchtable = self:_MatchKeywords(Eventtext)
|
||||||
self:MarkAdded(Eventtext,matchtable,coord)
|
self:MarkAdded(Eventtext,matchtable,coord,Event.idx,coalition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif Event.id==world.event.S_EVENT_MARK_CHANGE then
|
elseif Event.id==world.event.S_EVENT_MARK_CHANGE then
|
||||||
self:T({event="S_EVENT_MARK_CHANGE", carrier=self.groupname, vec3=Event.pos})
|
self:T({event="S_EVENT_MARK_CHANGE", carrier=Event.IniGroupName, vec3=Event.pos})
|
||||||
-- Handle event.
|
-- Handle event.
|
||||||
local Eventtext = tostring(Event.text)
|
local Eventtext = tostring(Event.text)
|
||||||
if Eventtext~=nil then
|
if Eventtext~=nil then
|
||||||
if self:_MatchTag(Eventtext) then
|
if self:_MatchTag(Eventtext) then
|
||||||
local matchtable = self:_MatchKeywords(Eventtext)
|
local matchtable = self:_MatchKeywords(Eventtext)
|
||||||
self:MarkChanged(Eventtext,matchtable,coord,Event.idx)
|
self:MarkChanged(Eventtext,matchtable,coord,Event.idx,coalition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif Event.id==world.event.S_EVENT_MARK_REMOVED then
|
elseif Event.id==world.event.S_EVENT_MARK_REMOVED then
|
||||||
self:T({event="S_EVENT_MARK_REMOVED", carrier=self.groupname, vec3=Event.pos})
|
self:T({event="S_EVENT_MARK_REMOVED", carrier=Event.IniGroupName, vec3=Event.pos})
|
||||||
-- Hande event.
|
-- Hande event.
|
||||||
local Eventtext = tostring(Event.text)
|
local Eventtext = tostring(Event.text)
|
||||||
if Eventtext~=nil then
|
if Eventtext~=nil then
|
||||||
@@ -230,8 +234,10 @@ end
|
|||||||
-- @param #string To The To state
|
-- @param #string To The To state
|
||||||
-- @param #string Text The text on the marker
|
-- @param #string Text The text on the marker
|
||||||
-- @param #table Keywords Table of matching keywords found in the Event text
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param #number MarkerID Id of this marker
|
||||||
|
-- @param #number CoalitionNumber Coalition of the marker creator
|
||||||
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
function MARKEROPS_BASE:onbeforeMarkAdded(From,Event,To,Text,Keywords,Coord)
|
function MARKEROPS_BASE:onbeforeMarkAdded(From,Event,To,Text,Keywords,Coord,MarkerID,CoalitionNumber)
|
||||||
self:T({self.lid,From,Event,To,Text,Keywords,Coord:ToStringLLDDM()})
|
self:T({self.lid,From,Event,To,Text,Keywords,Coord:ToStringLLDDM()})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -242,8 +248,10 @@ end
|
|||||||
-- @param #string To The To state
|
-- @param #string To The To state
|
||||||
-- @param #string Text The text on the marker
|
-- @param #string Text The text on the marker
|
||||||
-- @param #table Keywords Table of matching keywords found in the Event text
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param #number MarkerID Id of this marker
|
||||||
|
-- @param #number CoalitionNumber Coalition of the marker creator
|
||||||
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
function MARKEROPS_BASE:onbeforeMarkChanged(From,Event,To,Text,Keywords,Coord)
|
function MARKEROPS_BASE:onbeforeMarkChanged(From,Event,To,Text,Keywords,Coord,MarkerID,CoalitionNumber)
|
||||||
self:T({self.lid,From,Event,To,Text,Keywords,Coord:ToStringLLDDM()})
|
self:T({self.lid,From,Event,To,Text,Keywords,Coord:ToStringLLDDM()})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### Features:
|
-- ## Features:
|
||||||
--
|
--
|
||||||
-- * Setup mission sub menus.
|
-- * Setup mission sub menus.
|
||||||
-- * Setup mission command menus.
|
-- * Setup mission command menus.
|
||||||
@@ -44,7 +44,11 @@
|
|||||||
-- * @{Core.Menu#MENU_GROUP_COMMAND}: Manages command menus for GROUPs.
|
-- * @{Core.Menu#MENU_GROUP_COMMAND}: Manages command menus for GROUPs.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
---
|
--
|
||||||
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Core/Menu)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
-- ### Author: **FlightControl**
|
-- ### Author: **FlightControl**
|
||||||
-- ### Contributions:
|
-- ### Contributions:
|
||||||
--
|
--
|
||||||
@@ -166,7 +170,8 @@ function MENU_INDEX:Refresh( Group )
|
|||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_BASE
|
do -- MENU_BASE
|
||||||
--- @type MENU_BASE
|
---
|
||||||
|
-- @type MENU_BASE
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
--- Defines the main MENU class where other MENU classes are derived from.
|
--- Defines the main MENU class where other MENU classes are derived from.
|
||||||
-- This is an abstract class, so don't use it.
|
-- This is an abstract class, so don't use it.
|
||||||
@@ -206,6 +211,7 @@ do -- MENU_BASE
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_BASE:SetParentMenu( MenuText, Menu )
|
function MENU_BASE:SetParentMenu( MenuText, Menu )
|
||||||
if self.ParentMenu then
|
if self.ParentMenu then
|
||||||
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
||||||
@@ -277,8 +283,10 @@ do -- MENU_BASE
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
do -- MENU_COMMAND_BASE
|
do
|
||||||
--- @type MENU_COMMAND_BASE
|
---
|
||||||
|
-- MENU_COMMAND_BASE
|
||||||
|
-- @type MENU_COMMAND_BASE
|
||||||
-- @field #function MenuCallHandler
|
-- @field #function MenuCallHandler
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
@@ -343,8 +351,10 @@ do -- MENU_COMMAND_BASE
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_MISSION
|
do
|
||||||
--- @type MENU_MISSION
|
---
|
||||||
|
-- MENU_MISSION
|
||||||
|
-- @type MENU_MISSION
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
--- Manages the main menus for a complete mission.
|
--- Manages the main menus for a complete mission.
|
||||||
--
|
--
|
||||||
@@ -509,8 +519,9 @@ do -- MENU_MISSION_COMMAND
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
do -- MENU_COALITION
|
do
|
||||||
--- @type MENU_COALITION
|
--- MENU_COALITION
|
||||||
|
-- @type MENU_COALITION
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
--- Manages the main menus for DCS.coalition.
|
--- Manages the main menus for DCS.coalition.
|
||||||
@@ -635,9 +646,10 @@ do -- MENU_COALITION
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
do -- MENU_COALITION_COMMAND
|
do
|
||||||
|
|
||||||
--- @type MENU_COALITION_COMMAND
|
--- MENU_COALITION_COMMAND
|
||||||
|
-- @type MENU_COALITION_COMMAND
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
--- Manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
--- Manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
||||||
@@ -725,8 +737,11 @@ do
|
|||||||
-- So every menu for a client created must be tracked so that program logic accidentally does not create.
|
-- So every menu for a client created must be tracked so that program logic accidentally does not create.
|
||||||
-- the same menus twice during initialization logic.
|
-- the same menus twice during initialization logic.
|
||||||
-- These menu classes are handling this logic with this variable.
|
-- These menu classes are handling this logic with this variable.
|
||||||
|
|
||||||
local _MENUGROUPS = {}
|
local _MENUGROUPS = {}
|
||||||
--- @type MENU_GROUP
|
|
||||||
|
---
|
||||||
|
-- @type MENU_GROUP
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -757,7 +772,7 @@ do
|
|||||||
-- MenuStatus[MenuGroupName]:Remove()
|
-- MenuStatus[MenuGroupName]:Remove()
|
||||||
-- end
|
-- end
|
||||||
--
|
--
|
||||||
-- --- @param Wrapper.Group#GROUP MenuGroup
|
-- -- @param Wrapper.Group#GROUP MenuGroup
|
||||||
-- local function AddStatusMenu( MenuGroup )
|
-- local function AddStatusMenu( MenuGroup )
|
||||||
-- local MenuGroupName = MenuGroup:GetName()
|
-- local MenuGroupName = MenuGroup:GetName()
|
||||||
-- -- This would create a menu for the red coalition under the MenuCoalitionRed menu object.
|
-- -- This would create a menu for the red coalition under the MenuCoalitionRed menu object.
|
||||||
@@ -899,8 +914,8 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---
|
||||||
--- @type MENU_GROUP_COMMAND
|
-- @type MENU_GROUP_COMMAND
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
--- The @{Core.Menu#MENU_GROUP_COMMAND} class manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
--- The @{Core.Menu#MENU_GROUP_COMMAND} class manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
||||||
@@ -983,7 +998,8 @@ do
|
|||||||
end
|
end
|
||||||
--- MENU_GROUP_DELAYED
|
--- MENU_GROUP_DELAYED
|
||||||
do
|
do
|
||||||
--- @type MENU_GROUP_DELAYED
|
---
|
||||||
|
-- @type MENU_GROUP_DELAYED
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -1034,6 +1050,7 @@ do
|
|||||||
-- @param #MENU_GROUP_DELAYED self
|
-- @param #MENU_GROUP_DELAYED self
|
||||||
-- @return #MENU_GROUP_DELAYED
|
-- @return #MENU_GROUP_DELAYED
|
||||||
function MENU_GROUP_DELAYED:Set()
|
function MENU_GROUP_DELAYED:Set()
|
||||||
|
if not self.GroupID then return end
|
||||||
do
|
do
|
||||||
if not self.MenuSet then
|
if not self.MenuSet then
|
||||||
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
@@ -1106,8 +1123,8 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---
|
||||||
--- @type MENU_GROUP_COMMAND_DELAYED
|
-- @type MENU_GROUP_COMMAND_DELAYED
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
--- Manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
--- Manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ function MESSAGE:ToCoalition( CoalitionSide, Settings )
|
|||||||
if CoalitionSide then
|
if CoalitionSide then
|
||||||
if self.MessageDuration ~= 0 then
|
if self.MessageDuration ~= 0 then
|
||||||
self:T( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ) .. " / " .. self.MessageDuration )
|
self:T( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ) .. " / " .. self.MessageDuration )
|
||||||
trigger.action.outTextForCoalition( CoalitionSide, self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen )
|
trigger.action.outTextForCoalition( CoalitionSide, self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -459,14 +459,14 @@ end
|
|||||||
|
|
||||||
_MESSAGESRS = {}
|
_MESSAGESRS = {}
|
||||||
|
|
||||||
--- Set up MESSAGE generally to allow Text-To-Speech via SRS and TTS functions.
|
--- Set up MESSAGE generally to allow Text-To-Speech via SRS and TTS functions. `SetMSRS()` will try to use as many attributes configured with @{Sound.SRS#MSRS.LoadConfigFile}() as possible.
|
||||||
-- @param #string PathToSRS Path to SRS Folder, defaults to "C:\\\\Program Files\\\\DCS-SimpleRadio-Standalone".
|
-- @param #string PathToSRS (optional) Path to SRS Folder, defaults to "C:\\\\Program Files\\\\DCS-SimpleRadio-Standalone" or your configuration file setting.
|
||||||
-- @param #number Port Port number of SRS, defaults to 5002.
|
-- @param #number Port Port (optional) number of SRS, defaults to 5002 or your configuration file setting.
|
||||||
-- @param #string PathToCredentials (optional) Path to credentials file for e.g. Google.
|
-- @param #string PathToCredentials (optional) Path to credentials file for Google.
|
||||||
-- @param #number Frequency Frequency in MHz. Can also be given as a #table of frequencies.
|
-- @param #number Frequency Frequency in MHz. Can also be given as a #table of frequencies.
|
||||||
-- @param #number Modulation Modulation, i.e. radio.modulation.AM or radio.modulation.FM. Can also be given as a #table of modulations.
|
-- @param #number Modulation Modulation, i.e. radio.modulation.AM or radio.modulation.FM. Can also be given as a #table of modulations.
|
||||||
-- @param #string Gender (optional) Gender, i.e. "male" or "female", defaults to "female".
|
-- @param #string Gender (optional) Gender, i.e. "male" or "female", defaults to "female" or your configuration file setting.
|
||||||
-- @param #string Culture (optional) Culture, e.g. "en-US", defaults to "en-GB"
|
-- @param #string Culture (optional) Culture, e.g. "en-US", defaults to "en-GB" or your configuration file setting.
|
||||||
-- @param #string Voice (optional) Voice. Will override gender and culture settings, e.g. MSRS.Voices.Microsoft.Hazel or MSRS.Voices.Google.Standard.de_DE_Standard_D. Hint on Microsoft voices - working voices are limited to Hedda, Hazel, David, Zira and Hortense. **Must** be installed on your Desktop or Server!
|
-- @param #string Voice (optional) Voice. Will override gender and culture settings, e.g. MSRS.Voices.Microsoft.Hazel or MSRS.Voices.Google.Standard.de_DE_Standard_D. Hint on Microsoft voices - working voices are limited to Hedda, Hazel, David, Zira and Hortense. **Must** be installed on your Desktop or Server!
|
||||||
-- @param #number Coalition (optional) Coalition, can be coalition.side.RED, coalition.side.BLUE or coalition.side.NEUTRAL. Defaults to coalition.side.NEUTRAL.
|
-- @param #number Coalition (optional) Coalition, can be coalition.side.RED, coalition.side.BLUE or coalition.side.NEUTRAL. Defaults to coalition.side.NEUTRAL.
|
||||||
-- @param #number Volume (optional) Volume, can be between 0.0 and 1.0 (loudest).
|
-- @param #number Volume (optional) Volume, can be between 0.0 and 1.0 (loudest).
|
||||||
@@ -480,45 +480,51 @@ _MESSAGESRS = {}
|
|||||||
-- MESSAGE:New("Test message!",15,"SPAWN"):ToSRS()
|
-- MESSAGE:New("Test message!",15,"SPAWN"):ToSRS()
|
||||||
--
|
--
|
||||||
function MESSAGE.SetMSRS(PathToSRS,Port,PathToCredentials,Frequency,Modulation,Gender,Culture,Voice,Coalition,Volume,Label,Coordinate)
|
function MESSAGE.SetMSRS(PathToSRS,Port,PathToCredentials,Frequency,Modulation,Gender,Culture,Voice,Coalition,Volume,Label,Coordinate)
|
||||||
_MESSAGESRS.MSRS = MSRS:New(PathToSRS,Frequency or 243,Modulation or radio.modulation.AM,Volume)
|
|
||||||
|
|
||||||
_MESSAGESRS.frequency = Frequency
|
_MESSAGESRS.PathToSRS = PathToSRS or MSRS.path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||||
_MESSAGESRS.modulation = Modulation or radio.modulation.AM
|
|
||||||
|
|
||||||
_MESSAGESRS.MSRS:SetCoalition(Coalition or coalition.side.NEUTRAL)
|
_MESSAGESRS.frequency = Frequency or MSRS.frequencies or 243
|
||||||
_MESSAGESRS.coalition = Coalition or coalition.side.NEUTRAL
|
_MESSAGESRS.modulation = Modulation or MSRS.modulations or radio.modulation.AM
|
||||||
|
|
||||||
|
_MESSAGESRS.MSRS = MSRS:New(_MESSAGESRS.PathToSRS,_MESSAGESRS.frequency, _MESSAGESRS.modulation)
|
||||||
|
|
||||||
|
_MESSAGESRS.coalition = Coalition or MSRS.coalition or coalition.side.NEUTRAL
|
||||||
|
_MESSAGESRS.MSRS:SetCoalition(_MESSAGESRS.coalition)
|
||||||
|
|
||||||
_MESSAGESRS.coordinate = Coordinate
|
_MESSAGESRS.coordinate = Coordinate
|
||||||
_MESSAGESRS.MSRS:SetCoordinate(Coordinate)
|
|
||||||
|
|
||||||
|
if Coordinate then
|
||||||
|
_MESSAGESRS.MSRS:SetCoordinate(Coordinate)
|
||||||
|
end
|
||||||
|
|
||||||
|
_MESSAGESRS.Culture = Culture or MSRS.culture or "en-GB"
|
||||||
_MESSAGESRS.MSRS:SetCulture(Culture)
|
_MESSAGESRS.MSRS:SetCulture(Culture)
|
||||||
_MESSAGESRS.Culture = Culture or "en-GB"
|
|
||||||
|
|
||||||
|
_MESSAGESRS.Gender = Gender or MSRS.gender or "female"
|
||||||
_MESSAGESRS.MSRS:SetGender(Gender)
|
_MESSAGESRS.MSRS:SetGender(Gender)
|
||||||
_MESSAGESRS.Gender = Gender or "female"
|
|
||||||
|
|
||||||
_MESSAGESRS.MSRS:SetGoogle(PathToCredentials)
|
if PathToCredentials then
|
||||||
_MESSAGESRS.google = PathToCredentials
|
_MESSAGESRS.MSRS:SetProviderOptionsGoogle(PathToCredentials)
|
||||||
|
_MESSAGESRS.MSRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||||
|
end
|
||||||
|
|
||||||
_MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE")
|
_MESSAGESRS.label = Label or MSRS.Label or "MESSAGE"
|
||||||
_MESSAGESRS.label = Label or "MESSAGE"
|
_MESSAGESRS.MSRS:SetLabel(_MESSAGESRS.label)
|
||||||
|
|
||||||
_MESSAGESRS.MSRS:SetPort(Port or 5002)
|
_MESSAGESRS.port = Port or MSRS.port or 5002
|
||||||
_MESSAGESRS.port = Port or 5002
|
_MESSAGESRS.MSRS:SetPort(_MESSAGESRS.port)
|
||||||
|
|
||||||
_MESSAGESRS.volume = Volume or 1
|
_MESSAGESRS.volume = Volume or MSRS.volume or 1
|
||||||
_MESSAGESRS.MSRS:SetVolume(_MESSAGESRS.volume)
|
_MESSAGESRS.MSRS:SetVolume(_MESSAGESRS.volume)
|
||||||
|
|
||||||
if Voice then _MESSAGESRS.MSRS:SetVoice(Voice) end
|
if Voice then _MESSAGESRS.MSRS:SetVoice(Voice) end
|
||||||
|
|
||||||
_MESSAGESRS.voice = Voice --or MSRS.Voices.Microsoft.Hedda
|
_MESSAGESRS.voice = Voice or MSRS.voice --or MSRS.Voices.Microsoft.Hedda
|
||||||
--if _MESSAGESRS.google and not Voice then _MESSAGESRS.Voice = MSRS.Voices.Google.Standard.en_GB_Standard_A end
|
|
||||||
--_MESSAGESRS.MSRS:SetVoice(Voice or _MESSAGESRS.voice)
|
|
||||||
|
|
||||||
_MESSAGESRS.SRSQ = MSRSQUEUE:New(Label or "MESSAGE")
|
_MESSAGESRS.SRSQ = MSRSQUEUE:New(_MESSAGESRS.label)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sends a message via SRS.
|
--- Sends a message via SRS. `ToSRS()` will try to use as many attributes configured with @{Core.Message#MESSAGE.SetMSRS}() and @{Sound.SRS#MSRS.LoadConfigFile}() as possible.
|
||||||
-- @param #MESSAGE self
|
-- @param #MESSAGE self
|
||||||
-- @param #number frequency (optional) Frequency in MHz. Can also be given as a #table of frequencies. Only needed if you want to override defaults set with `MESSAGE.SetMSRS()` for this one setting.
|
-- @param #number frequency (optional) Frequency in MHz. Can also be given as a #table of frequencies. Only needed if you want to override defaults set with `MESSAGE.SetMSRS()` for this one setting.
|
||||||
-- @param #number modulation (optional) Modulation, i.e. radio.modulation.AM or radio.modulation.FM. Can also be given as a #table of modulations. Only needed if you want to override defaults set with `MESSAGE.SetMSRS()` for this one setting.
|
-- @param #number modulation (optional) Modulation, i.e. radio.modulation.AM or radio.modulation.FM. Can also be given as a #table of modulations. Only needed if you want to override defaults set with `MESSAGE.SetMSRS()` for this one setting.
|
||||||
@@ -546,7 +552,7 @@ function MESSAGE:ToSRS(frequency,modulation,gender,culture,voice,coalition,volum
|
|||||||
_MESSAGESRS.MSRS:SetCoordinate(coordinate)
|
_MESSAGESRS.MSRS:SetCoordinate(coordinate)
|
||||||
end
|
end
|
||||||
local category = string.gsub(self.MessageCategory,":","")
|
local category = string.gsub(self.MessageCategory,":","")
|
||||||
_MESSAGESRS.SRSQ:NewTransmission(self.MessageText,nil,_MESSAGESRS.MSRS,nil,nil,nil,nil,nil,frequency or _MESSAGESRS.frequency,modulation or _MESSAGESRS.modulation, gender or _MESSAGESRS.Gender,culture or _MESSAGESRS.Culture,nil,volume or _MESSAGESRS.volume,category,coordinate or _MESSAGESRS.coordinate)
|
_MESSAGESRS.SRSQ:NewTransmission(self.MessageText,nil,_MESSAGESRS.MSRS,0.5,1,nil,nil,nil,frequency or _MESSAGESRS.frequency,modulation or _MESSAGESRS.modulation, gender or _MESSAGESRS.Gender,culture or _MESSAGESRS.Culture,nil,volume or _MESSAGESRS.volume,category,coordinate or _MESSAGESRS.coordinate)
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ PATHLINE = {
|
|||||||
|
|
||||||
--- PATHLINE class version.
|
--- PATHLINE class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
PATHLINE.version="0.1.0"
|
PATHLINE.version="0.1.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -237,13 +237,14 @@ end
|
|||||||
--- Get COORDINATES of pathline. Note that COORDINATE objects are created when calling this function. That does involve deep copy calls and can have an impact on performance if done too often.
|
--- Get COORDINATES of pathline. Note that COORDINATE objects are created when calling this function. That does involve deep copy calls and can have an impact on performance if done too often.
|
||||||
-- @param #PATHLINE self
|
-- @param #PATHLINE self
|
||||||
-- @return <Core.Point#COORDINATE> List of COORDINATES points.
|
-- @return <Core.Point#COORDINATE> List of COORDINATES points.
|
||||||
function PATHLINE:GetCoordinats()
|
function PATHLINE:GetCoordinates()
|
||||||
|
|
||||||
local vecs={}
|
local vecs={}
|
||||||
|
|
||||||
for _,_point in pairs(self.points) do
|
for _,_point in pairs(self.points) do
|
||||||
local point=_point --#PATHLINE.Point
|
local point=_point --#PATHLINE.Point
|
||||||
local coord=COORDINATE:NewFromVec3(point.vec3)
|
local coord=COORDINATE:NewFromVec3(point.vec3)
|
||||||
|
table.insert(vecs,coord)
|
||||||
end
|
end
|
||||||
|
|
||||||
return vecs
|
return vecs
|
||||||
@@ -262,7 +263,7 @@ function PATHLINE:GetPointFromIndex(n)
|
|||||||
local point=nil --#PATHLINE.Point
|
local point=nil --#PATHLINE.Point
|
||||||
|
|
||||||
if n>=1 and n<=N then
|
if n>=1 and n<=N then
|
||||||
point=self.point[n]
|
point=self.points[n]
|
||||||
else
|
else
|
||||||
self:E(self.lid..string.format("ERROR: No point in pathline for N=%s", tostring(n)))
|
self:E(self.lid..string.format("ERROR: No point in pathline for N=%s", tostring(n)))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,22 +8,6 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- # Demo Missions
|
|
||||||
--
|
|
||||||
-- ### [POINT_VEC Demo Missions source code]()
|
|
||||||
--
|
|
||||||
-- ### [POINT_VEC Demo Missions, only for beta testers]()
|
|
||||||
--
|
|
||||||
-- ### [ALL Demo Missions pack of the last release](https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases)
|
|
||||||
--
|
|
||||||
-- ===
|
|
||||||
--
|
|
||||||
-- # YouTube Channel
|
|
||||||
--
|
|
||||||
-- ### [POINT_VEC YouTube Channel]()
|
|
||||||
--
|
|
||||||
-- ===
|
|
||||||
--
|
|
||||||
-- ### Authors:
|
-- ### Authors:
|
||||||
--
|
--
|
||||||
-- * FlightControl (Design & Programming)
|
-- * FlightControl (Design & Programming)
|
||||||
@@ -41,7 +25,8 @@
|
|||||||
|
|
||||||
do -- COORDINATE
|
do -- COORDINATE
|
||||||
|
|
||||||
--- @type COORDINATE
|
---
|
||||||
|
-- @type COORDINATE
|
||||||
-- @field #string ClassName Name of the class
|
-- @field #string ClassName Name of the class
|
||||||
-- @field #number x Component of the 3D vector.
|
-- @field #number x Component of the 3D vector.
|
||||||
-- @field #number y Component of the 3D vector.
|
-- @field #number y Component of the 3D vector.
|
||||||
@@ -196,7 +181,7 @@ do -- COORDINATE
|
|||||||
-- * @{#COORDINATE.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance.
|
-- * @{#COORDINATE.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance.
|
||||||
-- * @{#COORDINATE.ToStringBRA}(): Generates a Bearing, Range & Altitude text.
|
-- * @{#COORDINATE.ToStringBRA}(): Generates a Bearing, Range & Altitude text.
|
||||||
-- * @{#COORDINATE.ToStringBRAANATO}(): Generates a Generates a Bearing, Range, Aspect & Altitude text in NATOPS.
|
-- * @{#COORDINATE.ToStringBRAANATO}(): Generates a Generates a Bearing, Range, Aspect & Altitude text in NATOPS.
|
||||||
-- * @{#COORDINATE.ToStringLL}(): Generates a Latutide & Longitude text.
|
-- * @{#COORDINATE.ToStringLL}(): Generates a Latitude & Longitude text.
|
||||||
-- * @{#COORDINATE.ToStringLLDMS}(): Generates a Lat, Lon, Degree, Minute, Second text.
|
-- * @{#COORDINATE.ToStringLLDMS}(): Generates a Lat, Lon, Degree, Minute, Second text.
|
||||||
-- * @{#COORDINATE.ToStringLLDDM}(): Generates a Lat, Lon, Degree, decimal Minute text.
|
-- * @{#COORDINATE.ToStringLLDDM}(): Generates a Lat, Lon, Degree, decimal Minute text.
|
||||||
-- * @{#COORDINATE.ToStringMGRS}(): Generates a MGRS grid coordinate text.
|
-- * @{#COORDINATE.ToStringMGRS}(): Generates a MGRS grid coordinate text.
|
||||||
@@ -718,6 +703,7 @@ do -- COORDINATE
|
|||||||
-- @return DCS#Distance The distance from the reference @{#COORDINATE} in meters.
|
-- @return DCS#Distance The distance from the reference @{#COORDINATE} in meters.
|
||||||
function COORDINATE:DistanceFromPointVec2( PointVec2Reference )
|
function COORDINATE:DistanceFromPointVec2( PointVec2Reference )
|
||||||
self:F2( PointVec2Reference )
|
self:F2( PointVec2Reference )
|
||||||
|
if not PointVec2Reference then return math.huge end
|
||||||
|
|
||||||
local Distance = ( ( PointVec2Reference.x - self.x ) ^ 2 + ( PointVec2Reference.z - self.z ) ^2 ) ^ 0.5
|
local Distance = ( ( PointVec2Reference.x - self.x ) ^ 2 + ( PointVec2Reference.z - self.z ) ^2 ) ^ 0.5
|
||||||
|
|
||||||
@@ -920,7 +906,7 @@ do -- COORDINATE
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Return an angle in radians from the COORDINATE using a direction vector in Vec3 format.
|
--- Return an angle in radians from the COORDINATE using a **direction vector in Vec3 format**.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
|
-- @param DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
|
||||||
-- @return #number DirectionRadians The angle in radians.
|
-- @return #number DirectionRadians The angle in radians.
|
||||||
@@ -933,10 +919,12 @@ do -- COORDINATE
|
|||||||
return DirectionRadians
|
return DirectionRadians
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return an angle in degrees from the COORDINATE using a direction vector in Vec3 format.
|
--- Return an angle in degrees from the COORDINATE using a **direction vector in Vec3 format**.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
|
-- @param DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
|
||||||
-- @return #number DirectionRadians The angle in degrees.
|
-- @return #number DirectionRadians The angle in degrees.
|
||||||
|
-- @usage
|
||||||
|
-- local directionAngle = currentCoordinate:GetAngleDegrees(currentCoordinate:GetDirectionVec3(sourceCoordinate:GetVec3()))
|
||||||
function COORDINATE:GetAngleDegrees( DirectionVec3 )
|
function COORDINATE:GetAngleDegrees( DirectionVec3 )
|
||||||
local AngleRadians = self:GetAngleRadians( DirectionVec3 )
|
local AngleRadians = self:GetAngleRadians( DirectionVec3 )
|
||||||
local Angle = UTILS.ToDegree( AngleRadians )
|
local Angle = UTILS.ToDegree( AngleRadians )
|
||||||
@@ -2469,15 +2457,18 @@ do -- COORDINATE
|
|||||||
-- Write command as string and execute that. Idea by Grimes https://forum.dcs.world/topic/324201-mark-to-all-function/#comment-5273793
|
-- Write command as string and execute that. Idea by Grimes https://forum.dcs.world/topic/324201-mark-to-all-function/#comment-5273793
|
||||||
local s=string.format("trigger.action.markupToAll(7, %d, %d,", Coalition, MarkID)
|
local s=string.format("trigger.action.markupToAll(7, %d, %d,", Coalition, MarkID)
|
||||||
for _,vec in pairs(vecs) do
|
for _,vec in pairs(vecs) do
|
||||||
s=s..string.format("%s,", UTILS._OneLineSerialize(vec))
|
--s=s..string.format("%s,", UTILS._OneLineSerialize(vec))
|
||||||
|
s=s..string.format("{x=%.1f, y=%.1f, z=%.1f},", vec.x, vec.y, vec.z)
|
||||||
end
|
end
|
||||||
s=s..string.format("%s, %s, %s, %s", UTILS._OneLineSerialize(Color), UTILS._OneLineSerialize(FillColor), tostring(LineType), tostring(ReadOnly))
|
s=s..string.format("{%.3f, %.3f, %.3f, %.3f},", Color[1], Color[2], Color[3], Color[4])
|
||||||
if Text and Text~="" then
|
s=s..string.format("{%.3f, %.3f, %.3f, %.3f},", FillColor[1], FillColor[2], FillColor[3], FillColor[4])
|
||||||
s=s..string.format(", \"%s\"", Text)
|
s=s..string.format("%d,", LineType or 1)
|
||||||
|
s=s..string.format("%s", tostring(ReadOnly))
|
||||||
|
if Text and type(Text)=="string" and string.len(Text)>0 then
|
||||||
|
s=s..string.format(", \"%s\"", tostring(Text))
|
||||||
end
|
end
|
||||||
s=s..")"
|
s=s..")"
|
||||||
|
|
||||||
|
|
||||||
-- Execute string command
|
-- Execute string command
|
||||||
local success=UTILS.DoString(s)
|
local success=UTILS.DoString(s)
|
||||||
|
|
||||||
@@ -2565,7 +2556,7 @@ do -- COORDINATE
|
|||||||
|
|
||||||
Offset=Offset or 2
|
Offset=Offset or 2
|
||||||
|
|
||||||
-- Measurement of visibility should not be from the ground, so Adding a hypotethical 2 meters to each Coordinate.
|
-- Measurement of visibility should not be from the ground, so Adding a hypothetical 2 meters to each Coordinate.
|
||||||
local FromVec3 = self:GetVec3()
|
local FromVec3 = self:GetVec3()
|
||||||
FromVec3.y = FromVec3.y + Offset
|
FromVec3.y = FromVec3.y + Offset
|
||||||
|
|
||||||
@@ -2966,10 +2957,10 @@ do -- COORDINATE
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- corrected Track to be direction of travel of bogey (self in this case)
|
-- corrected Track to be direction of travel of bogey (self in this case)
|
||||||
local track = "Maneuver"
|
local track = "Maneuver"
|
||||||
|
|
||||||
if self.Heading then
|
if self.Heading then
|
||||||
track = UTILS.BearingToCardinal(self.Heading) or "North"
|
track = UTILS.BearingToCardinal(self.Heading) or "North"
|
||||||
end
|
end
|
||||||
|
|
||||||
if rangeNM > 3 then
|
if rangeNM > 3 then
|
||||||
@@ -3021,6 +3012,16 @@ do -- COORDINATE
|
|||||||
return BRAANATO
|
return BRAANATO
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Return the BULLSEYE as COORDINATE Object
|
||||||
|
-- @param #number Coalition Coalition of the bulls eye to return, e.g. coalition.side.BLUE
|
||||||
|
-- @return #COORDINATE self
|
||||||
|
-- @usage
|
||||||
|
-- -- note the dot (.) here,not using the colon (:)
|
||||||
|
-- local redbulls = COORDINATE.GetBullseyeCoordinate(coalition.side.RED)
|
||||||
|
function COORDINATE.GetBullseyeCoordinate(Coalition)
|
||||||
|
return COORDINATE:NewFromVec3( coalition.getMainRefPoint( Coalition ) )
|
||||||
|
end
|
||||||
|
|
||||||
--- Return a BULLS string out of the BULLS of the coalition to the COORDINATE.
|
--- Return a BULLS string out of the BULLS of the coalition to the COORDINATE.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param DCS#coalition.side Coalition The coalition.
|
-- @param DCS#coalition.side Coalition The coalition.
|
||||||
@@ -3071,6 +3072,18 @@ do -- COORDINATE
|
|||||||
return coord.LOtoLL( self:GetVec3() )
|
return coord.LOtoLL( self:GetVec3() )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get Latitude & Longitude text.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object.
|
||||||
|
-- @return #string LLText
|
||||||
|
function COORDINATE:ToStringLL( Settings )
|
||||||
|
|
||||||
|
local LL_Accuracy = Settings and Settings.LL_Accuracy or _SETTINGS.LL_Accuracy
|
||||||
|
local lat, lon = coord.LOtoLL( self:GetVec3() )
|
||||||
|
return string.format('%f', lat) .. ' ' .. string.format('%f', lon)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Provides a Lat Lon string in Degree Minute Second format.
|
--- Provides a Lat Lon string in Degree Minute Second format.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object.
|
-- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object.
|
||||||
@@ -3105,6 +3118,50 @@ do -- COORDINATE
|
|||||||
return "MGRS " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy )
|
return "MGRS " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Provides a COORDINATE from an MGRS String
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #string MGRSString MGRS String, e.g. "MGRS 37T DK 12345 12345"
|
||||||
|
-- @return #COORDINATE self
|
||||||
|
function COORDINATE:NewFromMGRSString( MGRSString )
|
||||||
|
local myparts = UTILS.Split(MGRSString," ")
|
||||||
|
local northing = tostring(myparts[5]) or ""
|
||||||
|
local easting = tostring(myparts[4]) or ""
|
||||||
|
if string.len(easting) < 5 then easting = easting..string.rep("0",5-string.len(easting)) end
|
||||||
|
if string.len(northing) < 5 then northing = northing..string.rep("0",5-string.len(northing)) end
|
||||||
|
local MGRS = {
|
||||||
|
UTMZone = myparts[2],
|
||||||
|
MGRSDigraph = myparts[3],
|
||||||
|
Easting = easting,
|
||||||
|
Northing = northing,
|
||||||
|
}
|
||||||
|
local lat, lon = coord.MGRStoLL(MGRS)
|
||||||
|
local point = coord.LLtoLO(lat, lon, 0)
|
||||||
|
local coord = COORDINATE:NewFromVec2({x=point.x,y=point.z})
|
||||||
|
return coord
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Provides a COORDINATE from an MGRS Coordinate
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #string UTMZone UTM Zone, e.g. "37T"
|
||||||
|
-- @param #string MGRSDigraph Digraph, e.g. "DK"
|
||||||
|
-- @param #string Easting Meters easting - string in order to allow for leading zeros, e.g. "01234". Should be 5 digits.
|
||||||
|
-- @param #string Northing Meters northing - string in order to allow for leading zeros, e.g. "12340". Should be 5 digits.
|
||||||
|
-- @return #COORDINATE self
|
||||||
|
function COORDINATE:NewFromMGRS( UTMZone, MGRSDigraph, Easting, Northing )
|
||||||
|
if string.len(Easting) < 5 then Easting = tostring(Easting..string.rep("0",5-string.len(Easting) )) end
|
||||||
|
if string.len(Northing) < 5 then Northing = tostring(Northing..string.rep("0",5-string.len(Northing) )) end
|
||||||
|
local MGRS = {
|
||||||
|
UTMZone = UTMZone,
|
||||||
|
MGRSDigraph = MGRSDigraph,
|
||||||
|
Easting = tostring(Easting),
|
||||||
|
Northing = tostring(Northing),
|
||||||
|
}
|
||||||
|
local lat, lon = coord.MGRStoLL(MGRS)
|
||||||
|
local point = coord.LLtoLO(lat, lon, 0)
|
||||||
|
local coord = COORDINATE:NewFromVec2({x=point.x,y=point.z})
|
||||||
|
return coord
|
||||||
|
end
|
||||||
|
|
||||||
--- Provides a coordinate string of the point, based on a coordinate format system:
|
--- Provides a coordinate string of the point, based on a coordinate format system:
|
||||||
-- * Uses default settings in COORDINATE.
|
-- * Uses default settings in COORDINATE.
|
||||||
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
|
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
|
||||||
@@ -3617,7 +3674,7 @@ end
|
|||||||
|
|
||||||
do -- POINT_VEC2
|
do -- POINT_VEC2
|
||||||
|
|
||||||
--- @type POINT_VEC2
|
-- @type POINT_VEC2
|
||||||
-- @field DCS#Distance x The x coordinate in meters.
|
-- @field DCS#Distance x The x coordinate in meters.
|
||||||
-- @field DCS#Distance y the y coordinate in meters.
|
-- @field DCS#Distance y the y coordinate in meters.
|
||||||
-- @extends Core.Point#COORDINATE
|
-- @extends Core.Point#COORDINATE
|
||||||
|
|||||||
@@ -14,17 +14,13 @@
|
|||||||
--
|
--
|
||||||
-- # Demo Missions
|
-- # Demo Missions
|
||||||
--
|
--
|
||||||
-- ### [SCHEDULER Demo Missions source code](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCH%20-%20Scheduler)
|
-- ### [SCHEDULER Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Core/Scheduler)
|
||||||
--
|
|
||||||
-- ### [SCHEDULER Demo Missions, only for beta testers](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCH%20-%20Scheduler)
|
|
||||||
--
|
|
||||||
-- ### [ALL Demo Missions pack of the last release](https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases)
|
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- # YouTube Channel
|
-- # YouTube Channel
|
||||||
--
|
--
|
||||||
-- ### [SCHEDULER YouTube Channel (none)]()
|
-- ### None
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -147,6 +147,44 @@ do -- SET_BASE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [Internal] Add a functional filter
|
||||||
|
-- @param #SET_BASE self
|
||||||
|
-- @param #function ConditionFunction If this function returns `true`, the object is added to the SET. The function needs to take a CONTROLLABLE object as first argument.
|
||||||
|
-- @param ... Condition function arguments, if any.
|
||||||
|
-- @return #boolean If true, at least one condition is true
|
||||||
|
function SET_BASE:FilterFunction(ConditionFunction, ...)
|
||||||
|
|
||||||
|
local condition={}
|
||||||
|
condition.func=ConditionFunction
|
||||||
|
condition.arg={}
|
||||||
|
|
||||||
|
if arg then
|
||||||
|
condition.arg=arg
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.Filter.Functions then self.Filter.Functions = {} end
|
||||||
|
table.insert(self.Filter.Functions, condition)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [Internal] Check if the condition functions returns true.
|
||||||
|
-- @param #SET_BASE self
|
||||||
|
-- @param Wrapper.Controllable#CONTROLLABLE Object The object to filter for
|
||||||
|
-- @return #boolean If true, if **all** conditions are true
|
||||||
|
function SET_BASE:_EvalFilterFunctions(Object)
|
||||||
|
-- All conditions must be true.
|
||||||
|
for _,_condition in pairs(self.Filter.Functions or {}) do
|
||||||
|
local condition=_condition
|
||||||
|
-- Call function.
|
||||||
|
if condition.func(Object,unpack(condition.arg)) == false then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- No condition was true.
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
--- Clear the Objects in the Set.
|
--- Clear the Objects in the Set.
|
||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @param #boolean TriggerEvent If `true`, an event remove is triggered for each group that is removed from the set.
|
-- @param #boolean TriggerEvent If `true`, an event remove is triggered for each group that is removed from the set.
|
||||||
@@ -417,14 +455,35 @@ do -- SET_BASE
|
|||||||
|
|
||||||
--- Gets a random object from the @{Core.Set#SET_BASE} and derived classes.
|
--- Gets a random object from the @{Core.Set#SET_BASE} and derived classes.
|
||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @return Core.Base#BASE
|
-- @return Core.Base#BASE or nil if none found or the SET is empty!
|
||||||
function SET_BASE:GetRandom()
|
function SET_BASE:GetRandom()
|
||||||
local tablemax = table.maxn(self.Index)
|
local tablemax = 0
|
||||||
|
for _,_ind in pairs(self.Index) do
|
||||||
|
tablemax = tablemax + 1
|
||||||
|
end
|
||||||
|
--local tablemax = table.maxn(self.Index)
|
||||||
local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
|
local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
|
||||||
self:T3( { RandomItem } )
|
self:T3( { RandomItem } )
|
||||||
return RandomItem
|
return RandomItem
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Gets a random object from the @{Core.Set#SET_BASE} and derived classes. A bit slower than @{#SET_BASE.GetRandom}() but tries to ensure you get an object back if the SET is not empty.
|
||||||
|
-- @param #SET_BASE self
|
||||||
|
-- @return Core.Base#BASE or nil if the SET is empty!
|
||||||
|
function SET_BASE:GetRandomSurely()
|
||||||
|
local tablemax = 0
|
||||||
|
local sorted = {}
|
||||||
|
for _,_obj in pairs(self.Set) do
|
||||||
|
tablemax = tablemax + 1
|
||||||
|
sorted[tablemax] = _obj
|
||||||
|
end
|
||||||
|
--local tablemax = table.maxn(self.Index)
|
||||||
|
--local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
|
||||||
|
local RandomItem = sorted[math.random(1,tablemax)]
|
||||||
|
self:T3( { RandomItem } )
|
||||||
|
return RandomItem
|
||||||
|
end
|
||||||
|
|
||||||
--- Retrieves the amount of objects in the @{Core.Set#SET_BASE} and derived classes.
|
--- Retrieves the amount of objects in the @{Core.Set#SET_BASE} and derived classes.
|
||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @return #number Count
|
-- @return #number Count
|
||||||
@@ -561,10 +620,12 @@ do -- SET_BASE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Iterate the SET_BASE while identifying the nearest object from a @{Core.Point#POINT_VEC2}.
|
--- Iterate the SET_BASE while identifying the nearest object in the set from a @{Core.Point#POINT_VEC2}.
|
||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @param Core.Point#POINT_VEC2 PointVec2 A @{Core.Point#POINT_VEC2} object from where to evaluate the closest object in the set.
|
-- @param Core.Point#POINT_VEC2 PointVec2 A @{Core.Point#COORDINATE} or @{Core.Point#POINT_VEC2} object (but **not** a simple DCS#Vec2!) from where to evaluate the closest object in the set.
|
||||||
-- @return Core.Base#BASE The closest object.
|
-- @return Core.Base#BASE The closest object.
|
||||||
|
-- @usage
|
||||||
|
-- myset:FindNearestObjectFromPointVec2( ZONE:New("Test Zone"):GetCoordinate() )
|
||||||
function SET_BASE:FindNearestObjectFromPointVec2( PointVec2 )
|
function SET_BASE:FindNearestObjectFromPointVec2( PointVec2 )
|
||||||
self:F2( PointVec2 )
|
self:F2( PointVec2 )
|
||||||
|
|
||||||
@@ -961,6 +1022,7 @@ do
|
|||||||
-- * @{#SET_GROUP.FilterCategoryShip}: Builds the SET_GROUP from ships.
|
-- * @{#SET_GROUP.FilterCategoryShip}: Builds the SET_GROUP from ships.
|
||||||
-- * @{#SET_GROUP.FilterCategoryStructure}: Builds the SET_GROUP from structures.
|
-- * @{#SET_GROUP.FilterCategoryStructure}: Builds the SET_GROUP from structures.
|
||||||
-- * @{#SET_GROUP.FilterZones}: Builds the SET_GROUP with the groups within a @{Core.Zone#ZONE}.
|
-- * @{#SET_GROUP.FilterZones}: Builds the SET_GROUP with the groups within a @{Core.Zone#ZONE}.
|
||||||
|
-- * @{#SET_GROUP.FilterFunction}: Builds the SET_GROUP with a custom condition.
|
||||||
--
|
--
|
||||||
-- Once the filter criteria have been set for the SET_GROUP, you can start filtering using:
|
-- Once the filter criteria have been set for the SET_GROUP, you can start filtering using:
|
||||||
--
|
--
|
||||||
@@ -1034,6 +1096,8 @@ do
|
|||||||
Countries = nil,
|
Countries = nil,
|
||||||
GroupPrefixes = nil,
|
GroupPrefixes = nil,
|
||||||
Zones = nil,
|
Zones = nil,
|
||||||
|
Functions = nil,
|
||||||
|
Alive = nil,
|
||||||
},
|
},
|
||||||
FilterMeta = {
|
FilterMeta = {
|
||||||
Coalitions = {
|
Coalitions = {
|
||||||
@@ -1065,6 +1129,13 @@ do
|
|||||||
self:FilterActive( false )
|
self:FilterActive( false )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
--- Filter the set once
|
||||||
|
-- @function [parent=#SET_GROUP] FilterOnce
|
||||||
|
-- @param #SET_GROUP self
|
||||||
|
-- @return #SET_GROUP self
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a *new* set that only contains alive groups.
|
--- Get a *new* set that only contains alive groups.
|
||||||
@@ -1134,7 +1205,7 @@ do
|
|||||||
if not DontSetCargoBayLimit then
|
if not DontSetCargoBayLimit then
|
||||||
-- I set the default cargo bay weight limit each time a new group is added to the set.
|
-- I set the default cargo bay weight limit each time a new group is added to the set.
|
||||||
-- TODO Why is this here in the first place?
|
-- TODO Why is this here in the first place?
|
||||||
for UnitID, UnitData in pairs( group:GetUnits() ) do
|
for UnitID, UnitData in pairs( group:GetUnits() or {} ) do
|
||||||
if UnitData and UnitData:IsAlive() then
|
if UnitData and UnitData:IsAlive() then
|
||||||
UnitData:SetCargoBayWeightLimit()
|
UnitData:SetCargoBayWeightLimit()
|
||||||
end
|
end
|
||||||
@@ -1241,6 +1312,25 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [User] Add a custom condition function.
|
||||||
|
-- @function [parent=#SET_GROUP] FilterFunction
|
||||||
|
-- @param #SET_GROUP self
|
||||||
|
-- @param #function ConditionFunction If this function returns `true`, the object is added to the SET. The function needs to take a GROUP object as first argument.
|
||||||
|
-- @param ... Condition function arguments if any.
|
||||||
|
-- @return #SET_GROUP self
|
||||||
|
-- @usage
|
||||||
|
-- -- Image you want to exclude a specific GROUP from a SET:
|
||||||
|
-- local groundset = SET_GROUP:New():FilterCoalitions("blue"):FilterCategoryGround():FilterFunction(
|
||||||
|
-- -- The function needs to take a GROUP object as first - and in this case, only - argument.
|
||||||
|
-- function(grp)
|
||||||
|
-- local isinclude = true
|
||||||
|
-- if grp:GetName() == "Exclude Me" then isinclude = false end
|
||||||
|
-- return isinclude
|
||||||
|
-- end
|
||||||
|
-- ):FilterOnce()
|
||||||
|
-- BASE:I(groundset:Flush())
|
||||||
|
|
||||||
|
|
||||||
--- Builds a set of groups of coalitions.
|
--- Builds a set of groups of coalitions.
|
||||||
-- Possible current coalitions are red, blue and neutral.
|
-- Possible current coalitions are red, blue and neutral.
|
||||||
-- @param #SET_GROUP self
|
-- @param #SET_GROUP self
|
||||||
@@ -1381,7 +1471,7 @@ do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Builds a set of groups that are only active.
|
--- Builds a set of groups that are active, ie in the mission but not yet activated (false) or actived (true).
|
||||||
-- Only the groups that are active will be included within the set.
|
-- Only the groups that are active will be included within the set.
|
||||||
-- @param #SET_GROUP self
|
-- @param #SET_GROUP self
|
||||||
-- @param #boolean Active (Optional) Include only active groups to the set.
|
-- @param #boolean Active (Optional) Include only active groups to the set.
|
||||||
@@ -1407,6 +1497,14 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Build a set of groups that are alive.
|
||||||
|
-- @param #SET_GROUP self
|
||||||
|
-- @return #SET_GROUP self
|
||||||
|
function SET_GROUP:FilterAlive()
|
||||||
|
self.Filter.Alive = true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Starts the filtering.
|
--- Starts the filtering.
|
||||||
-- @param #SET_GROUP self
|
-- @param #SET_GROUP self
|
||||||
-- @return #SET_GROUP self
|
-- @return #SET_GROUP self
|
||||||
@@ -1418,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
|
||||||
@@ -1489,7 +1588,7 @@ do
|
|||||||
function SET_GROUP:AddInDatabase( Event )
|
function SET_GROUP:AddInDatabase( Event )
|
||||||
self:F3( { Event } )
|
self:F3( { Event } )
|
||||||
|
|
||||||
if Event.IniObjectCategory == 1 then
|
if Event.IniObjectCategory == Object.Category.UNIT then
|
||||||
if not self.Database[Event.IniDCSGroupName] then
|
if not self.Database[Event.IniDCSGroupName] then
|
||||||
self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName )
|
self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName )
|
||||||
self:T3( self.Database[Event.IniDCSGroupName] )
|
self:T3( self.Database[Event.IniDCSGroupName] )
|
||||||
@@ -1905,6 +2004,15 @@ do
|
|||||||
self:F2( MGroup )
|
self:F2( MGroup )
|
||||||
local MGroupInclude = true
|
local MGroupInclude = true
|
||||||
|
|
||||||
|
if self.Filter.Alive == true then
|
||||||
|
local MGroupAlive = false
|
||||||
|
self:F( { Active = self.Filter.Active } )
|
||||||
|
if MGroup and MGroup:IsAlive() then
|
||||||
|
MGroupAlive = true
|
||||||
|
end
|
||||||
|
MGroupInclude = MGroupInclude and MGroupAlive
|
||||||
|
end
|
||||||
|
|
||||||
if self.Filter.Active ~= nil then
|
if self.Filter.Active ~= nil then
|
||||||
local MGroupActive = false
|
local MGroupActive = false
|
||||||
self:F( { Active = self.Filter.Active } )
|
self:F( { Active = self.Filter.Active } )
|
||||||
@@ -1914,7 +2022,7 @@ do
|
|||||||
MGroupInclude = MGroupInclude and MGroupActive
|
MGroupInclude = MGroupInclude and MGroupActive
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Coalitions then
|
if self.Filter.Coalitions and MGroupInclude then
|
||||||
local MGroupCoalition = false
|
local MGroupCoalition = false
|
||||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||||
self:T3( { "Coalition:", MGroup:GetCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
self:T3( { "Coalition:", MGroup:GetCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||||
@@ -1925,7 +2033,7 @@ do
|
|||||||
MGroupInclude = MGroupInclude and MGroupCoalition
|
MGroupInclude = MGroupInclude and MGroupCoalition
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Categories then
|
if self.Filter.Categories and MGroupInclude then
|
||||||
local MGroupCategory = false
|
local MGroupCategory = false
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
self:T3( { "Category:", MGroup:GetCategory(), self.FilterMeta.Categories[CategoryName], CategoryName } )
|
self:T3( { "Category:", MGroup:GetCategory(), self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||||
@@ -1936,7 +2044,7 @@ do
|
|||||||
MGroupInclude = MGroupInclude and MGroupCategory
|
MGroupInclude = MGroupInclude and MGroupCategory
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Countries then
|
if self.Filter.Countries and MGroupInclude then
|
||||||
local MGroupCountry = false
|
local MGroupCountry = false
|
||||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||||
self:T3( { "Country:", MGroup:GetCountry(), CountryName } )
|
self:T3( { "Country:", MGroup:GetCountry(), CountryName } )
|
||||||
@@ -1947,7 +2055,7 @@ do
|
|||||||
MGroupInclude = MGroupInclude and MGroupCountry
|
MGroupInclude = MGroupInclude and MGroupCountry
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.GroupPrefixes then
|
if self.Filter.GroupPrefixes and MGroupInclude then
|
||||||
local MGroupPrefix = false
|
local MGroupPrefix = false
|
||||||
for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do
|
for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do
|
||||||
self:T3( { "Prefix:", string.find( MGroup:GetName(), GroupPrefix, 1 ), GroupPrefix } )
|
self:T3( { "Prefix:", string.find( MGroup:GetName(), GroupPrefix, 1 ), GroupPrefix } )
|
||||||
@@ -1958,7 +2066,7 @@ do
|
|||||||
MGroupInclude = MGroupInclude and MGroupPrefix
|
MGroupInclude = MGroupInclude and MGroupPrefix
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Zones then
|
if self.Filter.Zones and MGroupInclude then
|
||||||
local MGroupZone = false
|
local MGroupZone = false
|
||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
--self:T( "Zone:", ZoneName )
|
--self:T( "Zone:", ZoneName )
|
||||||
@@ -1969,6 +2077,12 @@ do
|
|||||||
MGroupInclude = MGroupInclude and MGroupZone
|
MGroupInclude = MGroupInclude and MGroupZone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.Filter.Functions and MGroupInclude then
|
||||||
|
local MGroupFunc = false
|
||||||
|
MGroupFunc = self:_EvalFilterFunctions(MGroup)
|
||||||
|
MGroupInclude = MGroupInclude and MGroupFunc
|
||||||
|
end
|
||||||
|
|
||||||
self:T2( MGroupInclude )
|
self:T2( MGroupInclude )
|
||||||
return MGroupInclude
|
return MGroupInclude
|
||||||
end
|
end
|
||||||
@@ -1976,6 +2090,7 @@ do
|
|||||||
--- Get the closest group of the set with respect to a given reference coordinate. Optionally, only groups of given coalitions are considered in the search.
|
--- Get the closest group of the set with respect to a given reference coordinate. Optionally, only groups of given coalitions are considered in the search.
|
||||||
-- @param #SET_GROUP self
|
-- @param #SET_GROUP self
|
||||||
-- @param Core.Point#COORDINATE Coordinate Reference Coordinate from which the closest group is determined.
|
-- @param Core.Point#COORDINATE Coordinate Reference Coordinate from which the closest group is determined.
|
||||||
|
-- @param #table Coalitions (Optional) Table of coalition #number entries to filter for.
|
||||||
-- @return Wrapper.Group#GROUP The closest group (if any).
|
-- @return Wrapper.Group#GROUP The closest group (if any).
|
||||||
-- @return #number Distance in meters to the closest group.
|
-- @return #number Distance in meters to the closest group.
|
||||||
function SET_GROUP:GetClosestGroup(Coordinate, Coalitions)
|
function SET_GROUP:GetClosestGroup(Coordinate, Coalitions)
|
||||||
@@ -2066,6 +2181,7 @@ do -- SET_UNIT
|
|||||||
-- Have a read through here to understand the application of regular expressions: [LUA regular expressions](https://riptutorial.com/lua/example/20315/lua-pattern-matching)
|
-- Have a read through here to understand the application of regular expressions: [LUA regular expressions](https://riptutorial.com/lua/example/20315/lua-pattern-matching)
|
||||||
-- * @{#SET_UNIT.FilterActive}: Builds the SET_UNIT with the units that are only active. Units that are inactive (late activation) won't be included in the set!
|
-- * @{#SET_UNIT.FilterActive}: Builds the SET_UNIT with the units that are only active. Units that are inactive (late activation) won't be included in the set!
|
||||||
-- * @{#SET_UNIT.FilterZones}: Builds the SET_UNIT with the units within a @{Core.Zone#ZONE}.
|
-- * @{#SET_UNIT.FilterZones}: Builds the SET_UNIT with the units within a @{Core.Zone#ZONE}.
|
||||||
|
-- * @{#SET_UNIT.FilterFunction}: Builds the SET_UNIT with a custom condition.
|
||||||
--
|
--
|
||||||
-- Once the filter criteria have been set for the SET_UNIT, you can start filtering using:
|
-- Once the filter criteria have been set for the SET_UNIT, you can start filtering using:
|
||||||
--
|
--
|
||||||
@@ -2144,6 +2260,7 @@ do -- SET_UNIT
|
|||||||
Countries = nil,
|
Countries = nil,
|
||||||
UnitPrefixes = nil,
|
UnitPrefixes = nil,
|
||||||
Zones = nil,
|
Zones = nil,
|
||||||
|
Functions = nil,
|
||||||
},
|
},
|
||||||
FilterMeta = {
|
FilterMeta = {
|
||||||
Coalitions = {
|
Coalitions = {
|
||||||
@@ -2425,6 +2542,26 @@ do -- SET_UNIT
|
|||||||
return CountU
|
return CountU
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Gets the alive set.
|
||||||
|
-- @param #SET_UNIT self
|
||||||
|
-- @return #table Table of SET objects
|
||||||
|
-- @return #SET_UNIT AliveSet
|
||||||
|
function SET_UNIT:GetAliveSet()
|
||||||
|
|
||||||
|
local AliveSet = SET_UNIT:New()
|
||||||
|
|
||||||
|
-- Clean the Set before returning with only the alive Groups.
|
||||||
|
for GroupName, GroupObject in pairs(self.Set) do
|
||||||
|
local GroupObject=GroupObject --Wrapper.Client#CLIENT
|
||||||
|
|
||||||
|
if GroupObject and GroupObject:IsAlive() then
|
||||||
|
AliveSet:Add(GroupName, GroupObject)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return AliveSet.Set or {}, AliveSet
|
||||||
|
end
|
||||||
|
|
||||||
--- [Internal] Private function for use of continous zone filter
|
--- [Internal] Private function for use of continous zone filter
|
||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
-- @return #SET_UNIT self
|
-- @return #SET_UNIT self
|
||||||
@@ -2495,6 +2632,25 @@ do -- SET_UNIT
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [User] Add a custom condition function.
|
||||||
|
-- @function [parent=#SET_UNIT] FilterFunction
|
||||||
|
-- @param #SET_UNIT self
|
||||||
|
-- @param #function ConditionFunction If this function returns `true`, the object is added to the SET. The function needs to take a UNIT object as first argument.
|
||||||
|
-- @param ... Condition function arguments if any.
|
||||||
|
-- @return #SET_UNIT self
|
||||||
|
-- @usage
|
||||||
|
-- -- Image you want to exclude a specific UNIT from a SET:
|
||||||
|
-- local groundset = SET_UNIT:New():FilterCoalitions("blue"):FilterCategories("ground"):FilterFunction(
|
||||||
|
-- -- The function needs to take a UNIT object as first - and in this case, only - argument.
|
||||||
|
-- function(unit)
|
||||||
|
-- local isinclude = true
|
||||||
|
-- if unit:GetName() == "Exclude Me" then isinclude = false end
|
||||||
|
-- return isinclude
|
||||||
|
-- end
|
||||||
|
-- ):FilterOnce()
|
||||||
|
-- BASE:I(groundset:Flush())
|
||||||
|
|
||||||
|
|
||||||
--- Handles the Database to check on an event (birth) that the Object was added in the Database.
|
--- Handles the Database to check on an event (birth) that the Object was added in the Database.
|
||||||
-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event!
|
-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event!
|
||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
@@ -2504,7 +2660,7 @@ do -- SET_UNIT
|
|||||||
function SET_UNIT:AddInDatabase( Event )
|
function SET_UNIT:AddInDatabase( Event )
|
||||||
self:F3( { Event } )
|
self:F3( { Event } )
|
||||||
|
|
||||||
if Event.IniObjectCategory == 1 then
|
if Event.IniObjectCategory == Object.Category.UNIT then
|
||||||
if not self.Database[Event.IniDCSUnitName] then
|
if not self.Database[Event.IniDCSUnitName] then
|
||||||
self.Database[Event.IniDCSUnitName] = UNIT:Register( Event.IniDCSUnitName )
|
self.Database[Event.IniDCSUnitName] = UNIT:Register( Event.IniDCSUnitName )
|
||||||
self:T3( self.Database[Event.IniDCSUnitName] )
|
self:T3( self.Database[Event.IniDCSUnitName] )
|
||||||
@@ -2820,52 +2976,50 @@ do -- SET_UNIT
|
|||||||
-- @return Core.Point#COORDINATE The center coordinate of all the units in the set, including heading in degrees and speed in mps in case of moving units.
|
-- @return Core.Point#COORDINATE The center coordinate of all the units in the set, including heading in degrees and speed in mps in case of moving units.
|
||||||
function SET_UNIT:GetCoordinate()
|
function SET_UNIT:GetCoordinate()
|
||||||
|
|
||||||
local Coordinate = self:GetRandom():GetCoordinate()
|
local function GetSetVec3(units)
|
||||||
--self:F({Coordinate:GetVec3()})
|
-- Init.
|
||||||
|
local x=0
|
||||||
|
local y=0
|
||||||
local x1 = Coordinate.x
|
local z=0
|
||||||
local x2 = Coordinate.x
|
local n=0
|
||||||
local y1 = Coordinate.y
|
-- Loop over all units.
|
||||||
local y2 = Coordinate.y
|
for _,unit in pairs(units) do
|
||||||
local z1 = Coordinate.z
|
local vec3=nil --DCS#Vec3
|
||||||
local z2 = Coordinate.z
|
if unit and unit:IsAlive() then
|
||||||
local MaxVelocity = 0
|
vec3 = unit:GetVec3()
|
||||||
local AvgHeading = nil
|
end
|
||||||
local MovingCount = 0
|
if vec3 then
|
||||||
|
-- Sum up posits.
|
||||||
for UnitName, UnitData in pairs( self:GetSet() ) do
|
x=x+vec3.x
|
||||||
|
y=y+vec3.y
|
||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
z=z+vec3.z
|
||||||
local Coordinate = Unit:GetCoordinate()
|
-- Increase counter.
|
||||||
|
n=n+1
|
||||||
x1 = (Coordinate.x < x1) and Coordinate.x or x1
|
end
|
||||||
x2 = (Coordinate.x > x2) and Coordinate.x or x2
|
|
||||||
y1 = (Coordinate.y < y1) and Coordinate.y or y1
|
|
||||||
y2 = (Coordinate.y > y2) and Coordinate.y or y2
|
|
||||||
z1 = (Coordinate.y < z1) and Coordinate.z or z1
|
|
||||||
z2 = (Coordinate.y > z2) and Coordinate.z or z2
|
|
||||||
|
|
||||||
local Velocity = Coordinate:GetVelocity()
|
|
||||||
if Velocity ~= 0 then
|
|
||||||
MaxVelocity = (MaxVelocity < Velocity) and Velocity or MaxVelocity
|
|
||||||
local Heading = Coordinate:GetHeading()
|
|
||||||
AvgHeading = AvgHeading and (AvgHeading + Heading) or Heading
|
|
||||||
MovingCount = MovingCount + 1
|
|
||||||
end
|
end
|
||||||
|
if n>0 then
|
||||||
|
-- Average.
|
||||||
|
local Vec3={x=x/n, y=y/n, z=z/n} --DCS#Vec3
|
||||||
|
return Vec3
|
||||||
|
end
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
AvgHeading = AvgHeading and (AvgHeading / MovingCount)
|
local Coordinate = nil
|
||||||
|
local Vec3 = GetSetVec3(self.Set)
|
||||||
|
if Vec3 then
|
||||||
|
Coordinate = COORDINATE:NewFromVec3(Vec3)
|
||||||
|
end
|
||||||
|
|
||||||
Coordinate.x = (x2 - x1) / 2 + x1
|
if Coordinate then
|
||||||
Coordinate.y = (y2 - y1) / 2 + y1
|
local heading = self:GetHeading() or 0
|
||||||
Coordinate.z = (z2 - z1) / 2 + z1
|
local velocity = self:GetVelocity() or 0
|
||||||
Coordinate:SetHeading( AvgHeading )
|
Coordinate:SetHeading( heading )
|
||||||
Coordinate:SetVelocity( MaxVelocity )
|
Coordinate:SetVelocity( velocity )
|
||||||
|
self:T(UTILS.PrintTableToLog(Coordinate))
|
||||||
|
end
|
||||||
|
|
||||||
self:F( { Coordinate = Coordinate } )
|
|
||||||
return Coordinate
|
return Coordinate
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the maximum velocity of the SET_UNIT.
|
--- Get the maximum velocity of the SET_UNIT.
|
||||||
@@ -3074,7 +3228,7 @@ do -- SET_UNIT
|
|||||||
MUnitInclude = MUnitInclude and MUnitActive
|
MUnitInclude = MUnitInclude and MUnitActive
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Coalitions then
|
if self.Filter.Coalitions and MUnitInclude then
|
||||||
local MUnitCoalition = false
|
local MUnitCoalition = false
|
||||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||||
self:F( { "Coalition:", MUnit:GetCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
self:F( { "Coalition:", MUnit:GetCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||||
@@ -3085,7 +3239,7 @@ do -- SET_UNIT
|
|||||||
MUnitInclude = MUnitInclude and MUnitCoalition
|
MUnitInclude = MUnitInclude and MUnitCoalition
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Categories then
|
if self.Filter.Categories and MUnitInclude then
|
||||||
local MUnitCategory = false
|
local MUnitCategory = false
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
self:T3( { "Category:", MUnit:GetDesc().category, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
self:T3( { "Category:", MUnit:GetDesc().category, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||||
@@ -3096,7 +3250,7 @@ do -- SET_UNIT
|
|||||||
MUnitInclude = MUnitInclude and MUnitCategory
|
MUnitInclude = MUnitInclude and MUnitCategory
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Types then
|
if self.Filter.Types and MUnitInclude then
|
||||||
local MUnitType = false
|
local MUnitType = false
|
||||||
for TypeID, TypeName in pairs( self.Filter.Types ) do
|
for TypeID, TypeName in pairs( self.Filter.Types ) do
|
||||||
self:T3( { "Type:", MUnit:GetTypeName(), TypeName } )
|
self:T3( { "Type:", MUnit:GetTypeName(), TypeName } )
|
||||||
@@ -3107,7 +3261,7 @@ do -- SET_UNIT
|
|||||||
MUnitInclude = MUnitInclude and MUnitType
|
MUnitInclude = MUnitInclude and MUnitType
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Countries then
|
if self.Filter.Countries and MUnitInclude then
|
||||||
local MUnitCountry = false
|
local MUnitCountry = false
|
||||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||||
self:T3( { "Country:", MUnit:GetCountry(), CountryName } )
|
self:T3( { "Country:", MUnit:GetCountry(), CountryName } )
|
||||||
@@ -3118,7 +3272,7 @@ do -- SET_UNIT
|
|||||||
MUnitInclude = MUnitInclude and MUnitCountry
|
MUnitInclude = MUnitInclude and MUnitCountry
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.UnitPrefixes then
|
if self.Filter.UnitPrefixes and MUnitInclude then
|
||||||
local MUnitPrefix = false
|
local MUnitPrefix = false
|
||||||
for UnitPrefixId, UnitPrefix in pairs( self.Filter.UnitPrefixes ) do
|
for UnitPrefixId, UnitPrefix in pairs( self.Filter.UnitPrefixes ) do
|
||||||
self:T3( { "Prefix:", string.find( MUnit:GetName(), UnitPrefix, 1 ), UnitPrefix } )
|
self:T3( { "Prefix:", string.find( MUnit:GetName(), UnitPrefix, 1 ), UnitPrefix } )
|
||||||
@@ -3129,7 +3283,7 @@ do -- SET_UNIT
|
|||||||
MUnitInclude = MUnitInclude and MUnitPrefix
|
MUnitInclude = MUnitInclude and MUnitPrefix
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.RadarTypes then
|
if self.Filter.RadarTypes and MUnitInclude then
|
||||||
local MUnitRadar = false
|
local MUnitRadar = false
|
||||||
for RadarTypeID, RadarType in pairs( self.Filter.RadarTypes ) do
|
for RadarTypeID, RadarType in pairs( self.Filter.RadarTypes ) do
|
||||||
self:T3( { "Radar:", RadarType } )
|
self:T3( { "Radar:", RadarType } )
|
||||||
@@ -3143,7 +3297,7 @@ do -- SET_UNIT
|
|||||||
MUnitInclude = MUnitInclude and MUnitRadar
|
MUnitInclude = MUnitInclude and MUnitRadar
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.SEAD then
|
if self.Filter.SEAD and MUnitInclude then
|
||||||
local MUnitSEAD = false
|
local MUnitSEAD = false
|
||||||
if MUnit:HasSEAD() == true then
|
if MUnit:HasSEAD() == true then
|
||||||
self:T3( "SEAD Found" )
|
self:T3( "SEAD Found" )
|
||||||
@@ -3153,7 +3307,7 @@ do -- SET_UNIT
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Zones then
|
if self.Filter.Zones and MUnitInclude then
|
||||||
local MGroupZone = false
|
local MGroupZone = false
|
||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
self:T3( "Zone:", ZoneName )
|
self:T3( "Zone:", ZoneName )
|
||||||
@@ -3164,6 +3318,11 @@ do -- SET_UNIT
|
|||||||
MUnitInclude = MUnitInclude and MGroupZone
|
MUnitInclude = MUnitInclude and MGroupZone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.Filter.Functions and MUnitInclude then
|
||||||
|
local MUnitFunc = self:_EvalFilterFunctions(MUnit)
|
||||||
|
MUnitInclude = MUnitInclude and MUnitFunc
|
||||||
|
end
|
||||||
|
|
||||||
self:T2( MUnitInclude )
|
self:T2( MUnitInclude )
|
||||||
return MUnitInclude
|
return MUnitInclude
|
||||||
end
|
end
|
||||||
@@ -3245,6 +3404,7 @@ do -- SET_STATIC
|
|||||||
-- * @{#SET_STATIC.FilterPrefixes}: Builds the SET_STATIC with the units containing the same string(s) in their name. **Attention!** LUA regular expression apply here, so special characters in names like minus, dot, hash (#) etc might lead to unexpected results.
|
-- * @{#SET_STATIC.FilterPrefixes}: Builds the SET_STATIC with the units containing the same string(s) in their name. **Attention!** LUA regular expression apply here, so special characters in names like minus, dot, hash (#) etc might lead to unexpected results.
|
||||||
-- Have a read through here to understand the application of regular expressions: [LUA regular expressions](https://riptutorial.com/lua/example/20315/lua-pattern-matching)
|
-- Have a read through here to understand the application of regular expressions: [LUA regular expressions](https://riptutorial.com/lua/example/20315/lua-pattern-matching)
|
||||||
-- * @{#SET_STATIC.FilterZones}: Builds the SET_STATIC with the units within a @{Core.Zone#ZONE}.
|
-- * @{#SET_STATIC.FilterZones}: Builds the SET_STATIC with the units within a @{Core.Zone#ZONE}.
|
||||||
|
-- * @{#SET_STATIC.FilterFunction}: Builds the SET_STATIC with a custom condition.
|
||||||
--
|
--
|
||||||
-- Once the filter criteria have been set for the SET_STATIC, you can start filtering using:
|
-- Once the filter criteria have been set for the SET_STATIC, you can start filtering using:
|
||||||
--
|
--
|
||||||
@@ -3318,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() )
|
||||||
@@ -3448,6 +3608,24 @@ do -- SET_STATIC
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [User] Add a custom condition function.
|
||||||
|
-- @function [parent=#SET_STATIC] FilterFunction
|
||||||
|
-- @param #SET_STATIC self
|
||||||
|
-- @param #function ConditionFunction If this function returns `true`, the object is added to the SET. The function needs to take a STATIC object as first argument.
|
||||||
|
-- @param ... Condition function arguments if any.
|
||||||
|
-- @return #SET_STATIC self
|
||||||
|
-- @usage
|
||||||
|
-- -- Image you want to exclude a specific CLIENT from a SET:
|
||||||
|
-- local groundset = SET_STATIC:New():FilterCoalitions("blue"):FilterActive(true):FilterFunction(
|
||||||
|
-- -- The function needs to take a STATIC object as first - and in this case, only - argument.
|
||||||
|
-- function(static)
|
||||||
|
-- local isinclude = true
|
||||||
|
-- if static:GetName() == "Exclude Me" then isinclude = false end
|
||||||
|
-- return isinclude
|
||||||
|
-- end
|
||||||
|
-- ):FilterOnce()
|
||||||
|
-- BASE:I(groundset:Flush())
|
||||||
|
|
||||||
--- Builds a set of units of defined countries.
|
--- Builds a set of units of defined countries.
|
||||||
-- Possible current countries are those known within DCS world.
|
-- Possible current countries are those known within DCS world.
|
||||||
-- @param #SET_STATIC self
|
-- @param #SET_STATIC self
|
||||||
@@ -4004,6 +4182,7 @@ do -- SET_CLIENT
|
|||||||
-- Have a read through here to understand the application of regular expressions: [LUA regular expressions](https://riptutorial.com/lua/example/20315/lua-pattern-matching)
|
-- Have a read through here to understand the application of regular expressions: [LUA regular expressions](https://riptutorial.com/lua/example/20315/lua-pattern-matching)
|
||||||
-- * @{#SET_CLIENT.FilterActive}: Builds the SET_CLIENT with the units that are only active. Units that are inactive (late activation) won't be included in the set!
|
-- * @{#SET_CLIENT.FilterActive}: Builds the SET_CLIENT with the units that are only active. Units that are inactive (late activation) won't be included in the set!
|
||||||
-- * @{#SET_CLIENT.FilterZones}: Builds the SET_CLIENT with the clients within a @{Core.Zone#ZONE}.
|
-- * @{#SET_CLIENT.FilterZones}: Builds the SET_CLIENT with the clients within a @{Core.Zone#ZONE}.
|
||||||
|
-- * @{#SET_CLIENT.FilterFunction}: Builds the SET_CLIENT with a custom condition.
|
||||||
--
|
--
|
||||||
-- Once the filter criteria have been set for the SET_CLIENT, you can start filtering using:
|
-- Once the filter criteria have been set for the SET_CLIENT, you can start filtering using:
|
||||||
--
|
--
|
||||||
@@ -4210,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
|
||||||
@@ -4317,6 +4496,8 @@ do -- SET_CLIENT
|
|||||||
self:UnHandleEvent(EVENTS.Birth)
|
self:UnHandleEvent(EVENTS.Birth)
|
||||||
self:UnHandleEvent(EVENTS.Dead)
|
self:UnHandleEvent(EVENTS.Dead)
|
||||||
self:UnHandleEvent(EVENTS.Crash)
|
self:UnHandleEvent(EVENTS.Crash)
|
||||||
|
--self:UnHandleEvent(EVENTS.PlayerEnterUnit)
|
||||||
|
--self:UnHandleEvent(EVENTS.PlayerLeaveUnit)
|
||||||
|
|
||||||
if self.Filter.Zones and self.ZoneTimer and self.ZoneTimer:IsRunning() then
|
if self.Filter.Zones and self.ZoneTimer and self.ZoneTimer:IsRunning() then
|
||||||
self.ZoneTimer:Stop()
|
self.ZoneTimer:Stop()
|
||||||
@@ -4335,6 +4516,9 @@ do -- SET_CLIENT
|
|||||||
self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
|
self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
|
||||||
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.PlayerEnterUnit, self._EventPlayerEnterUnit)
|
||||||
|
--self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventPlayerLeaveUnit)
|
||||||
|
--self:SetEventPriority(1)
|
||||||
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
|
||||||
@@ -4346,6 +4530,43 @@ do -- SET_CLIENT
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Handle CA slots addition
|
||||||
|
-- @param #SET_CLIENT self
|
||||||
|
-- @param Core.Event#EVENTDATA Event
|
||||||
|
-- @return #SET_CLIENT self
|
||||||
|
function SET_CLIENT:_EventPlayerEnterUnit(Event)
|
||||||
|
self:I( "_EventPlayerEnterUnit" )
|
||||||
|
if Event.IniDCSUnit then
|
||||||
|
if Event.IniObjectCategory == Object.Category.UNIT and Event.IniGroup and Event.IniGroup:IsGround() then
|
||||||
|
-- CA Slot entered
|
||||||
|
local ObjectName, Object = self:AddInDatabase( Event )
|
||||||
|
self:T( ObjectName, UTILS.PrintTableToLog(Object) )
|
||||||
|
if Object and self:IsIncludeObject( Object ) then
|
||||||
|
self:Add( ObjectName, Object )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Handle CA slots removal
|
||||||
|
-- @param #SET_CLIENT self
|
||||||
|
-- @param Core.Event#EVENTDATA Event
|
||||||
|
-- @return #SET_CLIENT self
|
||||||
|
function SET_CLIENT:_EventPlayerLeaveUnit(Event)
|
||||||
|
self:I( "_EventPlayerLeaveUnit" )
|
||||||
|
if Event.IniDCSUnit then
|
||||||
|
if Event.IniObjectCategory == Object.Category.UNIT and Event.IniGroup and Event.IniGroup:IsGround() then
|
||||||
|
-- CA Slot left
|
||||||
|
local ObjectName, Object = self:FindInDatabase( Event )
|
||||||
|
if ObjectName then
|
||||||
|
self:Remove( ObjectName )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Handles the Database to check on an event (birth) that the Object was added in the Database.
|
--- Handles the Database to check on an event (birth) that the Object was added in the Database.
|
||||||
-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event!
|
-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event!
|
||||||
-- @param #SET_CLIENT self
|
-- @param #SET_CLIENT self
|
||||||
@@ -4464,6 +4685,25 @@ do -- SET_CLIENT
|
|||||||
return AliveSet.Set or {}
|
return AliveSet.Set or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [User] Add a custom condition function.
|
||||||
|
-- @function [parent=#SET_CLIENT] FilterFunction
|
||||||
|
-- @param #SET_CLIENT self
|
||||||
|
-- @param #function ConditionFunction If this function returns `true`, the object is added to the SET. The function needs to take a CLIENT object as first argument.
|
||||||
|
-- @param ... Condition function arguments if any.
|
||||||
|
-- @return #SET_CLIENT self
|
||||||
|
-- @usage
|
||||||
|
-- -- Image you want to exclude a specific CLIENT from a SET:
|
||||||
|
-- local groundset = SET_CLIENT:New():FilterCoalitions("blue"):FilterActive(true):FilterFunction(
|
||||||
|
-- -- The function needs to take a UNIT object as first - and in this case, only - argument.
|
||||||
|
-- function(client)
|
||||||
|
-- local isinclude = true
|
||||||
|
-- if client:GetPlayerName() == "Exclude Me" then isinclude = false end
|
||||||
|
-- return isinclude
|
||||||
|
-- end
|
||||||
|
-- ):FilterOnce()
|
||||||
|
-- BASE:I(groundset:Flush())
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #SET_CLIENT self
|
-- @param #SET_CLIENT self
|
||||||
-- @param Wrapper.Client#CLIENT MClient
|
-- @param Wrapper.Client#CLIENT MClient
|
||||||
@@ -4485,7 +4725,7 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientActive
|
MClientInclude = MClientInclude and MClientActive
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Coalitions then
|
if self.Filter.Coalitions and MClientInclude then
|
||||||
local MClientCoalition = false
|
local MClientCoalition = false
|
||||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||||
local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName )
|
local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName )
|
||||||
@@ -4498,7 +4738,7 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientCoalition
|
MClientInclude = MClientInclude and MClientCoalition
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Categories then
|
if self.Filter.Categories and MClientInclude then
|
||||||
local MClientCategory = false
|
local MClientCategory = false
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName )
|
local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName )
|
||||||
@@ -4511,7 +4751,7 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientCategory
|
MClientInclude = MClientInclude and MClientCategory
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Types then
|
if self.Filter.Types and MClientInclude then
|
||||||
local MClientType = false
|
local MClientType = false
|
||||||
for TypeID, TypeName in pairs( self.Filter.Types ) do
|
for TypeID, TypeName in pairs( self.Filter.Types ) do
|
||||||
self:T3( { "Type:", MClient:GetTypeName(), TypeName } )
|
self:T3( { "Type:", MClient:GetTypeName(), TypeName } )
|
||||||
@@ -4523,7 +4763,7 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientType
|
MClientInclude = MClientInclude and MClientType
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Countries then
|
if self.Filter.Countries and MClientInclude then
|
||||||
local MClientCountry = false
|
local MClientCountry = false
|
||||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||||
local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName )
|
local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName )
|
||||||
@@ -4536,7 +4776,7 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientCountry
|
MClientInclude = MClientInclude and MClientCountry
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.ClientPrefixes then
|
if self.Filter.ClientPrefixes and MClientInclude then
|
||||||
local MClientPrefix = false
|
local MClientPrefix = false
|
||||||
for ClientPrefixId, ClientPrefix in pairs( self.Filter.ClientPrefixes ) do
|
for ClientPrefixId, ClientPrefix in pairs( self.Filter.ClientPrefixes ) do
|
||||||
self:T3( { "Prefix:", string.find( MClient.UnitName, ClientPrefix, 1 ), ClientPrefix } )
|
self:T3( { "Prefix:", string.find( MClient.UnitName, ClientPrefix, 1 ), ClientPrefix } )
|
||||||
@@ -4548,7 +4788,7 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientPrefix
|
MClientInclude = MClientInclude and MClientPrefix
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Zones then
|
if self.Filter.Zones and MClientInclude then
|
||||||
local MClientZone = false
|
local MClientZone = false
|
||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
self:T3( "Zone:", ZoneName )
|
self:T3( "Zone:", ZoneName )
|
||||||
@@ -4560,7 +4800,7 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientZone
|
MClientInclude = MClientInclude and MClientZone
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Playernames then
|
if self.Filter.Playernames and MClientInclude then
|
||||||
local MClientPlayername = false
|
local MClientPlayername = false
|
||||||
local playername = MClient:GetPlayerName() or "Unknown"
|
local playername = MClient:GetPlayerName() or "Unknown"
|
||||||
--self:T(playername)
|
--self:T(playername)
|
||||||
@@ -4573,7 +4813,7 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientPlayername
|
MClientInclude = MClientInclude and MClientPlayername
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Callsigns then
|
if self.Filter.Callsigns and MClientInclude then
|
||||||
local MClientCallsigns = false
|
local MClientCallsigns = false
|
||||||
local callsign = MClient:GetCallsign()
|
local callsign = MClient:GetCallsign()
|
||||||
--self:I(callsign)
|
--self:I(callsign)
|
||||||
@@ -4586,6 +4826,11 @@ do -- SET_CLIENT
|
|||||||
MClientInclude = MClientInclude and MClientCallsigns
|
MClientInclude = MClientInclude and MClientCallsigns
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.Filter.Functions and MClientInclude then
|
||||||
|
local MClientFunc = self:_EvalFilterFunctions(MClient)
|
||||||
|
MClientInclude = MClientInclude and MClientFunc
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
self:T2( MClientInclude )
|
self:T2( MClientInclude )
|
||||||
return MClientInclude
|
return MClientInclude
|
||||||
@@ -5179,7 +5424,7 @@ do -- SET_AIRBASE
|
|||||||
function SET_AIRBASE:GetRandomAirbase()
|
function SET_AIRBASE:GetRandomAirbase()
|
||||||
|
|
||||||
local RandomAirbase = self:GetRandom()
|
local RandomAirbase = self:GetRandom()
|
||||||
self:F( { RandomAirbase = RandomAirbase:GetName() } )
|
--self:F( { RandomAirbase = RandomAirbase:GetName() } )
|
||||||
|
|
||||||
return RandomAirbase
|
return RandomAirbase
|
||||||
end
|
end
|
||||||
@@ -5345,7 +5590,7 @@ do -- SET_AIRBASE
|
|||||||
MAirbaseInclude = MAirbaseInclude and MAirbaseCoalition
|
MAirbaseInclude = MAirbaseInclude and MAirbaseCoalition
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Filter.Categories then
|
if self.Filter.Categories and MAirbaseInclude then
|
||||||
local MAirbaseCategory = false
|
local MAirbaseCategory = false
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
local AirbaseCategoryID = _DATABASE:GetCategoryFromAirbase( MAirbaseName )
|
local AirbaseCategoryID = _DATABASE:GetCategoryFromAirbase( MAirbaseName )
|
||||||
@@ -7611,6 +7856,28 @@ do -- SET_OPSGROUP
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Handles the OnBirth event for the Set.
|
||||||
|
-- @param #SET_OPSGROUP self
|
||||||
|
-- @param Core.Event#EVENTDATA Event Event data.
|
||||||
|
function SET_OPSGROUP:_EventOnBirth( Event )
|
||||||
|
self:F3( { Event } )
|
||||||
|
|
||||||
|
if Event.IniDCSUnit and Event.IniDCSGroup then
|
||||||
|
local DCSgroup=Event.IniDCSGroup --DCS#Group
|
||||||
|
|
||||||
|
if DCSgroup:getInitialSize() == DCSgroup:getSize() then -- This seems to be not a good check as even for the first birth event, getSize returns the total number of units in the group.
|
||||||
|
|
||||||
|
local groupname, group = self:AddInDatabase( Event )
|
||||||
|
|
||||||
|
if group and group:CountAliveUnits()==DCSgroup:getInitialSize() then
|
||||||
|
if group and self:IsIncludeObject( group ) then
|
||||||
|
self:Add( groupname, group )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Handles the OnDead or OnCrash event for alive groups set.
|
--- Handles the OnDead or OnCrash event for alive groups set.
|
||||||
-- Note: The GROUP object in the SET_OPSGROUP collection will only be removed if the last unit is destroyed of the GROUP.
|
-- Note: The GROUP object in the SET_OPSGROUP collection will only be removed if the last unit is destroyed of the GROUP.
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
@@ -7631,12 +7898,12 @@ do -- SET_OPSGROUP
|
|||||||
--- Handles the Database to check on an event (birth) that the Object was added in the Database.
|
--- Handles the Database to check on an event (birth) that the Object was added in the Database.
|
||||||
-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event!
|
-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event!
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param Core.Event#EVENTDATA Event
|
-- @param Core.Event#EVENTDATA Event Event data.
|
||||||
-- @return #string The name of the GROUP
|
-- @return #string The name of the GROUP.
|
||||||
-- @return #table The GROUP
|
-- @return Wrapper.Group#GROUP The GROUP object.
|
||||||
function SET_OPSGROUP:AddInDatabase( Event )
|
function SET_OPSGROUP:AddInDatabase( Event )
|
||||||
|
|
||||||
if Event.IniObjectCategory==1 then
|
if Event.IniObjectCategory==Object.Category.UNIT then
|
||||||
|
|
||||||
if not self.Database[Event.IniDCSGroupName] then
|
if not self.Database[Event.IniDCSGroupName] then
|
||||||
self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName )
|
self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName )
|
||||||
@@ -7651,8 +7918,8 @@ do -- SET_OPSGROUP
|
|||||||
-- This is required, because sometimes the _DATABASE event gets called later than the SET_BASE event or vise versa!
|
-- This is required, because sometimes the _DATABASE event gets called later than the SET_BASE event or vise versa!
|
||||||
-- @param #SET_OPSGROUP self
|
-- @param #SET_OPSGROUP self
|
||||||
-- @param Core.Event#EVENTDATA Event Event data table.
|
-- @param Core.Event#EVENTDATA Event Event data table.
|
||||||
-- @return #string The name of the GROUP
|
-- @return #string The name of the GROUP.
|
||||||
-- @return #table The GROUP
|
-- @return Wrapper.Group#GROUP The GROUP object.
|
||||||
function SET_OPSGROUP:FindInDatabase(Event)
|
function SET_OPSGROUP:FindInDatabase(Event)
|
||||||
return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName]
|
return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName]
|
||||||
end
|
end
|
||||||
@@ -7691,7 +7958,7 @@ do -- SET_OPSGROUP
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Filter coalitions.
|
-- Filter coalitions.
|
||||||
if self.Filter.Coalitions then
|
if self.Filter.Coalitions and MGroupInclude then
|
||||||
|
|
||||||
local MGroupCoalition = false
|
local MGroupCoalition = false
|
||||||
|
|
||||||
@@ -7705,7 +7972,7 @@ do -- SET_OPSGROUP
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Filter categories.
|
-- Filter categories.
|
||||||
if self.Filter.Categories then
|
if self.Filter.Categories and MGroupInclude then
|
||||||
|
|
||||||
local MGroupCategory = false
|
local MGroupCategory = false
|
||||||
|
|
||||||
@@ -7719,7 +7986,7 @@ do -- SET_OPSGROUP
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Filter countries.
|
-- Filter countries.
|
||||||
if self.Filter.Countries then
|
if self.Filter.Countries and MGroupInclude then
|
||||||
local MGroupCountry = false
|
local MGroupCountry = false
|
||||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||||
if country.id[CountryName] == MGroup:GetCountry() then
|
if country.id[CountryName] == MGroup:GetCountry() then
|
||||||
@@ -7730,12 +7997,12 @@ do -- SET_OPSGROUP
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Filter "prefixes".
|
-- Filter "prefixes".
|
||||||
if self.Filter.GroupPrefixes then
|
if self.Filter.GroupPrefixes and MGroupInclude then
|
||||||
|
|
||||||
local MGroupPrefix = false
|
local MGroupPrefix = false
|
||||||
|
|
||||||
for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do
|
for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do
|
||||||
if string.find( MGroup:GetName(), GroupPrefix:gsub ("-", "%%-"), 1 ) then --Not sure why "-" is replaced by "%-" ?!
|
if string.find( MGroup:GetName(), GroupPrefix:gsub ("-", "%%-"), 1 ) then --Not sure why "-" is replaced by "%-" ?! - So we can still match group names with a dash in them
|
||||||
MGroupPrefix = true
|
MGroupPrefix = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -7971,7 +8238,7 @@ do -- SET_SCENERY
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Get a table of alive objects.
|
--- Get a table of alive objects.
|
||||||
-- @param #SET_GROUP self
|
-- @param #SET_SCENERY self
|
||||||
-- @return #table Table of alive objects
|
-- @return #table Table of alive objects
|
||||||
-- @return Core.Set#SET_SCENERY SET of alive objects
|
-- @return Core.Set#SET_SCENERY SET of alive objects
|
||||||
function SET_SCENERY:GetAliveSet()
|
function SET_SCENERY:GetAliveSet()
|
||||||
@@ -8007,7 +8274,13 @@ do -- SET_SCENERY
|
|||||||
-- @return Core.Point#COORDINATE The center coordinate of all the objects in the set.
|
-- @return Core.Point#COORDINATE The center coordinate of all the objects in the set.
|
||||||
function SET_SCENERY:GetCoordinate()
|
function SET_SCENERY:GetCoordinate()
|
||||||
|
|
||||||
local Coordinate = self:GetRandom():GetCoordinate()
|
local Coordinate = COORDINATE:New({0,0,0})
|
||||||
|
|
||||||
|
local Item = self:GetRandomSurely()
|
||||||
|
|
||||||
|
if Item then
|
||||||
|
Coordinate:GetCoordinate()
|
||||||
|
end
|
||||||
|
|
||||||
local x1 = Coordinate.x
|
local x1 = Coordinate.x
|
||||||
local x2 = Coordinate.x
|
local x2 = Coordinate.x
|
||||||
@@ -8145,7 +8418,7 @@ do -- SET_SCENERY
|
|||||||
--- Calculate current relative lifepoints of the SET objects, i.e. Life divided by Life0 as percentage value, eg 75 meaning 75% alive.
|
--- Calculate current relative lifepoints of the SET objects, i.e. Life divided by Life0 as percentage value, eg 75 meaning 75% alive.
|
||||||
-- **CAVEAT**: Some objects change their life value or "hitpoints" **after** the first hit. Hence we will adjust the Life0 value to 120%
|
-- **CAVEAT**: Some objects change their life value or "hitpoints" **after** the first hit. Hence we will adjust the Life0 value to 120%
|
||||||
-- of the last life value if life exceeds life0 ata any point.
|
-- of the last life value if life exceeds life0 ata any point.
|
||||||
-- Thus will will get a smooth percentage decrease, if you use this e.g. as success criteria for a bombing task.
|
-- Thus we will get a smooth percentage decrease, if you use this e.g. as success criteria for a bombing task.
|
||||||
-- @param #SET_SCENERY self
|
-- @param #SET_SCENERY self
|
||||||
-- @return #number LifePoints
|
-- @return #number LifePoints
|
||||||
function SET_SCENERY:GetRelativeLife()
|
function SET_SCENERY:GetRelativeLife()
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SPA%20-%20Spawning)
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Core/Spawn)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -200,6 +200,22 @@
|
|||||||
-- * @{#SPAWN.InitRepeat}() or @{#SPAWN.InitRepeatOnLanding}(): This method is used to re-spawn automatically the same group after it has landed.
|
-- * @{#SPAWN.InitRepeat}() or @{#SPAWN.InitRepeatOnLanding}(): This method is used to re-spawn automatically the same group after it has landed.
|
||||||
-- * @{#SPAWN.InitRepeatOnEngineShutDown}(): This method is used to re-spawn automatically the same group after it has landed and it shuts down the engines at the ramp.
|
-- * @{#SPAWN.InitRepeatOnEngineShutDown}(): This method is used to re-spawn automatically the same group after it has landed and it shuts down the engines at the ramp.
|
||||||
--
|
--
|
||||||
|
-- ### 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.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
|
||||||
|
--
|
||||||
|
-- * @{#SPAWN.InitRandomizeCallsign}(): Set a random callsign name per spawn.
|
||||||
|
-- * @{#SPAWN.SpawnInitCallSign}(): Set a specific callsign for a spawned group.
|
||||||
|
--
|
||||||
|
-- ### Speed
|
||||||
|
--
|
||||||
|
-- * @{#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.InitSpeedKnots}(): Set the initial speed on spawning in knots.
|
||||||
|
--
|
||||||
-- ## SPAWN **Spawn** methods
|
-- ## SPAWN **Spawn** methods
|
||||||
--
|
--
|
||||||
-- Groups can be spawned at different times and methods:
|
-- Groups can be spawned at different times and methods:
|
||||||
@@ -276,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,
|
||||||
@@ -320,7 +337,7 @@ function SPAWN:New( SpawnTemplatePrefix )
|
|||||||
self.AIOnOff = true -- The AI is on by default when spawning a group.
|
self.AIOnOff = true -- The AI is on by default when spawning a group.
|
||||||
self.SpawnUnControlled = false
|
self.SpawnUnControlled = false
|
||||||
self.SpawnInitKeepUnitNames = false -- Overwrite unit names by default with group name.
|
self.SpawnInitKeepUnitNames = false -- Overwrite unit names by default with group name.
|
||||||
self.DelayOnOff = false -- No intial delay when spawning the first group.
|
self.DelayOnOff = false -- No initial delay when spawning the first group.
|
||||||
self.SpawnGrouping = nil -- No grouping.
|
self.SpawnGrouping = nil -- No grouping.
|
||||||
self.SpawnInitLivery = nil -- No special livery.
|
self.SpawnInitLivery = nil -- No special livery.
|
||||||
self.SpawnInitSkill = nil -- No special skill.
|
self.SpawnInitSkill = nil -- No special skill.
|
||||||
@@ -332,6 +349,7 @@ function SPAWN:New( SpawnTemplatePrefix )
|
|||||||
self.SpawnInitModexPostfix = nil
|
self.SpawnInitModexPostfix = nil
|
||||||
self.SpawnInitAirbase = nil
|
self.SpawnInitAirbase = nil
|
||||||
self.TweakedTemplate = false -- Check if the user is using self made template.
|
self.TweakedTemplate = false -- Check if the user is using self made template.
|
||||||
|
self.SpawnRandomCallsign = false
|
||||||
|
|
||||||
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
||||||
else
|
else
|
||||||
@@ -519,7 +537,7 @@ function SPAWN:NewFromTemplate( SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPr
|
|||||||
end
|
end
|
||||||
|
|
||||||
if SpawnTemplate then
|
if SpawnTemplate then
|
||||||
self.SpawnTemplate = SpawnTemplate -- Contains the template structure for a Group Spawn from the Mission Editor. Note that this group must have lateActivation always on!!!
|
self.SpawnTemplate = UTILS.DeepCopy(SpawnTemplate) -- Contains the template structure for a Group Spawn from the Mission Editor. Note that this group must have lateActivation always on!!!
|
||||||
self.SpawnTemplatePrefix = SpawnTemplatePrefix
|
self.SpawnTemplatePrefix = SpawnTemplatePrefix
|
||||||
self.SpawnAliasPrefix = SpawnAliasPrefix or SpawnTemplatePrefix
|
self.SpawnAliasPrefix = SpawnAliasPrefix or SpawnTemplatePrefix
|
||||||
self.SpawnTemplate.name = SpawnTemplatePrefix
|
self.SpawnTemplate.name = SpawnTemplatePrefix
|
||||||
@@ -602,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
|
||||||
@@ -723,7 +743,7 @@ end
|
|||||||
-- @param #number Country Country id as number or enumerator:
|
-- @param #number Country Country id as number or enumerator:
|
||||||
--
|
--
|
||||||
-- * @{DCS#country.id.RUSSIA}
|
-- * @{DCS#country.id.RUSSIA}
|
||||||
-- * @{DCS#county.id.USA}
|
-- * @{DCS#country.id.USA}
|
||||||
--
|
--
|
||||||
-- @return #SPAWN self
|
-- @return #SPAWN self
|
||||||
function SPAWN:InitCountry( Country )
|
function SPAWN:InitCountry( Country )
|
||||||
@@ -779,6 +799,82 @@ function SPAWN:InitSkill( Skill )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [Airplane - F15/16/18/AWACS/B1B/Tanker only] Set the STN Link16 starting number of the Group; each unit of the spawned group will have a consecutive STN set.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #number Octal The octal number (digits 1..7, max 5 digits, i.e. 1..77777) to set the STN to. Every STN needs to be unique!
|
||||||
|
-- @return #SPAWN self
|
||||||
|
function SPAWN:InitSTN(Octal)
|
||||||
|
self:F( { Octal = Octal } )
|
||||||
|
self.SpawnInitSTN = Octal or 77777
|
||||||
|
local num = UTILS.OctalToDecimal(Octal)
|
||||||
|
if num == nil or num < 1 then
|
||||||
|
self:E("WARNING - STN "..tostring(Octal).." is not valid!")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
if _DATABASE.STNS[num] ~= nil then
|
||||||
|
self:E("WARNING - STN already assigned: "..tostring(Octal).." is used for ".._DATABASE.STNS[Octal])
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [Airplane - A10-C II only] Set the SADL TN starting number of the Group; each unit of the spawned group will have a consecutive SADL set.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #number Octal The octal number (digits 1..7, max 4 digits, i.e. 1..7777) to set the SADL to. Every SADL needs to be unique!
|
||||||
|
-- @return #SPAWN self
|
||||||
|
function SPAWN:InitSADL(Octal)
|
||||||
|
self:F( { Octal = Octal } )
|
||||||
|
self.SpawnInitSADL = Octal or 7777
|
||||||
|
local num = UTILS.OctalToDecimal(Octal)
|
||||||
|
if num == nil or num < 1 then
|
||||||
|
self:E("WARNING - SADL "..tostring(Octal).." is not valid!")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
if _DATABASE.SADL[num] ~= nil then
|
||||||
|
self:E("WARNING - SADL already assigned: "..tostring(Octal).." is used for ".._DATABASE.SADL[Octal])
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [Airplane] Set the initial speed on spawning in meters per second. Useful when spawning in-air only.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #number MPS The speed in MPS to use.
|
||||||
|
-- @return #SPAWN self
|
||||||
|
function SPAWN:InitSpeedMps(MPS)
|
||||||
|
self:F( { MPS = MPS } )
|
||||||
|
if MPS == nil or tonumber(MPS)<0 then
|
||||||
|
MPS=125
|
||||||
|
end
|
||||||
|
self.InitSpeed = MPS
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [Airplane] Set the initial speed on spawning in knots. Useful when spawning in-air only.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #number Knots The speed in knots to use.
|
||||||
|
-- @return #SPAWN self
|
||||||
|
function SPAWN:InitSpeedKnots(Knots)
|
||||||
|
self:F( { Knots = Knots } )
|
||||||
|
if Knots == nil or tonumber(Knots)<0 then
|
||||||
|
Knots=300
|
||||||
|
end
|
||||||
|
self.InitSpeed = UTILS.KnotsToMps(Knots)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [Airplane] Set the initial speed on spawning in kilometers per hour. Useful when spawning in-air only.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #number KPH The speed in KPH to use.
|
||||||
|
-- @return #SPAWN self
|
||||||
|
function SPAWN:InitSpeedKph(KPH)
|
||||||
|
self:F( { KPH = KPH } )
|
||||||
|
if KPH == nil or tonumber(KPH)<0 then
|
||||||
|
KPH=UTILS.KnotsToKmph(300)
|
||||||
|
end
|
||||||
|
self.InitSpeed = UTILS.KmphToMps(KPH)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Sets the radio communication on or off. Same as checking/unchecking the COMM box in the mission editor.
|
--- Sets the radio communication on or off. Same as checking/unchecking the COMM box in the mission editor.
|
||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
-- @param #number switch If true (or nil), enables the radio communication. If false, disables the radio for the spawned group.
|
-- @param #number switch If true (or nil), enables the radio communication. If false, disables the radio for the spawned group.
|
||||||
@@ -1099,6 +1195,31 @@ function SPAWN:InitRandomizeZones( SpawnZoneTable )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [AIR/Fighter only!] This method randomizes the callsign for a new group.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @return #SPAWN self
|
||||||
|
function SPAWN:InitRandomizeCallsign()
|
||||||
|
self.SpawnRandomCallsign = true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [BLUE AIR only!] This method sets a specific callsign for a spawned group. Use for a group with one unit only!
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #number ID ID of the callsign enumerator, e.g. CALLSIGN.Tanker.Texaco - - resulting in e.g. Texaco-2-1
|
||||||
|
-- @param #string Name Name of this callsign as it cannot be determined from the ID because of the dependency on the task type of the plane, and the plane type. E.g. "Texaco"
|
||||||
|
-- @param #number Minor Minor number, i.e. the unit number within the group, e.g 2 - 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
|
||||||
|
function SPAWN:InitCallSign(ID,Name,Minor,Major)
|
||||||
|
local Name = Name or "Enfield"
|
||||||
|
self.SpawnInitCallSign = true
|
||||||
|
self.SpawnInitCallSignID = ID or 1
|
||||||
|
self.SpawnInitCallSignMinor = Minor or 1
|
||||||
|
self.SpawnInitCallSignMajor = Major or 1
|
||||||
|
self.SpawnInitCallSignName=string.lower(Name):gsub("^%l", string.upper)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- This method sets a spawn position for the group that is different from the location of the template.
|
--- This method sets a spawn position for the group that is different from the location of the template.
|
||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
-- @param Core.Point#COORDINATE Coordinate The position to spawn from
|
-- @param Core.Point#COORDINATE Coordinate The position to spawn from
|
||||||
@@ -1350,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
|
||||||
@@ -1433,6 +1578,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
else
|
else
|
||||||
|
|
||||||
local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate
|
local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate
|
||||||
|
local SpawnZone = self.SpawnGroups[self.SpawnIndex].SpawnZone
|
||||||
self:T( SpawnTemplate.name )
|
self:T( SpawnTemplate.name )
|
||||||
|
|
||||||
if SpawnTemplate then
|
if SpawnTemplate then
|
||||||
@@ -1458,6 +1604,23 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
if self.SpawnRandomizeUnits then
|
if self.SpawnRandomizeUnits then
|
||||||
for UnitID = 1, #SpawnTemplate.units do
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
local RandomVec2 = PointVec3:GetRandomVec2InRadius( self.SpawnOuterRadius, self.SpawnInnerRadius )
|
local RandomVec2 = PointVec3:GetRandomVec2InRadius( self.SpawnOuterRadius, self.SpawnInnerRadius )
|
||||||
|
if (SpawnZone) then
|
||||||
|
local inZone = SpawnZone:IsVec2InZone(RandomVec2)
|
||||||
|
local numTries = 1
|
||||||
|
while (not inZone) and (numTries < 20) do
|
||||||
|
if not inZone then
|
||||||
|
RandomVec2 = PointVec3:GetRandomVec2InRadius( self.SpawnOuterRadius, self.SpawnInnerRadius )
|
||||||
|
numTries = numTries + 1
|
||||||
|
inZone = SpawnZone:IsVec2InZone(RandomVec2)
|
||||||
|
--self:I("Retrying " .. numTries .. "spawn " .. SpawnTemplate.name .. " in Zone " .. SpawnZone:GetName() .. "!")
|
||||||
|
--self:I(SpawnZone)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (not inZone) then
|
||||||
|
self:I("Could not place unit within zone and within radius!")
|
||||||
|
RandomVec2 = SpawnZone:GetRandomVec2()
|
||||||
|
end
|
||||||
|
end
|
||||||
SpawnTemplate.units[UnitID].x = RandomVec2.x
|
SpawnTemplate.units[UnitID].x = RandomVec2.x
|
||||||
SpawnTemplate.units[UnitID].y = RandomVec2.y
|
SpawnTemplate.units[UnitID].y = RandomVec2.y
|
||||||
self:T( 'SpawnTemplate.units[' .. UnitID .. '].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units[' .. UnitID .. '].y = ' .. SpawnTemplate.units[UnitID].y )
|
self:T( 'SpawnTemplate.units[' .. UnitID .. '].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units[' .. UnitID .. '].y = ' .. SpawnTemplate.units[UnitID].y )
|
||||||
@@ -1509,12 +1672,14 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
|
|
||||||
for UnitID = 1, #SpawnTemplate.units do
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
|
|
||||||
if UnitID > 1 then -- don't rotate position of unit #1
|
if not self.SpawnRandomizeUnits then
|
||||||
local unitXOff = SpawnTemplate.units[UnitID].x - pivotX -- rotate position offset around unit #1
|
if UnitID > 1 then -- don't rotate position of unit #1
|
||||||
local unitYOff = SpawnTemplate.units[UnitID].y - pivotY
|
local unitXOff = SpawnTemplate.units[UnitID].x - pivotX -- rotate position offset around unit #1
|
||||||
|
local unitYOff = SpawnTemplate.units[UnitID].y - pivotY
|
||||||
|
|
||||||
SpawnTemplate.units[UnitID].x = pivotX + (unitXOff * cosHeading) - (unitYOff * sinHeading)
|
SpawnTemplate.units[UnitID].x = pivotX + (unitXOff * cosHeading) - (unitYOff * sinHeading)
|
||||||
SpawnTemplate.units[UnitID].y = pivotY + (unitYOff * cosHeading) + (unitXOff * sinHeading)
|
SpawnTemplate.units[UnitID].y = pivotY + (unitYOff * cosHeading) + (unitXOff * sinHeading)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- adjust heading of all units, including unit #1
|
-- adjust heading of all units, including unit #1
|
||||||
@@ -1604,6 +1769,19 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
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
|
||||||
@@ -1644,8 +1822,8 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
|
|
||||||
-- If there is a SpawnFunction hook defined, call it.
|
-- If there is a SpawnFunction hook defined, call it.
|
||||||
if self.SpawnFunctionHook then
|
if self.SpawnFunctionHook then
|
||||||
-- delay calling this for .1 seconds so that it hopefully comes after the BIRTH event of the group.
|
-- delay calling this for .3 seconds so that it hopefully comes after the BIRTH event of the group.
|
||||||
self.SpawnHookScheduler:Schedule( nil, self.SpawnFunctionHook, { self.SpawnGroups[self.SpawnIndex].Group, unpack( self.SpawnFunctionArguments ) }, 0.1 )
|
self.SpawnHookScheduler:Schedule( nil, self.SpawnFunctionHook, { self.SpawnGroups[self.SpawnIndex].Group, unpack( self.SpawnFunctionArguments ) }, 0.3 )
|
||||||
end
|
end
|
||||||
-- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats.
|
-- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats.
|
||||||
-- if self.Repeat then
|
-- if self.Repeat then
|
||||||
@@ -1654,6 +1832,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.SpawnGroups[self.SpawnIndex].Spawned = true
|
self.SpawnGroups[self.SpawnIndex].Spawned = true
|
||||||
|
self.SpawnGroups[self.SpawnIndex].Group.TemplateDonor = self.SpawnTemplatePrefix
|
||||||
return self.SpawnGroups[self.SpawnIndex].Group
|
return self.SpawnGroups[self.SpawnIndex].Group
|
||||||
else
|
else
|
||||||
-- self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
|
-- self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
|
||||||
@@ -3100,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 )
|
||||||
@@ -3112,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
|
||||||
@@ -3261,36 +3440,206 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
|||||||
|
|
||||||
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 UnitPrefix, Rest = string.match( SpawnTemplate.units[UnitID].name, "^([^#]+)#?" ):gsub( "^%s*(.-)%s*$", "%1" )
|
local SpawnInitKeepUnitIFF = false
|
||||||
self:T( { UnitPrefix, Rest } )
|
if string.find(SpawnTemplate.units[UnitID].name,"#IFF_",1,true) then --Razbam IFF hack for F15E etc
|
||||||
|
SpawnInitKeepUnitIFF = true
|
||||||
|
end
|
||||||
|
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].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
|
||||||
SpawnTemplate.units[UnitID].unitId = nil
|
SpawnTemplate.units[UnitID].unitId = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Callsign
|
-- Callsign
|
||||||
for UnitID = 1, #SpawnTemplate.units do
|
|
||||||
local Callsign = SpawnTemplate.units[UnitID].callsign
|
if self.SpawnRandomCallsign and SpawnTemplate.units[1].callsign then
|
||||||
if Callsign then
|
if type( SpawnTemplate.units[1].callsign ) ~= "number" then
|
||||||
if type( Callsign ) ~= "number" then -- blue callsign
|
-- change callsign
|
||||||
Callsign[2] = ((SpawnIndex - 1) % 10) + 1
|
local min = 1
|
||||||
local CallsignName = SpawnTemplate.units[UnitID].callsign["name"] -- #string
|
local max = 8
|
||||||
CallsignName = string.match(CallsignName,"^(%a+)") -- 2.8 - only the part w/o numbers
|
local ctable = CALLSIGN.Aircraft
|
||||||
local CallsignLen = CallsignName:len()
|
if string.find(SpawnTemplate.units[1].type, "A-10",1,true) then
|
||||||
SpawnTemplate.units[UnitID].callsign["name"] = CallsignName:sub( 1, CallsignLen ) .. SpawnTemplate.units[UnitID].callsign[2] .. SpawnTemplate.units[UnitID].callsign[3]
|
max = 12
|
||||||
else
|
end
|
||||||
SpawnTemplate.units[UnitID].callsign = Callsign + SpawnIndex
|
if string.find(SpawnTemplate.units[1].type, "18",1,true) then
|
||||||
|
min = 9
|
||||||
|
max = 20
|
||||||
|
ctable = CALLSIGN.F18
|
||||||
|
end
|
||||||
|
if string.find(SpawnTemplate.units[1].type, "16",1,true) then
|
||||||
|
min = 9
|
||||||
|
max = 20
|
||||||
|
ctable = CALLSIGN.F16
|
||||||
|
end
|
||||||
|
if SpawnTemplate.units[1].type == "F-15E" then
|
||||||
|
min = 9
|
||||||
|
max = 18
|
||||||
|
ctable = CALLSIGN.F15E
|
||||||
|
end
|
||||||
|
local callsignnr = math.random(min,max)
|
||||||
|
local callsignname = "Enfield"
|
||||||
|
for name, value in pairs(ctable) do
|
||||||
|
if value==callsignnr then
|
||||||
|
callsignname = name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
|
SpawnTemplate.units[UnitID].callsign[1] = callsignnr
|
||||||
|
SpawnTemplate.units[UnitID].callsign[2] = UnitID
|
||||||
|
SpawnTemplate.units[UnitID].callsign[3] = "1"
|
||||||
|
SpawnTemplate.units[UnitID].callsign["name"] = tostring(callsignname)..tostring(UnitID).."1"
|
||||||
|
-- UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].callsign,1)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Russkis
|
||||||
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
|
SpawnTemplate.units[UnitID].callsign = math.random(1,999)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.SpawnInitCallSign then
|
||||||
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
|
local Callsign = SpawnTemplate.units[UnitID].callsign
|
||||||
|
if Callsign and type( Callsign ) ~= "number" then
|
||||||
|
SpawnTemplate.units[UnitID].callsign[1] = self.SpawnInitCallSignID
|
||||||
|
SpawnTemplate.units[UnitID].callsign[2] = self.SpawnInitCallSignMinor
|
||||||
|
SpawnTemplate.units[UnitID].callsign[3] = self.SpawnInitCallSignMajor
|
||||||
|
SpawnTemplate.units[UnitID].callsign["name"] = string.format("%s%d%d",self.SpawnInitCallSignName,self.SpawnInitCallSignMinor,self.SpawnInitCallSignMajor)
|
||||||
|
--UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].callsign,1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
|
local Callsign = SpawnTemplate.units[UnitID].callsign
|
||||||
|
if Callsign then
|
||||||
|
if type( Callsign ) ~= "number" and not self.SpawnInitCallSign then -- blue callsign
|
||||||
|
-- UTILS.PrintTableToLog(Callsign,1)
|
||||||
|
Callsign[2] = ((SpawnIndex - 1) % 10) + 1
|
||||||
|
local CallsignName = SpawnTemplate.units[UnitID].callsign["name"] -- #string
|
||||||
|
CallsignName = string.match(CallsignName,"^(%a+)") -- 2.8 - only the part w/o numbers
|
||||||
|
local CallsignLen = CallsignName:len()
|
||||||
|
SpawnTemplate.units[UnitID].callsign[2] = UnitID
|
||||||
|
SpawnTemplate.units[UnitID].callsign["name"] = CallsignName:sub( 1, CallsignLen ) .. SpawnTemplate.units[UnitID].callsign[2] .. SpawnTemplate.units[UnitID].callsign[3]
|
||||||
|
elseif type( Callsign ) == "number" then
|
||||||
|
SpawnTemplate.units[UnitID].callsign = Callsign + SpawnIndex
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Speed
|
||||||
|
if self.InitSpeed then
|
||||||
|
SpawnTemplate.units[UnitID].speed = self.InitSpeed
|
||||||
|
end
|
||||||
|
-- Link16
|
||||||
|
local AddProps = SpawnTemplate.units[UnitID].AddPropAircraft
|
||||||
|
if AddProps then
|
||||||
|
if SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 then
|
||||||
|
if self.SpawnInitSTN then
|
||||||
|
local octal = self.SpawnInitSTN
|
||||||
|
if UnitID > 1 then
|
||||||
|
octal = _DATABASE:GetNextSTN(self.SpawnInitSTN,SpawnTemplate.units[UnitID].name)
|
||||||
|
end
|
||||||
|
SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 = string.format("%05d",octal)
|
||||||
|
else
|
||||||
|
-- 5 digit octal with leading 0
|
||||||
|
if tonumber(SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16) ~= nil then
|
||||||
|
local octal = SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16
|
||||||
|
local num = UTILS.OctalToDecimal(octal)
|
||||||
|
if _DATABASE.STNS[num] ~= nil or UnitID > 1 then -- STN taken or next unit
|
||||||
|
octal = _DATABASE:GetNextSTN(octal,SpawnTemplate.units[UnitID].name)
|
||||||
|
end
|
||||||
|
SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 = string.format("%05d",octal)
|
||||||
|
else -- ED bug - chars in here
|
||||||
|
local OSTN = _DATABASE:GetNextSTN(1,SpawnTemplate.units[UnitID].name)
|
||||||
|
SpawnTemplate.units[UnitID].AddPropAircraft.STN_L16 = string.format("%05d",OSTN)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- A10CII
|
||||||
|
if SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN then
|
||||||
|
-- 4 digit octal with leading 0
|
||||||
|
if self.SpawnInitSADL then
|
||||||
|
local octal = self.SpawnInitSADL
|
||||||
|
if UnitID > 1 then
|
||||||
|
octal = _DATABASE:GetNextSADL(self.SpawnInitSADL,SpawnTemplate.units[UnitID].name)
|
||||||
|
end
|
||||||
|
SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN = string.format("%04d",octal)
|
||||||
|
else
|
||||||
|
if tonumber(SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN) ~= nil then
|
||||||
|
local octal = SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN
|
||||||
|
local num = UTILS.OctalToDecimal(octal)
|
||||||
|
self.SpawnInitSADL = num -- we arrived here seeing that self.SpawnInitSADL == nil, but now that we have a SADL (num), we also need to set it to self.SpawnInitSADL in case
|
||||||
|
-- we need to get the next SADL from _DATABASE, or else UTILS.OctalToDecimal() will fail in GetNextSADL
|
||||||
|
if _DATABASE.SADL[num] ~= nil or UnitID > 1 then -- SADL taken or next unit
|
||||||
|
octal = _DATABASE:GetNextSADL(self.SpawnInitSADL,SpawnTemplate.units[UnitID].name)
|
||||||
|
end
|
||||||
|
SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN = string.format("%04d",octal)
|
||||||
|
else -- ED bug - chars in here
|
||||||
|
local OSTN = _DATABASE:GetNextSADL(1,SpawnTemplate.units[UnitID].name)
|
||||||
|
SpawnTemplate.units[UnitID].AddPropAircraft.SADL_TN = string.format("%04d",OSTN)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- VoiceCallsignNumber
|
||||||
|
if SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignNumber and type( Callsign ) ~= "number" then
|
||||||
|
SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignNumber = SpawnTemplate.units[UnitID].callsign[2] .. SpawnTemplate.units[UnitID].callsign[3]
|
||||||
|
end
|
||||||
|
-- VoiceCallsignLabel
|
||||||
|
if SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignLabel and type( Callsign ) ~= "number" then
|
||||||
|
local CallsignName = SpawnTemplate.units[UnitID].callsign["name"] -- #string
|
||||||
|
CallsignName = string.match(CallsignName,"^(%a+)") -- 2.8 - only the part w/o numbers
|
||||||
|
local label = "NY" -- Navy One exception
|
||||||
|
if not string.find(CallsignName," ") then
|
||||||
|
label = string.upper(string.match(CallsignName,"^%a")..string.match(CallsignName,"%a$"))
|
||||||
|
end
|
||||||
|
SpawnTemplate.units[UnitID].AddPropAircraft.VoiceCallsignLabel = label
|
||||||
|
end
|
||||||
|
-- UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].AddPropAircraft,1)
|
||||||
|
-- FlightLead
|
||||||
|
if SpawnTemplate.units[UnitID].datalinks and SpawnTemplate.units[UnitID].datalinks.Link16 and SpawnTemplate.units[UnitID].datalinks.Link16.settings then
|
||||||
|
SpawnTemplate.units[UnitID].datalinks.Link16.settings.flightLead = UnitID == 1 and true or false
|
||||||
|
end
|
||||||
|
-- A10CII
|
||||||
|
if SpawnTemplate.units[UnitID].datalinks and SpawnTemplate.units[UnitID].datalinks.SADL and SpawnTemplate.units[UnitID].datalinks.SADL.settings then
|
||||||
|
SpawnTemplate.units[UnitID].datalinks.SADL.settings.flightLead = UnitID == 1 and true or false
|
||||||
|
end
|
||||||
|
-- UTILS.PrintTableToLog(SpawnTemplate.units[UnitID].datalinks,1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Link16 team members
|
||||||
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
|
if SpawnTemplate.units[UnitID].datalinks and SpawnTemplate.units[UnitID].datalinks.Link16 and SpawnTemplate.units[UnitID].datalinks.Link16.network then
|
||||||
|
local team = {}
|
||||||
|
local isF16 = string.find(SpawnTemplate.units[UnitID].type,"F-16",1,true) and true or false
|
||||||
|
for ID = 1, #SpawnTemplate.units do
|
||||||
|
local member = {}
|
||||||
|
member.missionUnitId = ID
|
||||||
|
if isF16 then
|
||||||
|
member.TDOA = true
|
||||||
|
end
|
||||||
|
table.insert(team,member)
|
||||||
|
end
|
||||||
|
SpawnTemplate.units[UnitID].datalinks.Link16.network.teamMembers = team
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self:T3( { "Template:", SpawnTemplate } )
|
self:T3( { "Template:", SpawnTemplate } )
|
||||||
|
--UTILS.PrintTableToLog(SpawnTemplate,1)
|
||||||
return SpawnTemplate
|
return SpawnTemplate
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -3432,6 +3781,7 @@ function SPAWN:_RandomizeZones( SpawnIndex )
|
|||||||
self:T( { SpawnVec2 = SpawnVec2 } )
|
self:T( { SpawnVec2 = SpawnVec2 } )
|
||||||
|
|
||||||
local SpawnTemplate = self.SpawnGroups[SpawnIndex].SpawnTemplate
|
local SpawnTemplate = self.SpawnGroups[SpawnIndex].SpawnTemplate
|
||||||
|
self.SpawnGroups[SpawnIndex].SpawnZone = SpawnZone
|
||||||
|
|
||||||
self:T( { Route = SpawnTemplate.route } )
|
self:T( { Route = SpawnTemplate.route } )
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,14 @@
|
|||||||
--
|
--
|
||||||
-- # Demo Missions
|
-- # Demo Missions
|
||||||
--
|
--
|
||||||
-- ## [SPAWNSTATIC Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SPS%20-%20Spawning%20Statics)
|
-- ## [SPAWNSTATIC Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Core/SpawnStatic)
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- # YouTube Channel
|
-- # YouTube Channel
|
||||||
--
|
--
|
||||||
-- ## [SPAWNSTATIC YouTube Channel]() [No videos yet!]
|
-- ## No videos yet!
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -329,14 +329,14 @@ do
|
|||||||
if self.Lasing then
|
if self.Lasing then
|
||||||
if self.Target and self.Target:IsAlive() then
|
if self.Target and self.Target:IsAlive() then
|
||||||
|
|
||||||
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):GetVec3() )
|
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/200):AddX(math.random(-100,100)/200):GetVec3() )
|
||||||
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
||||||
|
|
||||||
self:__Lasing(0.2)
|
self:__Lasing(0.2)
|
||||||
elseif self.TargetCoord then
|
elseif self.TargetCoord then
|
||||||
|
|
||||||
-- Wiggle the IR spot a bit.
|
-- Wiggle the IR spot a bit.
|
||||||
local irvec3={x=self.TargetCoord.x+math.random(-100,100)/100, y=self.TargetCoord.y+math.random(-100,100)/100, z=self.TargetCoord.z} --#DCS.Vec3
|
local irvec3={x=self.TargetCoord.x+math.random(-100,100)/200, y=self.TargetCoord.y+math.random(-100,100)/200, z=self.TargetCoord.z} --#DCS.Vec3
|
||||||
local lsvec3={x=self.TargetCoord.x, y=self.TargetCoord.y, z=self.TargetCoord.z} --#DCS.Vec3
|
local lsvec3={x=self.TargetCoord.x, y=self.TargetCoord.y, z=self.TargetCoord.z} --#DCS.Vec3
|
||||||
|
|
||||||
self.SpotIR:setPoint(irvec3)
|
self.SpotIR:setPoint(irvec3)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
-- * Create moving zones around a unit.
|
-- * Create moving zones around a unit.
|
||||||
-- * Create moving zones around a group.
|
-- * Create moving zones around a group.
|
||||||
-- * Provide the zone behavior. Some zones are static, while others are moveable.
|
-- * Provide the zone behavior. Some zones are static, while others are moveable.
|
||||||
-- * Enquiry if a coordinate is within a zone.
|
-- * Enquire if a coordinate is within a zone.
|
||||||
-- * Smoke zones.
|
-- * Smoke zones.
|
||||||
-- * Set a zone probability to control zone selection.
|
-- * Set a zone probability to control zone selection.
|
||||||
-- * Get zone coordinates.
|
-- * Get zone coordinates.
|
||||||
@@ -42,11 +42,16 @@
|
|||||||
-- * @{#ZONE_UNIT}: The ZONE_UNIT class defines by a zone around a @{Wrapper.Unit#UNIT} with a radius.
|
-- * @{#ZONE_UNIT}: The ZONE_UNIT class defines by a zone around a @{Wrapper.Unit#UNIT} with a radius.
|
||||||
-- * @{#ZONE_GROUP}: The ZONE_GROUP class defines by a zone around a @{Wrapper.Group#GROUP} with a radius.
|
-- * @{#ZONE_GROUP}: The ZONE_GROUP class defines by a zone around a @{Wrapper.Group#GROUP} with a radius.
|
||||||
-- * @{#ZONE_POLYGON}: The ZONE_POLYGON class defines by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
-- * @{#ZONE_POLYGON}: The ZONE_POLYGON class defines by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||||
|
-- * @{#ZONE_OVAL}: The ZONE_OVAL class is defined by a center point, major axis, minor axis, and angle.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Core/Zone)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### Author: **FlightControl**
|
-- ### Author: **FlightControl**
|
||||||
-- ### Contributions: **Applevangelist**, **FunkyFranky**
|
-- ### Contributions: **Applevangelist**, **FunkyFranky**, **coconutcockpit**
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -325,14 +330,14 @@ function ZONE_BASE:GetRandomVec2()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define a random @{Core.Point#POINT_VEC2} within the zone.
|
--- Define a random @{Core.Point#POINT_VEC2} within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec2 table.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return Core.Point#POINT_VEC2 The PointVec2 coordinates.
|
-- @return Core.Point#POINT_VEC2 The PointVec2 coordinates.
|
||||||
function ZONE_BASE:GetRandomPointVec2()
|
function ZONE_BASE:GetRandomPointVec2()
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define a random @{Core.Point#POINT_VEC3} within the zone.
|
--- Define a random @{Core.Point#POINT_VEC3} within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec3 table.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return Core.Point#POINT_VEC3 The PointVec3 coordinates.
|
-- @return Core.Point#POINT_VEC3 The PointVec3 coordinates.
|
||||||
function ZONE_BASE:GetRandomPointVec3()
|
function ZONE_BASE:GetRandomPointVec3()
|
||||||
@@ -480,7 +485,13 @@ function ZONE_BASE:UndrawZone(Delay)
|
|||||||
self:ScheduleOnce(Delay, ZONE_BASE.UndrawZone, self)
|
self:ScheduleOnce(Delay, ZONE_BASE.UndrawZone, self)
|
||||||
else
|
else
|
||||||
if self.DrawID then
|
if self.DrawID then
|
||||||
UTILS.RemoveMark(self.DrawID)
|
if type(self.DrawID) ~= "table" then
|
||||||
|
UTILS.RemoveMark(self.DrawID)
|
||||||
|
else -- DrawID is a table with a collections of mark ids, as used in ZONE_POLYGON
|
||||||
|
for _, mark_id in pairs(self.DrawID) do
|
||||||
|
UTILS.RemoveMark(mark_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -892,6 +903,7 @@ function ZONE_RADIUS:BoundZone( Points, CountryID, UnBound )
|
|||||||
|
|
||||||
local Point = {}
|
local Point = {}
|
||||||
local Vec2 = self:GetVec2()
|
local Vec2 = self:GetVec2()
|
||||||
|
local countryID = CountryID or country.id.USA
|
||||||
|
|
||||||
Points = Points and Points or 360
|
Points = Points and Points or 360
|
||||||
|
|
||||||
@@ -903,7 +915,7 @@ function ZONE_RADIUS:BoundZone( Points, CountryID, UnBound )
|
|||||||
Point.x = Vec2.x + math.cos( Radial ) * self:GetRadius()
|
Point.x = Vec2.x + math.cos( Radial ) * self:GetRadius()
|
||||||
Point.y = Vec2.y + math.sin( Radial ) * self:GetRadius()
|
Point.y = Vec2.y + math.sin( Radial ) * self:GetRadius()
|
||||||
|
|
||||||
local CountryName = _DATABASE.COUNTRY_NAME[CountryID]
|
local CountryName = _DATABASE.COUNTRY_NAME[countryID]
|
||||||
|
|
||||||
local Tire = {
|
local Tire = {
|
||||||
["country"] = CountryName,
|
["country"] = CountryName,
|
||||||
@@ -918,7 +930,7 @@ function ZONE_RADIUS:BoundZone( Points, CountryID, UnBound )
|
|||||||
["heading"] = 0,
|
["heading"] = 0,
|
||||||
} -- end of ["group"]
|
} -- end of ["group"]
|
||||||
|
|
||||||
local Group = coalition.addStaticObject( CountryID, Tire )
|
local Group = coalition.addStaticObject( countryID, Tire )
|
||||||
if UnBound and UnBound == true then
|
if UnBound and UnBound == true then
|
||||||
Group:destroy()
|
Group:destroy()
|
||||||
end
|
end
|
||||||
@@ -1168,7 +1180,7 @@ function ZONE_RADIUS:RemoveJunk()
|
|||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Count the number of different coalitions inside the zone.
|
--- Get a table of scanned units.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #table Table of DCS units and DCS statics inside the zone.
|
-- @return #table Table of DCS units and DCS statics inside the zone.
|
||||||
function ZONE_RADIUS:GetScannedUnits()
|
function ZONE_RADIUS:GetScannedUnits()
|
||||||
@@ -1203,7 +1215,7 @@ function ZONE_RADIUS:GetScannedSetUnit()
|
|||||||
return SetUnit
|
return SetUnit
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a set of scanned units.
|
--- Get a set of scanned groups.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return Core.Set#SET_GROUP Set of groups.
|
-- @return Core.Set#SET_GROUP Set of groups.
|
||||||
function ZONE_RADIUS:GetScannedSetGroup()
|
function ZONE_RADIUS:GetScannedSetGroup()
|
||||||
@@ -1503,7 +1515,7 @@ function ZONE_RADIUS:GetRandomVec2(inner, outer, surfacetypes)
|
|||||||
return point
|
return point
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec2 table.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
@@ -1534,7 +1546,7 @@ function ZONE_RADIUS:GetRandomVec3( inner, outer )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC3} object reflecting a random 3D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC3} object reflecting a random 3D location within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec3 table.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
@@ -1978,7 +1990,7 @@ function ZONE_GROUP:GetRandomVec2()
|
|||||||
return Point
|
return Point
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec2 table.
|
||||||
-- @param #ZONE_GROUP self
|
-- @param #ZONE_GROUP self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
@@ -1994,9 +2006,134 @@ function ZONE_GROUP:GetRandomPointVec2( inner, outer )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Triangle.lua
|
||||||
|
--- This triangle "zone" is not really to be used on its own, it only serves as building blocks for
|
||||||
|
--- ZONE_POLYGON to accurately find a point inside a polygon; as well as getting the correct surface area of
|
||||||
|
--- a polygon.
|
||||||
|
-- @type _ZONE_TRIANGLE
|
||||||
|
-- @extends Core.Zone#ZONE_BASE
|
||||||
|
|
||||||
|
--- ## _ZONE_TRIANGLE class, extends @{#ZONE_BASE}
|
||||||
|
--
|
||||||
|
-- _ZONE_TRIANGLE class is a helper class for ZONE_POLYGON
|
||||||
|
-- This class implements the inherited functions from @{#ZONE_BASE} taking into account the own zone format and properties.
|
||||||
|
--
|
||||||
|
-- @field #_ZONE_TRIANGLE
|
||||||
|
_ZONE_TRIANGLE = {
|
||||||
|
ClassName="ZONE_TRIANGLE",
|
||||||
|
Points={},
|
||||||
|
Coords={},
|
||||||
|
CenterVec2={x=0, y=0},
|
||||||
|
SurfaceArea=0,
|
||||||
|
DrawID={}
|
||||||
|
}
|
||||||
|
---
|
||||||
|
-- @param #_ZONE_TRIANGLE self
|
||||||
|
-- @param DCS#Vec p1
|
||||||
|
-- @param DCS#Vec p2
|
||||||
|
-- @param DCS#Vec p3
|
||||||
|
-- @return #_ZONE_TRIANGLE self
|
||||||
|
function _ZONE_TRIANGLE:New(p1, p2, p3)
|
||||||
|
local self = BASE:Inherit(self, ZONE_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
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a point is contained within the triangle.
|
||||||
|
-- @param #_ZONE_TRIANGLE self
|
||||||
|
-- @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 _ZONE_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 #_ZONE_TRIANGLE self
|
||||||
|
-- @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 _ZONE_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
|
||||||
|
|
||||||
|
--- Draw the triangle
|
||||||
|
-- @param #_ZONE_TRIANGLE self
|
||||||
|
-- @return #table of draw IDs
|
||||||
|
function _ZONE_TRIANGLE:Draw(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
Coalition=Coalition or -1
|
||||||
|
|
||||||
|
Color=Color or {1, 0, 0 }
|
||||||
|
Alpha=Alpha or 1
|
||||||
|
|
||||||
|
FillColor=FillColor or Color
|
||||||
|
if not FillColor then UTILS.DeepCopy(Color) end
|
||||||
|
FillAlpha=FillAlpha or Alpha
|
||||||
|
if not FillAlpha then FillAlpha=1 end
|
||||||
|
|
||||||
|
for i=1, #self.Coords do
|
||||||
|
local c1 = self.Coords[i]
|
||||||
|
local c2 = self.Coords[i % #self.Coords + 1]
|
||||||
|
local id = c1:LineToAll(c2, Coalition, Color, Alpha, LineType, ReadOnly)
|
||||||
|
self.DrawID[#self.DrawID+1] = id
|
||||||
|
end
|
||||||
|
local newID = self.Coords[1]:MarkupToAllFreeForm({self.Coords[2],self.Coords[3]},Coalition,Color,Alpha,FillColor,FillAlpha,LineType,ReadOnly)
|
||||||
|
self.DrawID[#self.DrawID+1] = newID
|
||||||
|
return self.DrawID
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Draw the triangle
|
||||||
|
-- @param #_ZONE_TRIANGLE self
|
||||||
|
-- @return #table of draw IDs
|
||||||
|
function _ZONE_TRIANGLE:Fill(Coalition, FillColor, FillAlpha, ReadOnly)
|
||||||
|
Coalition=Coalition or -1
|
||||||
|
FillColor = FillColor
|
||||||
|
FillAlpha = FillAlpha
|
||||||
|
local newID = self.Coords[1]:MarkupToAllFreeForm({self.Coords[2],self.Coords[3]},Coalition,nil,nil,FillColor,FillAlpha,0,nil)
|
||||||
|
self.DrawID[#self.DrawID+1] = newID
|
||||||
|
return self.DrawID
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @type ZONE_POLYGON_BASE
|
-- @type ZONE_POLYGON_BASE
|
||||||
-- @field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}.
|
-- @field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}.
|
||||||
|
-- @field #number SurfaceArea
|
||||||
|
-- @field #table DrawID
|
||||||
|
-- @field #table FillTriangles
|
||||||
|
-- @field #table _Triangles
|
||||||
|
-- @field #table Borderlines
|
||||||
-- @extends #ZONE_BASE
|
-- @extends #ZONE_BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -2021,7 +2158,12 @@ end
|
|||||||
-- @field #ZONE_POLYGON_BASE
|
-- @field #ZONE_POLYGON_BASE
|
||||||
ZONE_POLYGON_BASE = {
|
ZONE_POLYGON_BASE = {
|
||||||
ClassName="ZONE_POLYGON_BASE",
|
ClassName="ZONE_POLYGON_BASE",
|
||||||
}
|
_Triangles={}, -- #table of #_ZONE_TRIANGLE
|
||||||
|
SurfaceArea=0,
|
||||||
|
DrawID={}, -- making a table out of the MarkID so its easier to draw an n-sided polygon, see ZONE_POLYGON_BASE:Draw()
|
||||||
|
FillTriangles = {},
|
||||||
|
Borderlines = {},
|
||||||
|
}
|
||||||
|
|
||||||
--- A 2D points array.
|
--- A 2D points array.
|
||||||
-- @type ZONE_POLYGON_BASE.ListVec2
|
-- @type ZONE_POLYGON_BASE.ListVec2
|
||||||
@@ -2053,11 +2195,104 @@ function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
|
|||||||
self._.Polygon[i].y = PointsArray[i].y
|
self._.Polygon[i].y = PointsArray[i].y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- triangulate the polygon so we can work with it
|
||||||
|
self._Triangles = self:_Triangulate()
|
||||||
|
-- set the polygon's surface area
|
||||||
|
self.SurfaceArea = self:_CalculateSurfaceArea()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Triangulates the polygon.
|
||||||
|
--- ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Polygon.lua
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @return #table The #_ZONE_TRIANGLE list that makes up the polygon
|
||||||
|
function ZONE_POLYGON_BASE:_Triangulate()
|
||||||
|
local points = self._.Polygon
|
||||||
|
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, _ZONE_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 = _ZONE_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
|
||||||
|
else
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
points = ensure_clockwise(points)
|
||||||
|
divide_recursively(points)
|
||||||
|
return triangles
|
||||||
|
end
|
||||||
|
|
||||||
--- Update polygon points with an array of @{DCS#Vec2}.
|
--- Update polygon points with an array of @{DCS#Vec2}.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @param #ZONE_POLYGON_BASE.ListVec2 Vec2Array An array of @{DCS#Vec2}, forming a polygon.
|
-- @param #ZONE_POLYGON_BASE.ListVec2 Vec2Array An array of @{DCS#Vec2}, forming a polygon.
|
||||||
@@ -2072,6 +2307,10 @@ function ZONE_POLYGON_BASE:UpdateFromVec2(Vec2Array)
|
|||||||
self._.Polygon[i].y=Vec2Array[i].y
|
self._.Polygon[i].y=Vec2Array[i].y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- triangulate the polygon so we can work with it
|
||||||
|
self._Triangles = self:_Triangulate()
|
||||||
|
-- set the polygon's surface area
|
||||||
|
self.SurfaceArea = self:_CalculateSurfaceArea()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2089,9 +2328,25 @@ function ZONE_POLYGON_BASE:UpdateFromVec3(Vec3Array)
|
|||||||
self._.Polygon[i].y=Vec3Array[i].z
|
self._.Polygon[i].y=Vec3Array[i].z
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- triangulate the polygon so we can work with it
|
||||||
|
self._Triangles = self:_Triangulate()
|
||||||
|
-- set the polygon's surface area
|
||||||
|
self.SurfaceArea = self:_CalculateSurfaceArea()
|
||||||
return self
|
return self
|
||||||
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.
|
||||||
|
--- ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Polygon.lua
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @return #number The surface area of the polygon
|
||||||
|
function ZONE_POLYGON_BASE:_CalculateSurfaceArea()
|
||||||
|
local area = 0
|
||||||
|
for _, triangle in pairs(self._Triangles) do
|
||||||
|
area = area + triangle.SurfaceArea
|
||||||
|
end
|
||||||
|
return area
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the center location of the polygon.
|
--- Returns the center location of the polygon.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
||||||
@@ -2233,63 +2488,133 @@ function ZONE_POLYGON_BASE:BoundZone( UnBound )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Draw the zone on the F10 map. **NOTE** Currently, only polygons **up to ten points** are supported!
|
--- Draw the zone on the F10 map. Infinite number of points supported
|
||||||
|
--- ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Polygon.lua
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
||||||
-- @param #number Alpha Transparency [0,1]. Default 1.
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value. -- doesn't seem to work
|
||||||
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15. -- doesn't seem to work
|
||||||
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.s
|
||||||
-- @return #ZONE_POLYGON_BASE self
|
-- @return #ZONE_POLYGON_BASE self
|
||||||
function ZONE_POLYGON_BASE:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
function ZONE_POLYGON_BASE:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, IncludeTriangles)
|
||||||
|
|
||||||
if self._.Polygon and #self._.Polygon>=3 then
|
|
||||||
|
|
||||||
local coordinate=COORDINATE:NewFromVec2(self._.Polygon[1])
|
if self._.Polygon and #self._.Polygon >= 3 then
|
||||||
|
Coalition = Coalition or self:GetDrawCoalition()
|
||||||
Coalition=Coalition or self:GetDrawCoalition()
|
|
||||||
|
|
||||||
-- Set draw coalition.
|
-- Set draw coalition.
|
||||||
self:SetDrawCoalition(Coalition)
|
self:SetDrawCoalition(Coalition)
|
||||||
|
|
||||||
Color=Color or self:GetColorRGB()
|
Color = Color or self:GetColorRGB()
|
||||||
Alpha=Alpha or 1
|
Alpha = Alpha or self:GetColorAlpha()
|
||||||
|
|
||||||
-- Set color.
|
FillColor = FillColor or self:GetFillColorRGB()
|
||||||
self:SetColor(Color, Alpha)
|
FillAlpha = FillAlpha or self:GetFillColorAlpha()
|
||||||
|
|
||||||
FillColor=FillColor or self:GetFillColorRGB()
|
|
||||||
if not FillColor then UTILS.DeepCopy(Color) end
|
|
||||||
FillAlpha=FillAlpha or self:GetFillColorAlpha()
|
|
||||||
if not FillAlpha then FillAlpha=0.15 end
|
|
||||||
|
|
||||||
-- Set fill color.
|
|
||||||
self:SetFillColor(FillColor, FillAlpha)
|
|
||||||
|
|
||||||
if #self._.Polygon==4 then
|
|
||||||
|
|
||||||
local Coord2=COORDINATE:NewFromVec2(self._.Polygon[2])
|
|
||||||
local Coord3=COORDINATE:NewFromVec2(self._.Polygon[3])
|
|
||||||
local Coord4=COORDINATE:NewFromVec2(self._.Polygon[4])
|
|
||||||
|
|
||||||
self.DrawID=coordinate:QuadToAll(Coord2, Coord3, Coord4, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
local Coordinates=self:GetVerticiesCoordinates()
|
|
||||||
table.remove(Coordinates, 1)
|
|
||||||
|
|
||||||
self.DrawID=coordinate:MarkupToAllFreeForm(Coordinates, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
|
||||||
|
|
||||||
|
if FillColor then
|
||||||
|
self:ReFill(FillColor,FillAlpha)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Color then
|
||||||
|
self:ReDrawBorderline(Color,Alpha,LineType)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if false then
|
||||||
|
local coords = self:GetVerticiesCoordinates()
|
||||||
|
|
||||||
|
local coord=coords[1] --Core.Point#COORDINATE
|
||||||
|
|
||||||
|
table.remove(coords, 1)
|
||||||
|
|
||||||
|
coord:MarkupToAllFreeForm(coords, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, "Drew Polygon")
|
||||||
|
|
||||||
|
if true then
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Change/Re-fill a Polygon Zone
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @return #ZONE_POLYGON_BASE self
|
||||||
|
function ZONE_POLYGON_BASE:ReFill(Color,Alpha)
|
||||||
|
local color = Color or self:GetFillColorRGB() or {1,0,0}
|
||||||
|
local alpha = Alpha or self:GetFillColorAlpha() or 1
|
||||||
|
local coalition = self:GetDrawCoalition() or -1
|
||||||
|
-- undraw if already filled
|
||||||
|
if #self.FillTriangles > 0 then
|
||||||
|
for _, triangle in pairs(self._Triangles) do
|
||||||
|
triangle:UndrawZone()
|
||||||
|
end
|
||||||
|
-- remove mark IDs
|
||||||
|
for _,_value in pairs(self.FillTriangles) do
|
||||||
|
table.remove_by_value(self.DrawID, _value)
|
||||||
|
end
|
||||||
|
self.FillTriangles = nil
|
||||||
|
self.FillTriangles = {}
|
||||||
|
end
|
||||||
|
-- refill
|
||||||
|
for _, triangle in pairs(self._Triangles) do
|
||||||
|
local draw_ids = triangle:Fill(coalition,color,alpha,nil)
|
||||||
|
self.FillTriangles = draw_ids
|
||||||
|
table.combine(self.DrawID, draw_ids)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Change/Re-draw the border of a Polygon Zone
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
|
-- @return #ZONE_POLYGON_BASE
|
||||||
|
function ZONE_POLYGON_BASE:ReDrawBorderline(Color, Alpha, LineType)
|
||||||
|
local color = Color or self:GetFillColorRGB() or {1,0,0}
|
||||||
|
local alpha = Alpha or self:GetFillColorAlpha() or 1
|
||||||
|
local coalition = self:GetDrawCoalition() or -1
|
||||||
|
local linetype = LineType or 1
|
||||||
|
-- undraw if already drawn
|
||||||
|
if #self.Borderlines > 0 then
|
||||||
|
for _, MarkID in pairs(self.Borderlines) do
|
||||||
|
trigger.action.removeMark(MarkID)
|
||||||
|
end
|
||||||
|
-- remove mark IDs
|
||||||
|
for _,_value in pairs(self.Borderlines) do
|
||||||
|
table.remove_by_value(self.DrawID, _value)
|
||||||
|
end
|
||||||
|
self.Borderlines = nil
|
||||||
|
self.Borderlines = {}
|
||||||
|
end
|
||||||
|
-- Redraw border
|
||||||
|
local coords = self:GetVerticiesCoordinates()
|
||||||
|
for i = 1, #coords do
|
||||||
|
local c1 = coords[i]
|
||||||
|
local c2 = coords[i % #coords + 1]
|
||||||
|
local newID = c1:LineToAll(c2, coalition, color, alpha, linetype, nil)
|
||||||
|
self.DrawID[#self.DrawID+1]=newID
|
||||||
|
self.Borderlines[#self.Borderlines+1] = newID
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the surface area of this polygon
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @return #number Surface area
|
||||||
|
function ZONE_POLYGON_BASE:GetSurfaceArea()
|
||||||
|
return self.SurfaceArea
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Get the smallest radius encompassing all points of the polygon zone.
|
--- Get the smallest radius encompassing all points of the polygon zone.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return #number Radius of the zone in meters.
|
-- @return #number Radius of the zone in meters.
|
||||||
@@ -2488,34 +2813,28 @@ function ZONE_POLYGON_BASE:IsVec3InZone( Vec3 )
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Define a random @{DCS#Vec2} within the zone.
|
--- Define a random @{DCS#Vec2} within the zone.
|
||||||
|
--- ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Polygon.lua
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return DCS#Vec2 The Vec2 coordinate.
|
-- @return DCS#Vec2 The Vec2 coordinate.
|
||||||
function ZONE_POLYGON_BASE:GetRandomVec2()
|
function ZONE_POLYGON_BASE:GetRandomVec2()
|
||||||
|
-- make sure we assign weights to the triangles based on their surface area, otherwise
|
||||||
-- It is a bit tricky to find a random point within a polygon. Right now i am doing it the dirty and inefficient way...
|
-- we'll be more likely to generate random points in smaller triangles
|
||||||
|
local weights = {}
|
||||||
-- Get the bounding square.
|
for _, triangle in pairs(self._Triangles) do
|
||||||
local BS = self:GetBoundingSquare()
|
weights[triangle] = triangle.SurfaceArea / self.SurfaceArea
|
||||||
|
|
||||||
local Nmax=1000 ; local n=0
|
|
||||||
while n<Nmax do
|
|
||||||
|
|
||||||
-- Random point in the bounding square.
|
|
||||||
local Vec2={x=math.random(BS.x1, BS.x2), y=math.random(BS.y1, BS.y2)}
|
|
||||||
|
|
||||||
-- Check if this is in the polygon.
|
|
||||||
if self:IsVec2InZone(Vec2) then
|
|
||||||
return Vec2
|
|
||||||
end
|
end
|
||||||
|
|
||||||
n=n+1
|
local random_weight = math.random()
|
||||||
end
|
local accumulated_weight = 0
|
||||||
|
for triangle, weight in pairs(weights) do
|
||||||
self:E("Could not find a random point in the polygon zone!")
|
accumulated_weight = accumulated_weight + weight
|
||||||
return nil
|
if accumulated_weight >= random_weight then
|
||||||
|
return triangle:GetRandomVec2()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return a @{Core.Point#POINT_VEC2} object representing a random 2D point at landheight within the zone.
|
--- Return a @{Core.Point#POINT_VEC2} object representing a random 2D point at landheight within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec2 table.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return @{Core.Point#POINT_VEC2}
|
-- @return @{Core.Point#POINT_VEC2}
|
||||||
function ZONE_POLYGON_BASE:GetRandomPointVec2()
|
function ZONE_POLYGON_BASE:GetRandomPointVec2()
|
||||||
@@ -2528,7 +2847,7 @@ function ZONE_POLYGON_BASE:GetRandomPointVec2()
|
|||||||
return PointVec2
|
return PointVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return a @{Core.Point#POINT_VEC3} object representing a random 3D point at landheight within the zone.
|
--- Return a @{Core.Point#POINT_VEC3} object representing a random 3D point at landheight within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec3 table.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return @{Core.Point#POINT_VEC3}
|
-- @return @{Core.Point#POINT_VEC3}
|
||||||
function ZONE_POLYGON_BASE:GetRandomPointVec3()
|
function ZONE_POLYGON_BASE:GetRandomPointVec3()
|
||||||
@@ -2620,6 +2939,7 @@ function ZONE_POLYGON_BASE:Boundary(Coalition, Color, Radius, Alpha, Segments, C
|
|||||||
Alpha = Alpha or 1
|
Alpha = Alpha or 1
|
||||||
Segments = Segments or 10
|
Segments = Segments or 10
|
||||||
Closed = Closed or false
|
Closed = Closed or false
|
||||||
|
local Limit
|
||||||
local i = 1
|
local i = 1
|
||||||
local j = #self._.Polygon
|
local j = #self._.Polygon
|
||||||
if (Closed) then
|
if (Closed) then
|
||||||
@@ -2644,12 +2964,17 @@ function ZONE_POLYGON_BASE:Boundary(Coalition, Color, Radius, Alpha, Segments, C
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do -- Zone_Polygon
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @type ZONE_POLYGON
|
-- @type ZONE_POLYGON
|
||||||
-- @extends #ZONE_POLYGON_BASE
|
-- @extends #ZONE_POLYGON_BASE
|
||||||
|
-- @extends #ZONE_BASE
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_POLYGON class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
--- The ZONE_POLYGON class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon, OR by drawings made with the Draw tool
|
||||||
|
--- in the Mission Editor
|
||||||
-- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
-- ## Declare a ZONE_POLYGON directly in the DCS mission editor!
|
-- ## Declare a ZONE_POLYGON directly in the DCS mission editor!
|
||||||
@@ -2672,6 +2997,12 @@ end
|
|||||||
-- then SetZone would contain the ZONE_POLYGON object `DefenseZone` as part of the zone collection,
|
-- then SetZone would contain the ZONE_POLYGON object `DefenseZone` as part of the zone collection,
|
||||||
-- without much scripting overhead!
|
-- without much scripting overhead!
|
||||||
--
|
--
|
||||||
|
-- This class now also supports drawings made with the Draw tool in the Mission Editor. Any drawing made with Line > Segments > Closed, Polygon > Rect or Polygon > Free can be
|
||||||
|
-- made into a ZONE_POLYGON.
|
||||||
|
--
|
||||||
|
-- This class has been updated to use a accurate way of generating random points inside the polygon without having to use trial and error guesses.
|
||||||
|
-- You can also get the surface area of the polygon now, handy if you want measure which coalition has the largest captured area, for example.
|
||||||
|
--
|
||||||
-- @field #ZONE_POLYGON
|
-- @field #ZONE_POLYGON
|
||||||
ZONE_POLYGON = {
|
ZONE_POLYGON = {
|
||||||
ClassName="ZONE_POLYGON",
|
ClassName="ZONE_POLYGON",
|
||||||
@@ -2732,6 +3063,66 @@ function ZONE_POLYGON:NewFromGroupName( GroupName )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Constructor to create a ZONE_POLYGON instance, taking the name of a drawing made with the draw tool in the Mission Editor.
|
||||||
|
-- @param #ZONE_POLYGON self
|
||||||
|
-- @param #string DrawingName The name of the drawing in the Mission Editor
|
||||||
|
-- @return #ZONE_POLYGON self
|
||||||
|
function ZONE_POLYGON:NewFromDrawing(DrawingName)
|
||||||
|
local points = {}
|
||||||
|
for _, layer in pairs(env.mission.drawings.layers) do
|
||||||
|
for _, object in pairs(layer["objects"]) do
|
||||||
|
if object["name"] == DrawingName then
|
||||||
|
if (object["primitiveType"] == "Line" and object["closed"] == true) or (object["polygonMode"] == "free") then
|
||||||
|
-- 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
|
||||||
|
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"],
|
||||||
|
y = object["mapY"] + point["y"] }
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
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
|
||||||
|
-- we need to rotate the points around the center of the rects by an angle. UTILS.RotatePointAroundPivot was
|
||||||
|
-- committed in an earlier commit
|
||||||
|
local angle = object["angle"]
|
||||||
|
local half_width = object["width"] / 2
|
||||||
|
local half_height = object["height"] / 2
|
||||||
|
|
||||||
|
local center = { x = object["mapX"], y = object["mapY"] }
|
||||||
|
local p1 = UTILS.RotatePointAroundPivot({ x = center.x - half_height, y = center.y + half_width }, center, angle)
|
||||||
|
local p2 = UTILS.RotatePointAroundPivot({ x = center.x + half_height, y = center.y + half_width }, center, angle)
|
||||||
|
local p3 = UTILS.RotatePointAroundPivot({ x = center.x + half_height, y = center.y - half_width }, center, angle)
|
||||||
|
local p4 = UTILS.RotatePointAroundPivot({ x = center.x - half_height, y = center.y - half_width }, center, angle)
|
||||||
|
|
||||||
|
points = {p1, p2, p3, p4}
|
||||||
|
else
|
||||||
|
-- bring the Arrow code over from Shape/Polygon
|
||||||
|
-- something else that might be added in the future
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local self = BASE:Inherit(self, ZONE_POLYGON_BASE:New(DrawingName, points))
|
||||||
|
_EVENTDISPATCHER:CreateEventNewZone(self)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Find a polygon zone in the _DATABASE using the name of the polygon zone.
|
--- Find a polygon zone in the _DATABASE using the name of the polygon zone.
|
||||||
-- @param #ZONE_POLYGON self
|
-- @param #ZONE_POLYGON self
|
||||||
@@ -3093,9 +3484,11 @@ function ZONE_POLYGON:IsNoneInZone()
|
|||||||
return self:CountScannedCoalitions() == 0
|
return self:CountScannedCoalitions() == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
do -- ZONE_ELASTIC
|
do -- ZONE_ELASTIC
|
||||||
|
|
||||||
|
---
|
||||||
-- @type ZONE_ELASTIC
|
-- @type ZONE_ELASTIC
|
||||||
-- @field #table points Points in 2D.
|
-- @field #table points Points in 2D.
|
||||||
-- @field #table setGroups Set of GROUPs.
|
-- @field #table setGroups Set of GROUPs.
|
||||||
@@ -3294,8 +3687,242 @@ do -- ZONE_ELASTIC
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- ZONE_OVAL created from a center point, major axis, minor axis, and angle.
|
||||||
|
-- Ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Oval.lua
|
||||||
|
-- @type ZONE_OVAL
|
||||||
|
-- @extends Core.Zone#ZONE_BASE
|
||||||
|
|
||||||
|
--- ## ZONE_OVAL class, extends @{#ZONE_BASE}
|
||||||
|
--
|
||||||
|
-- The ZONE_OVAL class is defined by a center point, major axis, minor axis, and angle.
|
||||||
|
-- This class implements the inherited functions from @{#ZONE_BASE} taking into account the own zone format and properties.
|
||||||
|
--
|
||||||
|
-- @field #ZONE_OVAL
|
||||||
|
ZONE_OVAL = {
|
||||||
|
ClassName = "OVAL",
|
||||||
|
ZoneName="",
|
||||||
|
MajorAxis = nil,
|
||||||
|
MinorAxis = nil,
|
||||||
|
Angle = 0,
|
||||||
|
DrawPoly = nil -- let's just use a ZONE_POLYGON to draw the ZONE_OVAL on the map
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Creates a new ZONE_OVAL from a center point, major axis, minor axis, and angle.
|
||||||
|
--- ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Oval.lua
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @param #string name Name of the zone.
|
||||||
|
-- @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 #ZONE_OVAL The new oval
|
||||||
|
function ZONE_OVAL:New(name, vec2, major_axis, minor_axis, angle)
|
||||||
|
|
||||||
|
self = BASE:Inherit(self, ZONE_BASE:New())
|
||||||
|
|
||||||
|
self.ZoneName = name
|
||||||
|
self.CenterVec2 = vec2
|
||||||
|
self.MajorAxis = major_axis
|
||||||
|
self.MinorAxis = minor_axis
|
||||||
|
self.Angle = angle or 0
|
||||||
|
|
||||||
|
_DATABASE:AddZone(name, self)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Constructor to create a ZONE_OVAL instance, taking the name of a drawing made with the draw tool in the Mission Editor.
|
||||||
|
--- ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Oval.lua
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @param #string DrawingName The name of the drawing in the Mission Editor
|
||||||
|
-- @return #ZONE_OVAL self
|
||||||
|
function ZONE_OVAL:NewFromDrawing(DrawingName)
|
||||||
|
self = BASE:Inherit(self, ZONE_BASE:New(DrawingName))
|
||||||
|
for _, layer in pairs(env.mission.drawings.layers) do
|
||||||
|
for _, object in pairs(layer["objects"]) do
|
||||||
|
if string.find(object["name"], DrawingName, 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
|
||||||
|
|
||||||
|
_DATABASE:AddZone(DrawingName, self)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the major axis of the oval.
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @return #number The major axis of the oval
|
||||||
|
function ZONE_OVAL:GetMajorAxis()
|
||||||
|
return self.MajorAxis
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the minor axis of the oval.
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @return #number The minor axis of the oval
|
||||||
|
function ZONE_OVAL:GetMinorAxis()
|
||||||
|
return self.MinorAxis
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Gets the angle of the oval.
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @return #number The angle of the oval
|
||||||
|
function ZONE_OVAL:GetAngle()
|
||||||
|
return self.Angle
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns a the center point of the oval
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @return #table The center Vec2
|
||||||
|
function ZONE_OVAL:GetVec2()
|
||||||
|
return self.CenterVec2
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a point is contained within the oval.
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @param #table point The point to check
|
||||||
|
-- @return #bool True if the point is contained, false otherwise
|
||||||
|
function ZONE_OVAL:IsVec2InZone(vec2)
|
||||||
|
local cos, sin = math.cos, math.sin
|
||||||
|
local dx = vec2.x - self.CenterVec2.x
|
||||||
|
local dy = vec2.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
|
||||||
|
|
||||||
|
--- Calculates the bounding box of the oval. The bounding box is the smallest rectangle that contains the oval.
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @return #table The bounding box of the oval
|
||||||
|
function ZONE_OVAL:GetBoundingSquare()
|
||||||
|
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
|
||||||
|
|
||||||
|
--- Find points on the edge of the oval
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @param #number num_points How many points should be found. More = smoother shape
|
||||||
|
-- @return #table Points on he edge
|
||||||
|
function ZONE_OVAL:PointsOnEdge(num_points)
|
||||||
|
num_points = num_points or 40
|
||||||
|
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
|
||||||
|
|
||||||
|
--- Returns a random Vec2 within the oval.
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @return #table The random Vec2
|
||||||
|
function ZONE_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
|
||||||
|
|
||||||
|
--- Define a random @{Core.Point#POINT_VEC2} within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec2 table.
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @return Core.Point#POINT_VEC2 The PointVec2 coordinates.
|
||||||
|
function ZONE_OVAL:GetRandomPointVec2()
|
||||||
|
return POINT_VEC2:NewFromVec2(self:GetRandomVec2())
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Define a random @{Core.Point#POINT_VEC2} within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec3 table.
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @return Core.Point#POINT_VEC2 The PointVec2 coordinates.
|
||||||
|
function ZONE_OVAL:GetRandomPointVec3()
|
||||||
|
return POINT_VEC3:NewFromVec3(self:GetRandomVec2())
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Draw the zone on the F10 map.
|
||||||
|
--- ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Oval.lua
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value. -- doesn't seem to work
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15. -- doesn't seem to work
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
|
-- @return #ZONE_OVAL self
|
||||||
|
function ZONE_OVAL:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType)
|
||||||
|
Coalition = Coalition or self:GetDrawCoalition()
|
||||||
|
|
||||||
|
-- Set draw coalition.
|
||||||
|
self:SetDrawCoalition(Coalition)
|
||||||
|
|
||||||
|
Color = Color or self:GetColorRGB()
|
||||||
|
Alpha = Alpha or 1
|
||||||
|
|
||||||
|
-- Set color.
|
||||||
|
self:SetColor(Color, Alpha)
|
||||||
|
|
||||||
|
FillColor = FillColor or self:GetFillColorRGB()
|
||||||
|
if not FillColor then
|
||||||
|
UTILS.DeepCopy(Color)
|
||||||
|
end
|
||||||
|
FillAlpha = FillAlpha or self:GetFillColorAlpha()
|
||||||
|
if not FillAlpha then
|
||||||
|
FillAlpha = 0.15
|
||||||
|
end
|
||||||
|
|
||||||
|
LineType = LineType or 1
|
||||||
|
|
||||||
|
-- Set fill color -----------> has fill color worked in recent versions of DCS?
|
||||||
|
-- doing something like
|
||||||
|
--
|
||||||
|
-- trigger.action.markupToAll(7, -1, 501, p.Coords[1]:GetVec3(), p.Coords[2]:GetVec3(),p.Coords[3]:GetVec3(),p.Coords[4]:GetVec3(),{1,0,0, 1}, {1,0,0, 1}, 4, false, Text or "")
|
||||||
|
--
|
||||||
|
-- doesn't seem to fill in the shape for an n-sided polygon
|
||||||
|
self:SetFillColor(FillColor, FillAlpha)
|
||||||
|
|
||||||
|
self.DrawPoly = ZONE_POLYGON:NewFromPointsArray(self.ZoneName, self:PointsOnEdge(80))
|
||||||
|
self.DrawPoly:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove drawing from F10 map
|
||||||
|
-- @param #ZONE_OVAL self
|
||||||
|
function ZONE_OVAL:UndrawZone()
|
||||||
|
if self.DrawPoly then
|
||||||
|
self.DrawPoly:UndrawZone()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
do -- ZONE_AIRBASE
|
do -- ZONE_AIRBASE
|
||||||
|
|
||||||
|
---
|
||||||
-- @type ZONE_AIRBASE
|
-- @type ZONE_AIRBASE
|
||||||
-- @field #boolean isShip If `true`, airbase is a ship.
|
-- @field #boolean isShip If `true`, airbase is a ship.
|
||||||
-- @field #boolean isHelipad If `true`, airbase is a helipad.
|
-- @field #boolean isHelipad If `true`, airbase is a helipad.
|
||||||
@@ -3376,7 +4003,7 @@ do -- ZONE_AIRBASE
|
|||||||
return ZoneVec2
|
return ZoneVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone. Note that this is actually a @{Core.Point#COORDINATE} type object, and not a simple Vec2 table.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions: None
|
||||||
--
|
|
||||||
-- [ABP - Airbase Police](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ABP%20-%20Airbase%20Police)
|
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -20,13 +18,15 @@
|
|||||||
-- ### Author: FlightControl - Framework Design & Programming
|
-- ### Author: FlightControl - Framework Design & Programming
|
||||||
-- ### Refactoring to use the Runway auto-detection: Applevangelist
|
-- ### Refactoring to use the Runway auto-detection: Applevangelist
|
||||||
-- @date August 2022
|
-- @date August 2022
|
||||||
|
-- Last Update Nov 2023
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module Functional.ATC_Ground
|
-- @module Functional.ATC_Ground
|
||||||
-- @image Air_Traffic_Control_Ground_Operations.JPG
|
-- @image Air_Traffic_Control_Ground_Operations.JPG
|
||||||
|
|
||||||
--- @type ATC_GROUND
|
---
|
||||||
|
-- @type ATC_GROUND
|
||||||
-- @field Core.Set#SET_CLIENT SetClient
|
-- @field Core.Set#SET_CLIENT SetClient
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
@@ -39,7 +39,8 @@ ATC_GROUND = {
|
|||||||
AirbaseNames = nil,
|
AirbaseNames = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @type ATC_GROUND.AirbaseNames
|
---
|
||||||
|
-- @type ATC_GROUND.AirbaseNames
|
||||||
-- @list <#string>
|
-- @list <#string>
|
||||||
|
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ function ATC_GROUND:New( Airbases, AirbaseList )
|
|||||||
|
|
||||||
-- Inherits from BASE
|
-- Inherits from BASE
|
||||||
local self = BASE:Inherit( self, BASE:New() ) -- #ATC_GROUND
|
local self = BASE:Inherit( self, BASE:New() ) -- #ATC_GROUND
|
||||||
self:E( { self.ClassName, Airbases } )
|
self:T( { self.ClassName, Airbases } )
|
||||||
|
|
||||||
self.Airbases = Airbases
|
self.Airbases = Airbases
|
||||||
self.AirbaseList = AirbaseList
|
self.AirbaseList = AirbaseList
|
||||||
@@ -82,7 +83,7 @@ function ATC_GROUND:New( Airbases, AirbaseList )
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.SetClient:ForEachClient(
|
self.SetClient:ForEachClient(
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
function( Client )
|
function( Client )
|
||||||
Client:SetState( self, "Speeding", false )
|
Client:SetState( self, "Speeding", false )
|
||||||
Client:SetState( self, "Warnings", 0)
|
Client:SetState( self, "Warnings", 0)
|
||||||
@@ -246,11 +247,11 @@ function ATC_GROUND:SetMaximumKickSpeedMiph( MaximumKickSpeedMiph, Airbase )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #ATC_GROUND self
|
-- @param #ATC_GROUND self
|
||||||
function ATC_GROUND:_AirbaseMonitor()
|
function ATC_GROUND:_AirbaseMonitor()
|
||||||
|
|
||||||
self.SetClient:ForEachClient(
|
self.SetClient:ForEachClient(
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
function( Client )
|
function( Client )
|
||||||
|
|
||||||
if Client:IsAlive() then
|
if Client:IsAlive() then
|
||||||
@@ -258,7 +259,7 @@ function ATC_GROUND:_AirbaseMonitor()
|
|||||||
local IsOnGround = Client:InAir() == false
|
local IsOnGround = Client:InAir() == false
|
||||||
|
|
||||||
for AirbaseID, AirbaseMeta in pairs( self.Airbases ) do
|
for AirbaseID, AirbaseMeta in pairs( self.Airbases ) do
|
||||||
self:E( AirbaseID, AirbaseMeta.KickSpeed )
|
self:T( AirbaseID, AirbaseMeta.KickSpeed )
|
||||||
|
|
||||||
if AirbaseMeta.Monitor == true and Client:IsInZone( AirbaseMeta.ZoneBoundary ) then
|
if AirbaseMeta.Monitor == true and Client:IsInZone( AirbaseMeta.ZoneBoundary ) then
|
||||||
|
|
||||||
@@ -271,7 +272,7 @@ function ATC_GROUND:_AirbaseMonitor()
|
|||||||
|
|
||||||
if IsOnGround then
|
if IsOnGround then
|
||||||
local Taxi = Client:GetState( self, "Taxi" )
|
local Taxi = Client:GetState( self, "Taxi" )
|
||||||
self:E( Taxi )
|
self:T( Taxi )
|
||||||
if Taxi == false then
|
if Taxi == false then
|
||||||
local Velocity = VELOCITY:New( AirbaseMeta.KickSpeed or self.KickSpeed )
|
local Velocity = VELOCITY:New( AirbaseMeta.KickSpeed or self.KickSpeed )
|
||||||
Client:Message( "Welcome to " .. AirbaseID .. ". The maximum taxiing speed is " ..
|
Client:Message( "Welcome to " .. AirbaseID .. ". The maximum taxiing speed is " ..
|
||||||
@@ -331,7 +332,7 @@ function ATC_GROUND:_AirbaseMonitor()
|
|||||||
Client:SetState( self, "Warnings", SpeedingWarnings + 1 )
|
Client:SetState( self, "Warnings", SpeedingWarnings + 1 )
|
||||||
else
|
else
|
||||||
MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " has been kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll()
|
MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " has been kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll()
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
Client:Destroy()
|
Client:Destroy()
|
||||||
Client:SetState( self, "Speeding", false )
|
Client:SetState( self, "Speeding", false )
|
||||||
Client:SetState( self, "Warnings", 0 )
|
Client:SetState( self, "Warnings", 0 )
|
||||||
@@ -363,7 +364,7 @@ function ATC_GROUND:_AirbaseMonitor()
|
|||||||
Client:SetState( self, "OffRunwayWarnings", OffRunwayWarnings + 1 )
|
Client:SetState( self, "OffRunwayWarnings", OffRunwayWarnings + 1 )
|
||||||
else
|
else
|
||||||
MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " has been kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll()
|
MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " has been kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll()
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
Client:Destroy()
|
Client:Destroy()
|
||||||
Client:SetState( self, "IsOffRunway", false )
|
Client:SetState( self, "IsOffRunway", false )
|
||||||
Client:SetState( self, "OffRunwayWarnings", 0 )
|
Client:SetState( self, "OffRunwayWarnings", 0 )
|
||||||
@@ -424,13 +425,20 @@ ATC_GROUND_UNIVERSAL = {
|
|||||||
|
|
||||||
--- Creates a new ATC\_GROUND\_UNIVERSAL object. This works on any map.
|
--- Creates a new ATC\_GROUND\_UNIVERSAL object. This works on any map.
|
||||||
-- @param #ATC_GROUND_UNIVERSAL self
|
-- @param #ATC_GROUND_UNIVERSAL self
|
||||||
-- @param AirbaseList (Optional) A table of Airbase Names.
|
-- @param AirbaseList A table of Airbase Names. Leave empty to cover **all** airbases of the map.
|
||||||
-- @return #ATC_GROUND_UNIVERSAL self
|
-- @return #ATC_GROUND_UNIVERSAL self
|
||||||
|
-- @usage
|
||||||
|
-- -- define monitoring for one airbase
|
||||||
|
-- local atc=ATC_GROUND_UNIVERSAL:New({AIRBASE.Syria.Gecitkale})
|
||||||
|
-- -- set kick speed
|
||||||
|
-- atc:SetKickSpeed(UTILS.KnotsToMps(20))
|
||||||
|
-- -- start monitoring evey 10 secs
|
||||||
|
-- atc:Start(10)
|
||||||
function ATC_GROUND_UNIVERSAL:New(AirbaseList)
|
function ATC_GROUND_UNIVERSAL:New(AirbaseList)
|
||||||
|
|
||||||
-- Inherits from BASE
|
-- Inherits from BASE
|
||||||
local self = BASE:Inherit( self, BASE:New() ) -- #ATC_GROUND
|
local self = BASE:Inherit( self, BASE:New() ) -- #ATC_GROUND
|
||||||
self:E( { self.ClassName } )
|
self:T( { self.ClassName } )
|
||||||
|
|
||||||
self.Airbases = {}
|
self.Airbases = {}
|
||||||
|
|
||||||
@@ -440,6 +448,13 @@ function ATC_GROUND_UNIVERSAL:New(AirbaseList)
|
|||||||
|
|
||||||
self.AirbaseList = AirbaseList
|
self.AirbaseList = AirbaseList
|
||||||
|
|
||||||
|
if not self.AirbaseList then
|
||||||
|
self.AirbaseList = {}
|
||||||
|
for _name,_ in pairs(_DATABASE.AIRBASES) do
|
||||||
|
self.AirbaseList[_name]=_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.SetClient = SET_CLIENT:New():FilterCategories( "plane" ):FilterStart()
|
self.SetClient = SET_CLIENT:New():FilterCategories( "plane" ):FilterStart()
|
||||||
|
|
||||||
|
|
||||||
@@ -460,8 +475,9 @@ function ATC_GROUND_UNIVERSAL:New(AirbaseList)
|
|||||||
self.Airbases[AirbaseName].Monitor = true
|
self.Airbases[AirbaseName].Monitor = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self.SetClient:ForEachClient(
|
self.SetClient:ForEachClient(
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
function( Client )
|
function( Client )
|
||||||
Client:SetState( self, "Speeding", false )
|
Client:SetState( self, "Speeding", false )
|
||||||
Client:SetState( self, "Warnings", 0)
|
Client:SetState( self, "Warnings", 0)
|
||||||
@@ -679,9 +695,10 @@ end
|
|||||||
-- @param #ATC_GROUND_UNIVERSAL self
|
-- @param #ATC_GROUND_UNIVERSAL self
|
||||||
-- @return #ATC_GROUND_UNIVERSAL self
|
-- @return #ATC_GROUND_UNIVERSAL self
|
||||||
function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
||||||
|
self:I("_AirbaseMonitor")
|
||||||
self.SetClient:ForEachClient(
|
self.SetClient:ForEachClient(
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
--- Nameless function
|
||||||
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
function( Client )
|
function( Client )
|
||||||
|
|
||||||
if Client:IsAlive() then
|
if Client:IsAlive() then
|
||||||
@@ -689,7 +706,7 @@ function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
|||||||
local IsOnGround = Client:InAir() == false
|
local IsOnGround = Client:InAir() == false
|
||||||
|
|
||||||
for AirbaseID, AirbaseMeta in pairs( self.Airbases ) do
|
for AirbaseID, AirbaseMeta in pairs( self.Airbases ) do
|
||||||
self:E( AirbaseID, AirbaseMeta.KickSpeed )
|
self:T( AirbaseID, AirbaseMeta.KickSpeed )
|
||||||
|
|
||||||
if AirbaseMeta.Monitor == true and Client:IsInZone( AirbaseMeta.ZoneBoundary ) then
|
if AirbaseMeta.Monitor == true and Client:IsInZone( AirbaseMeta.ZoneBoundary ) then
|
||||||
|
|
||||||
@@ -706,7 +723,7 @@ function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
|||||||
|
|
||||||
if IsOnGround then
|
if IsOnGround then
|
||||||
local Taxi = Client:GetState( self, "Taxi" )
|
local Taxi = Client:GetState( self, "Taxi" )
|
||||||
self:E( Taxi )
|
self:T( Taxi )
|
||||||
if Taxi == false then
|
if Taxi == false then
|
||||||
local Velocity = VELOCITY:New( AirbaseMeta.KickSpeed or self.KickSpeed )
|
local Velocity = VELOCITY:New( AirbaseMeta.KickSpeed or self.KickSpeed )
|
||||||
Client:Message( "Welcome to " .. AirbaseID .. ". The maximum taxiing speed is " ..
|
Client:Message( "Welcome to " .. AirbaseID .. ". The maximum taxiing speed is " ..
|
||||||
@@ -766,7 +783,7 @@ function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
|||||||
Client:SetState( self, "Warnings", SpeedingWarnings + 1 )
|
Client:SetState( self, "Warnings", SpeedingWarnings + 1 )
|
||||||
else
|
else
|
||||||
MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " has been kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll()
|
MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " has been kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll()
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
Client:Destroy()
|
Client:Destroy()
|
||||||
Client:SetState( self, "Speeding", false )
|
Client:SetState( self, "Speeding", false )
|
||||||
Client:SetState( self, "Warnings", 0 )
|
Client:SetState( self, "Warnings", 0 )
|
||||||
@@ -798,7 +815,7 @@ function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
|||||||
Client:SetState( self, "OffRunwayWarnings", OffRunwayWarnings + 1 )
|
Client:SetState( self, "OffRunwayWarnings", OffRunwayWarnings + 1 )
|
||||||
else
|
else
|
||||||
MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " has been kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll()
|
MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " has been kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll()
|
||||||
--- @param Wrapper.Client#CLIENT Client
|
-- @param Wrapper.Client#CLIENT Client
|
||||||
Client:Destroy()
|
Client:Destroy()
|
||||||
Client:SetState( self, "IsOffRunway", false )
|
Client:SetState( self, "IsOffRunway", false )
|
||||||
Client:SetState( self, "OffRunwayWarnings", 0 )
|
Client:SetState( self, "OffRunwayWarnings", 0 )
|
||||||
@@ -838,15 +855,16 @@ end
|
|||||||
|
|
||||||
--- Start SCHEDULER for ATC_GROUND_UNIVERSAL object.
|
--- Start SCHEDULER for ATC_GROUND_UNIVERSAL object.
|
||||||
-- @param #ATC_GROUND_UNIVERSAL self
|
-- @param #ATC_GROUND_UNIVERSAL self
|
||||||
-- @param RepeatScanSeconds Time in second for defining occurency of alerts.
|
-- @param RepeatScanSeconds Time in second for defining schedule of alerts.
|
||||||
-- @return #ATC_GROUND_UNIVERSAL self
|
-- @return #ATC_GROUND_UNIVERSAL self
|
||||||
function ATC_GROUND_UNIVERSAL:Start( RepeatScanSeconds )
|
function ATC_GROUND_UNIVERSAL:Start( RepeatScanSeconds )
|
||||||
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
||||||
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, 2, RepeatScanSeconds )
|
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, RepeatScanSeconds )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @type ATC_GROUND_CAUCASUS
|
---
|
||||||
|
-- @type ATC_GROUND_CAUCASUS
|
||||||
-- @extends #ATC_GROUND
|
-- @extends #ATC_GROUND
|
||||||
|
|
||||||
--- # ATC\_GROUND\_CAUCASUS, extends @{#ATC_GROUND_UNIVERSAL}
|
--- # ATC\_GROUND\_CAUCASUS, extends @{#ATC_GROUND_UNIVERSAL}
|
||||||
@@ -981,12 +999,12 @@ end
|
|||||||
-- @return nothing
|
-- @return nothing
|
||||||
function ATC_GROUND_CAUCASUS:Start( RepeatScanSeconds )
|
function ATC_GROUND_CAUCASUS:Start( RepeatScanSeconds )
|
||||||
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
||||||
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, 2, RepeatScanSeconds )
|
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, RepeatScanSeconds )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
--- @type ATC_GROUND_NEVADA
|
-- @type ATC_GROUND_NEVADA
|
||||||
-- @extends #ATC_GROUND
|
-- @extends #ATC_GROUND
|
||||||
|
|
||||||
|
|
||||||
@@ -1120,11 +1138,11 @@ end
|
|||||||
-- @return nothing
|
-- @return nothing
|
||||||
function ATC_GROUND_NEVADA:Start( RepeatScanSeconds )
|
function ATC_GROUND_NEVADA:Start( RepeatScanSeconds )
|
||||||
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
||||||
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, 2, RepeatScanSeconds )
|
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, RepeatScanSeconds )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---
|
||||||
--- @type ATC_GROUND_NORMANDY
|
-- @type ATC_GROUND_NORMANDY
|
||||||
-- @extends #ATC_GROUND
|
-- @extends #ATC_GROUND
|
||||||
|
|
||||||
|
|
||||||
@@ -1277,10 +1295,11 @@ end
|
|||||||
-- @return nothing
|
-- @return nothing
|
||||||
function ATC_GROUND_NORMANDY:Start( RepeatScanSeconds )
|
function ATC_GROUND_NORMANDY:Start( RepeatScanSeconds )
|
||||||
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
||||||
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, 2, RepeatScanSeconds )
|
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, RepeatScanSeconds )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @type ATC_GROUND_PERSIANGULF
|
---
|
||||||
|
-- @type ATC_GROUND_PERSIANGULF
|
||||||
-- @extends #ATC_GROUND
|
-- @extends #ATC_GROUND
|
||||||
|
|
||||||
|
|
||||||
@@ -1419,11 +1438,11 @@ end
|
|||||||
-- @return nothing
|
-- @return nothing
|
||||||
function ATC_GROUND_PERSIANGULF:Start( RepeatScanSeconds )
|
function ATC_GROUND_PERSIANGULF:Start( RepeatScanSeconds )
|
||||||
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
||||||
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, 2, RepeatScanSeconds )
|
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, RepeatScanSeconds )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @type ATC_GROUND_MARIANAISLANDS
|
-- @type ATC_GROUND_MARIANAISLANDS
|
||||||
-- @extends #ATC_GROUND
|
-- @extends #ATC_GROUND
|
||||||
|
|
||||||
|
|
||||||
@@ -1517,7 +1536,7 @@ end
|
|||||||
-- * @{#ATC_GROUND.SetMaximumKickSpeedKmph}(): Set the maximum speed allowed at an airbase in kilometers per hour.
|
-- * @{#ATC_GROUND.SetMaximumKickSpeedKmph}(): Set the maximum speed allowed at an airbase in kilometers per hour.
|
||||||
-- * @{#ATC_GROUND.SetMaximumKickSpeedMiph}(): Set the maximum speed allowed at an airbase in miles per hour.
|
-- * @{#ATC_GROUND.SetMaximumKickSpeedMiph}(): Set the maximum speed allowed at an airbase in miles per hour.
|
||||||
--
|
--
|
||||||
---- @field #ATC_GROUND_MARIANAISLANDS
|
-- @field #ATC_GROUND_MARIANAISLANDS
|
||||||
ATC_GROUND_MARIANAISLANDS = {
|
ATC_GROUND_MARIANAISLANDS = {
|
||||||
ClassName = "ATC_GROUND_MARIANAISLANDS",
|
ClassName = "ATC_GROUND_MARIANAISLANDS",
|
||||||
}
|
}
|
||||||
@@ -1529,7 +1548,7 @@ ATC_GROUND_MARIANAISLANDS = {
|
|||||||
function ATC_GROUND_MARIANAISLANDS:New( AirbaseNames )
|
function ATC_GROUND_MARIANAISLANDS:New( AirbaseNames )
|
||||||
|
|
||||||
-- Inherits from BASE
|
-- Inherits from BASE
|
||||||
local self = BASE:Inherit( self, ATC_GROUND_UNIVERSAL:New( self.Airbases, AirbaseNames ) )
|
local self = BASE:Inherit( self, ATC_GROUND_UNIVERSAL:New( AirbaseNames ) )
|
||||||
|
|
||||||
self:SetKickSpeedKmph( 50 )
|
self:SetKickSpeedKmph( 50 )
|
||||||
self:SetMaximumKickSpeedKmph( 150 )
|
self:SetMaximumKickSpeedKmph( 150 )
|
||||||
@@ -1543,5 +1562,5 @@ end
|
|||||||
-- @return nothing
|
-- @return nothing
|
||||||
function ATC_GROUND_MARIANAISLANDS:Start( RepeatScanSeconds )
|
function ATC_GROUND_MARIANAISLANDS:Start( RepeatScanSeconds )
|
||||||
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
RepeatScanSeconds = RepeatScanSeconds or 0.05
|
||||||
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, 2, RepeatScanSeconds )
|
self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, { self }, 0, RepeatScanSeconds )
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3546,9 +3546,7 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function ARTY:onafterRespawn(Controllable, From, Event, To)
|
function ARTY:onafterRespawn(Controllable, From, Event, To)
|
||||||
self:_EventFromTo("onafterRespawn", Event, From, To)
|
self:_EventFromTo("onafterRespawn", Event, From, To)
|
||||||
|
self:I("Respawning arty group")
|
||||||
env.info("FF Respawning arty group")
|
|
||||||
|
|
||||||
local group=self.Controllable --Wrapper.Group#GROUP
|
local group=self.Controllable --Wrapper.Group#GROUP
|
||||||
|
|
||||||
-- Respawn group.
|
-- Respawn group.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [CLA - CleanUp Airbase](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/CLA%20-%20CleanUp%20Airbase)
|
-- [CLA - CleanUp Airbase](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/CleanUp)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Additional Material:
|
||||||
--
|
--
|
||||||
-- [DES - Designation](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/DES%20-%20Designation)
|
-- * **Demo Missions:** [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/Designate)
|
||||||
|
-- * **YouTube videos:** None
|
||||||
|
-- * **Guides:** None
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -182,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.
|
||||||
@@ -523,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
|
||||||
@@ -552,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
|
||||||
@@ -824,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( ", " )
|
||||||
@@ -901,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
|
||||||
@@ -1058,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 )
|
||||||
@@ -1196,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
|
||||||
@@ -1227,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() } )
|
||||||
@@ -1251,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 ) } )
|
||||||
@@ -1273,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
|
||||||
|
|
||||||
@@ -1283,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
|
||||||
@@ -1390,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
|
||||||
@@ -1455,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
|
||||||
@@ -1470,5 +1476,3 @@ do -- DESIGNATE
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [DET - Detection](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/DET%20-%20Detection)
|
-- [DET - Detection](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Functional/Detection)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -39,7 +39,8 @@
|
|||||||
|
|
||||||
do -- DETECTION_BASE
|
do -- DETECTION_BASE
|
||||||
|
|
||||||
--- @type DETECTION_BASE
|
---
|
||||||
|
-- @type DETECTION_BASE
|
||||||
-- @field Core.Set#SET_GROUP DetectionSetGroup The @{Core.Set} of GROUPs in the Forward Air Controller role.
|
-- @field Core.Set#SET_GROUP DetectionSetGroup The @{Core.Set} of GROUPs in the Forward Air Controller role.
|
||||||
-- @field DCS#Distance DetectionRange The range till which targets are accepted to be detected.
|
-- @field DCS#Distance DetectionRange The range till which targets are accepted to be detected.
|
||||||
-- @field #DETECTION_BASE.DetectedObjects DetectedObjects The list of detected objects.
|
-- @field #DETECTION_BASE.DetectedObjects DetectedObjects The list of detected objects.
|
||||||
@@ -91,6 +92,11 @@ do -- DETECTION_BASE
|
|||||||
--
|
--
|
||||||
-- DetectionObject:FilterCategories( { Unit.Category.AIRPLANE, Unit.Category.HELICOPTER } )
|
-- DetectionObject:FilterCategories( { Unit.Category.AIRPLANE, Unit.Category.HELICOPTER } )
|
||||||
--
|
--
|
||||||
|
--
|
||||||
|
-- ## Radar Blur - use to make the radar less exact, e.g. for WWII scenarios
|
||||||
|
--
|
||||||
|
-- * @{#DETECTION_BASE.SetRadarBlur}(): Set the radar blur to be used.
|
||||||
|
--
|
||||||
-- ## **DETECTION_ derived classes** group the detected units into a **DetectedItems[]** list
|
-- ## **DETECTION_ derived classes** group the detected units into a **DetectedItems[]** list
|
||||||
--
|
--
|
||||||
-- DETECTION_BASE derived classes build a list called DetectedItems[], which is essentially a first later
|
-- DETECTION_BASE derived classes build a list called DetectedItems[], which is essentially a first later
|
||||||
@@ -269,10 +275,12 @@ do -- DETECTION_BASE
|
|||||||
DetectedItemsByIndex = {},
|
DetectedItemsByIndex = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @type DETECTION_BASE.DetectedObjects
|
---
|
||||||
|
-- @type DETECTION_BASE.DetectedObjects
|
||||||
-- @list <#DETECTION_BASE.DetectedObject>
|
-- @list <#DETECTION_BASE.DetectedObject>
|
||||||
|
|
||||||
--- @type DETECTION_BASE.DetectedObject
|
---
|
||||||
|
-- @type DETECTION_BASE.DetectedObject
|
||||||
-- @field #string Name
|
-- @field #string Name
|
||||||
-- @field #boolean IsVisible
|
-- @field #boolean IsVisible
|
||||||
-- @field #boolean KnowType
|
-- @field #boolean KnowType
|
||||||
@@ -284,7 +292,8 @@ do -- DETECTION_BASE
|
|||||||
-- @field #boolean LastPos
|
-- @field #boolean LastPos
|
||||||
-- @field #number LastVelocity
|
-- @field #number LastVelocity
|
||||||
|
|
||||||
--- @type DETECTION_BASE.DetectedItems
|
---
|
||||||
|
-- @type DETECTION_BASE.DetectedItems
|
||||||
-- @list <#DETECTION_BASE.DetectedItem>
|
-- @list <#DETECTION_BASE.DetectedItem>
|
||||||
|
|
||||||
--- Detected item data structure.
|
--- Detected item data structure.
|
||||||
@@ -522,7 +531,7 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
do -- State Transition Handling
|
do -- State Transition Handling
|
||||||
|
|
||||||
--- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
-- @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.
|
||||||
@@ -530,13 +539,13 @@ do -- DETECTION_BASE
|
|||||||
self:__Detect( 1 )
|
self:__Detect( 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
-- @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.
|
||||||
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
|
||||||
@@ -570,7 +579,7 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
-- @param #number The amount of alive recce.
|
-- @param #number The amount of alive recce.
|
||||||
function DETECTION_BASE:CountAliveRecce()
|
function DETECTION_BASE:CountAliveRecce()
|
||||||
|
|
||||||
@@ -578,7 +587,7 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
function DETECTION_BASE:ForEachAliveRecce( IteratorFunction, ... )
|
function DETECTION_BASE:ForEachAliveRecce( IteratorFunction, ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
@@ -587,7 +596,7 @@ do -- DETECTION_BASE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
-- @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.
|
||||||
@@ -595,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
|
||||||
|
|
||||||
@@ -603,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,
|
||||||
@@ -619,7 +628,9 @@ 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
|
||||||
@@ -712,6 +723,31 @@ do -- DETECTION_BASE
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Calculate radar blur probability
|
||||||
|
|
||||||
|
if self.RadarBlur then
|
||||||
|
MESSAGE:New("Radar Blur",10):ToLogIf(self.debug):ToAllIf(self.verbose)
|
||||||
|
local minheight = self.RadarBlurMinHeight or 250 -- meters
|
||||||
|
local thresheight = self.RadarBlurThresHeight or 90 -- 10% chance to find a low flying group
|
||||||
|
local thresblur = self.RadarBlurThresBlur or 85 -- 25% chance to escape the radar overall
|
||||||
|
local dist = math.floor(Distance)
|
||||||
|
if dist <= self.RadarBlurClosing then
|
||||||
|
thresheight = (((dist*dist)/self.RadarBlurClosingSquare)*thresheight)
|
||||||
|
thresblur = (((dist*dist)/self.RadarBlurClosingSquare)*thresblur)
|
||||||
|
end
|
||||||
|
local fheight = math.floor(math.random(1,10000)/100)
|
||||||
|
local fblur = math.floor(math.random(1,10000)/100)
|
||||||
|
local unit = UNIT:FindByName(DetectedObjectName)
|
||||||
|
if unit and unit:IsAlive() then
|
||||||
|
local AGL = unit:GetAltitude(true)
|
||||||
|
MESSAGE:New("Unit "..DetectedObjectName.." is at "..math.floor(AGL).."m. Distance "..math.floor(Distance).."km.",10):ToLogIf(self.debug):ToAllIf(self.verbose)
|
||||||
|
MESSAGE:New(string.format("fheight = %d/%d | fblur = %d/%d",fheight,thresheight,fblur,thresblur),10):ToLogIf(self.debug):ToAllIf(self.verbose)
|
||||||
|
if fblur > thresblur then DetectionAccepted = false end
|
||||||
|
if AGL <= minheight and fheight < thresheight then DetectionAccepted = false end
|
||||||
|
MESSAGE:New("Detection Accepted = "..tostring(DetectionAccepted),10):ToLogIf(self.debug):ToAllIf(self.verbose)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Calculate additional probabilities
|
-- Calculate additional probabilities
|
||||||
|
|
||||||
if not self.DetectedObjects[DetectedObjectName] and TargetIsVisible and self.DistanceProbability then
|
if not self.DetectedObjects[DetectedObjectName] and TargetIsVisible and self.DistanceProbability then
|
||||||
@@ -1012,6 +1048,23 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Method to make the radar detection less accurate, e.g. for WWII scenarios.
|
||||||
|
-- @param #DETECTION_BASE self
|
||||||
|
-- @param #number minheight Minimum flight height to be detected, in meters AGL (above ground)
|
||||||
|
-- @param #number thresheight Threshold to escape the radar if flying below minheight, defaults to 90 (90% escape chance)
|
||||||
|
-- @param #number thresblur Threshold to be detected by the radar overall, defaults to 85 (85% chance to be found)
|
||||||
|
-- @param #number closing Closing-in in km - the limit of km from which on it becomes increasingly difficult to escape radar detection if flying towards the radar position. Should be about 1/3 of the radar detection radius in kilometers, defaults to 20.
|
||||||
|
-- @return #DETECTION_BASE self
|
||||||
|
function DETECTION_BASE:SetRadarBlur(minheight,thresheight,thresblur,closing)
|
||||||
|
self.RadarBlur = true
|
||||||
|
self.RadarBlurMinHeight = minheight or 250 -- meters
|
||||||
|
self.RadarBlurThresHeight = thresheight or 90 -- 10% chance to find a low flying group
|
||||||
|
self.RadarBlurThresBlur = thresblur or 85 -- 25% chance to escape the radar overall
|
||||||
|
self.RadarBlurClosing = closing or 20 -- 20km
|
||||||
|
self.RadarBlurClosingSquare = self.RadarBlurClosing * self.RadarBlurClosing
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -1354,7 +1407,7 @@ do -- DETECTION_BASE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @param DCS#Unit FoundDCSUnit
|
-- @param DCS#Unit FoundDCSUnit
|
||||||
-- @param Wrapper.Group#GROUP ReportGroup
|
-- @param Wrapper.Group#GROUP ReportGroup
|
||||||
-- @param Core.Set#SET_GROUP ReportSetGroup
|
-- @param Core.Set#SET_GROUP ReportSetGroup
|
||||||
local FindNearByFriendlies = function( FoundDCSUnit, ReportGroupData )
|
local FindNearByFriendlies = function( FoundDCSUnit, ReportGroupData )
|
||||||
@@ -1419,7 +1472,7 @@ do -- DETECTION_BASE
|
|||||||
DetectedItem.PlayersNearBy = nil
|
DetectedItem.PlayersNearBy = nil
|
||||||
|
|
||||||
_DATABASE:ForEachPlayer(
|
_DATABASE:ForEachPlayer(
|
||||||
--- @param Wrapper.Unit#UNIT PlayerUnit
|
-- @param Wrapper.Unit#UNIT PlayerUnit
|
||||||
function( PlayerUnitName )
|
function( PlayerUnitName )
|
||||||
local PlayerUnit = UNIT:FindByName( PlayerUnitName )
|
local PlayerUnit = UNIT:FindByName( PlayerUnitName )
|
||||||
|
|
||||||
@@ -1976,7 +2029,8 @@ end
|
|||||||
|
|
||||||
do -- DETECTION_UNITS
|
do -- DETECTION_UNITS
|
||||||
|
|
||||||
--- @type DETECTION_UNITS
|
---
|
||||||
|
-- @type DETECTION_UNITS
|
||||||
-- @field DCS#Distance DetectionRange The range till which targets are detected.
|
-- @field DCS#Distance DetectionRange The range till which targets are detected.
|
||||||
-- @extends Functional.Detection#DETECTION_BASE
|
-- @extends Functional.Detection#DETECTION_BASE
|
||||||
|
|
||||||
@@ -2232,7 +2286,8 @@ end
|
|||||||
|
|
||||||
do -- DETECTION_TYPES
|
do -- DETECTION_TYPES
|
||||||
|
|
||||||
--- @type DETECTION_TYPES
|
---
|
||||||
|
-- @type DETECTION_TYPES
|
||||||
-- @extends Functional.Detection#DETECTION_BASE
|
-- @extends Functional.Detection#DETECTION_BASE
|
||||||
|
|
||||||
--- Will detect units within the battle zone.
|
--- Will detect units within the battle zone.
|
||||||
@@ -2435,7 +2490,8 @@ end
|
|||||||
|
|
||||||
do -- DETECTION_AREAS
|
do -- DETECTION_AREAS
|
||||||
|
|
||||||
--- @type DETECTION_AREAS
|
---
|
||||||
|
-- @type DETECTION_AREAS
|
||||||
-- @field DCS#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
-- @field DCS#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
||||||
-- @field #DETECTION_BASE.DetectedItems DetectedItems A list of areas containing the set of @{Wrapper.Unit}s, @{Core.Zone}s, the center @{Wrapper.Unit} within the zone, and ID of each area that was detected within a DetectionZoneRange.
|
-- @field #DETECTION_BASE.DetectedItems DetectedItems A list of areas containing the set of @{Wrapper.Unit}s, @{Core.Zone}s, the center @{Wrapper.Unit} within the zone, and ID of each area that was detected within a DetectionZoneRange.
|
||||||
-- @extends Functional.Detection#DETECTION_BASE
|
-- @extends Functional.Detection#DETECTION_BASE
|
||||||
@@ -2961,7 +3017,7 @@ do -- DETECTION_AREAS
|
|||||||
|
|
||||||
-- DetectedSet:Flush( self )
|
-- DetectedSet:Flush( self )
|
||||||
|
|
||||||
DetectedSet:ForEachUnit( --- @param Wrapper.Unit#UNIT DetectedUnit
|
DetectedSet:ForEachUnit( -- @param Wrapper.Unit#UNIT DetectedUnit
|
||||||
function( DetectedUnit )
|
function( DetectedUnit )
|
||||||
if DetectedUnit:IsAlive() then
|
if DetectedUnit:IsAlive() then
|
||||||
-- self:T( "Detected Set #" .. DetectedItem.ID .. ":" .. DetectedUnit:GetName() )
|
-- self:T( "Detected Set #" .. DetectedItem.ID .. ":" .. DetectedUnit:GetName() )
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Additional Material:
|
||||||
--
|
--
|
||||||
-- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ESC%20-%20Escorting)
|
-- * **Demo Missions:** [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/Escort)
|
||||||
|
-- * **YouTube videos:** None
|
||||||
|
-- * **Guides:** None
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Functional/FOX)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
-- ### Author: **funkyfranky**
|
-- ### Author: **funkyfranky**
|
||||||
-- @module Functional.Fox
|
-- @module Functional.Fox
|
||||||
-- @image Functional_FOX.png
|
-- @image Functional_FOX.png
|
||||||
@@ -437,7 +441,7 @@ function FOX:SetProtectedGroupSet(groupset)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a group to the protected set.
|
--- Add a group to the protected set. Works only with AI!
|
||||||
-- @param #FOX self
|
-- @param #FOX self
|
||||||
-- @param Wrapper.Group#GROUP group Protected group.
|
-- @param Wrapper.Group#GROUP group Protected group.
|
||||||
-- @return #FOX self
|
-- @return #FOX self
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- ### [MANTIS - Modular, Automatic and Network capable Targeting and Interception System](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/MTS%20-%20Mantis/MTS-010%20-%20Basic%20Mantis%20Demo)
|
-- ### [MANTIS - Modular, Automatic and Network capable Targeting and Interception System](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/Mantis)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
-- @module Functional.Mantis
|
-- @module Functional.Mantis
|
||||||
-- @image Functional.Mantis.jpg
|
-- @image Functional.Mantis.jpg
|
||||||
--
|
--
|
||||||
-- Last Update: Oct 2023
|
-- 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
|
||||||
|
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
-- Known SAM types at the time of writing are:
|
-- Known SAM types at the time of writing are:
|
||||||
--
|
--
|
||||||
-- * Avenger
|
-- * Avenger
|
||||||
-- * Chaparrel
|
-- * Chaparral
|
||||||
-- * Hawk
|
-- * Hawk
|
||||||
-- * Linebacker
|
-- * Linebacker
|
||||||
-- * NASAMS
|
-- * NASAMS
|
||||||
@@ -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
|
||||||
@@ -347,17 +354,17 @@ MANTIS.SamType = {
|
|||||||
-- @field #string Type #MANTIS.SamType of SAM, i.e. SHORT, MEDIUM or LONG (range)
|
-- @field #string Type #MANTIS.SamType of SAM, i.e. SHORT, MEDIUM or LONG (range)
|
||||||
-- @field #string Radar Radar typename on unit level (used as key)
|
-- @field #string Radar Radar typename on unit level (used as key)
|
||||||
MANTIS.SamData = {
|
MANTIS.SamData = {
|
||||||
["Hawk"] = { Range=44, Blindspot=0, Height=9, Type="Medium", Radar="Hawk" }, -- measures in km
|
["Hawk"] = { Range=35, Blindspot=0, Height=12, Type="Medium", Radar="Hawk" }, -- measures in km
|
||||||
["NASAMS"] = { Range=14, Blindspot=0, Height=3, Type="Short", Radar="NSAMS" },
|
["NASAMS"] = { Range=14, Blindspot=0, Height=7, Type="Short", Radar="NSAMS" }, -- AIM 120B
|
||||||
["Patriot"] = { Range=99, Blindspot=0, Height=9, Type="Long", Radar="Patriot" },
|
["Patriot"] = { Range=99, Blindspot=0, Height=25, Type="Long", Radar="Patriot" },
|
||||||
["Rapier"] = { Range=6, Blindspot=0, Height=3, Type="Short", Radar="rapier" },
|
["Rapier"] = { Range=10, Blindspot=0, Height=3, Type="Short", Radar="rapier" },
|
||||||
["SA-2"] = { Range=40, Blindspot=7, Height=25, Type="Medium", Radar="S_75M_Volhov" },
|
["SA-2"] = { Range=40, Blindspot=7, Height=25, Type="Medium", Radar="S_75M_Volhov" },
|
||||||
["SA-3"] = { Range=18, Blindspot=6, Height=18, Type="Short", Radar="5p73 s-125 ln" },
|
["SA-3"] = { Range=18, Blindspot=6, Height=18, Type="Short", Radar="5p73 s-125 ln" },
|
||||||
["SA-5"] = { Range=250, Blindspot=7, Height=40, Type="Long", Radar="5N62V" },
|
["SA-5"] = { Range=250, Blindspot=7, Height=40, Type="Long", Radar="5N62V" },
|
||||||
["SA-6"] = { Range=25, Blindspot=0, Height=8, Type="Medium", Radar="1S91" },
|
["SA-6"] = { Range=25, Blindspot=0, Height=8, Type="Medium", Radar="1S91" },
|
||||||
["SA-10"] = { Range=119, Blindspot=0, Height=18, Type="Long" , Radar="S-300PS 4"},
|
["SA-10"] = { Range=119, Blindspot=0, Height=18, Type="Long" , Radar="S-300PS 4"},
|
||||||
["SA-11"] = { Range=35, Blindspot=0, Height=20, Type="Medium", Radar="SA-11" },
|
["SA-11"] = { Range=35, Blindspot=0, Height=20, Type="Medium", Radar="SA-11" },
|
||||||
["Roland"] = { Range=8, Blindspot=0, Height=3, Type="Short", Radar="Roland" },
|
["Roland"] = { Range=5, Blindspot=0, Height=5, Type="Short", Radar="Roland" },
|
||||||
["HQ-7"] = { Range=12, Blindspot=0, Height=3, Type="Short", Radar="HQ-7" },
|
["HQ-7"] = { Range=12, Blindspot=0, Height=3, Type="Short", Radar="HQ-7" },
|
||||||
["SA-9"] = { Range=4, Blindspot=0, Height=3, Type="Short", Radar="Strela" },
|
["SA-9"] = { Range=4, Blindspot=0, Height=3, Type="Short", Radar="Strela" },
|
||||||
["SA-8"] = { Range=10, Blindspot=0, Height=5, Type="Short", Radar="Osa 9A33" },
|
["SA-8"] = { Range=10, Blindspot=0, Height=5, Type="Short", Radar="Osa 9A33" },
|
||||||
@@ -365,7 +372,7 @@ MANTIS.SamData = {
|
|||||||
["SA-15"] = { Range=11, Blindspot=0, Height=6, Type="Short", Radar="Tor 9A331" },
|
["SA-15"] = { Range=11, Blindspot=0, Height=6, Type="Short", Radar="Tor 9A331" },
|
||||||
["SA-13"] = { Range=5, Blindspot=0, Height=3, Type="Short", Radar="Strela" },
|
["SA-13"] = { Range=5, Blindspot=0, Height=3, Type="Short", Radar="Strela" },
|
||||||
["Avenger"] = { Range=4, Blindspot=0, Height=3, Type="Short", Radar="Avenger" },
|
["Avenger"] = { Range=4, Blindspot=0, Height=3, Type="Short", Radar="Avenger" },
|
||||||
["Chaparrel"] = { Range=8, Blindspot=0, Height=3, Type="Short", Radar="Chaparral" },
|
["Chaparral"] = { Range=8, Blindspot=0, Height=3, Type="Short", Radar="Chaparral" },
|
||||||
["Linebacker"] = { Range=4, Blindspot=0, Height=3, Type="Short", Radar="Linebacker" },
|
["Linebacker"] = { Range=4, Blindspot=0, Height=3, Type="Short", Radar="Linebacker" },
|
||||||
["Silkworm"] = { Range=90, Blindspot=1, Height=0.2, Type="Long", Radar="Silkworm" },
|
["Silkworm"] = { Range=90, Blindspot=1, Height=0.2, Type="Long", Radar="Silkworm" },
|
||||||
-- units from HDS Mod, multi launcher options is tricky
|
-- units from HDS Mod, multi launcher options is tricky
|
||||||
@@ -503,6 +510,7 @@ do
|
|||||||
-- 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.15"
|
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 ---
|
||||||
@@ -799,12 +807,16 @@ do
|
|||||||
-- @param #MANTIS self
|
-- @param #MANTIS self
|
||||||
-- @param Core.Set#SET_ZONE ZoneSet Set of zones to be used. Units will move around to the next (random) zone between 100m and 3000m away.
|
-- @param Core.Set#SET_ZONE ZoneSet Set of zones to be used. Units will move around to the next (random) zone between 100m and 3000m away.
|
||||||
-- @param #number Number Number of closest zones to be considered, defaults to 3.
|
-- @param #number Number Number of closest zones to be considered, defaults to 3.
|
||||||
|
-- @param #boolean Random If true, use a random coordinate inside the next zone to scoot to.
|
||||||
|
-- @param #string Formation Formation to use, defaults to "Cone". See mission editor dropdown for options.
|
||||||
-- @return #MANTIS self
|
-- @return #MANTIS self
|
||||||
function MANTIS:AddScootZones(ZoneSet, Number)
|
function MANTIS:AddScootZones(ZoneSet, Number, Random, Formation)
|
||||||
self:T(self.lid .. " AddScootZones")
|
self:T(self.lid .. " AddScootZones")
|
||||||
self.SkateZones = ZoneSet
|
self.SkateZones = ZoneSet
|
||||||
self.SkateNumber = Number or 3
|
self.SkateNumber = Number or 3
|
||||||
self.shootandscoot = true
|
self.shootandscoot = true
|
||||||
|
self.ScootRandom = Random
|
||||||
|
self.ScootFormation = Formation or "Cone"
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1145,7 +1157,7 @@ do
|
|||||||
--self:T(self.lid.." Relocating HQ")
|
--self:T(self.lid.." Relocating HQ")
|
||||||
local text = self.lid.." Relocating HQ"
|
local text = self.lid.." Relocating HQ"
|
||||||
--local m= MESSAGE:New(text,10,"MANTIS"):ToAll()
|
--local m= MESSAGE:New(text,10,"MANTIS"):ToAll()
|
||||||
_hqgrp:RelocateGroundRandomInRadius(20,500,true,true)
|
_hqgrp:RelocateGroundRandomInRadius(20,500,true,true,nil,true)
|
||||||
end
|
end
|
||||||
--relocate EWR
|
--relocate EWR
|
||||||
-- TODO: maybe dependent on AlarmState? Observed: SA11 SR only relocates if no objects in reach
|
-- TODO: maybe dependent on AlarmState? Observed: SA11 SR only relocates if no objects in reach
|
||||||
@@ -1159,7 +1171,7 @@ do
|
|||||||
local text = self.lid.." Relocating EWR ".._grp:GetName()
|
local text = self.lid.." Relocating EWR ".._grp:GetName()
|
||||||
local m= MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug)
|
local m= MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug)
|
||||||
if self.verbose then self:I(text) end
|
if self.verbose then self:I(text) end
|
||||||
_grp:RelocateGroundRandomInRadius(20,500,true,true)
|
_grp:RelocateGroundRandomInRadius(20,500,true,true,nil,true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1218,10 +1230,10 @@ do
|
|||||||
function MANTIS:_PreFilterHeight(height)
|
function MANTIS:_PreFilterHeight(height)
|
||||||
self:T(self.lid.."_PreFilterHeight")
|
self:T(self.lid.."_PreFilterHeight")
|
||||||
local set = {}
|
local set = {}
|
||||||
local dlink = self.Detection -- Ops.Intelligence#INTEL_DLINK
|
local dlink = self.Detection -- Ops.Intel#INTEL_DLINK
|
||||||
local detectedgroups = dlink:GetContactTable()
|
local detectedgroups = dlink:GetContactTable()
|
||||||
for _,_contact in pairs(detectedgroups) do
|
for _,_contact in pairs(detectedgroups) do
|
||||||
local contact = _contact -- Ops.Intelligence#INTEL.Contact
|
local contact = _contact -- Ops.Intel#INTEL.Contact
|
||||||
local grp = contact.group -- Wrapper.Group#GROUP
|
local grp = contact.group -- Wrapper.Group#GROUP
|
||||||
if grp:IsAlive() then
|
if grp:IsAlive() then
|
||||||
if grp:GetHeight(true) < height then
|
if grp:GetHeight(true) < height then
|
||||||
@@ -1251,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
|
||||||
@@ -1275,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
|
||||||
@@ -1773,7 +1797,7 @@ do
|
|||||||
-- @return #MANTIS self
|
-- @return #MANTIS self
|
||||||
function MANTIS:_CheckDLinkState()
|
function MANTIS:_CheckDLinkState()
|
||||||
self:T(self.lid .. "_CheckDLinkState")
|
self:T(self.lid .. "_CheckDLinkState")
|
||||||
local dlink = self.Detection -- Ops.Intelligence#INTEL_DLINK
|
local dlink = self.Detection -- Ops.Intel#INTEL_DLINK
|
||||||
local TS = timer.getAbsTime()
|
local TS = timer.getAbsTime()
|
||||||
if not dlink:Is("Running") and (TS - self.DLTimeStamp > 29) then
|
if not dlink:Is("Running") and (TS - self.DLTimeStamp > 29) then
|
||||||
self.DLink = false
|
self.DLink = false
|
||||||
@@ -1809,8 +1833,8 @@ do
|
|||||||
self.Shorad.Groupset=self.ShoradGroupSet
|
self.Shorad.Groupset=self.ShoradGroupSet
|
||||||
self.Shorad.debug = self.debug
|
self.Shorad.debug = self.debug
|
||||||
end
|
end
|
||||||
if self.shootandscoot and self.SkateZones then
|
if self.shootandscoot and self.SkateZones and self.Shorad then
|
||||||
self.Shorad:AddScootZones(self.SkateZones,self.SkateNumber or 3)
|
self.Shorad:AddScootZones(self.SkateZones,self.SkateNumber or 3,self.ScootRandom,self.ScootFormation)
|
||||||
end
|
end
|
||||||
self:__Status(-math.random(1,10))
|
self:__Status(-math.random(1,10))
|
||||||
return self
|
return self
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [MIT - Missile Trainer](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/MIT%20-%20Missile%20Trainer)
|
-- [MIT - Missile Trainer](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/MissileTrainer)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -72,7 +72,6 @@
|
|||||||
-- @module Functional.MissileTrainer
|
-- @module Functional.MissileTrainer
|
||||||
-- @image Missile_Trainer.JPG
|
-- @image Missile_Trainer.JPG
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @type MISSILETRAINER
|
-- @type MISSILETRAINER
|
||||||
-- @field Core.Set#SET_CLIENT DBClients
|
-- @field Core.Set#SET_CLIENT DBClients
|
||||||
|
|||||||
@@ -33,16 +33,11 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Additional Material:
|
||||||
--
|
--
|
||||||
-- ### [RAT - Random Air Traffic](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/RAT%20-%20Random%20Air%20Traffic)
|
-- * **Demo Missions:** [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/RAT)
|
||||||
--
|
-- * **YouTube videos:** [Random Air Traffic](https://www.youtube.com/playlist?list=PL7ZUrU4zZUl0u4Zxywtg-mx_ov4vi68CO)
|
||||||
-- ===
|
-- * **Guides:** None
|
||||||
--
|
|
||||||
-- # YouTube Channel
|
|
||||||
--
|
|
||||||
-- ### [MOOSE YouTube Channel](https://www.youtube.com/channel/UCjrA9j5LQoWsG4SpS8i79Qg)
|
|
||||||
-- ### [MOOSE - RAT - Random Air Traffic](https://www.youtube.com/playlist?list=PL7ZUrU4zZUl0u4Zxywtg-mx_ov4vi68CO)
|
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -170,7 +165,7 @@
|
|||||||
--
|
--
|
||||||
-- * A specific departure and/or destination airport can be chosen.
|
-- * A specific departure and/or destination airport can be chosen.
|
||||||
-- * Valid coalitions can be set, e.g. only red, blue or neutral, all three "colours".
|
-- * Valid coalitions can be set, e.g. only red, blue or neutral, all three "colours".
|
||||||
-- * It is possible to start in air within a zone defined in the mission editor or within a zone above an airport of the map.
|
-- * It is possible to start in air within a zone or within a zone above an airport of the map.
|
||||||
--
|
--
|
||||||
-- ## Flight Plan
|
-- ## Flight Plan
|
||||||
--
|
--
|
||||||
@@ -1179,13 +1174,13 @@ function RAT:SetTakeoffAir()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set possible departure ports. This can be an airport or a zone defined in the mission editor.
|
--- Set possible departure ports. This can be an airport or a zone.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param #string departurenames Name or table of names of departure airports or zones.
|
-- @param #string departurenames Name or table of names of departure airports or zones.
|
||||||
-- @return #RAT RAT self object.
|
-- @return #RAT RAT self object.
|
||||||
-- @usage RAT:SetDeparture("Sochi-Adler") will spawn RAT objects at Sochi-Adler airport.
|
-- @usage RAT:SetDeparture("Sochi-Adler") will spawn RAT objects at Sochi-Adler airport.
|
||||||
-- @usage RAT:SetDeparture({"Sochi-Adler", "Gudauta"}) will spawn RAT aircraft radomly at Sochi-Adler or Gudauta airport.
|
-- @usage RAT:SetDeparture({"Sochi-Adler", "Gudauta"}) will spawn RAT aircraft radomly at Sochi-Adler or Gudauta airport.
|
||||||
-- @usage RAT:SetDeparture({"Zone A", "Gudauta"}) will spawn RAT aircraft in air randomly within Zone A, which has to be defined in the mission editor, or within a zone around Gudauta airport. Note that this also requires RAT:takeoff("air") to be set.
|
-- @usage RAT:SetDeparture({"Zone A", "Gudauta"}) will spawn RAT aircraft in air randomly within Zone A, or within a zone around Gudauta airport. Note that this also requires RAT:takeoff("air") to be set.
|
||||||
function RAT:SetDeparture(departurenames)
|
function RAT:SetDeparture(departurenames)
|
||||||
self:F2(departurenames)
|
self:F2(departurenames)
|
||||||
|
|
||||||
@@ -2537,7 +2532,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
|
|||||||
end
|
end
|
||||||
elseif self:_ZoneExists(_departure) then
|
elseif self:_ZoneExists(_departure) then
|
||||||
-- If it's not an airport, check whether it's a zone.
|
-- If it's not an airport, check whether it's a zone.
|
||||||
departure=ZONE:New(_departure)
|
departure=ZONE:FindByName(_departure)
|
||||||
else
|
else
|
||||||
local text=string.format("ERROR! Specified departure airport %s does not exist for %s.", _departure, self.alias)
|
local text=string.format("ERROR! Specified departure airport %s does not exist for %s.", _departure, self.alias)
|
||||||
self:E(RAT.id..text)
|
self:E(RAT.id..text)
|
||||||
@@ -2635,7 +2630,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
|
|||||||
end
|
end
|
||||||
|
|
||||||
elseif self:_ZoneExists(_destination) then
|
elseif self:_ZoneExists(_destination) then
|
||||||
destination=ZONE:New(_destination)
|
destination=ZONE:FindByName(_destination)
|
||||||
else
|
else
|
||||||
local text=string.format("ERROR: Specified destination airport/zone %s does not exist for %s!", _destination, self.alias)
|
local text=string.format("ERROR: Specified destination airport/zone %s does not exist for %s!", _destination, self.alias)
|
||||||
self:E(RAT.id.."ERROR: "..text)
|
self:E(RAT.id.."ERROR: "..text)
|
||||||
@@ -3142,7 +3137,7 @@ function RAT:_PickDeparture(takeoff)
|
|||||||
end
|
end
|
||||||
elseif self:_ZoneExists(name) then
|
elseif self:_ZoneExists(name) then
|
||||||
if takeoff==RAT.wp.air then
|
if takeoff==RAT.wp.air then
|
||||||
dep=ZONE:New(name)
|
dep=ZONE:FindByName(name)
|
||||||
else
|
else
|
||||||
self:E(RAT.id..string.format("ERROR! Takeoff is not in air. Cannot use %s as departure.", name))
|
self:E(RAT.id..string.format("ERROR! Takeoff is not in air. Cannot use %s as departure.", name))
|
||||||
end
|
end
|
||||||
@@ -3254,7 +3249,7 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)
|
|||||||
end
|
end
|
||||||
elseif self:_ZoneExists(name) then
|
elseif self:_ZoneExists(name) then
|
||||||
if landing==RAT.wp.air then
|
if landing==RAT.wp.air then
|
||||||
dest=ZONE:New(name)
|
dest=ZONE:FindByName(name)
|
||||||
else
|
else
|
||||||
self:E(RAT.id..string.format("ERROR! Landing is not in air. Cannot use zone %s as destination!", name))
|
self:E(RAT.id..string.format("ERROR! Landing is not in air. Cannot use zone %s as destination!", name))
|
||||||
end
|
end
|
||||||
@@ -4930,12 +4925,12 @@ function RAT:_AirportExists(name)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Test if a trigger zone defined in the mission editor exists.
|
--- Test if a zone exists.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param #string name
|
-- @param #string name
|
||||||
-- @return #boolean True if zone exsits, false otherwise.
|
-- @return #boolean True if zone exsits, false otherwise.
|
||||||
function RAT:_ZoneExists(name)
|
function RAT:_ZoneExists(name)
|
||||||
local z=trigger.misc.getZone(name)
|
local z=ZONE:FindByName(name) --trigger.misc.getZone(name) as suggested by @Viking on MOOSE discord #rat
|
||||||
if z then
|
if z then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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:**
|
||||||
--
|
--
|
||||||
@@ -1207,20 +1207,22 @@ end
|
|||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume, PathToGoogleKey)
|
function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume, PathToGoogleKey)
|
||||||
|
|
||||||
if PathToSRS then
|
if PathToSRS or MSRS.path then
|
||||||
|
|
||||||
self.useSRS=true
|
self.useSRS=true
|
||||||
|
|
||||||
self.controlmsrs=MSRS:New(PathToSRS, Frequency or 256, Modulation or radio.modulation.AM, Volume or 1.0)
|
self.controlmsrs=MSRS:New(PathToSRS or MSRS.path, Frequency or 256, Modulation or radio.modulation.AM)
|
||||||
self.controlmsrs:SetPort(Port)
|
self.controlmsrs:SetPort(Port or MSRS.port)
|
||||||
self.controlmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
self.controlmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
||||||
self.controlmsrs:SetLabel("RANGEC")
|
self.controlmsrs:SetLabel("RANGEC")
|
||||||
|
self.controlmsrs:SetVolume(Volume or 1.0)
|
||||||
self.controlsrsQ = MSRSQUEUE:New("CONTROL")
|
self.controlsrsQ = MSRSQUEUE:New("CONTROL")
|
||||||
|
|
||||||
self.instructmsrs=MSRS:New(PathToSRS, Frequency or 305, Modulation or radio.modulation.AM, Volume or 1.0)
|
self.instructmsrs=MSRS:New(PathToSRS or MSRS.path, Frequency or 305, Modulation or radio.modulation.AM)
|
||||||
self.instructmsrs:SetPort(Port)
|
self.instructmsrs:SetPort(Port or MSRS.port)
|
||||||
self.instructmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
self.instructmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
||||||
self.instructmsrs:SetLabel("RANGEI")
|
self.instructmsrs:SetLabel("RANGEI")
|
||||||
|
self.instructmsrs:SetVolume(Volume or 1.0)
|
||||||
self.instructsrsQ = MSRSQUEUE:New("INSTRUCT")
|
self.instructsrsQ = MSRSQUEUE:New("INSTRUCT")
|
||||||
|
|
||||||
if PathToGoogleKey then
|
if PathToGoogleKey then
|
||||||
@@ -1234,7 +1236,7 @@ function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume,
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- (SRS) Set range control frequency and voice.
|
--- (SRS) Set range control frequency and voice. Use `RANGE:SetSRS()` once first before using this function.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #number frequency Frequency in MHz. Default 256 MHz.
|
-- @param #number frequency Frequency in MHz. Default 256 MHz.
|
||||||
-- @param #number modulation Modulation, defaults to radio.modulation.AM.
|
-- @param #number modulation Modulation, defaults to radio.modulation.AM.
|
||||||
@@ -1244,6 +1246,10 @@ end
|
|||||||
-- @param #string relayunitname Name of the unit used for transmission location.
|
-- @param #string relayunitname Name of the unit used for transmission location.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:SetSRSRangeControl( frequency, modulation, voice, culture, gender, relayunitname )
|
function RANGE:SetSRSRangeControl( frequency, modulation, voice, culture, gender, relayunitname )
|
||||||
|
if not self.instructmsrs then
|
||||||
|
self:E(self.lid.."Use myrange:SetSRS() once first before using myrange:SetSRSRangeControl!")
|
||||||
|
return self
|
||||||
|
end
|
||||||
self.rangecontrolfreq = frequency or 256
|
self.rangecontrolfreq = frequency or 256
|
||||||
self.controlmsrs:SetFrequencies(self.rangecontrolfreq)
|
self.controlmsrs:SetFrequencies(self.rangecontrolfreq)
|
||||||
self.controlmsrs:SetModulations(modulation or radio.modulation.AM)
|
self.controlmsrs:SetModulations(modulation or radio.modulation.AM)
|
||||||
@@ -1259,7 +1265,7 @@ function RANGE:SetSRSRangeControl( frequency, modulation, voice, culture, gender
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- (SRS) Set range instructor frequency and voice.
|
--- (SRS) Set range instructor frequency and voice. Use `RANGE:SetSRS()` once first before using this function.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #number frequency Frequency in MHz. Default 305 MHz.
|
-- @param #number frequency Frequency in MHz. Default 305 MHz.
|
||||||
-- @param #number modulation Modulation, defaults to radio.modulation.AM.
|
-- @param #number modulation Modulation, defaults to radio.modulation.AM.
|
||||||
@@ -1269,6 +1275,10 @@ end
|
|||||||
-- @param #string relayunitname Name of the unit used for transmission location.
|
-- @param #string relayunitname Name of the unit used for transmission location.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:SetSRSRangeInstructor( frequency, modulation, voice, culture, gender, relayunitname )
|
function RANGE:SetSRSRangeInstructor( frequency, modulation, voice, culture, gender, relayunitname )
|
||||||
|
if not self.instructmsrs then
|
||||||
|
self:E(self.lid.."Use myrange:SetSRS() once first before using myrange:SetSRSRangeInstructor!")
|
||||||
|
return self
|
||||||
|
end
|
||||||
self.instructorfreq = frequency or 305
|
self.instructorfreq = frequency or 305
|
||||||
self.instructmsrs:SetFrequencies(self.instructorfreq)
|
self.instructmsrs:SetFrequencies(self.instructorfreq)
|
||||||
self.instructmsrs:SetModulations(modulation or radio.modulation.AM)
|
self.instructmsrs:SetModulations(modulation or radio.modulation.AM)
|
||||||
@@ -1730,6 +1740,8 @@ end
|
|||||||
function RANGE:OnEventBirth( EventData )
|
function RANGE:OnEventBirth( EventData )
|
||||||
self:F( { eventbirth = EventData } )
|
self:F( { eventbirth = EventData } )
|
||||||
|
|
||||||
|
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 )
|
||||||
|
|
||||||
@@ -2179,7 +2191,7 @@ function RANGE:onafterExitRange( From, Event, To, player )
|
|||||||
|
|
||||||
local text = "You left the bombing range zone. "
|
local text = "You left the bombing range zone. "
|
||||||
|
|
||||||
local r=math.random(2)
|
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!"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [SCO - Scoring](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCO%20-%20Scoring)
|
-- [SCO - Scoring](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/Scoring)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -79,6 +79,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Contributions:
|
-- ### Contributions:
|
||||||
--
|
--
|
||||||
|
-- * **Applevangelist**: Additional functionality, fixes.
|
||||||
-- * **Wingthor (TAW)**: Testing & Advice.
|
-- * **Wingthor (TAW)**: Testing & Advice.
|
||||||
-- * **Dutch-Baron (TAW)**: Testing & Advice.
|
-- * **Dutch-Baron (TAW)**: Testing & Advice.
|
||||||
-- * **Whisper**: Testing and Advice.
|
-- * **Whisper**: Testing and Advice.
|
||||||
@@ -116,11 +117,13 @@
|
|||||||
-- Special targets can be set that will give extra scores to the players when these are destroyed.
|
-- Special targets can be set that will give extra scores to the players when these are destroyed.
|
||||||
-- Use the methods @{#SCORING.AddUnitScore}() and @{#SCORING.RemoveUnitScore}() to specify a special additional score for a specific @{Wrapper.Unit}s.
|
-- Use the methods @{#SCORING.AddUnitScore}() and @{#SCORING.RemoveUnitScore}() to specify a special additional score for a specific @{Wrapper.Unit}s.
|
||||||
-- Use the methods @{#SCORING.AddStaticScore}() and @{#SCORING.RemoveStaticScore}() to specify a special additional score for a specific @{Wrapper.Static}s.
|
-- Use the methods @{#SCORING.AddStaticScore}() and @{#SCORING.RemoveStaticScore}() to specify a special additional score for a specific @{Wrapper.Static}s.
|
||||||
-- Use the method @{#SCORING.SetGroupGroup}() to specify a special additional score for a specific @{Wrapper.Group}s.
|
-- Use the method @{#SCORING.AddScoreSetGroup}() to specify a special additional score for a specific @{Wrapper.Group}s gathered in a @{Core.Set#SET_GROUP}.
|
||||||
--
|
--
|
||||||
-- local Scoring = SCORING:New( "Scoring File" )
|
-- local Scoring = SCORING:New( "Scoring File" )
|
||||||
-- Scoring:AddUnitScore( UNIT:FindByName( "Unit #001" ), 200 )
|
-- Scoring:AddUnitScore( UNIT:FindByName( "Unit #001" ), 200 )
|
||||||
-- Scoring:AddStaticScore( STATIC:FindByName( "Static #1" ), 100 )
|
-- Scoring:AddStaticScore( STATIC:FindByName( "Static #1" ), 100 )
|
||||||
|
-- local GroupSet = SET_GROUP:New():FilterPrefixes("RAT"):FilterStart()
|
||||||
|
-- Scoring:AddScoreSetGroup( GroupSet, 100)
|
||||||
--
|
--
|
||||||
-- The above grants an additional score of 200 points for Unit #001 and an additional 100 points of Static #1 if these are destroyed.
|
-- The above grants an additional score of 200 points for Unit #001 and an additional 100 points of Static #1 if these are destroyed.
|
||||||
-- Note that later in the mission, one can remove these scores set, for example, when the a goal achievement time limit is over.
|
-- Note that later in the mission, one can remove these scores set, for example, when the a goal achievement time limit is over.
|
||||||
@@ -226,7 +229,7 @@ SCORING = {
|
|||||||
ClassID = 0,
|
ClassID = 0,
|
||||||
Players = {},
|
Players = {},
|
||||||
AutoSave = true,
|
AutoSave = true,
|
||||||
version = "1.17.1"
|
version = "1.18.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
local _SCORINGCoalition = {
|
local _SCORINGCoalition = {
|
||||||
@@ -245,13 +248,15 @@ local _SCORINGCategory = {
|
|||||||
--- Creates a new SCORING object to administer the scoring achieved by players.
|
--- Creates a new SCORING object to administer the scoring achieved by players.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @param #string GameName The name of the game. This name is also logged in the CSV score file.
|
-- @param #string GameName The name of the game. This name is also logged in the CSV score file.
|
||||||
|
-- @param #string SavePath (Optional) Path where to save the CSV file, defaults to your **<User>\\Saved Games\\DCS\\Logs** folder.
|
||||||
|
-- @param #boolean AutoSave (Optional) If passed as `false`, then swith autosave off.
|
||||||
-- @return #SCORING self
|
-- @return #SCORING self
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Define a new scoring object for the mission Gori Valley.
|
-- -- Define a new scoring object for the mission Gori Valley.
|
||||||
-- ScoringObject = SCORING:New( "Gori Valley" )
|
-- ScoringObject = SCORING:New( "Gori Valley" )
|
||||||
--
|
--
|
||||||
function SCORING:New( GameName )
|
function SCORING:New( GameName, SavePath, AutoSave )
|
||||||
|
|
||||||
-- Inherits from BASE
|
-- Inherits from BASE
|
||||||
local self = BASE:Inherit( self, BASE:New() ) -- #SCORING
|
local self = BASE:Inherit( self, BASE:New() ) -- #SCORING
|
||||||
@@ -276,9 +281,15 @@ function SCORING:New( GameName )
|
|||||||
self:SetMessagesZone( true )
|
self:SetMessagesZone( true )
|
||||||
|
|
||||||
-- Scales
|
-- Scales
|
||||||
|
|
||||||
self:SetScaleDestroyScore( 10 )
|
self:SetScaleDestroyScore( 10 )
|
||||||
self:SetScaleDestroyPenalty( 30 )
|
self:SetScaleDestroyPenalty( 30 )
|
||||||
|
|
||||||
|
-- Hitting a target multiple times before destoying it should not result in a higger score
|
||||||
|
-- Multiple hits is typically a results of bombs/missles missing their target but still inflict some spash damage
|
||||||
|
-- Making this configurable to anyone can enable this anyway if they want
|
||||||
|
self:SetScoreIncrementOnHit(0)
|
||||||
|
|
||||||
-- Default fratricide penalty level (maximum penalty that can be assigned to a player before he gets kicked).
|
-- Default fratricide penalty level (maximum penalty that can be assigned to a player before he gets kicked).
|
||||||
self:SetFratricide( self.ScaleDestroyPenalty * 3 )
|
self:SetFratricide( self.ScaleDestroyPenalty * 3 )
|
||||||
self.penaltyonfratricide = true
|
self.penaltyonfratricide = true
|
||||||
@@ -308,7 +319,8 @@ function SCORING:New( GameName )
|
|||||||
end )
|
end )
|
||||||
|
|
||||||
-- Create the CSV file.
|
-- Create the CSV file.
|
||||||
self.AutoSave = true
|
self.AutoSavePath = SavePath
|
||||||
|
self.AutoSave = AutoSave or true
|
||||||
self:OpenCSV( GameName )
|
self:OpenCSV( GameName )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -422,6 +434,31 @@ function SCORING:AddScoreGroup( ScoreGroup, Score )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Specify a special additional score for a @{Core.Set#SET_GROUP}.
|
||||||
|
-- @param #SCORING self
|
||||||
|
-- @param Core.Set#SET_GROUP Set The @{Core.Set#SET_GROUP} for which each @{Wrapper.Unit} in each Group a Score is given.
|
||||||
|
-- @param #number Score The Score value.
|
||||||
|
-- @return #SCORING
|
||||||
|
function SCORING:AddScoreSetGroup(Set, Score)
|
||||||
|
local set = Set:GetSetObjects()
|
||||||
|
|
||||||
|
for _,_group in pairs (set) do
|
||||||
|
if _group and _group:IsAlive() then
|
||||||
|
self:AddScoreGroup(_group,Score)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function AddScore(group)
|
||||||
|
self:AddScoreGroup(group,Score)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Set:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||||
|
AddScore(Object)
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Add a @{Core.Zone} to define additional scoring when any object is destroyed in that zone.
|
--- Add a @{Core.Zone} to define additional scoring when any object is destroyed in that zone.
|
||||||
-- Note that if a @{Core.Zone} with the same name is already within the scoring added, the @{Core.Zone} (type) and Score will be replaced!
|
-- Note that if a @{Core.Zone} with the same name is already within the scoring added, the @{Core.Zone} (type) and Score will be replaced!
|
||||||
-- This allows for a dynamic destruction zone evolution within your mission.
|
-- This allows for a dynamic destruction zone evolution within your mission.
|
||||||
@@ -467,6 +504,16 @@ function SCORING:SetMessagesHit( OnOff )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Configure to increment score after a target has been hit.
|
||||||
|
-- @param #SCORING self
|
||||||
|
-- @param #number score amount of point to inclement score on each hit
|
||||||
|
-- @return #SCORING
|
||||||
|
function SCORING:SetScoreIncrementOnHit( score )
|
||||||
|
|
||||||
|
self.ScoreIncrementOnHit = score
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- If to send messages after a target has been hit.
|
--- If to send messages after a target has been hit.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
@@ -885,6 +932,7 @@ function SCORING:OnEventBirth( Event )
|
|||||||
Event.IniUnit.BirthTime = timer.getTime()
|
Event.IniUnit.BirthTime = timer.getTime()
|
||||||
if PlayerName then
|
if PlayerName then
|
||||||
self:_AddPlayerFromUnit( Event.IniUnit )
|
self:_AddPlayerFromUnit( Event.IniUnit )
|
||||||
|
self.Players[PlayerName].PlayerKills = 0
|
||||||
self:SetScoringMenu( Event.IniGroup )
|
self:SetScoringMenu( Event.IniGroup )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1013,11 +1061,11 @@ function SCORING:_EventOnHit( Event )
|
|||||||
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0
|
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0
|
||||||
PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0
|
PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0
|
||||||
PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT
|
PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT
|
||||||
-- After an instant kill we can't compute the thread level anymore. To fix this we compute at OnEventBirth
|
-- After an instant kill we can't compute the threat level anymore. To fix this we compute at OnEventBirth
|
||||||
if PlayerHit.UNIT.ThreatType == nil then
|
if PlayerHit.UNIT.ThreatType == nil then
|
||||||
PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel()
|
PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel()
|
||||||
-- if this fails for some reason, set a good default value
|
-- if this fails for some reason, set a good default value
|
||||||
if PlayerHit.ThreatType == nil then
|
if PlayerHit.ThreatType == nil or PlayerHit.ThreatType == "" then
|
||||||
PlayerHit.ThreatLevel = 1
|
PlayerHit.ThreatLevel = 1
|
||||||
PlayerHit.ThreatType = "Unknown"
|
PlayerHit.ThreatType = "Unknown"
|
||||||
end
|
end
|
||||||
@@ -1060,10 +1108,8 @@ function SCORING:_EventOnHit( Event )
|
|||||||
end
|
end
|
||||||
self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
else
|
else
|
||||||
-- Hitting a target multiple times before destoying it should not result in a higger score
|
Player.Score = Player.Score + self.ScoreIncrementOnHit
|
||||||
-- Multiple hits is typically a results of bombs/missles missing their target but still inflict some spash damage
|
PlayerHit.Score = PlayerHit.Score + self.ScoreIncrementOnHit
|
||||||
-- Player.Score = Player.Score + 1
|
|
||||||
-- PlayerHit.Score = PlayerHit.Score + 1
|
|
||||||
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
||||||
if TargetPlayerName ~= nil then -- It is a player hitting another player ...
|
if TargetPlayerName ~= nil then -- It is a player hitting another player ...
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit enemy player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " ..
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. InitPlayerName .. "' hit enemy player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " ..
|
||||||
@@ -1126,9 +1172,9 @@ function SCORING:_EventOnHit( Event )
|
|||||||
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0
|
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0
|
||||||
PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0
|
PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0
|
||||||
PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT
|
PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT
|
||||||
-- After an instant kill we can't compute the thread level anymore. To fix this we compute at OnEventBirth
|
-- After an instant kill we can't compute the threat level anymore. To fix this we compute at OnEventBirth
|
||||||
if PlayerHit.UNIT.ThreatType == nil then
|
if PlayerHit.UNIT.ThreatType == nil then
|
||||||
PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel()
|
PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel()
|
||||||
-- if this fails for some reason, set a good default value
|
-- if this fails for some reason, set a good default value
|
||||||
if PlayerHit.ThreatType == nil then
|
if PlayerHit.ThreatType == nil then
|
||||||
PlayerHit.ThreatLevel = 1
|
PlayerHit.ThreatLevel = 1
|
||||||
@@ -1163,10 +1209,8 @@ function SCORING:_EventOnHit( Event )
|
|||||||
:ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
:ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() )
|
||||||
self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
else
|
else
|
||||||
-- Hitting a target multiple times before destoying it should not result in a higger score
|
Player.Score = Player.Score + self.ScoreIncrementOnHit
|
||||||
-- Multiple hits is typically a results of bombs/missles missing their target but still inflict some spash damage
|
PlayerHit.Score = PlayerHit.Score + self.ScoreIncrementOnHit
|
||||||
-- Player.Score = Player.Score + 1
|
|
||||||
-- PlayerHit.Score = PlayerHit.Score + 1
|
|
||||||
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit enemy target " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " ..
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit enemy target " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " ..
|
||||||
"Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty,
|
"Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty,
|
||||||
@@ -1274,13 +1318,18 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
|||||||
TargetDestroy.Penalty = TargetDestroy.Penalty + ThreatPenalty
|
TargetDestroy.Penalty = TargetDestroy.Penalty + ThreatPenalty
|
||||||
TargetDestroy.PenaltyDestroy = TargetDestroy.PenaltyDestroy + 1
|
TargetDestroy.PenaltyDestroy = TargetDestroy.PenaltyDestroy + 1
|
||||||
|
|
||||||
|
|
||||||
|
--self:OnKillPvP(PlayerName, TargetPlayerName, true, TargetThreatLevel, Player.ThreatLevel, ThreatPenalty)
|
||||||
|
|
||||||
if Player.HitPlayers[TargetPlayerName] then -- A player destroyed another player
|
if Player.HitPlayers[TargetPlayerName] then -- A player destroyed another player
|
||||||
|
self:OnKillPvP(PlayerName, TargetPlayerName, true)
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||||
"Penalty: -" .. ThreatPenalty .. " = " .. Player.Score - Player.Penalty,
|
"Penalty: -" .. ThreatPenalty .. " = " .. Player.Score - Player.Penalty,
|
||||||
MESSAGE.Type.Information )
|
MESSAGE.Type.Information )
|
||||||
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
||||||
else
|
else
|
||||||
|
self:OnKillPvE(PlayerName, TargetUnitName, true, TargetThreatLevel, Player.ThreatLevel, ThreatPenalty)
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly target " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly target " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||||
"Penalty: -" .. ThreatPenalty .. " = " .. Player.Score - Player.Penalty,
|
"Penalty: -" .. ThreatPenalty .. " = " .. Player.Score - Player.Penalty,
|
||||||
MESSAGE.Type.Information )
|
MESSAGE.Type.Information )
|
||||||
@@ -1303,12 +1352,19 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
|||||||
TargetDestroy.Score = TargetDestroy.Score + ThreatScore
|
TargetDestroy.Score = TargetDestroy.Score + ThreatScore
|
||||||
TargetDestroy.ScoreDestroy = TargetDestroy.ScoreDestroy + 1
|
TargetDestroy.ScoreDestroy = TargetDestroy.ScoreDestroy + 1
|
||||||
if Player.HitPlayers[TargetPlayerName] then -- A player destroyed another player
|
if Player.HitPlayers[TargetPlayerName] then -- A player destroyed another player
|
||||||
|
if Player.PlayerKills ~= nil then
|
||||||
|
Player.PlayerKills = Player.PlayerKills + 1
|
||||||
|
else
|
||||||
|
Player.PlayerKills = 1
|
||||||
|
end
|
||||||
|
self:OnKillPvP(PlayerName, TargetPlayerName, false, TargetThreatLevel, Player.ThreatLevel, ThreatScore)
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy player '" .. TargetPlayerName .. "' " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||||
"Score: +" .. ThreatScore .. " = " .. Player.Score - Player.Penalty,
|
"Score: +" .. ThreatScore .. " = " .. Player.Score - Player.Penalty,
|
||||||
MESSAGE.Type.Information )
|
MESSAGE.Type.Information )
|
||||||
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
||||||
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
||||||
else
|
else
|
||||||
|
self:OnKillPvE(PlayerName, TargetUnitName, false, TargetThreatLevel, Player.ThreatLevel, ThreatScore)
|
||||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||||
"Score: +" .. ThreatScore .. " = " .. Player.Score - Player.Penalty,
|
"Score: +" .. ThreatScore .. " = " .. Player.Score - Player.Penalty,
|
||||||
MESSAGE.Type.Information )
|
MESSAGE.Type.Information )
|
||||||
@@ -1786,10 +1842,11 @@ end
|
|||||||
function SCORING:OpenCSV( ScoringCSV )
|
function SCORING:OpenCSV( ScoringCSV )
|
||||||
self:F( ScoringCSV )
|
self:F( ScoringCSV )
|
||||||
|
|
||||||
if lfs and io and os and self.AutoSave then
|
if lfs and io and os and self.AutoSave == true then
|
||||||
if ScoringCSV then
|
if ScoringCSV then
|
||||||
self.ScoringCSV = ScoringCSV
|
self.ScoringCSV = ScoringCSV
|
||||||
local fdir = lfs.writedir() .. [[Logs\]] .. self.ScoringCSV .. " " .. os.date( "%Y-%m-%d %H-%M-%S" ) .. ".csv"
|
local path = self.AutoSavePath or lfs.writedir() .. [[Logs\]]
|
||||||
|
local fdir = path .. self.ScoringCSV .. " " .. os.date( "%Y-%m-%d %H-%M-%S" ) .. ".csv"
|
||||||
|
|
||||||
self.CSVFile, self.err = io.open( fdir, "w+" )
|
self.CSVFile, self.err = io.open( fdir, "w+" )
|
||||||
if not self.CSVFile then
|
if not self.CSVFile then
|
||||||
@@ -1907,3 +1964,26 @@ function SCORING:SwitchAutoSave(OnOff)
|
|||||||
self.AutoSave = OnOff
|
self.AutoSave = OnOff
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Handles the event when one player kill another player
|
||||||
|
-- @param #SCORING self
|
||||||
|
-- @param #string PlayerName The attacking player
|
||||||
|
-- @param #string TargetPlayerName The name of the killed player
|
||||||
|
-- @param #boolean IsTeamKill true if this kill was a team kill
|
||||||
|
-- @param #number TargetThreatLevel Threat level of the target
|
||||||
|
-- @param #number PlayerThreatLevel Threat level of the player
|
||||||
|
-- @param #number Score The score based on both threat levels
|
||||||
|
function SCORING:OnKillPvP(PlayerName, TargetPlayerName, IsTeamKill, TargetThreatLevel, PlayerThreatLevel, Score)
|
||||||
|
|
||||||
|
end
|
||||||
|
--- Handles the event when one player kill another player
|
||||||
|
-- @param #SCORING self
|
||||||
|
-- @param #string PlayerName The attacking player
|
||||||
|
-- @param #string TargetUnitName the name of the killed unit
|
||||||
|
-- @param #boolean IsTeamKill true if this kill was a team kill
|
||||||
|
-- @param #number TargetThreatLevel Threat level of the target
|
||||||
|
-- @param #number PlayerThreatLevel Threat level of the player
|
||||||
|
-- @param #number Score The score based on both threat levels
|
||||||
|
function SCORING:OnKillPvE(PlayerName, TargetUnitName, IsTeamKill, TargetThreatLevel, PlayerThreatLevel, Score)
|
||||||
|
|
||||||
|
end
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [SEV - SEAD Evasion](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SEV%20-%20SEAD%20Evasion)
|
-- [SEV - SEAD Evasion](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/Sead)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### Authors: **FlightControl**, **applevangelist**
|
-- ### Authors: **applevangelist**, **FlightControl**
|
||||||
--
|
--
|
||||||
-- Last Update: Oct 2023
|
-- Last Update: Dec 2023
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -144,7 +144,7 @@ function SEAD:New( SEADGroupPrefixes, Padding )
|
|||||||
self:AddTransition("*", "ManageEvasion", "*")
|
self:AddTransition("*", "ManageEvasion", "*")
|
||||||
self:AddTransition("*", "CalculateHitZone", "*")
|
self:AddTransition("*", "CalculateHitZone", "*")
|
||||||
|
|
||||||
self:I("*** SEAD - Started Version 0.4.5")
|
self:I("*** SEAD - Started Version 0.4.6")
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -320,9 +320,6 @@ function SEAD:onafterCalculateHitZone(From,Event,To,SEADWeapon,pos0,height,SEADG
|
|||||||
end
|
end
|
||||||
|
|
||||||
local seadset = SET_GROUP:New():FilterPrefixes(self.SEADGroupPrefixes):FilterZones({targetzone}):FilterOnce()
|
local seadset = SET_GROUP:New():FilterPrefixes(self.SEADGroupPrefixes):FilterZones({targetzone}):FilterOnce()
|
||||||
local tgtcoord = targetzone:GetRandomPointVec2()
|
|
||||||
--if tgtcoord and tgtcoord.ClassName == "COORDINATE" then
|
|
||||||
--local tgtgrp = seadset:FindNearestGroupFromPointVec2(tgtcoord)
|
|
||||||
local tgtgrp = seadset:GetRandom()
|
local tgtgrp = seadset:GetRandom()
|
||||||
local _targetgroup = nil
|
local _targetgroup = nil
|
||||||
local _targetgroupname = "none"
|
local _targetgroupname = "none"
|
||||||
@@ -401,7 +398,7 @@ function SEAD:onafterManageEvasion(From,Event,To,_targetskill,_targetgroup,SEADP
|
|||||||
grp:EnableEmission(false)
|
grp:EnableEmission(false)
|
||||||
end
|
end
|
||||||
grp:OptionAlarmStateGreen() -- needed else we cannot move around
|
grp:OptionAlarmStateGreen() -- needed else we cannot move around
|
||||||
grp:RelocateGroundRandomInRadius(20,300,false,false,"Diamond")
|
grp:RelocateGroundRandomInRadius(20,300,false,false,"Diamond",true)
|
||||||
if self.UseCallBack then
|
if self.UseCallBack then
|
||||||
local object = self.CallBack
|
local object = self.CallBack
|
||||||
object:SeadSuppressionStart(grp,name,attacker)
|
object:SeadSuppressionStart(grp,name,attacker)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- ### [SHORAD - Short Range Air Defense](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SRD%20-%20SHORAD%20Defense)
|
-- ### [SHORAD - Short Range Air Defense](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/Shorad)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -41,10 +41,14 @@
|
|||||||
-- @field #boolean DefendMavs Default true, intercept incoming AG-Missiles
|
-- @field #boolean DefendMavs Default true, intercept incoming AG-Missiles
|
||||||
-- @field #number DefenseLowProb Default 70, minimum detection limit
|
-- @field #number DefenseLowProb Default 70, minimum detection limit
|
||||||
-- @field #number DefenseHighProb Default 90, maximum detection limit
|
-- @field #number DefenseHighProb Default 90, maximum detection limit
|
||||||
-- @field #boolean UseEmOnOff Decide if we are using Emission on/off (default) or AlarmState red/green.
|
-- @field #boolean UseEmOnOff Decide if we are using Emission on/off (default) or AlarmState red/green
|
||||||
-- @field #boolean shootandscoot
|
-- @field #boolean shootandscoot If true, shoot and scoot between zones
|
||||||
-- @field #number SkateNumber
|
-- @field #number SkateNumber Number of zones to consider
|
||||||
-- @field Core.Set#SET_ZONE SkateZones
|
-- @field Core.Set#SET_ZONE SkateZones Zones in this set are considered
|
||||||
|
-- @field #number minscootdist Min distance of the next zone
|
||||||
|
-- @field #number maxscootdist Max distance of the next zone
|
||||||
|
-- @field #boolean scootrandomcoord If true, use a random coordinate in the zone and not the center
|
||||||
|
-- @field #string scootformation Formation to take for scooting, e.g. "Vee" or "Cone"
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -77,14 +81,15 @@
|
|||||||
--
|
--
|
||||||
-- `myshorad = SHORAD:New("RedShorad", "Red SHORAD", SamSet, 25000, 600, "red")`
|
-- `myshorad = SHORAD:New("RedShorad", "Red SHORAD", SamSet, 25000, 600, "red")`
|
||||||
--
|
--
|
||||||
-- ## Customize options
|
-- ## Customization options
|
||||||
--
|
--
|
||||||
-- * SHORAD:SwitchDebug(debug)
|
-- * myshorad:SwitchDebug(debug)
|
||||||
-- * SHORAD:SwitchHARMDefense(onoff)
|
-- * myshorad:SwitchHARMDefense(onoff)
|
||||||
-- * SHORAD:SwitchAGMDefense(onoff)
|
-- * myshorad:SwitchAGMDefense(onoff)
|
||||||
-- * SHORAD:SetDefenseLimits(low,high)
|
-- * myshorad:SetDefenseLimits(low,high)
|
||||||
-- * SHORAD:SetActiveTimer(seconds)
|
-- * myshorad:SetActiveTimer(seconds)
|
||||||
-- * SHORAD:SetDefenseRadius(meters)
|
-- * myshorad:SetDefenseRadius(meters)
|
||||||
|
-- * myshorad:AddScootZones(ZoneSet,Number,Random,Formation)
|
||||||
--
|
--
|
||||||
-- @field #SHORAD
|
-- @field #SHORAD
|
||||||
SHORAD = {
|
SHORAD = {
|
||||||
@@ -107,6 +112,9 @@ SHORAD = {
|
|||||||
shootandscoot = false,
|
shootandscoot = false,
|
||||||
SkateNumber = 3,
|
SkateNumber = 3,
|
||||||
SkateZones = nil,
|
SkateZones = nil,
|
||||||
|
minscootdist = 100,
|
||||||
|
minscootdist = 3000,
|
||||||
|
scootrandomcoord = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@@ -174,7 +182,7 @@ do
|
|||||||
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
||||||
self.UseEmOnOff = true -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
self.UseEmOnOff = true -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
||||||
if UseEmOnOff == false then self.UseEmOnOff = UseEmOnOff end
|
if UseEmOnOff == false then self.UseEmOnOff = UseEmOnOff end
|
||||||
self:I("*** SHORAD - Started Version 0.3.2")
|
self:I("*** SHORAD - Started Version 0.3.4")
|
||||||
-- Set the string id for output to DCS.log file.
|
-- Set the string id for output to DCS.log file.
|
||||||
self.lid=string.format("SHORAD %s | ", self.name)
|
self.lid=string.format("SHORAD %s | ", self.name)
|
||||||
self:_InitState()
|
self:_InitState()
|
||||||
@@ -219,12 +227,16 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param Core.Set#SET_ZONE ZoneSet Set of zones to be used. Units will move around to the next (random) zone between 100m and 3000m away.
|
-- @param Core.Set#SET_ZONE ZoneSet Set of zones to be used. Units will move around to the next (random) zone between 100m and 3000m away.
|
||||||
-- @param #number Number Number of closest zones to be considered, defaults to 3.
|
-- @param #number Number Number of closest zones to be considered, defaults to 3.
|
||||||
|
-- @param #boolean Random If true, use a random coordinate inside the next zone to scoot to.
|
||||||
|
-- @param #string Formation Formation to use, defaults to "Cone". See mission editor dropdown for options.
|
||||||
-- @return #SHORAD self
|
-- @return #SHORAD self
|
||||||
function SHORAD:AddScootZones(ZoneSet, Number)
|
function SHORAD:AddScootZones(ZoneSet, Number, Random, Formation)
|
||||||
self:T(self.lid .. " AddScootZones")
|
self:T(self.lid .. " AddScootZones")
|
||||||
self.SkateZones = ZoneSet
|
self.SkateZones = ZoneSet
|
||||||
self.SkateNumber = Number or 3
|
self.SkateNumber = Number or 3
|
||||||
self.shootandscoot = true
|
self.shootandscoot = true
|
||||||
|
self.scootrandomcoord = Random
|
||||||
|
self.scootformation = Formation or "Cone"
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -613,8 +625,8 @@ do
|
|||||||
function SHORAD:onafterShootAndScoot(From,Event,To,Shorad)
|
function SHORAD:onafterShootAndScoot(From,Event,To,Shorad)
|
||||||
self:T( { From,Event,To } )
|
self:T( { From,Event,To } )
|
||||||
local possibleZones = {}
|
local possibleZones = {}
|
||||||
local mindist = 100
|
local mindist = self.minscootdist or 100
|
||||||
local maxdist = 3000
|
local maxdist = self.maxscootdist or 3000
|
||||||
if Shorad and Shorad:IsAlive() then
|
if Shorad and Shorad:IsAlive() then
|
||||||
local NowCoord = Shorad:GetCoordinate()
|
local NowCoord = Shorad:GetCoordinate()
|
||||||
for _,_zone in pairs(self.SkateZones.Set) do
|
for _,_zone in pairs(self.SkateZones.Set) do
|
||||||
@@ -630,7 +642,11 @@ do
|
|||||||
if rand == 0 then rand = 1 end
|
if rand == 0 then rand = 1 end
|
||||||
self:T(self.lid .. " ShootAndScoot to zone "..rand)
|
self:T(self.lid .. " ShootAndScoot to zone "..rand)
|
||||||
local ToCoordinate = possibleZones[rand]:GetCoordinate()
|
local ToCoordinate = possibleZones[rand]:GetCoordinate()
|
||||||
Shorad:RouteGroundTo(ToCoordinate,20,"Cone",1)
|
if self.scootrandomcoord then
|
||||||
|
ToCoordinate = possibleZones[rand]:GetRandomCoordinate(nil,nil,{land.SurfaceType.LAND,land.SurfaceType.ROAD})
|
||||||
|
end
|
||||||
|
local formation = self.scootformation or "Cone"
|
||||||
|
Shorad:RouteGroundTo(ToCoordinate,20,formation,1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
-- @field #number respawndelay Delay before respawn in seconds.
|
-- @field #number respawndelay Delay before respawn in seconds.
|
||||||
-- @field #number runwaydestroyed Time stamp timer.getAbsTime() when the runway was destroyed.
|
-- @field #number runwaydestroyed Time stamp timer.getAbsTime() when the runway was destroyed.
|
||||||
-- @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 Ops.FlightControl#FLIGHTCONTROL flightcontrol Flight control of this warehouse.
|
-- @field OPS.FlightControl#FLIGHTCONTROL flightcontrol Flight control of this warehouse.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- Have your assets at the right place at the right time - or not!
|
--- Have your assets at the right place at the right time - or not!
|
||||||
@@ -3414,7 +3414,7 @@ end
|
|||||||
-- FSM states
|
-- FSM states
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- On after Start event. Starts the warehouse. Addes event handlers and schedules status updates of reqests and queue.
|
--- On after Start event. Starts the warehouse. Adds event handlers and schedules status updates of reqests and queue.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
@@ -3595,6 +3595,7 @@ function WAREHOUSE:onafterStatus(From, Event, To)
|
|||||||
local Trepair=self:GetRunwayRepairtime()
|
local Trepair=self:GetRunwayRepairtime()
|
||||||
self:I(self.lid..string.format("Runway destroyed! Will be repaired in %d sec", Trepair))
|
self:I(self.lid..string.format("Runway destroyed! Will be repaired in %d sec", Trepair))
|
||||||
if Trepair==0 then
|
if Trepair==0 then
|
||||||
|
self.runwaydestroyed = nil
|
||||||
self:RunwayRepaired()
|
self:RunwayRepaired()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5393,6 +5394,7 @@ function WAREHOUSE:onafterRunwayDestroyed(From, Event, To)
|
|||||||
|
|
||||||
self.runwaydestroyed=timer.getAbsTime()
|
self.runwaydestroyed=timer.getAbsTime()
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "RunwayRepaired" event.
|
--- On after "RunwayRepaired" event.
|
||||||
@@ -5408,6 +5410,7 @@ function WAREHOUSE:onafterRunwayRepaired(From, Event, To)
|
|||||||
|
|
||||||
self.runwaydestroyed=nil
|
self.runwaydestroyed=nil
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -7405,6 +7408,8 @@ function WAREHOUSE:_CheckRequestNow(request)
|
|||||||
-- Check if at least one (cargo) asset is available.
|
-- Check if at least one (cargo) asset is available.
|
||||||
if _nassets>0 then
|
if _nassets>0 then
|
||||||
|
|
||||||
|
local asset=_assets[1] --#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
-- Get the attibute of the requested asset.
|
-- Get the attibute of the requested asset.
|
||||||
_assetattribute=_assets[1].attribute
|
_assetattribute=_assets[1].attribute
|
||||||
_assetcategory=_assets[1].category
|
_assetcategory=_assets[1].category
|
||||||
@@ -7415,6 +7420,19 @@ function WAREHOUSE:_CheckRequestNow(request)
|
|||||||
|
|
||||||
if self.airbase and self.airbase:GetCoalition()==self:GetCoalition() then
|
if self.airbase and self.airbase:GetCoalition()==self:GetCoalition() then
|
||||||
|
|
||||||
|
-- Check if DCS warehouse of airbase has enough assets
|
||||||
|
if self.airbase.storage then
|
||||||
|
local nS=self.airbase.storage:GetAmount(asset.unittype)
|
||||||
|
local nA=asset.nunits*request.nasset -- Number of units requested
|
||||||
|
if nS<nA then
|
||||||
|
local text=string.format("Warehouse %s: Request denied! DCS Warehouse has only %d assets of type %s ==> NOT enough to spawn the requested %d asset units (%d groups)",
|
||||||
|
self.alias, nS, asset.unittype, nA, request.nasset)
|
||||||
|
self:_InfoMessage(text, 5)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if self:IsRunwayOperational() or _assetairstart then
|
if self:IsRunwayOperational() or _assetairstart then
|
||||||
|
|
||||||
if _assetairstart then
|
if _assetairstart then
|
||||||
@@ -7531,6 +7549,9 @@ function WAREHOUSE:_CheckRequestNow(request)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif _assetcategory==Group.Category.AIRPLANE or _assetcategory==Group.Category.HELICOPTER then
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- [CAZ - Capture Zones](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/CAZ%20-%20Capture%20Zones)
|
-- [CAZ - Capture Zones](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/ZoneCaptureCoalition)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -1,149 +1,157 @@
|
|||||||
__Moose.Include( 'Scripts/Moose/Utilities/Enums.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Enums.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Utils.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Profiler.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Templates.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Templates.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/STTS.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/STTS.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/FiFo.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/FiFo.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Socket.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Socket.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Base.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Base.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Astar.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Astar.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Beacon.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Beacon.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Condition.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Condition.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/UserFlag.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/UserFlag.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Report.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Report.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Scheduler.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Scheduler.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/ScheduleDispatcher.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/ScheduleDispatcher.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Event.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Event.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Settings.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Settings.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Menu.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Menu.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Zone.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Zone.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Zone_Detection.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Zone_Detection.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Database.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Database.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Set.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Set.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Point.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Point.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Velocity.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Velocity.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Message.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Message.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Fsm.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Fsm.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Spawn.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Spawn.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/SpawnStatic.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/SpawnStatic.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Timer.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Timer.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Goal.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Goal.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Spot.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Spot.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/MarkerOps_Base.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/MarkerOps_Base.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/TextAndSound.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/TextAndSound.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Pathline.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Pathline.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Object.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Object.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Identifiable.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Identifiable.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Positionable.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Positionable.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Controllable.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Controllable.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Group.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Group.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Unit.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Unit.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Client.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Client.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Static.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Static.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Airbase.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Airbase.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Scenery.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Scenery.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Marker.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Marker.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Weapon.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Weapon.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Net.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Net.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Storage.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Storage.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Cargo/Cargo.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/Cargo.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Cargo/CargoUnit.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/CargoUnit.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Cargo/CargoSlingload.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/CargoSlingload.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Cargo/CargoCrate.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/CargoCrate.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Cargo/CargoGroup.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/CargoGroup.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Scoring.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Scoring.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/CleanUp.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/CleanUp.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Movement.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Movement.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Sead.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Sead.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Escort.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Escort.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/MissileTrainer.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/MissileTrainer.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/ATC_Ground.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ATC_Ground.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Detection.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Detection.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/DetectionZones.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/DetectionZones.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Designate.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Designate.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/RAT.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/RAT.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Range.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Range.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/ZoneGoal.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ZoneGoal.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/ZoneGoalCoalition.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ZoneGoalCoalition.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/ZoneCaptureCoalition.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ZoneCaptureCoalition.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Artillery.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Artillery.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Suppression.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Suppression.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/PseudoATC.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/PseudoATC.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Warehouse.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Warehouse.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Fox.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Fox.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Mantis.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Mantis.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Functional/Shorad.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Shorad.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Ops/Airboss.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Airboss.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Ops/RecoveryTanker.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/RecoveryTanker.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Ops/RescueHelo.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/RescueHelo.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Ops/ATIS.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/ATIS.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Ops/CTLD.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/CTLD.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Ops/CSAR.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/CSAR.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Balancer.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Balancer.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Air.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air_Patrol.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Air_Patrol.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air_Engage.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Air_Engage.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2A_Patrol.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2A_Patrol.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2A_Cap.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2A_Cap.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2A_Gci.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2A_Gci.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2A_Dispatcher.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2A_Dispatcher.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2G_BAI.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2G_BAI.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2G_CAS.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2G_CAS.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2G_SEAD.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2G_SEAD.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2G_Dispatcher.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2G_Dispatcher.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Patrol.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Patrol.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_CAP.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_CAP.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_CAS.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_CAS.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_BAI.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_BAI.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Formation.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Formation.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Escort.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Escort.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Escort_Request.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Escort_Request.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Escort_Dispatcher.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Escort_Dispatcher.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Escort_Dispatcher_Request.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Escort_Dispatcher_Request.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_APC.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_APC.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Helicopter.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Helicopter.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Airplane.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Airplane.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Ship.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Ship.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher_APC.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher_APC.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher_Airplane.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher_Airplane.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher_Ship.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher_Ship.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Actions/Act_Assign.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Assign.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Actions/Act_Route.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Route.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Actions/Act_Account.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Account.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Actions/Act_Assist.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Assist.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Sound/UserSound.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/ShapeBase.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Sound/SoundOutput.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Circle.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Sound/Radio.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Cube.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Sound/RadioQueue.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Line.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Sound/RadioSpeech.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Oval.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Sound/SRS.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Polygon.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Shapes/Triangle.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/CommandCenter.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/UserSound.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Mission.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/SoundOutput.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/Radio.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/TaskInfo.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/RadioQueue.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_Manager.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/RadioSpeech.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/DetectionManager.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/SRS.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_A2G_Dispatcher.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_A2G.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_A2A_Dispatcher.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_A2A.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_CARGO.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_Cargo_Transport.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_Cargo_CSAR.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_Cargo_Dispatcher.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_Capture_Zone.lua' )
|
|
||||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_Capture_Dispatcher.lua' )
|
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Globals.lua' )
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/CommandCenter.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Mission.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/TaskInfo.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_Manager.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/DetectionManager.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_A2G_Dispatcher.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_A2G.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_A2A_Dispatcher.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_A2A.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_CARGO.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_Cargo_Transport.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_Cargo_CSAR.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_Cargo_Dispatcher.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_Capture_Zone.lua' )
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Tasking/Task_Capture_Dispatcher.lua' )
|
||||||
|
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Globals.lua' )
|
||||||
|
|||||||
@@ -316,6 +316,12 @@
|
|||||||
--
|
--
|
||||||
-- This uses a male voice with US accent. It requires SRS to be installed in the `D:\DCS\_SRS\` directory. Note that backslashes need to be escaped or simply use slashes (as in linux).
|
-- This uses a male voice with US accent. It requires SRS to be installed in the `D:\DCS\_SRS\` directory. Note that backslashes need to be escaped or simply use slashes (as in linux).
|
||||||
--
|
--
|
||||||
|
-- ### SRS can use multiple frequencies:
|
||||||
|
--
|
||||||
|
-- atis=ATIS:New("Batumi", {305,103.85}, {radio.modulation.AM,radio.modulation.FM})
|
||||||
|
-- atis:SetSRS("D:\\DCS\\_SRS\\", "male", "en-US")
|
||||||
|
-- atis:Start()
|
||||||
|
--
|
||||||
-- ### SRS Localization
|
-- ### SRS Localization
|
||||||
--
|
--
|
||||||
-- You can localize the SRS output, all you need is to provide a table of translations and set the `locale` of your instance. You need to provide the translations in your script **before you instantiate your ATIS**.
|
-- You can localize the SRS output, all you need is to provide a table of translations and set the `locale` of your instance. You need to provide the translations in your script **before you instantiate your ATIS**.
|
||||||
@@ -694,7 +700,7 @@ ATIS.Messages = {
|
|||||||
EN =
|
EN =
|
||||||
{
|
{
|
||||||
HOURS = "hours",
|
HOURS = "hours",
|
||||||
TIME = "hours",
|
TIME = "Hours",
|
||||||
NOCLOUDINFO = "Cloud coverage information not available",
|
NOCLOUDINFO = "Cloud coverage information not available",
|
||||||
OVERCAST = "Overcast",
|
OVERCAST = "Overcast",
|
||||||
BROKEN = "Broken clouds",
|
BROKEN = "Broken clouds",
|
||||||
@@ -884,13 +890,14 @@ _ATIS = {}
|
|||||||
|
|
||||||
--- ATIS class version.
|
--- ATIS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
ATIS.version = "0.10.3"
|
ATIS.version = "1.0.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- TODO: Correct fog for elevation.
|
-- TODO: Correct fog for elevation.
|
||||||
|
-- DONE: Option to add multiple frequencies for SRS
|
||||||
-- DONE: Zulu time --> Zulu in output.
|
-- DONE: Zulu time --> Zulu in output.
|
||||||
-- DONE: Fix for AB not having a runway - Helopost like Naqoura
|
-- DONE: Fix for AB not having a runway - Helopost like Naqoura
|
||||||
-- DONE: Add new Normandy airfields.
|
-- DONE: Add new Normandy airfields.
|
||||||
@@ -899,7 +906,7 @@ ATIS.version = "0.10.3"
|
|||||||
-- DONE: Visibility reported twice over SRS
|
-- DONE: Visibility reported twice over SRS
|
||||||
-- DONE: Add text report for output.
|
-- DONE: Add text report for output.
|
||||||
-- DONE: Add stop FMS functions.
|
-- DONE: Add stop FMS functions.
|
||||||
-- NOGO: Use local time. Not realisitc!
|
-- NOGO: Use local time. Not realistic!
|
||||||
-- DONE: Dew point. Approx. done.
|
-- DONE: Dew point. Approx. done.
|
||||||
-- DONE: Metric units.
|
-- DONE: Metric units.
|
||||||
-- DONE: Set UTC correction.
|
-- DONE: Set UTC correction.
|
||||||
@@ -915,8 +922,8 @@ ATIS.version = "0.10.3"
|
|||||||
--- Create a new ATIS class object for a specific airbase.
|
--- Create a new ATIS class object for a specific airbase.
|
||||||
-- @param #ATIS self
|
-- @param #ATIS self
|
||||||
-- @param #string AirbaseName Name of the airbase.
|
-- @param #string AirbaseName Name of the airbase.
|
||||||
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz.
|
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz. When using **SRS** this can be passed as a table of multiple frequencies.
|
||||||
-- @param #number Modulation Radio modulation: 0=AM, 1=FM. Default 0=AM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators.
|
-- @param #number Modulation Radio modulation: 0=AM, 1=FM. Default 0=AM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators. When using **SRS** this can be passed as a table of multiple modulations.
|
||||||
-- @return #ATIS self
|
-- @return #ATIS self
|
||||||
function ATIS:New(AirbaseName, Frequency, Modulation)
|
function ATIS:New(AirbaseName, Frequency, Modulation)
|
||||||
|
|
||||||
@@ -1519,34 +1526,62 @@ function ATIS:MarkRunways( markall )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Use SRS Simple-Text-To-Speech for transmissions. No sound files necessary.
|
--- Use SRS Simple-Text-To-Speech for transmissions. No sound files necessary.`SetSRS()` will try to use as many attributes configured with @{Sound.SRS#MSRS.LoadConfigFile}() as possible.
|
||||||
-- @param #ATIS self
|
-- @param #ATIS self
|
||||||
-- @param #string PathToSRS Path to SRS directory.
|
-- @param #string PathToSRS Path to SRS directory (only necessary if SRS exe backend is used).
|
||||||
-- @param #string Gender Gender: "male" or "female" (default).
|
-- @param #string Gender Gender: "male" or "female" (default).
|
||||||
-- @param #string Culture Culture, e.g. "en-GB" (default).
|
-- @param #string Culture Culture, e.g. "en-GB" (default).
|
||||||
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`.
|
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`.
|
||||||
-- @param #number Port SRS port. Default 5002.
|
-- @param #number Port SRS port. Default 5002.
|
||||||
-- @param #string GoogleKey Path to Google JSON-Key.
|
-- @param #string GoogleKey Path to Google JSON-Key (SRS exe backend) or Google API key (DCS-gRPC backend).
|
||||||
-- @return #ATIS self
|
-- @return #ATIS self
|
||||||
function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port, GoogleKey)
|
function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port, GoogleKey)
|
||||||
if PathToSRS or MSRS.path then
|
--if PathToSRS or MSRS.path then
|
||||||
self.useSRS=true
|
self.useSRS=true
|
||||||
self.msrs=MSRS:New(PathToSRS, self.frequency, self.modulation)
|
|
||||||
self.msrs:SetGender(Gender)
|
local path = PathToSRS or MSRS.path
|
||||||
self.msrs:SetCulture(Culture)
|
local gender = Gender or MSRS.gender
|
||||||
self.msrs:SetVoice(Voice)
|
local culture = Culture or MSRS.culture
|
||||||
self.msrs:SetPort(Port)
|
local voice = Voice or MSRS.voice
|
||||||
|
local port = Port or MSRS.port or 5002
|
||||||
|
|
||||||
|
self.msrs=MSRS:New(path, self.frequency, self.modulation)
|
||||||
|
self.msrs:SetGender(gender)
|
||||||
|
self.msrs:SetCulture(culture)
|
||||||
|
self.msrs:SetPort(port)
|
||||||
self.msrs:SetCoalition(self:GetCoalition())
|
self.msrs:SetCoalition(self:GetCoalition())
|
||||||
self.msrs:SetLabel("ATIS")
|
self.msrs:SetLabel("ATIS")
|
||||||
self.msrs:SetGoogle(GoogleKey)
|
if GoogleKey then
|
||||||
|
self.msrs:SetProviderOptionsGoogle(GoogleKey,GoogleKey)
|
||||||
|
self.msrs:SetProvider(MSRS.Provider.GOOGLE)
|
||||||
|
end
|
||||||
|
-- Pre-configured Google?
|
||||||
|
if (not GoogleKey) and self.msrs:GetProvider() == MSRS.Provider.GOOGLE then
|
||||||
|
voice = Voice or MSRS.poptions.gcloud.voice
|
||||||
|
end
|
||||||
|
self.msrs:SetVoice(voice)
|
||||||
self.msrs:SetCoordinate(self.airbase:GetCoordinate())
|
self.msrs:SetCoordinate(self.airbase:GetCoordinate())
|
||||||
self.msrsQ = MSRSQUEUE:New("ATIS")
|
self.msrsQ = MSRSQUEUE:New("ATIS")
|
||||||
self.msrsQ:SetTransmitOnlyWithPlayers(self.TransmitOnlyWithPlayers)
|
self.msrsQ:SetTransmitOnlyWithPlayers(self.TransmitOnlyWithPlayers)
|
||||||
if self.dTQueueCheck<=10 then
|
if self.dTQueueCheck<=10 then
|
||||||
self:SetQueueUpdateTime(90)
|
self:SetQueueUpdateTime(90)
|
||||||
end
|
end
|
||||||
|
--else
|
||||||
|
--self:E(self.lid..string.format("ERROR: No SRS path specified!"))
|
||||||
|
--end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set an alternative provider to the one set in your MSRS configuration file.
|
||||||
|
-- @param #ATIS self
|
||||||
|
-- @param #string Provider The provider to use. Known providers are: `MSRS.Provider.WINDOWS` and `MSRS.Provider.GOOGLE`
|
||||||
|
-- @return #ATIS self
|
||||||
|
function ATIS:SetSRSProvider(Provider)
|
||||||
|
self:T(self.lid.."SetSRSProvider")
|
||||||
|
if self.msrs then
|
||||||
|
self.msrs:SetProvider(Provider)
|
||||||
else
|
else
|
||||||
self:E(self.lid..string.format("ERROR: No SRS path specified!"))
|
MESSAGE:New(self.lid.."Set up SRS first before trying to change the provider!",30,"ATIS"):ToAll():ToLog()
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -1594,8 +1629,16 @@ function ATIS:onafterStart( From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Info.
|
-- Info.
|
||||||
self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation ) )
|
if type(self.frequency) == "table" then
|
||||||
|
local frequency = table.concat(self.frequency,"/")
|
||||||
|
local modulation = self.modulation
|
||||||
|
if type(self.modulation) == "table" then
|
||||||
|
modulation = table.concat(self.modulation,"/")
|
||||||
|
end
|
||||||
|
self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %s MHz Modulation=%s", ATIS.version, self.airbasename, frequency, modulation ) )
|
||||||
|
else
|
||||||
|
self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation ) )
|
||||||
|
end
|
||||||
-- Start radio queue.
|
-- Start radio queue.
|
||||||
if not self.useSRS then
|
if not self.useSRS then
|
||||||
self.radioqueue = RADIOQUEUE:New( self.frequency, self.modulation, string.format( "ATIS %s", self.airbasename ) )
|
self.radioqueue = RADIOQUEUE:New( self.frequency, self.modulation, string.format( "ATIS %s", self.airbasename ) )
|
||||||
@@ -1653,7 +1696,17 @@ function ATIS:onafterStatus( From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Info text.
|
-- Info text.
|
||||||
local text = string.format( "State %s: Freq=%.3f MHz %s", fsmstate, self.frequency, UTILS.GetModulationName( self.modulation ) )
|
local text = ""
|
||||||
|
if type(self.frequency) == "table" then
|
||||||
|
local frequency = table.concat(self.frequency,"/")
|
||||||
|
local modulation = self.modulation
|
||||||
|
if type(self.modulation) == "table" then
|
||||||
|
modulation = table.concat(self.modulation,"/")
|
||||||
|
end
|
||||||
|
text = string.format( "State %s: Freq=%s MHz %s", fsmstate, frequency, modulation )
|
||||||
|
else
|
||||||
|
text = string.format( "State %s: Freq=%.3f MHz %s", fsmstate, self.frequency, UTILS.GetModulationName( self.modulation ) )
|
||||||
|
end
|
||||||
if self.useSRS then
|
if self.useSRS then
|
||||||
text = text .. string.format( ", SRS path=%s (%s), gender=%s, culture=%s, voice=%s", tostring( self.msrs.path ), tostring( self.msrs.port ), tostring( self.msrs.gender ), tostring( self.msrs.culture ), tostring( self.msrs.voice ) )
|
text = text .. string.format( ", SRS path=%s (%s), gender=%s, culture=%s, voice=%s", tostring( self.msrs.path ), tostring( self.msrs.port ), tostring( self.msrs.gender ), tostring( self.msrs.culture ), tostring( self.msrs.voice ) )
|
||||||
else
|
else
|
||||||
@@ -2919,8 +2972,17 @@ function ATIS:UpdateMarker( information, runact, wind, altimeter, temperature )
|
|||||||
if self.markerid then
|
if self.markerid then
|
||||||
self.airbase:GetCoordinate():RemoveMark( self.markerid )
|
self.airbase:GetCoordinate():RemoveMark( self.markerid )
|
||||||
end
|
end
|
||||||
|
local text = ""
|
||||||
local text = string.format( "ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName( self.modulation ), tostring( information ) )
|
if type(self.frequency) == "table" then
|
||||||
|
local frequency = table.concat(self.frequency,"/")
|
||||||
|
local modulation = self.modulation
|
||||||
|
if type(modulation) == "table" then
|
||||||
|
modulation = table.concat(self.modulation,"/")
|
||||||
|
end
|
||||||
|
text = string.format( "ATIS on %s %s, %s:\n", tostring(frequency), tostring(modulation), tostring( information ) )
|
||||||
|
else
|
||||||
|
text = string.format( "ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName( self.modulation ), tostring( information ) )
|
||||||
|
end
|
||||||
text = text .. string.format( "%s\n", tostring( runact ) )
|
text = text .. string.format( "%s\n", tostring( runact ) )
|
||||||
text = text .. string.format( "%s\n", tostring( wind ) )
|
text = text .. string.format( "%s\n", tostring( wind ) )
|
||||||
text = text .. string.format( "%s\n", tostring( altimeter ) )
|
text = text .. string.format( "%s\n", tostring( altimeter ) )
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Example Missions
|
-- ## Example Missions
|
||||||
--
|
--
|
||||||
-- Example missions can be found [here](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Airboss).
|
-- Example missions can be found [here](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Ops/Airboss).
|
||||||
-- They contain the latest development Moose.lua file.
|
-- They contain the latest development Moose.lua file.
|
||||||
--
|
--
|
||||||
-- ## IMPORTANT
|
-- ## IMPORTANT
|
||||||
@@ -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!
|
||||||
@@ -1746,7 +1747,7 @@ AIRBOSS.MenuF10Root = nil
|
|||||||
|
|
||||||
--- Airboss class version.
|
--- Airboss class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AIRBOSS.version = "1.3.2"
|
AIRBOSS.version = "1.3.3"
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -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.
|
||||||
@@ -3062,7 +3075,7 @@ function AIRBOSS:EnableSRS(PathToSRS,Port,Culture,Gender,Voice,GoogleCreds,Volum
|
|||||||
-- SRS
|
-- SRS
|
||||||
local Frequency = self.AirbossRadio.frequency
|
local Frequency = self.AirbossRadio.frequency
|
||||||
local Modulation = self.AirbossRadio.modulation
|
local Modulation = self.AirbossRadio.modulation
|
||||||
self.SRS = MSRS:New(PathToSRS,Frequency,Modulation,Volume,AltBackend)
|
self.SRS = MSRS:New(PathToSRS,Frequency,Modulation,AltBackend)
|
||||||
self.SRS:SetCoalition(self:GetCoalition())
|
self.SRS:SetCoalition(self:GetCoalition())
|
||||||
self.SRS:SetCoordinate(self:GetCoordinate())
|
self.SRS:SetCoordinate(self:GetCoordinate())
|
||||||
self.SRS:SetCulture(Culture or "en-US")
|
self.SRS:SetCulture(Culture or "en-US")
|
||||||
@@ -3071,6 +3084,8 @@ function AIRBOSS:EnableSRS(PathToSRS,Port,Culture,Gender,Voice,GoogleCreds,Volum
|
|||||||
self.SRS:SetPath(PathToSRS)
|
self.SRS:SetPath(PathToSRS)
|
||||||
self.SRS:SetPort(Port or 5002)
|
self.SRS:SetPort(Port or 5002)
|
||||||
self.SRS:SetLabel(self.AirbossRadio.alias or "AIRBOSS")
|
self.SRS:SetLabel(self.AirbossRadio.alias or "AIRBOSS")
|
||||||
|
self.SRS:SetCoordinate(self.carrier:GetCoordinate())
|
||||||
|
self.SRS:SetVolume(Volume or 1)
|
||||||
--self.SRS:SetModulations(Modulations)
|
--self.SRS:SetModulations(Modulations)
|
||||||
if GoogleCreds then
|
if GoogleCreds then
|
||||||
self.SRS:SetGoogle(GoogleCreds)
|
self.SRS:SetGoogle(GoogleCreds)
|
||||||
@@ -3639,6 +3654,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))
|
||||||
|
|
||||||
@@ -5198,6 +5219,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 },
|
||||||
@@ -6472,7 +6494,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 )
|
||||||
@@ -8211,7 +8233,7 @@ function AIRBOSS:OnEventBirth( EventData )
|
|||||||
self:E( EventData )
|
self:E( EventData )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if EventData.IniUnit == nil then
|
if EventData.IniUnit == nil and (not EventData.IniObjectCategory == Object.Category.STATIC) then
|
||||||
self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event BIRTH!" )
|
self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event BIRTH!" )
|
||||||
self:E( EventData )
|
self:E( EventData )
|
||||||
return
|
return
|
||||||
@@ -9752,7 +9774,7 @@ function AIRBOSS:_Groove( playerData )
|
|||||||
local glideslopeError = groovedata.GSE
|
local glideslopeError = groovedata.GSE
|
||||||
local AoA = groovedata.AoA
|
local AoA = groovedata.AoA
|
||||||
|
|
||||||
if rho <= RXX and playerData.step == AIRBOSS.PatternStep.GROOVE_XX and (math.abs( groovedata.Roll ) <= 4.0 or playerData.unit:IsInZone( self:_GetZoneLineup() )) then
|
if rho <= RXX and playerData.step == AIRBOSS.PatternStep.GROOVE_XX and (math.abs( groovedata.Roll ) <= 4.0 and playerData.unit:IsInZone( self:_GetZoneLineup() )) then
|
||||||
|
|
||||||
-- Start time in groove
|
-- Start time in groove
|
||||||
playerData.TIG0 = timer.getTime()
|
playerData.TIG0 = timer.getTime()
|
||||||
@@ -10266,7 +10288,7 @@ function AIRBOSS:_GetSternCoord()
|
|||||||
elseif case==2 or case==1 then
|
elseif case==2 or case==1 then
|
||||||
-- V/Stol: Translate 8 meters port.
|
-- V/Stol: Translate 8 meters port.
|
||||||
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true)
|
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true)
|
||||||
end
|
end
|
||||||
elseif self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
elseif self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
||||||
-- Stennis: translate 7 meters starboard wrt Final bearing.
|
-- Stennis: translate 7 meters starboard wrt Final bearing.
|
||||||
self.sterncoord:Translate( self.carrierparam.sterndist, hdg, true, true ):Translate( 7, FB + 90, true, true )
|
self.sterncoord:Translate( self.carrierparam.sterndist, hdg, true, true ):Translate( 7, FB + 90, true, true )
|
||||||
@@ -11196,7 +11218,7 @@ function AIRBOSS:_AttitudeMonitor( playerData )
|
|||||||
end
|
end
|
||||||
text = text .. string.format( "\nPitch=%.1f° | Roll=%.1f° | Yaw=%.1f°", pitch, roll, yaw )
|
text = text .. string.format( "\nPitch=%.1f° | Roll=%.1f° | Yaw=%.1f°", pitch, roll, yaw )
|
||||||
text = text .. string.format( "\nClimb Angle=%.1f° | Rate=%d ft/min", unit:GetClimbAngle(), velo.y * 196.85 )
|
text = text .. string.format( "\nClimb Angle=%.1f° | Rate=%d ft/min", unit:GetClimbAngle(), velo.y * 196.85 )
|
||||||
local dist = self:_GetOptLandingCoordinate():Get3DDistance( playerData.unit )
|
local dist = self:_GetOptLandingCoordinate():Get3DDistance( playerData.unit:GetVec3() )
|
||||||
-- Get player velocity in km/h.
|
-- Get player velocity in km/h.
|
||||||
local vplayer = playerData.unit:GetVelocityKMH()
|
local vplayer = playerData.unit:GetVelocityKMH()
|
||||||
-- Get carrier velocity in km/h.
|
-- Get carrier velocity in km/h.
|
||||||
@@ -11473,7 +11495,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.
|
||||||
@@ -11545,10 +11567,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
|
||||||
@@ -11605,7 +11648,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.
|
||||||
@@ -11616,7 +11665,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
|
||||||
@@ -12120,16 +12169,18 @@ function AIRBOSS:_LSOgrade( playerData )
|
|||||||
local GIC, nIC = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.IC )
|
local GIC, nIC = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.IC )
|
||||||
local GAR, nAR = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.AR )
|
local GAR, nAR = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.AR )
|
||||||
|
|
||||||
|
-- VTOL approach, which is graded differently (currently only Harrier).
|
||||||
|
local vtol=playerData.actype==AIRBOSS.AircraftCarrier.AV8B
|
||||||
|
|
||||||
-- Put everything together.
|
-- Put everything together.
|
||||||
local G = GXX .. " " .. GIM .. " " .. " " .. GIC .. " " .. GAR
|
local G = GXX .. " " .. GIM .. " " .. " " .. GIC .. " " .. GAR
|
||||||
|
|
||||||
-- Count number of minor, normal and major deviations.
|
-- Count number of minor/small nS, normal nN and major/large deviations nL.
|
||||||
local N=nXX+nIM+nIC+nAR
|
local N=nXX+nIM+nIC+nAR
|
||||||
local Nv=nXX+nIM
|
|
||||||
local nL=count(G, '_')/2
|
local nL=count(G, '_')/2
|
||||||
local nS=count(G, '%(')
|
local nS=count(G, '%(')
|
||||||
local nN=N-nS-nL
|
local nN=N-nS-nL
|
||||||
local nNv=Nv-nS-nL
|
|
||||||
|
|
||||||
-- Groove time 15-18.99 sec for a unicorn. Or 60-65 for V/STOL unicorn.
|
-- Groove time 15-18.99 sec for a unicorn. Or 60-65 for V/STOL unicorn.
|
||||||
local Tgroove=playerData.Tgroove
|
local Tgroove=playerData.Tgroove
|
||||||
@@ -12145,34 +12196,64 @@ function AIRBOSS:_LSOgrade( playerData )
|
|||||||
G = "Unicorn"
|
G = "Unicorn"
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Add AV-8B Harrier devation allowances due to lower groundspeed and 3x conventional groove time, this allows to maintain LSO tolerances while respecting the deviations are not unsafe.--Pene testing
|
if vtol then
|
||||||
-- Large devaitions still result in a No Grade, A Unicorn still requires a clean pass with no deviation.
|
|
||||||
if nL > 1 and playerData.actype==AIRBOSS.AircraftCarrier.AV8B then
|
|
||||||
-- Larger deviations ==> "No grade" 2.0 points.
|
|
||||||
grade="--"
|
|
||||||
points=2.0
|
|
||||||
elseif nNv >= 1 and playerData.actype==AIRBOSS.AircraftCarrier.AV8B then
|
|
||||||
-- Only average deviations ==> "Fair Pass" Pass with average deviations and corrections.
|
|
||||||
grade="(OK)"
|
|
||||||
points=3.0
|
|
||||||
elseif nNv < 1 and playerData.actype==AIRBOSS.AircraftCarrier.AV8B then
|
|
||||||
-- Only minor average deviations ==> "OK" Pass with minor deviations and corrections. (test nNv<=1 and)
|
|
||||||
grade="OK"
|
|
||||||
points=4.0
|
|
||||||
elseif nL > 0 then
|
|
||||||
-- Larger deviations ==> "No grade" 2.0 points.
|
|
||||||
grade="--"
|
|
||||||
points=2.0
|
|
||||||
elseif nN> 0 then
|
|
||||||
-- No larger but average deviations ==> "Fair Pass" Pass with average deviations and corrections.
|
|
||||||
grade="(OK)"
|
|
||||||
points=3.0
|
|
||||||
else
|
|
||||||
-- Only minor corrections
|
|
||||||
grade="OK"
|
|
||||||
points=4.0
|
|
||||||
end
|
|
||||||
|
|
||||||
|
-- Add AV-8B Harrier devation allowances due to lower groundspeed and 3x conventional groove time, this allows to maintain LSO tolerances while respecting the deviations are not unsafe.--Pene testing
|
||||||
|
-- Large devaitions still result in a No Grade, A Unicorn still requires a clean pass with no deviation.
|
||||||
|
|
||||||
|
-- Normal laning part at the beginning
|
||||||
|
local Gb = GXX .. " " .. GIM
|
||||||
|
|
||||||
|
-- Number of deviations that occurred at the the beginning of the landing (XX or IM). These are graded like in non-VTOL landings, i.e. on deviations is
|
||||||
|
local N=nXX+nIM
|
||||||
|
local nL=count(Gb, '_')/2
|
||||||
|
local nS=count(Gb, '%(')
|
||||||
|
local nN=N-nS-nL
|
||||||
|
|
||||||
|
|
||||||
|
-- VTOL part of the landing
|
||||||
|
local Gv = GIC .. " " .. GAR
|
||||||
|
|
||||||
|
-- Number of deviations that occurred at the the end (VTOL part) of the landing (IC or AR).
|
||||||
|
local Nv=nIC+nAR
|
||||||
|
local nLv=count(Gv, '_')/2
|
||||||
|
local nSv=count(Gv, '%(')
|
||||||
|
local nNv=Nv-nSv-nLv
|
||||||
|
|
||||||
|
if nL>0 or nLv>1 then
|
||||||
|
-- Larger deviations at XX or IM or at least one larger deviation IC or AR==> "No grade" 2.0 points.
|
||||||
|
-- In other words, we allow one larger deviation at IC+AR
|
||||||
|
grade="--"
|
||||||
|
points=2.0
|
||||||
|
elseif nN>0 or nNv>1 or nLv==1 then
|
||||||
|
-- Average deviations at XX+IM or more than one normal deviation IC or AR ==> "Fair Pass" Pass with average deviations and corrections.
|
||||||
|
grade="(OK)"
|
||||||
|
points=3.0
|
||||||
|
else
|
||||||
|
-- Only minor corrections
|
||||||
|
grade="OK"
|
||||||
|
points=4.0
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- This is a normal (non-VTOL) landing.
|
||||||
|
|
||||||
|
if nL > 0 then
|
||||||
|
-- Larger deviations ==> "No grade" 2.0 points.
|
||||||
|
grade="--"
|
||||||
|
points=2.0
|
||||||
|
elseif nN> 0 then
|
||||||
|
-- No larger but average/normal deviations ==> "Fair Pass" Pass with average deviations and corrections.
|
||||||
|
grade="(OK)"
|
||||||
|
points=3.0
|
||||||
|
else
|
||||||
|
-- Only minor corrections ==> "Okay pass" 4.0 points.
|
||||||
|
grade="OK"
|
||||||
|
points=4.0
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Replace" )"( and "__"
|
-- Replace" )"( and "__"
|
||||||
@@ -14245,6 +14326,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
|
||||||
@@ -14881,6 +14964,7 @@ function AIRBOSS:RadioTransmission( radio, call, loud, delay, interval, click, p
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- SRS transmission
|
-- SRS transmission
|
||||||
if call.subtitle ~= nil and string.len(call.subtitle) > 1 then
|
if call.subtitle ~= nil and string.len(call.subtitle) > 1 then
|
||||||
|
|
||||||
@@ -14955,7 +15039,7 @@ function AIRBOSS:SetSRSPilotVoice( Voice, Gender, Culture )
|
|||||||
self.PilotRadio.gender = Gender or "male"
|
self.PilotRadio.gender = Gender or "male"
|
||||||
self.PilotRadio.culture = Culture or "en-US"
|
self.PilotRadio.culture = Culture or "en-US"
|
||||||
|
|
||||||
if (not Voice) and self.SRS and self.SRS.google then
|
if (not Voice) and self.SRS and self.SRS:GetProvider() == MSRS.Provider.GOOGLE then
|
||||||
self.PilotRadio.voice = MSRS.Voices.Google.Standard.en_US_Standard_J
|
self.PilotRadio.voice = MSRS.Voices.Google.Standard.en_US_Standard_J
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -15604,6 +15688,11 @@ function AIRBOSS:_Number2Radio( radio, number, delay, interval, pilotcall )
|
|||||||
Sender = "PilotCall"
|
Sender = "PilotCall"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Sender=="" then
|
||||||
|
self:E( self.lid .. string.format( "ERROR: Sender unknown!") )
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Split string into characters.
|
-- Split string into characters.
|
||||||
local numbers = _split( number )
|
local numbers = _split( number )
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- ### [CSAR - Combat Search & Rescue](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20CSAR)
|
-- ### [CSAR - Combat Search & Rescue](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/CSAR)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
-- @module Ops.CSAR
|
-- @module Ops.CSAR
|
||||||
-- @image OPS_CSAR.jpg
|
-- @image OPS_CSAR.jpg
|
||||||
|
|
||||||
-- Date: May 2023
|
---
|
||||||
-- Last: Update Oct 2024
|
-- Last Update April 2024
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
||||||
@@ -290,10 +290,13 @@ CSAR.AircraftType["Bell-47"] = 2
|
|||||||
CSAR.AircraftType["UH-60L"] = 10
|
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["OH-6A"] = 2
|
||||||
|
CSAR.AircraftType["OH-58D"] = 2
|
||||||
|
|
||||||
--- CSAR class version.
|
--- CSAR class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CSAR.version="1.0.18"
|
CSAR.version="1.0.24"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@@ -462,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
|
||||||
@@ -536,6 +539,7 @@ function CSAR:New(Coalition, Template, Alias)
|
|||||||
-- @param #number Frequency Beacon frequency in kHz.
|
-- @param #number Frequency Beacon frequency in kHz.
|
||||||
-- @param #string Leadername Name of the #UNIT of the downed pilot.
|
-- @param #string Leadername Name of the #UNIT of the downed pilot.
|
||||||
-- @param #string CoordinatesText String of the position of the pilot. Format determined by self.coordtype.
|
-- @param #string CoordinatesText String of the position of the pilot. Format determined by self.coordtype.
|
||||||
|
-- @param #string Playername Player name if any given. Might be nil!
|
||||||
|
|
||||||
--- On After "Aproach" event. Heli close to downed Pilot.
|
--- On After "Aproach" event. Heli close to downed Pilot.
|
||||||
-- @function [parent=#CSAR] OnAfterApproach
|
-- @function [parent=#CSAR] OnAfterApproach
|
||||||
@@ -732,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)
|
||||||
|
|
||||||
@@ -842,7 +846,7 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
|
|||||||
|
|
||||||
self:_CreateDownedPilotTrack(_spawnedGroup,_GroupName,_coalition,_unitName,_text,_typeName,_freq,_playerName,wetfeet)
|
self:_CreateDownedPilotTrack(_spawnedGroup,_GroupName,_coalition,_unitName,_text,_typeName,_freq,_playerName,wetfeet)
|
||||||
|
|
||||||
self:_InitSARForPilot(_spawnedGroup, _unitName, _freq, noMessage) --shagrat use unitName to have the aircraft callsign / descriptive "name" etc.
|
self:_InitSARForPilot(_spawnedGroup, _unitName, _freq, noMessage, _playerName) --shagrat use unitName to have the aircraft callsign / descriptive "name" etc.
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -1188,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
|
||||||
@@ -1224,7 +1228,8 @@ end
|
|||||||
-- @param #string _GroupName Name of the Group
|
-- @param #string _GroupName Name of the Group
|
||||||
-- @param #number _freq Beacon frequency.
|
-- @param #number _freq Beacon frequency.
|
||||||
-- @param #boolean _nomessage Send message true or false.
|
-- @param #boolean _nomessage Send message true or false.
|
||||||
function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
-- @param #string _playername Name of the downed pilot if any
|
||||||
|
function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage, _playername)
|
||||||
self:T(self.lid .. " _InitSARForPilot")
|
self:T(self.lid .. " _InitSARForPilot")
|
||||||
local _leader = _downedGroup:GetUnit(1)
|
local _leader = _downedGroup:GetUnit(1)
|
||||||
local _groupName = _GroupName
|
local _groupName = _GroupName
|
||||||
@@ -1235,10 +1240,24 @@ function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
|||||||
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
|
||||||
|
|
||||||
@@ -1247,7 +1266,7 @@ function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- trigger FSM event
|
-- trigger FSM event
|
||||||
self:__PilotDown(2,_downedGroup, _freqk, _groupName, _coordinatesText)
|
self:__PilotDown(2,_downedGroup, _freqk, _groupName, _coordinatesText, _playername)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -1526,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)
|
||||||
@@ -1535,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()
|
||||||
@@ -1553,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
|
||||||
@@ -1565,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
|
||||||
@@ -1594,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
|
||||||
@@ -1604,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
|
||||||
@@ -1644,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)
|
||||||
@@ -1664,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
|
||||||
|
|
||||||
@@ -1749,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
|
||||||
@@ -1918,21 +1963,26 @@ end
|
|||||||
-- @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.google == nil 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
|
||||||
@@ -1978,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
|
||||||
@@ -2216,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
|
||||||
@@ -2310,7 +2360,8 @@ function CSAR:onafterStart(From, Event, To)
|
|||||||
self.msrs:SetVoice(self.SRSVoice)
|
self.msrs:SetVoice(self.SRSVoice)
|
||||||
self.msrs:SetGender(self.SRSGender)
|
self.msrs:SetGender(self.SRSGender)
|
||||||
if self.SRSGPathToCredentials then
|
if self.SRSGPathToCredentials then
|
||||||
self.msrs:SetGoogle(self.SRSGPathToCredentials)
|
self.msrs:SetProviderOptionsGoogle(self.SRSGPathToCredentials,self.SRSGPathToCredentials)
|
||||||
|
self.msrs:SetProvider(MSRS.Provider.GOOGLE)
|
||||||
end
|
end
|
||||||
self.msrs:SetVolume(self.SRSVolume)
|
self.msrs:SetVolume(self.SRSVolume)
|
||||||
self.msrs:SetLabel("CSAR")
|
self.msrs:SetLabel("CSAR")
|
||||||
@@ -2497,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
|
||||||
|
|
||||||
@@ -2542,8 +2593,9 @@ end
|
|||||||
-- @param #number Frequency Beacon frequency in kHz.
|
-- @param #number Frequency Beacon frequency in kHz.
|
||||||
-- @param #string Leadername Name of the #UNIT of the downed pilot.
|
-- @param #string Leadername Name of the #UNIT of the downed pilot.
|
||||||
-- @param #string CoordinatesText String of the position of the pilot. Format determined by self.coordtype.
|
-- @param #string CoordinatesText String of the position of the pilot. Format determined by self.coordtype.
|
||||||
function CSAR:onbeforePilotDown(From, Event, To, Group, Frequency, Leadername, CoordinatesText)
|
-- @param #string Playername Player name if any given. Might be nil!
|
||||||
self:T({From, Event, To, Group, Frequency, Leadername, CoordinatesText})
|
function CSAR:onbeforePilotDown(From, Event, To, Group, Frequency, Leadername, CoordinatesText, Playername)
|
||||||
|
self:T({From, Event, To, Group, Frequency, Leadername, CoordinatesText, tostring(Playername)})
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- ### [CTLD - Combat Troop & Logistics Deployment](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20CTLD)
|
-- ### [CTLD - Combat Troop & Logistics Deployment](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/CTLD)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
-- @module Ops.CTLD
|
-- @module Ops.CTLD
|
||||||
-- @image OPS_CTLD.jpg
|
-- @image OPS_CTLD.jpg
|
||||||
|
|
||||||
-- Last Update October 2023
|
-- Last Update April 2024
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
@@ -44,6 +44,8 @@ do
|
|||||||
-- @field #number PerCrateMass Mass in kg.
|
-- @field #number PerCrateMass Mass in kg.
|
||||||
-- @field #number Stock Number of builds available, -1 for unlimited.
|
-- @field #number Stock Number of builds available, -1 for unlimited.
|
||||||
-- @field #string Subcategory Sub-category name.
|
-- @field #string Subcategory Sub-category name.
|
||||||
|
-- @field #boolean DontShowInMenu Show this item in menu or not.
|
||||||
|
-- @field Core.Zone#ZONE Location Location (if set) where to get this cargo item.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -62,6 +64,8 @@ CTLD_CARGO = {
|
|||||||
PerCrateMass = 0,
|
PerCrateMass = 0,
|
||||||
Stock = nil,
|
Stock = nil,
|
||||||
Mark = nil,
|
Mark = nil,
|
||||||
|
DontShowInMenu = false,
|
||||||
|
Location = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Define cargo types.
|
--- Define cargo types.
|
||||||
@@ -97,8 +101,10 @@ CTLD_CARGO = {
|
|||||||
-- @param #number PerCrateMass Mass in kg
|
-- @param #number PerCrateMass Mass in kg
|
||||||
-- @param #number Stock Number of builds available, nil for unlimited
|
-- @param #number Stock Number of builds available, nil for unlimited
|
||||||
-- @param #string Subcategory Name of subcategory, handy if using > 10 types to load.
|
-- @param #string Subcategory Name of subcategory, handy if using > 10 types to load.
|
||||||
|
-- @param #boolean DontShowInMenu Show this item in menu or not (default: false == show it).
|
||||||
|
-- @param Core.Zone#ZONE Location (optional) Where the cargo is available (one location only).
|
||||||
-- @return #CTLD_CARGO self
|
-- @return #CTLD_CARGO self
|
||||||
function CTLD_CARGO:New(ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped, PerCrateMass, Stock, Subcategory)
|
function CTLD_CARGO:New(ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped, PerCrateMass, Stock, Subcategory, DontShowInMenu, Location)
|
||||||
-- Inherit everything from BASE class.
|
-- Inherit everything from BASE class.
|
||||||
local self=BASE:Inherit(self, BASE:New()) -- #CTLD_CARGO
|
local self=BASE:Inherit(self, BASE:New()) -- #CTLD_CARGO
|
||||||
self:T({ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped})
|
self:T({ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped})
|
||||||
@@ -115,9 +121,21 @@ CTLD_CARGO = {
|
|||||||
self.Stock = Stock or nil --#number
|
self.Stock = Stock or nil --#number
|
||||||
self.Mark = nil
|
self.Mark = nil
|
||||||
self.Subcategory = Subcategory or "Other"
|
self.Subcategory = Subcategory or "Other"
|
||||||
|
self.DontShowInMenu = DontShowInMenu or false
|
||||||
|
if type(Location) == "string" then
|
||||||
|
Location = ZONE:New(Location)
|
||||||
|
end
|
||||||
|
self.Location = Location
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Query Location.
|
||||||
|
-- @param #CTLD_CARGO self
|
||||||
|
-- @return Core.Zone#ZONE location or `nil` if not set
|
||||||
|
function CTLD_CARGO:GetLocation()
|
||||||
|
return self.Location
|
||||||
|
end
|
||||||
|
|
||||||
--- Query ID.
|
--- Query ID.
|
||||||
-- @param #CTLD_CARGO self
|
-- @param #CTLD_CARGO self
|
||||||
-- @return #number ID
|
-- @return #number ID
|
||||||
@@ -656,6 +674,8 @@ do
|
|||||||
-- my_ctld:AddCratesCargo("Humvee",{"Humvee"},CTLD_CARGO.Enum.VEHICLE,2,2775)
|
-- my_ctld:AddCratesCargo("Humvee",{"Humvee"},CTLD_CARGO.Enum.VEHICLE,2,2775)
|
||||||
-- -- if you want to limit your stock, add a number (here: 10) as parameter after weight. No parameter / nil means unlimited stock.
|
-- -- if you want to limit your stock, add a number (here: 10) as parameter after weight. No parameter / nil means unlimited stock.
|
||||||
-- my_ctld:AddCratesCargo("Humvee",{"Humvee"},CTLD_CARGO.Enum.VEHICLE,2,2775,10)
|
-- my_ctld:AddCratesCargo("Humvee",{"Humvee"},CTLD_CARGO.Enum.VEHICLE,2,2775,10)
|
||||||
|
-- -- additionally, you can limit **where** the stock is available (one location only!) - this one is available in a zone called "Vehicle Store".
|
||||||
|
-- my_ctld:AddCratesCargo("Humvee",{"Humvee"},CTLD_CARGO.Enum.VEHICLE,2,2775,10,nil,nil,"Vehicle Store")
|
||||||
--
|
--
|
||||||
-- -- add infantry unit called "Forward Ops Base" using template "FOB", of type FOB, size 4, i.e. needs four crates to be build:
|
-- -- add infantry unit called "Forward Ops Base" using template "FOB", of type FOB, size 4, i.e. needs four crates to be build:
|
||||||
-- my_ctld:AddCratesCargo("Forward Ops Base",{"FOB"},CTLD_CARGO.Enum.FOB,4)
|
-- my_ctld:AddCratesCargo("Forward Ops Base",{"FOB"},CTLD_CARGO.Enum.FOB,4)
|
||||||
@@ -741,7 +761,7 @@ do
|
|||||||
--
|
--
|
||||||
-- -- E.g. update unit capabilities for testing. Please stay realistic in your mission design.
|
-- -- E.g. update unit capabilities for testing. Please stay realistic in your mission design.
|
||||||
-- -- Make a Gazelle into a heavy truck, this type can load both crates and troops and eight of each type, up to 4000 kgs:
|
-- -- Make a Gazelle into a heavy truck, this type can load both crates and troops and eight of each type, up to 4000 kgs:
|
||||||
-- my_ctld:UnitCapabilities("SA342L", true, true, 8, 8, 12, 4000)
|
-- my_ctld:SetUnitCapabilities("SA342L", true, true, 8, 8, 12, 4000)
|
||||||
--
|
--
|
||||||
-- -- Default unit type capabilities are:
|
-- -- Default unit type capabilities are:
|
||||||
-- ["SA342Mistral"] = {type="SA342Mistral", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 12, cargoweightlimit = 400},
|
-- ["SA342Mistral"] = {type="SA342Mistral", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 12, cargoweightlimit = 400},
|
||||||
@@ -757,6 +777,9 @@ do
|
|||||||
-- ["Hercules"] = {type="Hercules", crates=true, troops=true, cratelimit = 7, trooplimit = 64, length = 25, cargoweightlimit = 19000},
|
-- ["Hercules"] = {type="Hercules", crates=true, troops=true, cratelimit = 7, trooplimit = 64, length = 25, cargoweightlimit = 19000},
|
||||||
-- ["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500},
|
-- ["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500},
|
||||||
-- ["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200},
|
-- ["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200},
|
||||||
|
-- ["MH-60R"] = {type="MH-60R", 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
|
||||||
|
-- ["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
|
||||||
--
|
--
|
||||||
-- ### 2.1.2 Activate and deactivate zones
|
-- ### 2.1.2 Activate and deactivate zones
|
||||||
--
|
--
|
||||||
@@ -1200,14 +1223,14 @@ CTLD.CargoZoneType = {
|
|||||||
-- @field #CTLD_CARGO.Enum Type Type enumerator (for moves).
|
-- @field #CTLD_CARGO.Enum Type Type enumerator (for moves).
|
||||||
|
|
||||||
--- Unit capabilities.
|
--- Unit capabilities.
|
||||||
-- @type CTLD.UnitCapabilities
|
-- @type CTLD.UnitTypeCapabilities
|
||||||
-- @field #string type Unit type.
|
-- @field #string type Unit type.
|
||||||
-- @field #boolean crates Can transport crate.
|
-- @field #boolean crates Can transport crate.
|
||||||
-- @field #boolean troops Can transport troops.
|
-- @field #boolean troops Can transport troops.
|
||||||
-- @field #number cratelimit Number of crates transportable.
|
-- @field #number cratelimit Number of crates transportable.
|
||||||
-- @field #number trooplimit Number of troop units transportable.
|
-- @field #number trooplimit Number of troop units transportable.
|
||||||
-- @field #number cargoweightlimit Max loadable kgs of cargo.
|
-- @field #number cargoweightlimit Max loadable kgs of cargo.
|
||||||
CTLD.UnitTypes = {
|
CTLD.UnitTypeCapabilities = {
|
||||||
["SA342Mistral"] = {type="SA342Mistral", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 12, cargoweightlimit = 400},
|
["SA342Mistral"] = {type="SA342Mistral", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 12, cargoweightlimit = 400},
|
||||||
["SA342L"] = {type="SA342L", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 12, cargoweightlimit = 400},
|
["SA342L"] = {type="SA342L", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 12, cargoweightlimit = 400},
|
||||||
["SA342M"] = {type="SA342M", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 12, cargoweightlimit = 400},
|
["SA342M"] = {type="SA342M", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 12, cargoweightlimit = 400},
|
||||||
@@ -1222,13 +1245,17 @@ CTLD.UnitTypes = {
|
|||||||
["Hercules"] = {type="Hercules", crates=true, troops=true, cratelimit = 7, trooplimit = 64, length = 25, cargoweightlimit = 19000}, -- 19t cargo, 64 paratroopers.
|
["Hercules"] = {type="Hercules", crates=true, troops=true, cratelimit = 7, trooplimit = 64, length = 25, cargoweightlimit = 19000}, -- 19t cargo, 64 paratroopers.
|
||||||
--Actually it's longer, but the center coord is off-center of the model.
|
--Actually it's longer, but the center coord is off-center of the model.
|
||||||
["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
||||||
|
["MH-60R"] = {type="MH-60R", 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},
|
||||||
|
["OH-58D"] = {type="OH-58D", 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.41"
|
CTLD.version="1.0.54"
|
||||||
|
|
||||||
--- Instantiate a new CTLD.
|
--- Instantiate a new CTLD.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
@@ -1293,6 +1320,8 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
|||||||
self:AddTransition("*", "CratesDropped", "*") -- CTLD deploy event.
|
self:AddTransition("*", "CratesDropped", "*") -- CTLD deploy event.
|
||||||
self:AddTransition("*", "CratesBuild", "*") -- CTLD build event.
|
self:AddTransition("*", "CratesBuild", "*") -- CTLD build event.
|
||||||
self:AddTransition("*", "CratesRepaired", "*") -- CTLD repair event.
|
self:AddTransition("*", "CratesRepaired", "*") -- CTLD repair event.
|
||||||
|
self:AddTransition("*", "CratesBuildStarted", "*") -- CTLD build event.
|
||||||
|
self:AddTransition("*", "CratesRepairStarted", "*") -- CTLD repair event.
|
||||||
self:AddTransition("*", "Load", "*") -- CTLD load event.
|
self:AddTransition("*", "Load", "*") -- CTLD load event.
|
||||||
self:AddTransition("*", "Save", "*") -- CTLD save event.
|
self:AddTransition("*", "Save", "*") -- CTLD save event.
|
||||||
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||||
@@ -1431,7 +1460,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
|||||||
--- Pseudo Functions ---
|
--- Pseudo Functions ---
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
--- Triggers the FSM event "Start". Starts the CTLD. Initializes parameters and starts event handlers.
|
--- Triggers the FSM event "Start". Starts the CTLD. Initializes parameters and starts event handlers.
|
||||||
-- @function [parent=#CTLD] Start
|
-- @function [parent=#CTLD] Start
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
|
|
||||||
@@ -1441,6 +1470,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
|||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
--- Triggers the FSM event "Stop". Stops the CTLD and all its event handlers.
|
--- Triggers the FSM event "Stop". Stops the CTLD and all its event handlers.
|
||||||
|
-- @function [parent=#CTLD] Stop
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
|
|
||||||
--- Triggers the FSM event "Stop" after a delay. Stops the CTLD and all its event handlers.
|
--- Triggers the FSM event "Stop" after a delay. Stops the CTLD and all its event handlers.
|
||||||
@@ -1475,7 +1505,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
|||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
--- FSM Function OnBeforeTroopsPickedUp.
|
--- FSM Function OnBeforeTroopsPickedUp.
|
||||||
-- @function [parent=#CTLD] OnBeforeTroopsPickedUp
|
-- @function [parent=#CTLD] OnBeforeTroopsPickedUp
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param #string From State.
|
-- @param #string From State.
|
||||||
@@ -1627,6 +1657,46 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
|||||||
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build.
|
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build.
|
||||||
-- @return #CTLD self
|
-- @return #CTLD self
|
||||||
|
|
||||||
|
--- FSM Function OnAfterCratesBuildStarted. Info event that a build has been started.
|
||||||
|
-- @function [parent=#CTLD] OnAfterCratesBuildStarted
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param #string From State.
|
||||||
|
-- @param #string Event Trigger.
|
||||||
|
-- @param #string To State.
|
||||||
|
-- @param Wrapper.Group#GROUP Group Group Object.
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit Unit Object.
|
||||||
|
-- @return #CTLD self
|
||||||
|
|
||||||
|
--- FSM Function OnAfterCratesRepairStarted. Info event that a repair has been started.
|
||||||
|
-- @function [parent=#CTLD] OnAfterCratesRepairStarted
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param #string From State.
|
||||||
|
-- @param #string Event Trigger.
|
||||||
|
-- @param #string To State.
|
||||||
|
-- @param Wrapper.Group#GROUP Group Group Object.
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit Unit Object.
|
||||||
|
-- @return #CTLD self
|
||||||
|
|
||||||
|
--- FSM Function OnBeforeCratesBuildStarted. Info event that a build has been started.
|
||||||
|
-- @function [parent=#CTLD] OnBeforeCratesBuildStarted
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param #string From State.
|
||||||
|
-- @param #string Event Trigger.
|
||||||
|
-- @param #string To State.
|
||||||
|
-- @param Wrapper.Group#GROUP Group Group Object.
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit Unit Object.
|
||||||
|
-- @return #CTLD self
|
||||||
|
|
||||||
|
--- FSM Function OnBeforeCratesRepairStarted. Info event that a repair has been started.
|
||||||
|
-- @function [parent=#CTLD] OnBeforeCratesRepairStarted
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param #string From State.
|
||||||
|
-- @param #string Event Trigger.
|
||||||
|
-- @param #string To State.
|
||||||
|
-- @param Wrapper.Group#GROUP Group Group Object.
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit Unit Object.
|
||||||
|
-- @return #CTLD self
|
||||||
|
|
||||||
--- FSM Function OnAfterCratesRepaired.
|
--- FSM Function OnAfterCratesRepaired.
|
||||||
-- @function [parent=#CTLD] OnAfterCratesRepaired
|
-- @function [parent=#CTLD] OnAfterCratesRepaired
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
@@ -1680,7 +1750,7 @@ function CTLD:_GetUnitCapabilities(Unit)
|
|||||||
self:T(self.lid .. " _GetUnitCapabilities")
|
self:T(self.lid .. " _GetUnitCapabilities")
|
||||||
local _unit = Unit -- Wrapper.Unit#UNIT
|
local _unit = Unit -- Wrapper.Unit#UNIT
|
||||||
local unittype = _unit:GetTypeName()
|
local unittype = _unit:GetTypeName()
|
||||||
local capabilities = self.UnitTypes[unittype] -- #CTLD.UnitCapabilities
|
local capabilities = self.UnitTypeCapabilities[unittype] -- #CTLD.UnitTypeCapabilities
|
||||||
if not capabilities or capabilities == {} then
|
if not capabilities or capabilities == {} then
|
||||||
-- e.g. ["Ka-50"] = {type="Ka-50", crates=false, troops=false, cratelimit = 0, trooplimit = 0},
|
-- e.g. ["Ka-50"] = {type="Ka-50", crates=false, troops=false, cratelimit = 0, trooplimit = 0},
|
||||||
capabilities = {}
|
capabilities = {}
|
||||||
@@ -1701,7 +1771,7 @@ end
|
|||||||
function CTLD:_GenerateUHFrequencies()
|
function CTLD:_GenerateUHFrequencies()
|
||||||
self:T(self.lid .. " _GenerateUHFrequencies")
|
self:T(self.lid .. " _GenerateUHFrequencies")
|
||||||
self.FreeUHFFrequencies = {}
|
self.FreeUHFFrequencies = {}
|
||||||
self.FreeUHFFrequencies = UTILS.GenerateUHFrequencies()
|
self.FreeUHFFrequencies = UTILS.GenerateUHFrequencies(243,320)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1871,7 +1941,7 @@ function CTLD:_PreloadCrates(Group, Unit, Cargo, NumberOfCrates)
|
|||||||
local unitname = unit:GetName()
|
local unitname = unit:GetName()
|
||||||
-- see if this heli can load crates
|
-- see if this heli can load crates
|
||||||
local unittype = unit:GetTypeName()
|
local unittype = unit:GetTypeName()
|
||||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||||
local cancrates = capabilities.crates -- #boolean
|
local cancrates = capabilities.crates -- #boolean
|
||||||
local cratelimit = capabilities.cratelimit -- #number
|
local cratelimit = capabilities.cratelimit -- #number
|
||||||
if not cancrates then
|
if not cancrates then
|
||||||
@@ -2124,6 +2194,7 @@ function CTLD:_RepairObjectFromCrates(Group,Unit,Crates,Build,Number,Engineering
|
|||||||
desttimer:Start(self.repairtime - 1)
|
desttimer:Start(self.repairtime - 1)
|
||||||
local buildtimer = TIMER:New(self._BuildObjectFromCrates,self,Group,Unit,object,true,NearestGroup:GetCoordinate())
|
local buildtimer = TIMER:New(self._BuildObjectFromCrates,self,Group,Unit,object,true,NearestGroup:GetCoordinate())
|
||||||
buildtimer:Start(self.repairtime)
|
buildtimer:Start(self.repairtime)
|
||||||
|
self:__CratesRepairStarted(1,Group,Unit)
|
||||||
else
|
else
|
||||||
if not Engineering then
|
if not Engineering then
|
||||||
self:_SendMessage("Can't repair this unit with " .. build.Name, 10, false, Group)
|
self:_SendMessage("Can't repair this unit with " .. build.Name, 10, false, Group)
|
||||||
@@ -2171,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
|
||||||
@@ -2191,7 +2264,7 @@ end
|
|||||||
local secondarygroups = {}
|
local secondarygroups = {}
|
||||||
|
|
||||||
for i=1,#distancekeys do
|
for i=1,#distancekeys do
|
||||||
local nearestGroup = nearestList[distancekeys[i]]
|
local nearestGroup = nearestList[distancekeys[i]] -- Wrapper.Group#GROUP
|
||||||
-- find matching cargo type
|
-- find matching cargo type
|
||||||
local groupType = string.match(nearestGroup:GetName(), "(.+)-(.+)$")
|
local groupType = string.match(nearestGroup:GetName(), "(.+)-(.+)$")
|
||||||
local Cargotype = nil
|
local Cargotype = nil
|
||||||
@@ -2222,25 +2295,38 @@ 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
|
||||||
loaded.Troopsloaded = loaded.Troopsloaded + troopsize
|
loaded.Troopsloaded = loaded.Troopsloaded + troopsize
|
||||||
table.insert(loaded.Cargo,loadcargotype)
|
table.insert(loaded.Cargo,loadcargotype)
|
||||||
self.Loaded_Cargo[unitname] = loaded
|
self.Loaded_Cargo[unitname] = loaded
|
||||||
self:_SendMessage("Troops boarded!", 10, false, Group)
|
self:ScheduleOnce(running,self._SendMessage,self,"Troops boarded!", 10, false, Group)
|
||||||
|
self:_SendMessage("Troops boarding!", 10, false, Group)
|
||||||
self:_UpdateUnitCargoMass(Unit)
|
self:_UpdateUnitCargoMass(Unit)
|
||||||
self:__TroopsExtracted(1,Group, Unit, nearestGroup)
|
self:__TroopsExtracted(running,Group, Unit, nearestGroup)
|
||||||
|
local coord = Unit:GetCoordinate() or Group:GetCoordinate() -- Core.Point#COORDINATE
|
||||||
|
local Point
|
||||||
|
if coord then
|
||||||
|
local heading = unit:GetHeading() or 0
|
||||||
|
local Angle = math.floor((heading+160)%360)
|
||||||
|
Point = coord:Translate(8,Angle):GetVec2()
|
||||||
|
if Point then
|
||||||
|
nearestGroup:RouteToVec2(Point,4)
|
||||||
|
end
|
||||||
|
end
|
||||||
-- clean up:
|
-- clean up:
|
||||||
if type(Cargotype.Templates) == "table" and Cargotype.Templates[2] then
|
if type(Cargotype.Templates) == "table" and Cargotype.Templates[2] then
|
||||||
for _,_key in pairs (Cargotype.Templates) do
|
for _,_key in pairs (Cargotype.Templates) do
|
||||||
table.insert(secondarygroups,_key)
|
table.insert(secondarygroups,_key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
nearestGroup:Destroy(false)
|
nearestGroup:Destroy(false,running)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2250,7 +2336,7 @@ end
|
|||||||
if _group and _group:IsAlive() then
|
if _group and _group:IsAlive() then
|
||||||
local groupname = string.match(_group:GetName(), "(.+)-(.+)$")
|
local groupname = string.match(_group:GetName(), "(.+)-(.+)$")
|
||||||
if _name == groupname then
|
if _name == groupname then
|
||||||
_group:Destroy(false)
|
_group:Destroy(false,15)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2307,8 +2393,22 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop, pack)
|
|||||||
if not self.debug then return self end
|
if not self.debug then return self end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check cargo location if available
|
||||||
|
local location = Cargo:GetLocation()
|
||||||
|
|
||||||
|
if location then
|
||||||
|
local unitcoord = Unit:GetCoordinate() or Group:GetCoordinate()
|
||||||
|
if unitcoord then
|
||||||
|
if not location:IsCoordinateInZone(unitcoord) then
|
||||||
|
-- no we're not at the right spot
|
||||||
|
self:_SendMessage("The requested cargo is not available in this zone!", 10, false, Group)
|
||||||
|
if not self.debug then return self end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- avoid crate spam
|
-- avoid crate spam
|
||||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||||
local canloadcratesno = capabilities.cratelimit
|
local canloadcratesno = capabilities.cratelimit
|
||||||
local loaddist = self.CrateDistance or 35
|
local loaddist = self.CrateDistance or 35
|
||||||
local nearcrates, numbernearby = self:_FindCratesNearby(Group,Unit,loaddist,true)
|
local nearcrates, numbernearby = self:_FindCratesNearby(Group,Unit,loaddist,true)
|
||||||
@@ -2412,10 +2512,12 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop, pack)
|
|||||||
table.insert(droppedcargo,realcargo)
|
table.insert(droppedcargo,realcargo)
|
||||||
else
|
else
|
||||||
realcargo = CTLD_CARGO:New(self.CargoCounter,cratename,templ,sorte,false,false,cratesneeded,self.Spawned_Crates[self.CrateCounter],false,cargotype.PerCrateMass,nil,subcat)
|
realcargo = CTLD_CARGO:New(self.CargoCounter,cratename,templ,sorte,false,false,cratesneeded,self.Spawned_Crates[self.CrateCounter],false,cargotype.PerCrateMass,nil,subcat)
|
||||||
Cargo:RemoveStock()
|
|
||||||
end
|
end
|
||||||
table.insert(self.Spawned_Cargo, realcargo)
|
table.insert(self.Spawned_Cargo, realcargo)
|
||||||
end
|
end
|
||||||
|
if not (drop or pack) then
|
||||||
|
Cargo:RemoveStock()
|
||||||
|
end
|
||||||
local text = string.format("Crates for %s have been positioned near you!",cratename)
|
local text = string.format("Crates for %s have been positioned near you!",cratename)
|
||||||
if drop then
|
if drop then
|
||||||
text = string.format("Crates for %s have been dropped!",cratename)
|
text = string.format("Crates for %s have been dropped!",cratename)
|
||||||
@@ -2518,6 +2620,40 @@ function CTLD:_ListCratesNearby( _group, _unit)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- (Internal) Function to find and Remove nearby crates.
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param Wrapper.Group#GROUP Group
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit
|
||||||
|
-- @return #CTLD self
|
||||||
|
function CTLD:_RemoveCratesNearby( _group, _unit)
|
||||||
|
self:T(self.lid .. " _RemoveCratesNearby")
|
||||||
|
local finddist = self.CrateDistance or 35
|
||||||
|
local crates,number = self:_FindCratesNearby(_group,_unit, finddist,true) -- #table
|
||||||
|
if number > 0 then
|
||||||
|
local text = REPORT:New("Removing Crates Found Nearby:")
|
||||||
|
text:Add("------------------------------------------------------------")
|
||||||
|
for _,_entry in pairs (crates) do
|
||||||
|
local entry = _entry -- #CTLD_CARGO
|
||||||
|
local name = entry:GetName() --#string
|
||||||
|
local dropped = entry:WasDropped()
|
||||||
|
if dropped then
|
||||||
|
text:Add(string.format("Crate for %s, %dkg removed",name, entry.PerCrateMass))
|
||||||
|
else
|
||||||
|
text:Add(string.format("Crate for %s, %dkg removed",name, entry.PerCrateMass))
|
||||||
|
end
|
||||||
|
entry:GetPositionable():Destroy(false)
|
||||||
|
end
|
||||||
|
if text:GetCount() == 1 then
|
||||||
|
text:Add(" N O N E")
|
||||||
|
end
|
||||||
|
text:Add("------------------------------------------------------------")
|
||||||
|
self:_SendMessage(text:Text(), 30, true, _group)
|
||||||
|
else
|
||||||
|
self:_SendMessage(string.format("No (loadable) crates within %d meters!",finddist), 10, false, _group)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- (Internal) Return distance in meters between two coordinates.
|
--- (Internal) Return distance in meters between two coordinates.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param Core.Point#COORDINATE _point1 Coordinate one
|
-- @param Core.Point#COORDINATE _point1 Coordinate one
|
||||||
@@ -2601,8 +2737,8 @@ function CTLD:_LoadCratesNearby(Group, Unit)
|
|||||||
local unitname = unit:GetName()
|
local unitname = unit:GetName()
|
||||||
-- see if this heli can load crates
|
-- see if this heli can load crates
|
||||||
local unittype = unit:GetTypeName()
|
local unittype = unit:GetTypeName()
|
||||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||||
--local capabilities = self.UnitTypes[unittype] -- #CTLD.UnitCapabilities
|
--local capabilities = self.UnitTypeCapabilities[unittype] -- #CTLD.UnitTypeCapabilities
|
||||||
local cancrates = capabilities.crates -- #boolean
|
local cancrates = capabilities.crates -- #boolean
|
||||||
local cratelimit = capabilities.cratelimit -- #number
|
local cratelimit = capabilities.cratelimit -- #number
|
||||||
local grounded = not self:IsUnitInAir(Unit)
|
local grounded = not self:IsUnitInAir(Unit)
|
||||||
@@ -2753,7 +2889,7 @@ function CTLD:_GetMaxLoadableMass(Unit)
|
|||||||
if not Unit then return 0 end
|
if not Unit then return 0 end
|
||||||
local loadable = 0
|
local loadable = 0
|
||||||
local loadedmass = self:_GetUnitCargoMass(Unit)
|
local loadedmass = self:_GetUnitCargoMass(Unit)
|
||||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||||
local maxmass = capabilities.cargoweightlimit or 2000 -- max 2 tons
|
local maxmass = capabilities.cargoweightlimit or 2000 -- max 2 tons
|
||||||
loadable = maxmass - loadedmass
|
loadable = maxmass - loadedmass
|
||||||
return loadable
|
return loadable
|
||||||
@@ -2778,7 +2914,7 @@ function CTLD:_ListCargo(Group, Unit)
|
|||||||
self:T(self.lid .. " _ListCargo")
|
self:T(self.lid .. " _ListCargo")
|
||||||
local unitname = Unit:GetName()
|
local unitname = Unit:GetName()
|
||||||
local unittype = Unit:GetTypeName()
|
local unittype = Unit:GetTypeName()
|
||||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||||
local trooplimit = capabilities.trooplimit -- #boolean
|
local trooplimit = capabilities.trooplimit -- #boolean
|
||||||
local cratelimit = capabilities.cratelimit -- #number
|
local cratelimit = capabilities.cratelimit -- #number
|
||||||
local loadedcargo = self.Loaded_Cargo[unitname] or {} -- #CTLD.LoadedCargo
|
local loadedcargo = self.Loaded_Cargo[unitname] or {} -- #CTLD.LoadedCargo
|
||||||
@@ -2933,6 +3069,36 @@ function CTLD:IsHercules(Unit)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- (Internal) Function to set troops positions of a template to a nice circle
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate Start coordinate to use
|
||||||
|
-- @param #number Radius Radius to be used
|
||||||
|
-- @param #number Heading Heading starting with
|
||||||
|
-- @param #string Template The group template name
|
||||||
|
-- @return #table Positions The positions table
|
||||||
|
function CTLD:_GetUnitPositions(Coordinate,Radius,Heading,Template)
|
||||||
|
local Positions = {}
|
||||||
|
local template = _DATABASE:GetGroupTemplate(Template)
|
||||||
|
--UTILS.PrintTableToLog(template)
|
||||||
|
local numbertroops = #template.units
|
||||||
|
local slightshift = math.abs(math.random(0,200)/100)
|
||||||
|
local newcenter = Coordinate:Translate(Radius+slightshift,((Heading+270)%360))
|
||||||
|
for i=1,360,math.floor(360/numbertroops) do
|
||||||
|
local phead = ((Heading+270+i)%360)
|
||||||
|
local post = newcenter:Translate(Radius,phead)
|
||||||
|
local pos1 = post:GetVec2()
|
||||||
|
local p1t = {
|
||||||
|
x = pos1.x,
|
||||||
|
y = pos1.y,
|
||||||
|
heading = phead,
|
||||||
|
}
|
||||||
|
table.insert(Positions,p1t)
|
||||||
|
end
|
||||||
|
--UTILS.PrintTableToLog(Positions)
|
||||||
|
return Positions
|
||||||
|
end
|
||||||
|
|
||||||
--- (Internal) Function to unload troops from heli.
|
--- (Internal) Function to unload troops from heli.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param Wrapper.Group#GROUP Group
|
-- @param Wrapper.Group#GROUP Group
|
||||||
@@ -2984,14 +3150,29 @@ function CTLD:_UnloadTroops(Group, Unit)
|
|||||||
zoneradius = Unit:GetVelocityMPS() or 100
|
zoneradius = Unit:GetVelocityMPS() or 100
|
||||||
end
|
end
|
||||||
local zone = ZONE_GROUP:New(string.format("Unload zone-%s",unitname),Group,zoneradius*factor)
|
local zone = ZONE_GROUP:New(string.format("Unload zone-%s",unitname),Group,zoneradius*factor)
|
||||||
local randomcoord = zone:GetRandomCoordinate(10,30*factor):GetVec2()
|
local randomcoord = zone:GetRandomCoordinate(10,30*factor) --:GetVec2()
|
||||||
|
local heading = Group:GetHeading() or 0
|
||||||
|
-- Spawn troops left from us, closer when hovering, further off when landed
|
||||||
|
if hoverunload or grounded then
|
||||||
|
randomcoord = Group:GetCoordinate()
|
||||||
|
-- slightly left from us
|
||||||
|
local Angle = (heading+270)%360
|
||||||
|
local offset = hoverunload and 1.5 or 5
|
||||||
|
randomcoord:Translate(offset,Angle,nil,true)
|
||||||
|
end
|
||||||
|
local tempcount = 0
|
||||||
for _,_template in pairs(temptable) do
|
for _,_template in pairs(temptable) do
|
||||||
self.TroopCounter = self.TroopCounter + 1
|
self.TroopCounter = self.TroopCounter + 1
|
||||||
|
tempcount = tempcount+1
|
||||||
local alias = string.format("%s-%d", _template, math.random(1,100000))
|
local alias = string.format("%s-%d", _template, math.random(1,100000))
|
||||||
|
local rad = 2.5+tempcount
|
||||||
|
local Positions = self:_GetUnitPositions(randomcoord,rad,heading,_template)
|
||||||
self.DroppedTroops[self.TroopCounter] = SPAWN:NewWithAlias(_template,alias)
|
self.DroppedTroops[self.TroopCounter] = SPAWN:NewWithAlias(_template,alias)
|
||||||
:InitRandomizeUnits(true,20,2)
|
--:InitRandomizeUnits(true,20,2)
|
||||||
|
--:InitHeading(heading)
|
||||||
:InitDelayOff()
|
:InitDelayOff()
|
||||||
:SpawnFromVec2(randomcoord)
|
:InitSetUnitAbsolutePositions(Positions)
|
||||||
|
:SpawnFromVec2(randomcoord:GetVec2())
|
||||||
self:__TroopsDeployed(1, Group, Unit, self.DroppedTroops[self.TroopCounter],type)
|
self:__TroopsDeployed(1, Group, Unit, self.DroppedTroops[self.TroopCounter],type)
|
||||||
end -- template loop
|
end -- template loop
|
||||||
cargo:SetWasDropped(true)
|
cargo:SetWasDropped(true)
|
||||||
@@ -3226,6 +3407,7 @@ function CTLD:_BuildCrates(Group, Unit,Engineering)
|
|||||||
local buildtimer = TIMER:New(self._BuildObjectFromCrates,self,Group,Unit,build,false,Group:GetCoordinate())
|
local buildtimer = TIMER:New(self._BuildObjectFromCrates,self,Group,Unit,build,false,Group:GetCoordinate())
|
||||||
buildtimer:Start(self.buildtime)
|
buildtimer:Start(self.buildtime)
|
||||||
self:_SendMessage(string.format("Build started, ready in %d seconds!",self.buildtime),15,false,Group)
|
self:_SendMessage(string.format("Build started, ready in %d seconds!",self.buildtime),15,false,Group)
|
||||||
|
self:__CratesBuildStarted(1,Group,Unit)
|
||||||
else
|
else
|
||||||
self:_BuildObjectFromCrates(Group,Unit,build)
|
self:_BuildObjectFromCrates(Group,Unit,build)
|
||||||
end
|
end
|
||||||
@@ -3427,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
|
||||||
@@ -3536,13 +3718,19 @@ function CTLD:_RefreshF10Menus()
|
|||||||
if _group then
|
if _group then
|
||||||
-- get chopper capabilities
|
-- get chopper capabilities
|
||||||
local unittype = _unit:GetTypeName()
|
local unittype = _unit:GetTypeName()
|
||||||
local capabilities = self:_GetUnitCapabilities(_unit) -- #CTLD.UnitCapabilities
|
local capabilities = self:_GetUnitCapabilities(_unit) -- #CTLD.UnitTypeCapabilities
|
||||||
local cantroops = capabilities.troops
|
local cantroops = capabilities.troops
|
||||||
local cancrates = capabilities.crates
|
local cancrates = capabilities.crates
|
||||||
-- top menu
|
-- top menu
|
||||||
local topmenu = MENU_GROUP:New(_group,"CTLD",nil)
|
local topmenu = MENU_GROUP:New(_group,"CTLD",nil)
|
||||||
local toptroops = MENU_GROUP:New(_group,"Manage Troops",topmenu)
|
local toptroops = nil
|
||||||
local topcrates = MENU_GROUP:New(_group,"Manage Crates",topmenu)
|
local topcrates = nil
|
||||||
|
if cantroops then
|
||||||
|
toptroops = MENU_GROUP:New(_group,"Manage Troops",topmenu)
|
||||||
|
end
|
||||||
|
if cancrates then
|
||||||
|
topcrates = MENU_GROUP:New(_group,"Manage Crates",topmenu)
|
||||||
|
end
|
||||||
local listmenu = MENU_GROUP_COMMAND:New(_group,"List boarded cargo",topmenu, self._ListCargo, self, _group, _unit)
|
local listmenu = MENU_GROUP_COMMAND:New(_group,"List boarded cargo",topmenu, self._ListCargo, self, _group, _unit)
|
||||||
local invtry = MENU_GROUP_COMMAND:New(_group,"Inventory",topmenu, self._ListInventory, self, _group, _unit)
|
local invtry = MENU_GROUP_COMMAND:New(_group,"Inventory",topmenu, self._ListInventory, self, _group, _unit)
|
||||||
local rbcns = MENU_GROUP_COMMAND:New(_group,"List active zone beacons",topmenu, self._ListRadioBeacons, self, _group, _unit)
|
local rbcns = MENU_GROUP_COMMAND:New(_group,"List active zone beacons",topmenu, self._ListRadioBeacons, self, _group, _unit)
|
||||||
@@ -3569,14 +3757,20 @@ function CTLD:_RefreshF10Menus()
|
|||||||
for _,_entry in pairs(self.Cargo_Troops) do
|
for _,_entry in pairs(self.Cargo_Troops) do
|
||||||
local entry = _entry -- #CTLD_CARGO
|
local entry = _entry -- #CTLD_CARGO
|
||||||
local subcat = entry.Subcategory
|
local subcat = entry.Subcategory
|
||||||
menucount = menucount + 1
|
local noshow = entry.DontShowInMenu
|
||||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,entry.Name,subcatmenus[subcat],self._LoadTroops, self, _group, _unit, entry)
|
if not noshow then
|
||||||
|
menucount = menucount + 1
|
||||||
|
menus[menucount] = MENU_GROUP_COMMAND:New(_group,entry.Name,subcatmenus[subcat],self._LoadTroops, self, _group, _unit, entry)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for _,_entry in pairs(self.Cargo_Troops) do
|
for _,_entry in pairs(self.Cargo_Troops) do
|
||||||
local entry = _entry -- #CTLD_CARGO
|
local entry = _entry -- #CTLD_CARGO
|
||||||
menucount = menucount + 1
|
local noshow = entry.DontShowInMenu
|
||||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,entry.Name,troopsmenu,self._LoadTroops, self, _group, _unit, entry)
|
if not noshow then
|
||||||
|
menucount = menucount + 1
|
||||||
|
menus[menucount] = MENU_GROUP_COMMAND:New(_group,entry.Name,troopsmenu,self._LoadTroops, self, _group, _unit, entry)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local unloadmenu1 = MENU_GROUP_COMMAND:New(_group,"Drop troops",toptroops, self._UnloadTroops, self, _group, _unit):Refresh()
|
local unloadmenu1 = MENU_GROUP_COMMAND:New(_group,"Drop troops",toptroops, self._UnloadTroops, self, _group, _unit):Refresh()
|
||||||
@@ -3587,6 +3781,7 @@ function CTLD:_RefreshF10Menus()
|
|||||||
local loadmenu = MENU_GROUP_COMMAND:New(_group,"Load crates",topcrates, self._LoadCratesNearby, self, _group, _unit)
|
local loadmenu = MENU_GROUP_COMMAND:New(_group,"Load crates",topcrates, self._LoadCratesNearby, self, _group, _unit)
|
||||||
local cratesmenu = MENU_GROUP:New(_group,"Get Crates",topcrates)
|
local cratesmenu = MENU_GROUP:New(_group,"Get Crates",topcrates)
|
||||||
local packmenu = MENU_GROUP_COMMAND:New(_group, "Pack crates", topcrates, self._PackCratesNearby, self, _group, _unit)
|
local packmenu = MENU_GROUP_COMMAND:New(_group, "Pack crates", topcrates, self._PackCratesNearby, self, _group, _unit)
|
||||||
|
local removecratesmenu = MENU_GROUP:New(_group, "Remove crates", topcrates)
|
||||||
|
|
||||||
if self.usesubcats then
|
if self.usesubcats then
|
||||||
local subcatmenus = {}
|
local subcatmenus = {}
|
||||||
@@ -3596,32 +3791,61 @@ function CTLD:_RefreshF10Menus()
|
|||||||
for _,_entry in pairs(self.Cargo_Crates) do
|
for _,_entry in pairs(self.Cargo_Crates) do
|
||||||
local entry = _entry -- #CTLD_CARGO
|
local entry = _entry -- #CTLD_CARGO
|
||||||
local subcat = entry.Subcategory
|
local subcat = entry.Subcategory
|
||||||
menucount = menucount + 1
|
local noshow = entry.DontShowInMenu
|
||||||
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
local zone = entry.Location
|
||||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,subcatmenus[subcat],self._GetCrates, self, _group, _unit, entry)
|
if not noshow then
|
||||||
|
menucount = menucount + 1
|
||||||
|
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
||||||
|
if zone then
|
||||||
|
menutext = string.format("Crate %s (%dkg)[R]",entry.Name,entry.PerCrateMass or 0)
|
||||||
|
end
|
||||||
|
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,subcatmenus[subcat],self._GetCrates, self, _group, _unit, entry)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
for _,_entry in pairs(self.Cargo_Statics) do
|
for _,_entry in pairs(self.Cargo_Statics) do
|
||||||
local entry = _entry -- #CTLD_CARGO
|
local entry = _entry -- #CTLD_CARGO
|
||||||
local subcat = entry.Subcategory
|
local subcat = entry.Subcategory
|
||||||
menucount = menucount + 1
|
local noshow = entry.DontShowInMenu
|
||||||
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
local zone = entry.Location
|
||||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,subcatmenus[subcat],self._GetCrates, self, _group, _unit, entry)
|
if not noshow then
|
||||||
|
menucount = menucount + 1
|
||||||
|
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
||||||
|
if zone then
|
||||||
|
menutext = string.format("Crate %s (%dkg)[R]",entry.Name,entry.PerCrateMass or 0)
|
||||||
|
end
|
||||||
|
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,subcatmenus[subcat],self._GetCrates, self, _group, _unit, entry)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for _,_entry in pairs(self.Cargo_Crates) do
|
for _,_entry in pairs(self.Cargo_Crates) do
|
||||||
local entry = _entry -- #CTLD_CARGO
|
local entry = _entry -- #CTLD_CARGO
|
||||||
menucount = menucount + 1
|
local noshow = entry.DontShowInMenu
|
||||||
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
local zone = entry.Location
|
||||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,cratesmenu,self._GetCrates, self, _group, _unit, entry)
|
if not noshow then
|
||||||
|
menucount = menucount + 1
|
||||||
|
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
||||||
|
if zone then
|
||||||
|
menutext = string.format("Crate %s (%dkg)[R]",entry.Name,entry.PerCrateMass or 0)
|
||||||
|
end
|
||||||
|
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,cratesmenu,self._GetCrates, self, _group, _unit, entry)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
for _,_entry in pairs(self.Cargo_Statics) do
|
for _,_entry in pairs(self.Cargo_Statics) do
|
||||||
local entry = _entry -- #CTLD_CARGO
|
local entry = _entry -- #CTLD_CARGO
|
||||||
menucount = menucount + 1
|
local noshow = entry.DontShowInMenu
|
||||||
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
local zone = entry.Location
|
||||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,cratesmenu,self._GetCrates, self, _group, _unit, entry)
|
if not noshow then
|
||||||
|
menucount = menucount + 1
|
||||||
|
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
||||||
|
if zone then
|
||||||
|
menutext = string.format("Crate %s (%dkg)[R]",entry.Name,entry.PerCrateMass or 0)
|
||||||
|
end
|
||||||
|
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,cratesmenu,self._GetCrates, self, _group, _unit, entry)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
listmenu = MENU_GROUP_COMMAND:New(_group,"List crates nearby",topcrates, self._ListCratesNearby, self, _group, _unit)
|
listmenu = MENU_GROUP_COMMAND:New(_group,"List crates nearby",topcrates, self._ListCratesNearby, self, _group, _unit)
|
||||||
|
local removecrates = MENU_GROUP_COMMAND:New(_group,"Remove crates nearby",removecratesmenu, self._RemoveCratesNearby, self, _group, _unit)
|
||||||
local unloadmenu = MENU_GROUP_COMMAND:New(_group,"Drop crates",topcrates, self._UnloadCrates, self, _group, _unit)
|
local unloadmenu = MENU_GROUP_COMMAND:New(_group,"Drop crates",topcrates, self._UnloadCrates, self, _group, _unit)
|
||||||
if not self.nobuildmenu then
|
if not self.nobuildmenu then
|
||||||
local buildmenu = MENU_GROUP_COMMAND:New(_group,"Build crates",topcrates, self._BuildCrates, self, _group, _unit)
|
local buildmenu = MENU_GROUP_COMMAND:New(_group,"Build crates",topcrates, self._BuildCrates, self, _group, _unit)
|
||||||
@@ -3694,9 +3918,11 @@ end
|
|||||||
-- @param #CTLD_CARGO.Enum Type Type of cargo. I.e. VEHICLE or FOB. VEHICLE will move to destination zones when dropped/build, FOB stays put.
|
-- @param #CTLD_CARGO.Enum Type Type of cargo. I.e. VEHICLE or FOB. VEHICLE will move to destination zones when dropped/build, FOB stays put.
|
||||||
-- @param #number NoCrates Number of crates needed to build this cargo.
|
-- @param #number NoCrates Number of crates needed to build this cargo.
|
||||||
-- @param #number PerCrateMass Mass in kg of each crate
|
-- @param #number PerCrateMass Mass in kg of each crate
|
||||||
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
-- @param #number Stock Number of buildable groups in stock. Nil for unlimited.
|
||||||
-- @param #string SubCategory Name of sub-category (optional).
|
-- @param #string SubCategory Name of sub-category (optional).
|
||||||
function CTLD:AddCratesCargo(Name,Templates,Type,NoCrates,PerCrateMass,Stock,SubCategory)
|
-- @param #boolean DontShowInMenu (optional) If set to "true" this won't show up in the menu.
|
||||||
|
-- @param Core.Zone#ZONE Location (optional) If set, the cargo item is **only** available here. Can be a #ZONE object or the name of a zone as #string.
|
||||||
|
function CTLD:AddCratesCargo(Name,Templates,Type,NoCrates,PerCrateMass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
self:T(self.lid .. " AddCratesCargo")
|
self:T(self.lid .. " AddCratesCargo")
|
||||||
if not self:_CheckTemplates(Templates) then
|
if not self:_CheckTemplates(Templates) then
|
||||||
self:E(self.lid .. "Crates Cargo for " .. Name .. " has missing template(s)!" )
|
self:E(self.lid .. "Crates Cargo for " .. Name .. " has missing template(s)!" )
|
||||||
@@ -3704,7 +3930,7 @@ function CTLD:AddCratesCargo(Name,Templates,Type,NoCrates,PerCrateMass,Stock,Sub
|
|||||||
end
|
end
|
||||||
self.CargoCounter = self.CargoCounter + 1
|
self.CargoCounter = self.CargoCounter + 1
|
||||||
-- Crates are not directly loadable
|
-- Crates are not directly loadable
|
||||||
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Templates,Type,false,false,NoCrates,nil,nil,PerCrateMass,Stock,SubCategory)
|
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Templates,Type,false,false,NoCrates,nil,nil,PerCrateMass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
table.insert(self.Cargo_Crates,cargo)
|
table.insert(self.Cargo_Crates,cargo)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -3715,13 +3941,15 @@ end
|
|||||||
-- @param #number Mass Mass in kg of each static in kg, e.g. 100.
|
-- @param #number Mass Mass in kg of each static in kg, e.g. 100.
|
||||||
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
||||||
-- @param #string SubCategory Name of sub-category (optional).
|
-- @param #string SubCategory Name of sub-category (optional).
|
||||||
function CTLD:AddStaticsCargo(Name,Mass,Stock,SubCategory)
|
-- @param #boolean DontShowInMenu (optional) If set to "true" this won't show up in the menu.
|
||||||
|
-- @param Core.Zone#ZONE Location (optional) If set, the cargo item is **only** available here. Can be a #ZONE object or the name of a zone as #string.
|
||||||
|
function CTLD:AddStaticsCargo(Name,Mass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
self:T(self.lid .. " AddStaticsCargo")
|
self:T(self.lid .. " AddStaticsCargo")
|
||||||
self.CargoCounter = self.CargoCounter + 1
|
self.CargoCounter = self.CargoCounter + 1
|
||||||
local type = CTLD_CARGO.Enum.STATIC
|
local type = CTLD_CARGO.Enum.STATIC
|
||||||
local template = STATIC:FindByName(Name,true):GetTypeName()
|
local template = STATIC:FindByName(Name,true):GetTypeName()
|
||||||
-- Crates are not directly loadable
|
-- Crates are not directly loadable
|
||||||
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,template,type,false,false,1,nil,nil,Mass,Stock,SubCategory)
|
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,template,type,false,false,1,nil,nil,Mass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
table.insert(self.Cargo_Statics,cargo)
|
table.insert(self.Cargo_Statics,cargo)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -3751,7 +3979,9 @@ end
|
|||||||
-- @param #number PerCrateMass Mass in kg of each crate
|
-- @param #number PerCrateMass Mass in kg of each crate
|
||||||
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
||||||
-- @param #string SubCategory Name of the sub-category (optional).
|
-- @param #string SubCategory Name of the sub-category (optional).
|
||||||
function CTLD:AddCratesRepair(Name,Template,Type,NoCrates, PerCrateMass,Stock,SubCategory)
|
-- @param #boolean DontShowInMenu (optional) If set to "true" this won't show up in the menu.
|
||||||
|
-- @param Core.Zone#ZONE Location (optional) If set, the cargo item is **only** available here. Can be a #ZONE object or the name of a zone as #string.
|
||||||
|
function CTLD:AddCratesRepair(Name,Template,Type,NoCrates, PerCrateMass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
self:T(self.lid .. " AddCratesRepair")
|
self:T(self.lid .. " AddCratesRepair")
|
||||||
if not self:_CheckTemplates(Template) then
|
if not self:_CheckTemplates(Template) then
|
||||||
self:E(self.lid .. "Repair Cargo for " .. Name .. " has a missing template!" )
|
self:E(self.lid .. "Repair Cargo for " .. Name .. " has a missing template!" )
|
||||||
@@ -3759,7 +3989,7 @@ function CTLD:AddCratesRepair(Name,Template,Type,NoCrates, PerCrateMass,Stock,Su
|
|||||||
end
|
end
|
||||||
self.CargoCounter = self.CargoCounter + 1
|
self.CargoCounter = self.CargoCounter + 1
|
||||||
-- Crates are not directly loadable
|
-- Crates are not directly loadable
|
||||||
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Template,Type,false,false,NoCrates,nil,nil,PerCrateMass,Stock,SubCategory)
|
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Template,Type,false,false,NoCrates,nil,nil,PerCrateMass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
table.insert(self.Cargo_Crates,cargo)
|
table.insert(self.Cargo_Crates,cargo)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -4236,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
|
||||||
@@ -4339,7 +4568,7 @@ end
|
|||||||
-- @param #number Trooplimit Unit can carry number of troops. Default 0.
|
-- @param #number Trooplimit Unit can carry number of troops. Default 0.
|
||||||
-- @param #number Length Unit lenght (in metres) for the load radius. Default 20.
|
-- @param #number Length Unit lenght (in metres) for the load radius. Default 20.
|
||||||
-- @param #number Maxcargoweight Maxmimum weight in kgs this helo can carry. Default 500.
|
-- @param #number Maxcargoweight Maxmimum weight in kgs this helo can carry. Default 500.
|
||||||
function CTLD:UnitCapabilities(Unittype, Cancrates, Cantroops, Cratelimit, Trooplimit, Length, Maxcargoweight)
|
function CTLD:SetUnitCapabilities(Unittype, Cancrates, Cantroops, Cratelimit, Trooplimit, Length, Maxcargoweight)
|
||||||
self:T(self.lid .. " UnitCapabilities")
|
self:T(self.lid .. " UnitCapabilities")
|
||||||
local unittype = nil
|
local unittype = nil
|
||||||
local unit = nil
|
local unit = nil
|
||||||
@@ -4353,13 +4582,13 @@ end
|
|||||||
end
|
end
|
||||||
local length = 20
|
local length = 20
|
||||||
local maxcargo = 500
|
local maxcargo = 500
|
||||||
local existingcaps = self.UnitTypes[unittype] -- #CTLD.UnitCapabilities
|
local existingcaps = self.UnitTypeCapabilities[unittype] -- #CTLD.UnitTypeCapabilities
|
||||||
if existingcaps then
|
if existingcaps then
|
||||||
length = existingcaps.length or 20
|
length = existingcaps.length or 20
|
||||||
maxcargo = existingcaps.cargoweightlimit or 500
|
maxcargo = existingcaps.cargoweightlimit or 500
|
||||||
end
|
end
|
||||||
-- set capabilities
|
-- set capabilities
|
||||||
local capabilities = {} -- #CTLD.UnitCapabilities
|
local capabilities = {} -- #CTLD.UnitTypeCapabilities
|
||||||
capabilities.type = unittype
|
capabilities.type = unittype
|
||||||
capabilities.crates = Cancrates or false
|
capabilities.crates = Cancrates or false
|
||||||
capabilities.troops = Cantroops or false
|
capabilities.troops = Cantroops or false
|
||||||
@@ -4367,10 +4596,26 @@ end
|
|||||||
capabilities.trooplimit = Trooplimit or 0
|
capabilities.trooplimit = Trooplimit or 0
|
||||||
capabilities.length = Length or length
|
capabilities.length = Length or length
|
||||||
capabilities.cargoweightlimit = Maxcargoweight or maxcargo
|
capabilities.cargoweightlimit = Maxcargoweight or maxcargo
|
||||||
self.UnitTypes[unittype] = capabilities
|
self.UnitTypeCapabilities[unittype] = capabilities
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [Deprecated] - Function to add/adjust unittype capabilities. Has been replaced with `SetUnitCapabilities()` - pls use the new one going forward!
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param #string Unittype The unittype to adjust. If passed as Wrapper.Unit#UNIT, it will search for the unit in the mission.
|
||||||
|
-- @param #boolean Cancrates Unit can load crates. Default false.
|
||||||
|
-- @param #boolean Cantroops Unit can load troops. Default false.
|
||||||
|
-- @param #number Cratelimit Unit can carry number of crates. Default 0.
|
||||||
|
-- @param #number Trooplimit Unit can carry number of troops. Default 0.
|
||||||
|
-- @param #number Length Unit lenght (in metres) for the load radius. Default 20.
|
||||||
|
-- @param #number Maxcargoweight Maxmimum weight in kgs this helo can carry. Default 500.
|
||||||
|
function CTLD:UnitCapabilities(Unittype, Cancrates, Cantroops, Cratelimit, Trooplimit, Length, Maxcargoweight)
|
||||||
|
self:I(self.lid.."This function been replaced with `SetUnitCapabilities()` - pls use the new one going forward!")
|
||||||
|
self:SetUnitCapabilities(Unittype, Cancrates, Cantroops, Cratelimit, Trooplimit, Length, Maxcargoweight)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- (Internal) Check if a unit is hovering *in parameters*.
|
--- (Internal) Check if a unit is hovering *in parameters*.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param Wrapper.Unit#UNIT Unit
|
-- @param Wrapper.Unit#UNIT Unit
|
||||||
@@ -4523,7 +4768,7 @@ end
|
|||||||
local unittype = Unit:GetTypeName()
|
local unittype = Unit:GetTypeName()
|
||||||
local unitname = Unit:GetName()
|
local unitname = Unit:GetName()
|
||||||
local Group = Unit:GetGroup()
|
local Group = Unit:GetGroup()
|
||||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||||
local cancrates = capabilities.crates -- #boolean
|
local cancrates = capabilities.crates -- #boolean
|
||||||
local cratelimit = capabilities.cratelimit -- #number
|
local cratelimit = capabilities.cratelimit -- #number
|
||||||
if cancrates then
|
if cancrates then
|
||||||
@@ -5208,19 +5453,19 @@ end
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- (Internal) FSM Function onbeforeTroopsExtracted.
|
--- (Internal) FSM Function onbeforeTroopsExtracted.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param #string From State.
|
-- @param #string From State.
|
||||||
-- @param #string Event Trigger.
|
-- @param #string Event Trigger.
|
||||||
-- @param #string To State.
|
-- @param #string To State.
|
||||||
-- @param Wrapper.Group#GROUP Group Group Object.
|
-- @param Wrapper.Group#GROUP Group Group Object.
|
||||||
-- @param Wrapper.Unit#UNIT Unit Unit Object.
|
-- @param Wrapper.Unit#UNIT Unit Unit Object.
|
||||||
-- @param Wrapper.Group#GROUP Troops Troops #GROUP Object.
|
-- @param Wrapper.Group#GROUP Troops Troops #GROUP Object.
|
||||||
-- @return #CTLD self
|
-- @return #CTLD self
|
||||||
function CTLD:onbeforeTroopsExtracted(From, Event, To, Group, Unit, Troops)
|
function CTLD:onbeforeTroopsExtracted(From, Event, To, Group, Unit, Troops)
|
||||||
self:T({From, Event, To})
|
self:T({From, Event, To})
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- (Internal) FSM Function onbeforeTroopsDeployed.
|
--- (Internal) FSM Function onbeforeTroopsDeployed.
|
||||||
|
|||||||
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
|
||||||
@@ -30,6 +30,10 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Sound/Radio)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
-- ### Authors: Hugues "Grey_Echo" Bousquet, funkyfranky
|
-- ### Authors: Hugues "Grey_Echo" Bousquet, funkyfranky
|
||||||
--
|
--
|
||||||
-- @module Sound.Radio
|
-- @module Sound.Radio
|
||||||
|
|||||||
@@ -183,8 +183,10 @@ end
|
|||||||
-- @param #number Port SRS port. Default 5002.
|
-- @param #number Port SRS port. Default 5002.
|
||||||
-- @return #RADIOQUEUE self The RADIOQUEUE object.
|
-- @return #RADIOQUEUE self The RADIOQUEUE object.
|
||||||
function RADIOQUEUE:SetSRS(PathToSRS, Port)
|
function RADIOQUEUE:SetSRS(PathToSRS, Port)
|
||||||
self.msrs=MSRS:New(PathToSRS, self.frequency/1000000, self.modulation)
|
local path = PathToSRS or MSRS.path
|
||||||
self.msrs:SetPort(Port)
|
local port = Port or MSRS.port
|
||||||
|
self.msrs=MSRS:New(path, self.frequency/1000000, self.modulation)
|
||||||
|
self.msrs:SetPort(port)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -160,24 +160,28 @@ do -- Sound File
|
|||||||
-- @param #string FileName The name of the sound file, e.g. "Hello World.ogg".
|
-- @param #string FileName The name of the sound file, e.g. "Hello World.ogg".
|
||||||
-- @param #string Path The path of the directory, where the sound file is located. Default is "l10n/DEFAULT/" within the miz file.
|
-- @param #string Path The path of the directory, where the sound file is located. Default is "l10n/DEFAULT/" within the miz file.
|
||||||
-- @param #number Duration Duration in seconds, how long it takes to play the sound file. Default is 3 seconds.
|
-- @param #number Duration Duration in seconds, how long it takes to play the sound file. Default is 3 seconds.
|
||||||
|
-- @param #bolean UseSrs Set if SRS should be used to play this file. Default is false.
|
||||||
-- @return #SOUNDFILE self
|
-- @return #SOUNDFILE self
|
||||||
function SOUNDFILE:New(FileName, Path, Duration)
|
function SOUNDFILE:New(FileName, Path, Duration, UseSrs)
|
||||||
|
|
||||||
-- Inherit BASE.
|
-- Inherit BASE.
|
||||||
local self=BASE:Inherit(self, BASE:New()) -- #SOUNDFILE
|
local self=BASE:Inherit(self, BASE:New()) -- #SOUNDFILE
|
||||||
|
|
||||||
|
-- Debug info:
|
||||||
|
self:F( {FileName, Path, Duration, UseSrs} )
|
||||||
|
|
||||||
-- Set file name.
|
-- Set file name.
|
||||||
self:SetFileName(FileName)
|
self:SetFileName(FileName)
|
||||||
|
|
||||||
|
-- Set if SRS should be used to play this file
|
||||||
|
self:SetPlayWithSRS(UseSrs or false)
|
||||||
|
|
||||||
-- Set path.
|
-- Set path.
|
||||||
self:SetPath(Path)
|
self:SetPath(Path)
|
||||||
|
|
||||||
-- Set duration.
|
-- Set duration.
|
||||||
self:SetDuration(Duration)
|
self:SetDuration(Duration)
|
||||||
|
|
||||||
-- Debug info:
|
|
||||||
self:T(string.format("New SOUNDFILE: file name=%s, path=%s", self.filename, self.path))
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -186,12 +190,17 @@ do -- Sound File
|
|||||||
-- @param #string Path Path to the directory, where the sound file is located. In case this is nil, it defaults to the DCS mission temp directory.
|
-- @param #string Path Path to the directory, where the sound file is located. In case this is nil, it defaults to the DCS mission temp directory.
|
||||||
-- @return #SOUNDFILE self
|
-- @return #SOUNDFILE self
|
||||||
function SOUNDFILE:SetPath(Path)
|
function SOUNDFILE:SetPath(Path)
|
||||||
|
self:F( {Path} )
|
||||||
|
|
||||||
-- Init path.
|
-- Init path.
|
||||||
self.path=Path or "l10n/DEFAULT/"
|
if not Path then
|
||||||
|
if self.useSRS then -- use path to mission temp dir
|
||||||
if not Path and self.useSRS then -- use path to mission temp dir
|
self.path = lfs.tempdir() .. "Mission\\l10n\\DEFAULT"
|
||||||
self.path = os.getenv('TMP') .. "\\DCS\\Mission\\l10n\\DEFAULT"
|
else -- use internal path in miz file
|
||||||
|
self.path="l10n/DEFAULT/"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.path = Path
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove (back)slashes.
|
-- Remove (back)slashes.
|
||||||
@@ -204,6 +213,8 @@ do -- Sound File
|
|||||||
-- Append slash.
|
-- Append slash.
|
||||||
self.path=self.path.."/"
|
self.path=self.path.."/"
|
||||||
|
|
||||||
|
self:T("self.path=".. self.path)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -264,11 +275,13 @@ do -- Sound File
|
|||||||
-- @param #boolean Switch If true or nil, use SRS. If false, use DCS transmission.
|
-- @param #boolean Switch If true or nil, use SRS. If false, use DCS transmission.
|
||||||
-- @return #SOUNDFILE self
|
-- @return #SOUNDFILE self
|
||||||
function SOUNDFILE:SetPlayWithSRS(Switch)
|
function SOUNDFILE:SetPlayWithSRS(Switch)
|
||||||
|
self:F( {Switch} )
|
||||||
if Switch==true or Switch==nil then
|
if Switch==true or Switch==nil then
|
||||||
self.useSRS=true
|
self.useSRS=true
|
||||||
else
|
else
|
||||||
self.useSRS=false
|
self.useSRS=false
|
||||||
end
|
end
|
||||||
|
self:T("self.useSRS=".. tostring(self.useSRS))
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ do -- UserSound
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Play the usersound to the given @{Wrapper.Unit}.
|
--- Play the usersound to the given @{Wrapper.Unit}.
|
||||||
-- @param #USERSOUND self
|
-- @param #USERSOUND self
|
||||||
-- @param Wrapper.Unit#UNIT Unit The @{Wrapper.Unit} to play the usersound to.
|
-- @param Wrapper.Unit#UNIT Unit The @{Wrapper.Unit} to play the usersound to.
|
||||||
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
|
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
|
||||||
@@ -159,4 +159,24 @@ do -- UserSound
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Play the usersound to the given @{Wrapper.Client}.
|
||||||
|
-- @param #USERSOUND self
|
||||||
|
-- @param Wrapper.Client#CLIENT The @{Wrapper.Client} to play the usersound to.
|
||||||
|
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
|
||||||
|
-- @return #USERSOUND The usersound instance.
|
||||||
|
-- @usage
|
||||||
|
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||||
|
-- local PlayerUnit = CLIENT:FindByPlayerName("Karl Heinz")-- Search for the active client with playername "Karl Heinz", a human player.
|
||||||
|
-- BlueVictory:ToClient( PlayerUnit ) -- Play the victory sound to the player unit.
|
||||||
|
--
|
||||||
|
function USERSOUND:ToClient( Client, Delay )
|
||||||
|
Delay=Delay or 0
|
||||||
|
if Delay>0 then
|
||||||
|
SCHEDULER:New(nil, USERSOUND.ToClient,{self, Client}, Delay)
|
||||||
|
else
|
||||||
|
trigger.action.outSoundForUnit( Client:GetID(), self.UserSoundFileName )
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
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 )
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
--
|
--
|
||||||
-- Test missions can be located on the main GITHUB site.
|
-- Test missions can be located on the main GITHUB site.
|
||||||
--
|
--
|
||||||
-- [FlightControl-Master/MOOSE_MISSIONS/TAD - Task Dispatching/CGO - Cargo Dispatching/](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/TAD%20-%20Task%20Dispatching/CGO%20-%20Cargo%20Task%20Dispatching)
|
-- [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Tasking/Task_Cargo_Dispatcher)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ ENUMS = {}
|
|||||||
--- Suppress the error box
|
--- Suppress the error box
|
||||||
env.setErrorMessageBoxEnabled( false )
|
env.setErrorMessageBoxEnabled( false )
|
||||||
|
|
||||||
|
|
||||||
--- Rules of Engagement.
|
--- Rules of Engagement.
|
||||||
-- @type ENUMS.ROE
|
-- @type ENUMS.ROE
|
||||||
-- @field #number WeaponFree [AIR] AI will engage any enemy group it detects. Target prioritization is based based on the threat of the target.
|
-- @field #number WeaponFree [AIR] AI will engage any enemy group it detects. Target prioritization is based based on the threat of the target.
|
||||||
@@ -524,6 +523,7 @@ ENUMS.ReportingName =
|
|||||||
Hawkeye = "E-2D",
|
Hawkeye = "E-2D",
|
||||||
Sentry = "E-3A",
|
Sentry = "E-3A",
|
||||||
Stratotanker = "KC-135",
|
Stratotanker = "KC-135",
|
||||||
|
Gasstation = "KC-135MPRS",
|
||||||
Extender = "KC-10",
|
Extender = "KC-10",
|
||||||
Orion = "P-3C",
|
Orion = "P-3C",
|
||||||
Viking = "S-3B",
|
Viking = "S-3B",
|
||||||
@@ -567,6 +567,14 @@ ENUMS.ReportingName =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Enums for Link16 transmit power
|
||||||
|
-- @type ENUMS.Link16Power
|
||||||
|
ENUMS.Link16Power = {
|
||||||
|
none = 0,
|
||||||
|
low = 1,
|
||||||
|
medium = 2,
|
||||||
|
high = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Enums for the STORAGE class for stores - which need to be in ""
|
--- Enums for the STORAGE class for stores - which need to be in ""
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -99,7 +99,7 @@
|
|||||||
-- This method can also be used to **embed a function call when a certain waypoint has been reached**.
|
-- This method can also be used to **embed a function call when a certain waypoint has been reached**.
|
||||||
-- See below the **Tasks at Waypoints** section.
|
-- See below the **Tasks at Waypoints** section.
|
||||||
--
|
--
|
||||||
-- Demonstration Mission: [GRP-502 - Route at waypoint to random point](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/GRP%20-%20Group%20Commands/GRP-502%20-%20Route%20at%20waypoint%20to%20random%20point)
|
-- Demonstration Mission: [GRP-502 - Route at waypoint to random point](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Wrapper/Group/502-Route-at-waypoint-to-random-point)
|
||||||
--
|
--
|
||||||
-- ## 2.5) Tasks at Waypoints
|
-- ## 2.5) Tasks at Waypoints
|
||||||
--
|
--
|
||||||
@@ -938,20 +938,22 @@ end
|
|||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param #number Frequency Radio frequency in MHz.
|
-- @param #number Frequency Radio frequency in MHz.
|
||||||
-- @param #number Modulation Radio modulation. Default `radio.modulation.AM`.
|
-- @param #number Modulation Radio modulation. Default `radio.modulation.AM`.
|
||||||
|
-- @param #number Power (Optional) Power of the Radio in Watts. Defaults to 10.
|
||||||
-- @param #number Delay (Optional) Delay in seconds before the frequency is set. Default is immediately.
|
-- @param #number Delay (Optional) Delay in seconds before the frequency is set. Default is immediately.
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:CommandSetFrequency( Frequency, Modulation, Delay )
|
function CONTROLLABLE:CommandSetFrequency( Frequency, Modulation, Power, Delay )
|
||||||
|
|
||||||
local CommandSetFrequency = {
|
local CommandSetFrequency = {
|
||||||
id = 'SetFrequency',
|
id = 'SetFrequency',
|
||||||
params = {
|
params = {
|
||||||
frequency = Frequency * 1000000,
|
frequency = Frequency * 1000000,
|
||||||
modulation = Modulation or radio.modulation.AM,
|
modulation = Modulation or radio.modulation.AM,
|
||||||
|
power=Power or 10,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if Delay and Delay > 0 then
|
if Delay and Delay > 0 then
|
||||||
SCHEDULER:New( nil, self.CommandSetFrequency, { self, Frequency, Modulation }, Delay )
|
SCHEDULER:New( nil, self.CommandSetFrequency, { self, Frequency, Modulation, Power } )
|
||||||
else
|
else
|
||||||
self:SetCommand( CommandSetFrequency )
|
self:SetCommand( CommandSetFrequency )
|
||||||
end
|
end
|
||||||
@@ -959,6 +961,32 @@ function CONTROLLABLE:CommandSetFrequency( Frequency, Modulation, Delay )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set radio frequency. See [DCS command EPLRS](https://wiki.hoggitworld.com/view/DCS_command_setFrequencyForUnit)
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #number Frequency Radio frequency in MHz.
|
||||||
|
-- @param #number Modulation Radio modulation. Default `radio.modulation.AM`.
|
||||||
|
-- @param #number Power (Optional) Power of the Radio in Watts. Defaults to 10.
|
||||||
|
-- @param #UnitID UnitID (Optional, if your object is a UNIT) The UNIT ID this is for.
|
||||||
|
-- @param #number Delay (Optional) Delay in seconds before the frequency is set. Default is immediately.
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:CommandSetFrequencyForUnit(Frequency,Modulation,Power,UnitID,Delay)
|
||||||
|
local CommandSetFrequencyForUnit={
|
||||||
|
id='SetFrequencyForUnit',
|
||||||
|
params={
|
||||||
|
frequency=Frequency*1000000,
|
||||||
|
modulation=Modulation or radio.modulation.AM,
|
||||||
|
unitId=UnitID or self:GetID(),
|
||||||
|
power=Power or 10,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if Delay and Delay>0 then
|
||||||
|
SCHEDULER:New(nil,self.CommandSetFrequencyForUnit,{self,Frequency,Modulation,Power,UnitID})
|
||||||
|
else
|
||||||
|
self:SetCommand(CommandSetFrequencyForUnit)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Set EPLRS data link on/off.
|
--- Set EPLRS data link on/off.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param #boolean SwitchOnOff If true (or nil) switch EPLRS on. If false switch off.
|
-- @param #boolean SwitchOnOff If true (or nil) switch EPLRS on. If false switch off.
|
||||||
@@ -2145,7 +2173,7 @@ do -- Patrol methods
|
|||||||
local Waypoint = Waypoints[#Waypoints]
|
local Waypoint = Waypoints[#Waypoints]
|
||||||
PatrolGroup:SetTaskWaypoint( Waypoint, TaskRoute ) -- Set for the given Route at Waypoint 2 the TaskRouteToZone.
|
PatrolGroup:SetTaskWaypoint( Waypoint, TaskRoute ) -- Set for the given Route at Waypoint 2 the TaskRouteToZone.
|
||||||
|
|
||||||
PatrolGroup:Route( Waypoints ) -- Move after a random seconds to the Route. See the Route method for details.
|
PatrolGroup:Route( Waypoints, 2 ) -- Move after a random seconds to the Route. See the Route method for details.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2937,7 +2965,7 @@ function CONTROLLABLE:CopyRoute( Begin, End, Randomize, Radius )
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Return the detected targets of the controllable.
|
--- Return the detected targets of the controllable.
|
||||||
-- The optional parametes specify the detection methods that can be applied.
|
-- The optional parameters specify the detection methods that can be applied.
|
||||||
-- If no detection method is given, the detection will use all the available methods by default.
|
-- If no detection method is given, the detection will use all the available methods by default.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param #boolean DetectVisual (optional)
|
-- @param #boolean DetectVisual (optional)
|
||||||
@@ -3772,54 +3800,66 @@ function CONTROLLABLE:OptionProhibitAfterburner( Prohibit )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Defines the usage of Electronic Counter Measures by airborne forces. Disables the ability for AI to use their ECM.
|
--- [Air] Defines the usage of Electronic Counter Measures by airborne forces.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #number ECMvalue Can be - 0=Never on, 1=if locked by radar, 2=if detected by radar, 3=always on, defaults to 1
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:OptionECM( ECMvalue )
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if DCSControllable then
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
|
||||||
|
if self:IsAir() then
|
||||||
|
Controller:setOption( AI.Option.Air.id.ECM_USING, ECMvalue or 1 )
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [Air] Defines the usage of Electronic Counter Measures by airborne forces. Disables the ability for AI to use their ECM.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:OptionECM_Never()
|
function CONTROLLABLE:OptionECM_Never()
|
||||||
self:F2( { self.ControllableName } )
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
if self:IsAir() then
|
self:OptionECM(0)
|
||||||
self:SetOption( AI.Option.Air.id.ECM_USING, 0 )
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Defines the usage of Electronic Counter Measures by airborne forces. If the AI is actively being locked by an enemy radar they will enable their ECM jammer.
|
--- [Air] Defines the usage of Electronic Counter Measures by airborne forces. If the AI is actively being locked by an enemy radar they will enable their ECM jammer.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:OptionECM_OnlyLockByRadar()
|
function CONTROLLABLE:OptionECM_OnlyLockByRadar()
|
||||||
self:F2( { self.ControllableName } )
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
if self:IsAir() then
|
self:OptionECM(1)
|
||||||
self:SetOption( AI.Option.Air.id.ECM_USING, 1 )
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Defines the usage of Electronic Counter Measures by airborne forces. If the AI is being detected by a radar they will enable their ECM.
|
--- [Air] Defines the usage of Electronic Counter Measures by airborne forces. If the AI is being detected by a radar they will enable their ECM.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:OptionECM_DetectedLockByRadar()
|
function CONTROLLABLE:OptionECM_DetectedLockByRadar()
|
||||||
self:F2( { self.ControllableName } )
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
if self:IsAir() then
|
self:OptionECM(2)
|
||||||
self:SetOption( AI.Option.Air.id.ECM_USING, 2 )
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Defines the usage of Electronic Counter Measures by airborne forces. AI will leave their ECM on all the time.
|
--- [Air] Defines the usage of Electronic Counter Measures by airborne forces. AI will leave their ECM on all the time.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:OptionECM_AlwaysOn()
|
function CONTROLLABLE:OptionECM_AlwaysOn()
|
||||||
self:F2( { self.ControllableName } )
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
if self:IsAir() then
|
self:OptionECM(3)
|
||||||
self:SetOption( AI.Option.Air.id.ECM_USING, 3 )
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -3831,6 +3871,10 @@ end
|
|||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param #table WayPoints If WayPoints is given, then use the route.
|
-- @param #table WayPoints If WayPoints is given, then use the route.
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
|
-- @usage Intended Workflow is:
|
||||||
|
-- mygroup:WayPointInitialize()
|
||||||
|
-- mygroup:WayPointFunction( WayPoint, WayPointIndex, WayPointFunction, ... )
|
||||||
|
-- mygroup:WayPointExecute()
|
||||||
function CONTROLLABLE:WayPointInitialize( WayPoints )
|
function CONTROLLABLE:WayPointInitialize( WayPoints )
|
||||||
self:F( { WayPoints } )
|
self:F( { WayPoints } )
|
||||||
|
|
||||||
@@ -3862,9 +3906,15 @@ end
|
|||||||
-- @param #number WayPointIndex When defining multiple WayPoint functions for one WayPoint, use WayPointIndex to set the sequence of actions.
|
-- @param #number WayPointIndex When defining multiple WayPoint functions for one WayPoint, use WayPointIndex to set the sequence of actions.
|
||||||
-- @param #function WayPointFunction The waypoint function to be called when the controllable moves over the waypoint. The waypoint function takes variable parameters.
|
-- @param #function WayPointFunction The waypoint function to be called when the controllable moves over the waypoint. The waypoint function takes variable parameters.
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
|
-- @usage Intended Workflow is:
|
||||||
|
-- mygroup:WayPointInitialize()
|
||||||
|
-- mygroup:WayPointFunction( WayPoint, WayPointIndex, WayPointFunction, ... )
|
||||||
|
-- mygroup:WayPointExecute()
|
||||||
function CONTROLLABLE:WayPointFunction( WayPoint, WayPointIndex, WayPointFunction, ... )
|
function CONTROLLABLE:WayPointFunction( WayPoint, WayPointIndex, WayPointFunction, ... )
|
||||||
self:F2( { WayPoint, WayPointIndex, WayPointFunction } )
|
self:F2( { WayPoint, WayPointIndex, WayPointFunction } )
|
||||||
|
if not self.WayPoints then
|
||||||
|
self:WayPointInitialize()
|
||||||
|
end
|
||||||
table.insert( self.WayPoints[WayPoint].task.params.tasks, WayPointIndex )
|
table.insert( self.WayPoints[WayPoint].task.params.tasks, WayPointIndex )
|
||||||
self.WayPoints[WayPoint].task.params.tasks[WayPointIndex] = self:TaskFunction( WayPointFunction, arg )
|
self.WayPoints[WayPoint].task.params.tasks[WayPointIndex] = self:TaskFunction( WayPointFunction, arg )
|
||||||
return self
|
return self
|
||||||
@@ -3877,6 +3927,10 @@ end
|
|||||||
-- @param #number WayPoint The WayPoint from where to execute the mission.
|
-- @param #number WayPoint The WayPoint from where to execute the mission.
|
||||||
-- @param #number WaitTime The amount seconds to wait before initiating the mission.
|
-- @param #number WaitTime The amount seconds to wait before initiating the mission.
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
|
-- @usage Intended Workflow is:
|
||||||
|
-- mygroup:WayPointInitialize()
|
||||||
|
-- mygroup:WayPointFunction( WayPoint, WayPointIndex, WayPointFunction, ... )
|
||||||
|
-- mygroup:WayPointExecute()
|
||||||
function CONTROLLABLE:WayPointExecute( WayPoint, WaitTime )
|
function CONTROLLABLE:WayPointExecute( WayPoint, WaitTime )
|
||||||
self:F( { WayPoint, WaitTime } )
|
self:F( { WayPoint, WaitTime } )
|
||||||
|
|
||||||
@@ -3974,7 +4028,7 @@ function CONTROLLABLE:OptionAAAttackRange( range )
|
|||||||
local Controller = self:_GetController()
|
local Controller = self:_GetController()
|
||||||
if Controller then
|
if Controller then
|
||||||
if self:IsAir() then
|
if self:IsAir() then
|
||||||
self:SetOption( AI.Option.Air.val.MISSILE_ATTACK, range )
|
self:SetOption( AI.Option.Air.id.MISSILE_ATTACK, range )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -4006,6 +4060,130 @@ function CONTROLLABLE:OptionEngageRange( EngageRange )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set how the AI uses the onboard radar.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #number Option Options are: `NEVER = 0, FOR_ATTACK_ONLY = 1,FOR_SEARCH_IF_REQUIRED = 2, FOR_CONTINUOUS_SEARCH = 3`
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadarUsing(Option)
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.RADAR_USING,Option)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set how the AI uses the onboard radar. Here: never.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadarUsingNever()
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.RADAR_USING,0)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set how the AI uses the onboard radar, here: for attack only.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadarUsingForAttackOnly()
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.RADAR_USING,1)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set how the AI uses the onboard radar, here: when required for searching.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadarUsingForSearchIfRequired()
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.RADAR_USING,2)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set how the AI uses the onboard radar, here: always on.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadarUsingForContinousSearch()
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.RADAR_USING,3)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set if the AI is reporting passing of waypoints
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #boolean OnOff If true or nil, AI will report passing waypoints, if false, it will not.
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionWaypointPassReport(OnOff)
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
local onoff = (OnOff == nil or OnOff == true) and false or true
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.PROHIBIT_WP_PASS_REPORT,onoff)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set the AI to not report anything over the radio - radio silence
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #boolean OnOff If true or nil, radio is set to silence, if false radio silence is lifted.
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadioSilence(OnOff)
|
||||||
|
local onoff = (OnOff == true or OnOff == nil) and true or false
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.SILENCE,onoff)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set the AI to report contact for certain types of objects.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #table Objects Table of attribute names for which AI reports contact. Defaults to {"Air"}. See [Hoggit Wiki](https://wiki.hoggitworld.com/view/DCS_enum_attributes)
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadioContact(Objects)
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if not Objects then Objects = {"Air"} end
|
||||||
|
if type(Objects) ~= "table" then Objects = {Objects} end
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.OPTION_RADIO_USAGE_CONTACT,Objects)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set the AI to report engaging certain types of objects.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #table Objects Table of attribute names for which AI reports contact. Defaults to {"Air"}, see [Hoggit Wiki](https://wiki.hoggitworld.com/view/DCS_enum_attributes)
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadioEngage(Objects)
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if not Objects then Objects = {"Air"} end
|
||||||
|
if type(Objects) ~= "table" then Objects = {Objects} end
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.OPTION_RADIO_USAGE_ENGAGE,Objects)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Set the AI to report killing certain types of objects.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #table Objects Table of attribute names for which AI reports contact. Defaults to {"Air"}, see [Hoggit Wiki](https://wiki.hoggitworld.com/view/DCS_enum_attributes)
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetOptionRadioKill(Objects)
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
if not Objects then Objects = {"Air"} end
|
||||||
|
if type(Objects) ~= "table" then Objects = {Objects} end
|
||||||
|
if self:IsAir() then
|
||||||
|
self:SetOption(AI.Option.Air.id.OPTION_RADIO_USAGE_KILL,Objects)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- (GROUND) Relocate controllable to a random point within a given radius; use e.g.for evasive actions; Note that not all ground controllables can actually drive, also the alarm state of the controllable might stop it from moving.
|
--- (GROUND) Relocate controllable to a random point within a given radius; use e.g.for evasive actions; Note that not all ground controllables can actually drive, also the alarm state of the controllable might stop it from moving.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param #number speed Speed of the controllable, default 20
|
-- @param #number speed Speed of the controllable, default 20
|
||||||
@@ -4013,14 +4191,22 @@ end
|
|||||||
-- @param #boolean onroad If true, route on road (less problems with AI way finding), default true
|
-- @param #boolean onroad If true, route on road (less problems with AI way finding), default true
|
||||||
-- @param #boolean shortcut If true and onroad is set, take a shorter route - if available - off road, default false
|
-- @param #boolean shortcut If true and onroad is set, take a shorter route - if available - off road, default false
|
||||||
-- @param #string formation Formation string as in the mission editor, e.g. "Vee", "Diamond", "Line abreast", etc. Defaults to "Off Road"
|
-- @param #string formation Formation string as in the mission editor, e.g. "Vee", "Diamond", "Line abreast", etc. Defaults to "Off Road"
|
||||||
|
-- @param #boolean onland (optional) If true, try up to 50 times to get a coordinate on land.SurfaceType.LAND. Note - this descriptor value is not reliably implemented on all maps.
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:RelocateGroundRandomInRadius( speed, radius, onroad, shortcut, formation )
|
function CONTROLLABLE:RelocateGroundRandomInRadius( speed, radius, onroad, shortcut, formation, onland )
|
||||||
self:F2( { self.ControllableName } )
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
local _coord = self:GetCoordinate()
|
local _coord = self:GetCoordinate()
|
||||||
local _radius = radius or 500
|
local _radius = radius or 500
|
||||||
local _speed = speed or 20
|
local _speed = speed or 20
|
||||||
local _tocoord = _coord:GetRandomCoordinateInRadius( _radius, 100 )
|
local _tocoord = _coord:GetRandomCoordinateInRadius( _radius, 100 )
|
||||||
|
if onland then
|
||||||
|
for i=1,50 do
|
||||||
|
local island = _tocoord:GetSurfaceType() == land.SurfaceType.LAND and true or false
|
||||||
|
if island then break end
|
||||||
|
_tocoord = _coord:GetRandomCoordinateInRadius( _radius, 100 )
|
||||||
|
end
|
||||||
|
end
|
||||||
local _onroad = onroad or true
|
local _onroad = onroad or true
|
||||||
local _grptsk = {}
|
local _grptsk = {}
|
||||||
local _candoroad = false
|
local _candoroad = false
|
||||||
@@ -5337,9 +5523,10 @@ end
|
|||||||
-- @param #number Altitude (Optional) Altitude in meters. Defaults to the altitude of the coordinate.
|
-- @param #number Altitude (Optional) Altitude in meters. Defaults to the altitude of the coordinate.
|
||||||
-- @param #number Speed (Optional) Speed in kph. Defaults to 500 kph.
|
-- @param #number Speed (Optional) Speed in kph. Defaults to 500 kph.
|
||||||
-- @param #number Formation (Optional) Formation to take, e.g. ENUMS.Formation.FixedWing.Trail.Close, also see [Hoggit Wiki](https://wiki.hoggitworld.com/view/DCS_option_formation).
|
-- @param #number Formation (Optional) Formation to take, e.g. ENUMS.Formation.FixedWing.Trail.Close, also see [Hoggit Wiki](https://wiki.hoggitworld.com/view/DCS_option_formation).
|
||||||
|
-- @param #boolean AGL (Optional) If true, set altitude to above ground level (AGL), not above sea level (ASL).
|
||||||
-- @param #number Delay (Optional) Set the task after delay seconds only.
|
-- @param #number Delay (Optional) Set the task after delay seconds only.
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:PatrolRaceTrack(Point1, Point2, Altitude, Speed, Formation, Delay)
|
function CONTROLLABLE:PatrolRaceTrack(Point1, Point2, Altitude, Speed, Formation, AGL, Delay)
|
||||||
|
|
||||||
local PatrolGroup = self -- Wrapper.Group#GROUP
|
local PatrolGroup = self -- Wrapper.Group#GROUP
|
||||||
|
|
||||||
@@ -5361,8 +5548,10 @@ function CONTROLLABLE:PatrolRaceTrack(Point1, Point2, Altitude, Speed, Formation
|
|||||||
|
|
||||||
-- Calculate the new Route
|
-- Calculate the new Route
|
||||||
if Altitude then
|
if Altitude then
|
||||||
FromCoord:SetAltitude(Altitude)
|
local asl = true
|
||||||
ToCoord:SetAltitude(Altitude)
|
if AGL then asl = false end
|
||||||
|
FromCoord:SetAltitude(Altitude, asl)
|
||||||
|
ToCoord:SetAltitude(Altitude, asl)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create a "air waypoint", which is a "point" structure that can be given as a parameter to a Task
|
-- Create a "air waypoint", which is a "point" structure that can be given as a parameter to a Task
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Wrapper/Group)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
-- ### Author: **FlightControl**
|
-- ### Author: **FlightControl**
|
||||||
--
|
--
|
||||||
-- ### Contributions:
|
-- ### Contributions:
|
||||||
@@ -302,7 +306,7 @@ end
|
|||||||
|
|
||||||
--- Find the first(!) GROUP matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
--- Find the first(!) GROUP matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_(Regular_Expressions)) for regular expressions in LUA.
|
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_\(Regular_Expressions\)) for regular expressions in LUA.
|
||||||
-- @return #GROUP The GROUP.
|
-- @return #GROUP The GROUP.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Find a group with a partial group name
|
-- -- Find a group with a partial group name
|
||||||
@@ -327,7 +331,7 @@ end
|
|||||||
|
|
||||||
--- Find all GROUP objects matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
--- Find all GROUP objects matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_(Regular_Expressions)) for regular expressions in LUA.
|
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_\(Regular_Expressions\)) for regular expressions in LUA.
|
||||||
-- @return #table Groups Table of matching #GROUP objects found
|
-- @return #table Groups Table of matching #GROUP objects found
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Find all group with a partial group name
|
-- -- Find all group with a partial group name
|
||||||
@@ -422,7 +426,7 @@ function GROUP:IsActive()
|
|||||||
|
|
||||||
local DCSGroup = self:GetDCSObject() -- DCS#Group
|
local DCSGroup = self:GetDCSObject() -- DCS#Group
|
||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup and DCSGroup:isExist() then
|
||||||
local unit = DCSGroup:getUnit(1)
|
local unit = DCSGroup:getUnit(1)
|
||||||
if unit then
|
if unit then
|
||||||
local GroupIsActive = unit:isActive()
|
local GroupIsActive = unit:isActive()
|
||||||
@@ -689,7 +693,15 @@ function GROUP:GetUnits()
|
|||||||
local DCSUnits = DCSGroup:getUnits() or {}
|
local DCSUnits = DCSGroup:getUnits() or {}
|
||||||
local Units = {}
|
local Units = {}
|
||||||
for Index, UnitData in pairs( DCSUnits ) do
|
for Index, UnitData in pairs( DCSUnits ) do
|
||||||
Units[#Units+1] = UNIT:Find( UnitData )
|
|
||||||
|
local unit=UNIT:Find( UnitData )
|
||||||
|
if unit then
|
||||||
|
Units[#Units+1] = UNIT:Find( UnitData )
|
||||||
|
else
|
||||||
|
local UnitName=UnitData:getName()
|
||||||
|
unit=_DATABASE:AddUnit(UnitName)
|
||||||
|
Units[#Units+1]=unit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self:T3( Units )
|
self:T3( Units )
|
||||||
return Units
|
return Units
|
||||||
@@ -1124,8 +1136,9 @@ function GROUP:GetAverageVec3()
|
|||||||
-- Average.
|
-- Average.
|
||||||
local Vec3={x=x/n, y=y/n, z=z/n} --DCS#Vec3
|
local Vec3={x=x/n, y=y/n, z=z/n} --DCS#Vec3
|
||||||
return Vec3
|
return Vec3
|
||||||
|
else
|
||||||
|
return self:GetVec3()
|
||||||
end
|
end
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a POINT_VEC2 object indicating the point in 2D of the first UNIT of the GROUP within the mission.
|
--- Returns a POINT_VEC2 object indicating the point in 2D of the first UNIT of the GROUP within the mission.
|
||||||
@@ -1157,9 +1170,15 @@ function GROUP:GetAverageCoordinate()
|
|||||||
local coord = COORDINATE:NewFromVec3(vec3)
|
local coord = COORDINATE:NewFromVec3(vec3)
|
||||||
local Heading = self:GetHeading()
|
local Heading = self:GetHeading()
|
||||||
coord.Heading = Heading
|
coord.Heading = Heading
|
||||||
|
return coord
|
||||||
else
|
else
|
||||||
BASE:E( { "Cannot GetAverageCoordinate", Group = self, Alive = self:IsAlive() } )
|
local coord = self:GetCoordinate()
|
||||||
return nil
|
if coord then
|
||||||
|
return coord
|
||||||
|
else
|
||||||
|
BASE:E( { "Cannot GetAverageCoordinate", Group = self, Alive = self:IsAlive() } )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1168,13 +1187,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()
|
||||||
|
|
||||||
@@ -1186,6 +1204,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
|
||||||
@@ -1815,6 +1851,7 @@ end
|
|||||||
|
|
||||||
--- Randomize the positions of the units of the respawned group within the @{Core.Zone}.
|
--- Randomize the positions of the units of the respawned group within the @{Core.Zone}.
|
||||||
-- When a Respawn happens, the units of the group will be placed at random positions within the Zone (selected).
|
-- When a Respawn happens, the units of the group will be placed at random positions within the Zone (selected).
|
||||||
|
-- NOTE: InitRandomizePositionZone will not ensure, that every unit is placed within the zone!
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #boolean PositionZone true will randomize the positions within the Zone.
|
-- @param #boolean PositionZone true will randomize the positions within the Zone.
|
||||||
-- @return #GROUP self
|
-- @return #GROUP self
|
||||||
@@ -2762,9 +2799,17 @@ end
|
|||||||
|
|
||||||
--- Switch on/off invisible flag for the group.
|
--- Switch on/off invisible flag for the group.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #boolean switch If true, emission is enabled. If false, emission is disabled.
|
-- @param #boolean switch If true, Invisible is enabled. If false, Invisible is disabled.
|
||||||
-- @return #GROUP self
|
-- @return #GROUP self
|
||||||
function GROUP:SetCommandInvisible(switch)
|
function GROUP:SetCommandInvisible(switch)
|
||||||
|
return self:CommandSetInvisible(switch)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Switch on/off invisible flag for the group.
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @param #boolean switch If true, Invisible is enabled. If false, Invisible is disabled.
|
||||||
|
-- @return #GROUP self
|
||||||
|
function GROUP:CommandSetInvisible(switch)
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
if switch==nil then
|
if switch==nil then
|
||||||
switch=false
|
switch=false
|
||||||
@@ -2776,9 +2821,17 @@ end
|
|||||||
|
|
||||||
--- Switch on/off immortal flag for the group.
|
--- Switch on/off immortal flag for the group.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #boolean switch If true, emission is enabled. If false, emission is disabled.
|
-- @param #boolean switch If true, Immortal is enabled. If false, Immortal is disabled.
|
||||||
-- @return #GROUP self
|
-- @return #GROUP self
|
||||||
function GROUP:SetCommandImmortal(switch)
|
function GROUP:SetCommandImmortal(switch)
|
||||||
|
return self:CommandSetImmortal(switch)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Switch on/off immortal flag for the group.
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @param #boolean switch If true, Immortal is enabled. If false, Immortal is disabled.
|
||||||
|
-- @return #GROUP self
|
||||||
|
function GROUP:CommandSetImmortal(switch)
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
if switch==nil then
|
if switch==nil then
|
||||||
switch=false
|
switch=false
|
||||||
@@ -2922,7 +2975,7 @@ function GROUP:GetCustomCallSign(ShortCallsign,Keepnumber,CallsignTranslations)
|
|||||||
return callsign
|
return callsign
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
--- Set a GROUP to act as recovery tanker
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param Wrapper.Group#GROUP CarrierGroup.
|
-- @param Wrapper.Group#GROUP CarrierGroup.
|
||||||
-- @param #number Speed Speed in knots.
|
-- @param #number Speed Speed in knots.
|
||||||
@@ -2948,3 +3001,70 @@ function GROUP:SetAsRecoveryTanker(CarrierGroup,Speed,ToKIAS,Altitude,Delay,Last
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get a list of Link16 S/TN data from a GROUP. Can (as of Nov 2023) be obtained from F-18, F-16, F-15E (not the user flyable one) and A-10C-II groups.
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @return #table Table of data entries, indexed by unit name, each entry is a table containing STN, VCL (voice call label), VCN (voice call number), and Lead (#boolean, if true it's the flight lead)
|
||||||
|
-- @return #string Report Formatted report of all data
|
||||||
|
function GROUP:GetGroupSTN()
|
||||||
|
local tSTN = {} -- table
|
||||||
|
local units = self:GetUnits()
|
||||||
|
local gname = self:GetName()
|
||||||
|
gname = string.gsub(gname,"(#%d+)$","")
|
||||||
|
local report = REPORT:New()
|
||||||
|
report:Add("Link16 S/TN Report")
|
||||||
|
report:Add("Group: "..gname)
|
||||||
|
report:Add("==================")
|
||||||
|
for _,_unit in pairs(units) do
|
||||||
|
local unit = _unit -- Wrapper.Unit#UNIT
|
||||||
|
if unit and unit:IsAlive() then
|
||||||
|
local STN, VCL, VCN, Lead = unit:GetSTN()
|
||||||
|
local name = unit:GetName()
|
||||||
|
tSTN[name] = {
|
||||||
|
STN=STN,
|
||||||
|
VCL=VCL,
|
||||||
|
VCN=VCN,
|
||||||
|
Lead=Lead,
|
||||||
|
}
|
||||||
|
local lead = Lead == true and "(*)" or ""
|
||||||
|
report:Add(string.format("| %s%s %s %s",tostring(VCL),tostring(VCN),tostring(STN),lead))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
report:Add("==================")
|
||||||
|
local text = report:Text()
|
||||||
|
return tSTN,text
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [GROUND] Determine if a GROUP is a SAM unit, i.e. has radar or optical tracker and is no mobile AAA.
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @return #boolean IsSAM True if SAM, else false
|
||||||
|
function GROUP:IsSAM()
|
||||||
|
local issam = false
|
||||||
|
local units = self:GetUnits()
|
||||||
|
for _,_unit in pairs(units or {}) do
|
||||||
|
local unit = _unit -- Wrapper.Unit#UNIT
|
||||||
|
if unit:HasSEAD() and unit:IsGround() and (not unit:HasAttribute("Mobile AAA")) then
|
||||||
|
issam = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return issam
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [GROUND] Determine if a GROUP has a AAA unit, i.e. has no radar or optical tracker but the AAA = true or the "Mobile AAA" = true attribute.
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @return #boolean IsSAM True if AAA, else false
|
||||||
|
function GROUP:IsAAA()
|
||||||
|
local issam = false
|
||||||
|
local units = self:GetUnits()
|
||||||
|
for _,_unit in pairs(units or {}) do
|
||||||
|
local unit = _unit -- Wrapper.Unit#UNIT
|
||||||
|
local desc = unit:GetDesc() or {}
|
||||||
|
local attr = desc.attributes or {}
|
||||||
|
if unit:HasSEAD() then return false end
|
||||||
|
if attr["AAA"] or attr["SAM related"] then
|
||||||
|
issam = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return issam
|
||||||
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -123,16 +123,36 @@ end
|
|||||||
|
|
||||||
--- Check if SCENERY Object is alive.
|
--- Check if SCENERY Object is alive.
|
||||||
--@param #SCENERY self
|
--@param #SCENERY self
|
||||||
|
--@param #number Threshold (Optional) If given, SCENERY counts as alive above this relative life in percent (1..100).
|
||||||
--@return #number life
|
--@return #number life
|
||||||
function SCENERY:IsAlive()
|
function SCENERY:IsAlive(Threshold)
|
||||||
return self:GetLife() >= 1 and true or false
|
if not Threshold then
|
||||||
|
return self:GetLife() >= 1 and true or false
|
||||||
|
else
|
||||||
|
return self:GetRelativeLife() > Threshold and true or false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if SCENERY Object is dead.
|
--- Check if SCENERY Object is dead.
|
||||||
--@param #SCENERY self
|
--@param #SCENERY self
|
||||||
|
--@param #number Threshold (Optional) If given, SCENERY counts as dead below this relative life in percent (1..100).
|
||||||
--@return #number life
|
--@return #number life
|
||||||
function SCENERY:IsDead()
|
function SCENERY:IsDead(Threshold)
|
||||||
return self:GetLife() < 1 and true or false
|
if not Threshold then
|
||||||
|
return self:GetLife() < 1 and true or false
|
||||||
|
else
|
||||||
|
return self:GetRelativeLife() <= Threshold and true or false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get SCENERY relative life in percent, e.g. 75.
|
||||||
|
--@param #SCENERY self
|
||||||
|
--@return #number rlife
|
||||||
|
function SCENERY:GetRelativeLife()
|
||||||
|
local life = self:GetLife()
|
||||||
|
local life0 = self:GetLife0()
|
||||||
|
local rlife = math.floor((life/life0)*100)
|
||||||
|
return rlife
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the threat level of a SCENERY object. Always 0 as scenery does not pose a threat to anyone.
|
--- Get the threat level of a SCENERY object. Always 0 as scenery does not pose a threat to anyone.
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
-- @image Wrapper_Static.JPG
|
-- @image Wrapper_Static.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type STATIC
|
---
|
||||||
|
-- @type STATIC
|
||||||
-- @extends Wrapper.Positionable#POSITIONABLE
|
-- @extends Wrapper.Positionable#POSITIONABLE
|
||||||
|
|
||||||
--- Wrapper class to handle Static objects.
|
--- Wrapper class to handle Static objects.
|
||||||
@@ -236,7 +237,7 @@ function STATIC:SpawnAt(Coordinate, Heading, Delay)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the @{Wrapper.Unit} at the same location with the same properties.
|
--- Respawn the @{Wrapper.Static} at the same location with the same properties.
|
||||||
-- This is useful to respawn a cargo after it has been destroyed.
|
-- This is useful to respawn a cargo after it has been destroyed.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
||||||
@@ -280,3 +281,52 @@ function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Find the first(!) STATIC matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||||
|
-- @param #STATIC self
|
||||||
|
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_\(Regular_Expressions\)) for regular expressions in LUA.
|
||||||
|
-- @return #STATIC The STATIC.
|
||||||
|
-- @usage
|
||||||
|
-- -- Find a static with a partial static name
|
||||||
|
-- local grp = STATIC:FindByMatching( "Apple" )
|
||||||
|
-- -- will return e.g. a static named "Apple-1-1"
|
||||||
|
--
|
||||||
|
-- -- using a pattern
|
||||||
|
-- local grp = STATIC:FindByMatching( ".%d.%d$" )
|
||||||
|
-- -- will return the first static found ending in "-1-1" to "-9-9", but not e.g. "-10-1"
|
||||||
|
function STATIC:FindByMatching( Pattern )
|
||||||
|
local GroupFound = nil
|
||||||
|
|
||||||
|
for name,static in pairs(_DATABASE.STATICS) do
|
||||||
|
if string.match(name, Pattern ) then
|
||||||
|
GroupFound = static
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return GroupFound
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Find all STATIC objects matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||||
|
-- @param #STATIC self
|
||||||
|
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_\(Regular_Expressions\)) for regular expressions in LUA.
|
||||||
|
-- @return #table Groups Table of matching #STATIC objects found
|
||||||
|
-- @usage
|
||||||
|
-- -- Find all static with a partial static name
|
||||||
|
-- local grptable = STATIC:FindAllByMatching( "Apple" )
|
||||||
|
-- -- will return all statics with "Apple" in the name
|
||||||
|
--
|
||||||
|
-- -- using a pattern
|
||||||
|
-- local grp = STATIC:FindAllByMatching( ".%d.%d$" )
|
||||||
|
-- -- will return the all statics found ending in "-1-1" to "-9-9", but not e.g. "-10-1" or "-1-10"
|
||||||
|
function STATIC:FindAllByMatching( Pattern )
|
||||||
|
local GroupsFound = {}
|
||||||
|
|
||||||
|
for name,static in pairs(_DATABASE.STATICS) do
|
||||||
|
if string.match(name, Pattern ) then
|
||||||
|
GroupsFound[#GroupsFound+1] = static
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return GroupsFound
|
||||||
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
--
|
--
|
||||||
-- ## Example Missions:
|
-- ## Example Missions:
|
||||||
--
|
--
|
||||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Wrapper/Storage).
|
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Wrapper/Storage).
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ end
|
|||||||
|
|
||||||
--- Find the first(!) UNIT matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
--- Find the first(!) UNIT matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_(Regular_Expressions)) for regular expressions in LUA.
|
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_\(Regular_Expressions\)) for regular expressions in LUA.
|
||||||
-- @return #UNIT The UNIT.
|
-- @return #UNIT The UNIT.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Find a group with a partial group name
|
-- -- Find a group with a partial group name
|
||||||
@@ -189,7 +189,7 @@ end
|
|||||||
|
|
||||||
--- Find all UNIT objects matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
--- Find all UNIT objects matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_(Regular_Expressions)) for regular expressions in LUA.
|
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_\(Regular_Expressions\)) for regular expressions in LUA.
|
||||||
-- @return #table Units Table of matching #UNIT objects found
|
-- @return #table Units Table of matching #UNIT objects found
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Find all group with a partial group name
|
-- -- Find all group with a partial group name
|
||||||
@@ -1244,7 +1244,9 @@ function UNIT:GetThreatLevel()
|
|||||||
|
|
||||||
if Attributes["Fighters"] then ThreatLevel = 10
|
if Attributes["Fighters"] then ThreatLevel = 10
|
||||||
elseif Attributes["Multirole fighters"] then ThreatLevel = 9
|
elseif Attributes["Multirole fighters"] then ThreatLevel = 9
|
||||||
|
elseif Attributes["Interceptors"] then ThreatLevel = 9
|
||||||
elseif Attributes["Battleplanes"] then ThreatLevel = 8
|
elseif Attributes["Battleplanes"] then ThreatLevel = 8
|
||||||
|
elseif Attributes["Battle airplanes"] then ThreatLevel = 8
|
||||||
elseif Attributes["Attack helicopters"] then ThreatLevel = 7
|
elseif Attributes["Attack helicopters"] then ThreatLevel = 7
|
||||||
elseif Attributes["Strategic bombers"] then ThreatLevel = 6
|
elseif Attributes["Strategic bombers"] then ThreatLevel = 6
|
||||||
elseif Attributes["Bombers"] then ThreatLevel = 5
|
elseif Attributes["Bombers"] then ThreatLevel = 5
|
||||||
@@ -1659,3 +1661,36 @@ function UNIT:GetSkill()
|
|||||||
local skill = _DATABASE.Templates.Units[name].Template.skill or "Random"
|
local skill = _DATABASE.Templates.Units[name].Template.skill or "Random"
|
||||||
return skill
|
return skill
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get Link16 STN or SADL TN and other datalink info from Unit, if any.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #string STN STN or TN Octal as string, or nil if not set/capable.
|
||||||
|
-- @return #string VCL Voice Callsign Label or nil if not set/capable.
|
||||||
|
-- @return #string VCN Voice Callsign Number or nil if not set/capable.
|
||||||
|
-- @return #string Lead If true, unit is Flight Lead, else false or nil.
|
||||||
|
function UNIT:GetSTN()
|
||||||
|
self:F2(self.UnitName)
|
||||||
|
local STN = nil -- STN/TN
|
||||||
|
local VCL = nil -- VoiceCallsignLabel
|
||||||
|
local VCN = nil -- VoiceCallsignNumber
|
||||||
|
local FGL = false -- FlightGroupLeader
|
||||||
|
local template = self:GetTemplate()
|
||||||
|
if template.AddPropAircraft then
|
||||||
|
if template.AddPropAircraft.STN_L16 then
|
||||||
|
STN = template.AddPropAircraft.STN_L16
|
||||||
|
elseif template.AddPropAircraft.SADL_TN then
|
||||||
|
STN = template.AddPropAircraft.SADL_TN
|
||||||
|
end
|
||||||
|
VCN = template.AddPropAircraft.VoiceCallsignNumber
|
||||||
|
VCL = template.AddPropAircraft.VoiceCallsignLabel
|
||||||
|
end
|
||||||
|
if template.datalinks and template.datalinks.Link16 and template.datalinks.Link16.settings then
|
||||||
|
FGL = template.datalinks.Link16.settings.flightLead
|
||||||
|
end
|
||||||
|
-- A10CII
|
||||||
|
if template.datalinks and template.datalinks.SADL and template.datalinks.SADL.settings then
|
||||||
|
FGL = template.datalinks.SADL.settings.flightLead
|
||||||
|
end
|
||||||
|
|
||||||
|
return STN, VCL, VCN, FGL
|
||||||
|
end
|
||||||
|
|||||||
@@ -12,9 +12,11 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ## Example Missions:
|
-- ## Additional Material:
|
||||||
--
|
--
|
||||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/WRAPPER%20-%20Weapon).
|
-- * **Demo Missions:** [GitHub](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Wrapper/Weapon)
|
||||||
|
-- * **YouTube videos:** None
|
||||||
|
-- * **Guides:** None
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -38,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.
|
||||||
@@ -194,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.
|
||||||
@@ -224,6 +230,14 @@ function WEAPON:New(WeaponObject)
|
|||||||
-- Set log ID.
|
-- Set log ID.
|
||||||
self.lid=string.format("[%s] %s | ", self.typeName, self.name)
|
self.lid=string.format("[%s] %s | ", self.typeName, self.name)
|
||||||
|
|
||||||
|
if self.launcherUnit then
|
||||||
|
self.releaseHeading = self.launcherUnit:GetHeading()
|
||||||
|
self.releaseAltitudeASL = self.launcherUnit:GetAltitude()
|
||||||
|
self.releaseAltitudeAGL = self.launcherUnit:GetAltitude(true)
|
||||||
|
self.releaseCoordinate = self.launcherUnit:GetCoordinate()
|
||||||
|
self.releasePitch = self.launcherUnit:GetPitch()
|
||||||
|
end
|
||||||
|
|
||||||
-- Set default parameters
|
-- Set default parameters
|
||||||
self:SetTimeStepTrack()
|
self:SetTimeStepTrack()
|
||||||
self:SetDistanceInterceptPoint()
|
self:SetDistanceInterceptPoint()
|
||||||
@@ -552,6 +566,52 @@ function WEAPON:GetImpactCoordinate()
|
|||||||
return self.impactCoord
|
return self.impactCoord
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the heading on which the weapon was released
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @param #bool AccountForMagneticInclination (Optional) If true will account for the magnetic declination of the current map. Default is true
|
||||||
|
-- @return #number Heading
|
||||||
|
function WEAPON:GetReleaseHeading(AccountForMagneticInclination)
|
||||||
|
AccountForMagneticInclination = AccountForMagneticInclination or true
|
||||||
|
if AccountForMagneticInclination then return UTILS.ClampAngle(self.releaseHeading - UTILS.GetMagneticDeclination()) else return UTILS.ClampAngle(self.releaseHeading) end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the altitude above sea level at which the weapon was released
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @return #number Altitude in meters
|
||||||
|
function WEAPON:GetReleaseAltitudeASL()
|
||||||
|
return self.releaseAltitudeASL
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the altitude above ground level at which the weapon was released
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @return #number Altitude in meters
|
||||||
|
function WEAPON:GetReleaseAltitudeAGL()
|
||||||
|
return self.releaseAltitudeAGL
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the coordinate where the weapon was released
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @return Core.Point#COORDINATE Impact coordinate (if any).
|
||||||
|
function WEAPON:GetReleaseCoordinate()
|
||||||
|
return self.releaseCoordinate
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the pitch of the unit when the weapon was released
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @return #number Degrees
|
||||||
|
function WEAPON:GetReleasePitch()
|
||||||
|
return self.releasePitch
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get the heading of the weapon when it impacted. Note that this might not exist if the weapon has not impacted yet!
|
||||||
|
-- @param #WEAPON self
|
||||||
|
-- @param #bool AccountForMagneticInclination (Optional) If true will account for the magnetic declination of the current map. Default is true
|
||||||
|
-- @return #number Heading
|
||||||
|
function WEAPON:GetImpactHeading(AccountForMagneticInclination)
|
||||||
|
AccountForMagneticInclination = AccountForMagneticInclination or true
|
||||||
|
if AccountForMagneticInclination then return UTILS.ClampAngle(self.impactHeading - UTILS.GetMagneticDeclination()) else return self.impactHeading end
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if weapon is in the air. Obviously not really useful for torpedos. Well, then again, this is DCS...
|
--- Check if weapon is in the air. Obviously not really useful for torpedos. Well, then again, this is DCS...
|
||||||
-- @param #WEAPON self
|
-- @param #WEAPON self
|
||||||
-- @return #boolean If `true`, weapon is in the air and `false` if not. Returns `nil` if weapon object itself is `nil`.
|
-- @return #boolean If `true`, weapon is in the air and `false` if not. Returns `nil` if weapon object itself is `nil`.
|
||||||
@@ -611,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
|
||||||
@@ -713,6 +793,9 @@ function WEAPON:_TrackWeapon(time)
|
|||||||
-- Update coordinate.
|
-- Update coordinate.
|
||||||
self.coordinate:UpdateFromVec3(self.vec3)
|
self.coordinate:UpdateFromVec3(self.vec3)
|
||||||
|
|
||||||
|
-- Safe the last velocity of the weapon. This is needed to get the impact heading
|
||||||
|
self.last_velocity = self.weapon:getVelocity()
|
||||||
|
|
||||||
-- Keep on tracking by returning the next time below.
|
-- Keep on tracking by returning the next time below.
|
||||||
self.tracking=true
|
self.tracking=true
|
||||||
|
|
||||||
@@ -782,6 +865,9 @@ function WEAPON:_TrackWeapon(time)
|
|||||||
-- Safe impact coordinate.
|
-- Safe impact coordinate.
|
||||||
self.impactCoord=COORDINATE:NewFromVec3(self.vec3)
|
self.impactCoord=COORDINATE:NewFromVec3(self.vec3)
|
||||||
|
|
||||||
|
-- Safe impact heading, using last_velocity because self:GetVelocityVec3() is no longer possible
|
||||||
|
self.impactHeading = UTILS.VecHdg(self.last_velocity)
|
||||||
|
|
||||||
-- Mark impact point on F10 map.
|
-- Mark impact point on F10 map.
|
||||||
if self.impactMark then
|
if self.impactMark then
|
||||||
self.impactCoord:MarkToAll(string.format("Impact point of weapon %s\ntype=%s\nlauncher=%s", self.name, self.typeName, self.launcherName))
|
self.impactCoord:MarkToAll(string.format("Impact point of weapon %s\ntype=%s\nlauncher=%s", self.name, self.typeName, self.launcherName))
|
||||||
|
|||||||
@@ -18,5 +18,7 @@ __Moose.Include = function( IncludeFile )
|
|||||||
end
|
end
|
||||||
|
|
||||||
__Moose.Includes = {}
|
__Moose.Includes = {}
|
||||||
|
if not MOOSE_DEVELOPMENT_FOLDER then
|
||||||
__Moose.Include( 'Scripts/Moose/Modules.lua' )
|
MOOSE_DEVELOPMENT_FOLDER='Scripts'
|
||||||
|
end
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Modules.lua' )
|
||||||
|
|||||||
@@ -1,2 +1,51 @@
|
|||||||
|
|
||||||
|
-- Automatic dynamic loading of development files, if they exists.
|
||||||
|
-- Try to load Moose as individual script files from <DcsInstallDir\Script\Moose
|
||||||
|
-- which should be a Junction link to the MOOSE repository subfolder "Moose Development\Moose".
|
||||||
|
-- This method is used by Moose developers and not mission builders.
|
||||||
|
if not MOOSE_DEVELOPMENT_FOLDER then
|
||||||
|
MOOSE_DEVELOPMENT_FOLDER='Scripts'
|
||||||
|
end
|
||||||
|
|
||||||
|
ModuleLoader = MOOSE_DEVELOPMENT_FOLDER..'/Moose/Modules.lua'
|
||||||
|
|
||||||
|
if io then
|
||||||
|
local f=io.open(ModuleLoader,"r")
|
||||||
|
if f~=nil then
|
||||||
|
io.close(f)
|
||||||
|
|
||||||
|
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||||
|
|
||||||
|
local base = _G
|
||||||
|
|
||||||
|
__Moose = {}
|
||||||
|
|
||||||
|
__Moose.Include = function( IncludeFile )
|
||||||
|
if not __Moose.Includes[ IncludeFile ] then
|
||||||
|
__Moose.Includes[IncludeFile] = IncludeFile
|
||||||
|
local f = assert( base.loadfile( IncludeFile ) )
|
||||||
|
if f == nil then
|
||||||
|
error ("Moose: Could not load Moose file " .. IncludeFile )
|
||||||
|
else
|
||||||
|
env.info( "Moose: " .. IncludeFile .. " dynamically loaded." )
|
||||||
|
return f()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
__Moose.Includes = {}
|
||||||
|
|
||||||
|
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Modules.lua' )
|
||||||
|
BASE:TraceOnOff( true )
|
||||||
|
env.info( '*** MOOSE INCLUDE END *** ' )
|
||||||
|
|
||||||
|
-- Skip the static part of this file completly
|
||||||
|
do return end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
env.info( '*** MOOSE DYNAMIC INCLUDE NOT POSSIBLE (Desanitize io to use it) *** ' )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Individual Moose files are not found. Use the static code below.
|
||||||
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ while( MooseSource ) do
|
|||||||
MooseSource = string.gsub(MooseSource, "\r", "")
|
MooseSource = string.gsub(MooseSource, "\r", "")
|
||||||
|
|
||||||
if MooseSource ~= "" then
|
if MooseSource ~= "" then
|
||||||
MooseSource = string.match( MooseSource, "Scripts/Moose/(.+)'" )
|
MooseSource = string.match( MooseSource, "/Moose/(.+)'" )
|
||||||
local MooseFilePath = MooseDevelopmentPath .. "/" .. MooseSource
|
local MooseFilePath = MooseDevelopmentPath .. "/" .. MooseSource
|
||||||
if MooseDynamicStatic == "D" then
|
if MooseDynamicStatic == "D" then
|
||||||
print( "Load dynamic: " .. MooseFilePath )
|
print( "Load dynamic: " .. MooseFilePath )
|
||||||
|
|||||||
263
docs/advanced/concepts.md
Normal file
263
docs/advanced/concepts.md
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
---
|
||||||
|
title: Concepts
|
||||||
|
parent: Advanced
|
||||||
|
nav_order: 01
|
||||||
|
---
|
||||||
|
|
||||||
|
# Concepts
|
||||||
|
{: .no_toc }
|
||||||
|
|
||||||
|
1. Table of contents
|
||||||
|
{:toc}
|
||||||
|
|
||||||
|
If you want to get deeper into Moose, you will encounter a few terms and
|
||||||
|
concepts that we will explain here. You will need them for the later pages.
|
||||||
|
|
||||||
|
# Git and GitHub
|
||||||
|
|
||||||
|
Moose has about 260.000 lines of code and the amount is increasing each week.
|
||||||
|
To maintain such a big code base a vcs (version control system) is needed.
|
||||||
|
Moose uses [GitHub] as developer platform to create, store, and manage the code.
|
||||||
|
[GitHub] uses [Git] as version control system and provides additional
|
||||||
|
functionality like access control, bug tracking, feature requests and much more.
|
||||||
|
|
||||||
|
As a Moose user you don't need to learn how to use [Git]. You can download the
|
||||||
|
files on [GitHub] with a browser. But using [Git] will ease up the steps to keep
|
||||||
|
the Moose version on your hard disk up to date.
|
||||||
|
|
||||||
|
You will need to interact with [GitHub]. At least to download the Moose files.
|
||||||
|
For non-developers the page can be confusing. Take your time and read this
|
||||||
|
documentation. We are not able to explain every single detail on using [GitHub]
|
||||||
|
and [Git]. Especially because it is changing really quick and this documentation
|
||||||
|
will not. So try to use the help system of [GitHub] or find some videos on
|
||||||
|
[YouTube]. If you get stuck ask for help in the [Moose Discord].
|
||||||
|
|
||||||
|
Moose uses more than one repository on [GitHub] which doesn't exactly make it
|
||||||
|
any clearer. A list can be found on the [reposities] page.
|
||||||
|
|
||||||
|
# Branches: master & develop
|
||||||
|
|
||||||
|
As already explained in the [overview] two branches are used:
|
||||||
|
|
||||||
|
- Branch [master]: Stable release branch.
|
||||||
|
- Branch [develop]: Newest development with more OPS classes.
|
||||||
|
|
||||||
|
As a starter it is okay to begin your journey with the `master` branch.
|
||||||
|
If you are interested in some newer classes you need to use the `develop`
|
||||||
|
branch. The later one is also very stable, but it's missing more detailed
|
||||||
|
documentation and example missions for some of the new OPS classes.
|
||||||
|
|
||||||
|
You can switch between these branches with a drop down in the upper left corner
|
||||||
|
of the [GitHub] repository page. The list of branches is long. So it is a best
|
||||||
|
practice to save a bookmark in your browser with the links above.
|
||||||
|
Both branches are available on most of the different repositories. But because
|
||||||
|
of a limitation of [GitHub pages], we had to split the documentation in two
|
||||||
|
different repositories:
|
||||||
|
|
||||||
|
- Documentation of `master` branch: [MOOSE_DOCS]
|
||||||
|
- Documentation of `develop` branch: [MOOSE_DOCS_DEVELOP]
|
||||||
|
|
||||||
|
# Build result vs. source files
|
||||||
|
|
||||||
|
Moose consists of more than 140 individual files with the file extension `.lua`.
|
||||||
|
They are places in a [directory tree], which makes it more organized and its
|
||||||
|
semantic is pre-defined for [IntelliSense] to work.
|
||||||
|
|
||||||
|
On every change which is pushed to [GitHub] a build job will combine all of
|
||||||
|
these files to a single file called `Moose.lua`. In a second step all
|
||||||
|
comments will be removed to decrease the file size and the result will be saved
|
||||||
|
as `Moose_.lua`. These both files are created for users of Moose to include in
|
||||||
|
your missions.
|
||||||
|
|
||||||
|
The individual `.lua` files are used by the Moose developers and power users.
|
||||||
|
It is complicated to use them, but in combination with an IDE and a debugger it
|
||||||
|
is very useful to analyze even complex problems or write new additions to the
|
||||||
|
Moose framework.
|
||||||
|
|
||||||
|
# Static loading
|
||||||
|
|
||||||
|
If you add a script file with a `DO SCRIPT FILE` trigger, like we described in
|
||||||
|
[Create your own Hello world], the script file will be copied into the mission
|
||||||
|
file. This mission file (file extension .MIZ) is only a compressed ZIP archive
|
||||||
|
with another file ending.
|
||||||
|
|
||||||
|
If you change the script file after adding it to the mission, the changes are
|
||||||
|
not available on mission start. You have to re-add the script after each change.
|
||||||
|
This can be very annoying and often leads to forgetting to add the change again.
|
||||||
|
Then you wonder why the mission does not deliver the desired result.
|
||||||
|
|
||||||
|
But when the mission is finished you can upload it to your dedicated DCS server
|
||||||
|
or give it to a friend and it should run without problems. This way of embedding
|
||||||
|
the scripts do we call `static loading` and the resulting mission is very
|
||||||
|
portable.
|
||||||
|
|
||||||
|
# Dynamic loading of mission scripts
|
||||||
|
|
||||||
|
The other way of loading scripts is by using `DO SCRIPT`. This time the mission
|
||||||
|
editor don't show a file browse button. Instead you see a (very small) text
|
||||||
|
field to enter the code directly into it. It is only useful for very small
|
||||||
|
script snippets. But we can use it to load a file from your hard drive like
|
||||||
|
this:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
dofile('C:/MyScripts/hello-world.lua')
|
||||||
|
dofile('C:\\MyScripts\\hello-world.lua')
|
||||||
|
dofile([[C:\MyScripts\hello-world.lua]])
|
||||||
|
```
|
||||||
|
|
||||||
|
So all lines above do the same. In [Lua] you need to specify the path with
|
||||||
|
slashes, escape backslashes or use double square brackets around the string.
|
||||||
|
Double square brackets are usefull, because you can copy paste the path
|
||||||
|
without any modification.
|
||||||
|
|
||||||
|
If you upload a mission with this code, you need to create the folder
|
||||||
|
`C:\MyScripts\` on the server file system and upload the newest version of
|
||||||
|
`hello-world.lua`, too. The same applies, if you give the mission to a friend.
|
||||||
|
This makes the mission less portable, but on the other hand the mission uses the
|
||||||
|
file on the hard disk, without the need to add it to the mission again.
|
||||||
|
All you need to do is save the file and restart the mission.
|
||||||
|
|
||||||
|
The following can be used to increase portability:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
dofile(lfs.writedir() .. '/Missions/hello-world.lua')
|
||||||
|
```
|
||||||
|
|
||||||
|
The function `lfs.writedir()` will return your [Saved Games folder].
|
||||||
|
So you place the scripts in the subfolder Missions. This way the folder
|
||||||
|
structure is already available on all target systems. But you need to ensure
|
||||||
|
mission and script are both in sync to avoid problems. If you changed both and
|
||||||
|
upload only one of them to your server, you may get trouble.
|
||||||
|
|
||||||
|
There is another method you may find useful to dynamically load scripts:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
assert(loadfile('C:/MyScripts/hello-world.lua'))()
|
||||||
|
assert(loadfile('C:\\MyScripts\\hello-world.lua'))()
|
||||||
|
assert(loadfile([[C:\MyScripts\hello-world.lua]]))()
|
||||||
|
```
|
||||||
|
|
||||||
|
It is a little bit harder to read and write because of all these different
|
||||||
|
brackets. Especially the one on line 3. But it is a little safer than `dofile`.
|
||||||
|
Because of readability I prefer to use `dofile`.
|
||||||
|
|
||||||
|
# Dynamic loading of Moose
|
||||||
|
|
||||||
|
Of course you can use the same method to load Moose. This way you can place one
|
||||||
|
Moose file in your [Saved Games folder], which is used by multiple missions.
|
||||||
|
If you want to update Moose you just need to replace the file and all missions
|
||||||
|
will use the new version. But I prefer to add Moose by a `DO SCRIPT FILE`
|
||||||
|
trigger so I can add and test the new version for each mission step by step.
|
||||||
|
|
||||||
|
But we added two different ways to load the Moose source files automatically.
|
||||||
|
This is useful for Moose developers and it is a requirement to use a debugger.
|
||||||
|
This will be explained later in the [Debugger Guide].
|
||||||
|
|
||||||
|
# Automatic dynamic loading
|
||||||
|
|
||||||
|
With the code below you can have the advantages of both approaches.
|
||||||
|
- Copy the code into your mission script at the beginning.
|
||||||
|
- Save the mission script into the folder Missions in your [Saved Games folder].
|
||||||
|
- Change script filename in line 2 to match to your script.
|
||||||
|
- [De-Sanitize] your `MissionScripting.lua`.
|
||||||
|
|
||||||
|
Now the mission will use the script on your hard drive instead of the script
|
||||||
|
embedded in th MIZ file, as long as it is available. So you can chnge the
|
||||||
|
script, save it and restart the mission, without the need to readd it after each
|
||||||
|
change.
|
||||||
|
|
||||||
|
If you reach a stable state in your script development and want to upload the
|
||||||
|
mission to your server or give it to a friend, then just add the script again
|
||||||
|
like in the static method and save the mission.
|
||||||
|
|
||||||
|
{: .important }
|
||||||
|
> Do not forget to readd the script, prior uploading or sharing the mission,
|
||||||
|
> or it will run with an outdated version of your script and may fail if the
|
||||||
|
> objects in the mission don't match to this old version.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Use script file from hard disk instead of the one included in the .miz file
|
||||||
|
if lfs and io then
|
||||||
|
MissionScript = lfs.writedir() .. '/Missions/hello-world-autodyn.lua'
|
||||||
|
-- Check if the running skript is from temp directory to avoid an endless loop
|
||||||
|
if string.find( debug.getinfo(1).source, lfs.tempdir() ) then
|
||||||
|
local f=io.open(MissionScript,"r")
|
||||||
|
if f~=nil then
|
||||||
|
io.close(f)
|
||||||
|
|
||||||
|
env.info( '*** LOAD MISSION SCRIPT FROM HARD DISK *** ' )
|
||||||
|
dofile(MissionScript)
|
||||||
|
do return end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
env.error( '*** LOAD MISSION SCRIPT FROM HARD DISK FAILED (Desanitize lfs and io)*** ' )
|
||||||
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Simple example mission to show the very basics of MOOSE
|
||||||
|
--
|
||||||
|
MESSAGE:New( "Hello World! This messages is printed by MOOSE!", 35, "INFO" ):ToAll():ToLog()
|
||||||
|
```
|
||||||
|
|
||||||
|
# IDE vs. Notepad++
|
||||||
|
|
||||||
|
As a beginner you should start with a good text editor, which supports syntax
|
||||||
|
highlighting of [Lua] code. This must not be [Notepad++]. It can be any other
|
||||||
|
powerful editor of your choice. Do yourself a favor and don't use the Windows
|
||||||
|
editor.
|
||||||
|
|
||||||
|
If you are a developer of [Lua] or another programming language, then your are
|
||||||
|
most likely familiar with an IDE (Integrated Develop Environment).
|
||||||
|
|
||||||
|
Otherwise you should know, that an IDE may help you with code completion,
|
||||||
|
Refactoring, Autocorrection, Formatting Source Code, showing documentation
|
||||||
|
as popup on mouse hover over keywords and Debugging.
|
||||||
|
|
||||||
|
There are different IDEs available. And not all IDEs support all features.
|
||||||
|
The three most important for Moose are:
|
||||||
|
|
||||||
|
- [Eclipse LDT]
|
||||||
|
- [Visual Studio Code]
|
||||||
|
- [PyCharm] (or [IntelliJ IDEA])
|
||||||
|
|
||||||
|
Eclipse has the best support for hover documentation and [IntelliSense] with
|
||||||
|
Moose. The Inventor of Moose (FlightControl) did an amazing job by adding an
|
||||||
|
integration to Eclipse LDT (a special version for Lua).
|
||||||
|
Unfortunately Eclipse LDT is not maintained any longer (last release 2018).
|
||||||
|
And the debugger doesn't work anymore, since an update of DCS.
|
||||||
|
|
||||||
|
In Visual Studio Code the support of Lua can be added by an addon.
|
||||||
|
The debugger works with Moose and DCS, but showing the LuaDoc and [IntelliSense]
|
||||||
|
is very limited.
|
||||||
|
|
||||||
|
PyCharm supports Lua also with an addon. The debugger works with Moose and DCS,
|
||||||
|
but showing the LuaDoc and [IntelliSense] is very limited.
|
||||||
|
|
||||||
|
It is up to you to choose the IDE according to your taste. Guides on how to
|
||||||
|
setup Moose with different IDEs and Debuggers are provided later in this
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
[Git]: https://en.wikipedia.org/wiki/Git
|
||||||
|
[GitHub]: https://github.com/
|
||||||
|
[YouTube]: https://www.youtube.com/
|
||||||
|
[Moose Discord]: https://discord.gg/gj68fm969S
|
||||||
|
[overview]: ../index.md
|
||||||
|
[reposities]: ../repositories.md
|
||||||
|
[master]: https://github.com/FlightControl-Master/MOOSE/tree/master
|
||||||
|
[develop]: https://github.com/FlightControl-Master/MOOSE/tree/develop
|
||||||
|
[GitHub pages]: https://pages.github.com/
|
||||||
|
[MOOSE_DOCS]: https://flightcontrol-master.github.io/MOOSE_DOCS/
|
||||||
|
[MOOSE_DOCS_DEVELOP]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/
|
||||||
|
[directory tree]: https://github.com/FlightControl-Master/MOOSE/tree/master/Moose%20Development/Moose
|
||||||
|
[Saved Games folder]: ../beginner/tipps-and-tricks.md#find-the-saved-games-folder
|
||||||
|
[Lua]: https://www.lua.org/
|
||||||
|
[Create your own Hello world]: ../beginner/hello-world-build.md
|
||||||
|
[Debugger Guide]: debugger.md
|
||||||
|
[IntelliSense]: https://en.wikipedia.org/wiki/IntelliSense
|
||||||
|
[De-Sanitize]: desanitize-dcs.md
|
||||||
|
[Notepad++]: https://notepad-plus-plus.org/downloads/
|
||||||
|
[Eclipse LDT]: https://projects.eclipse.org/projects/tools.ldt
|
||||||
|
[Visual Studio Code]: https://code.visualstudio.com/
|
||||||
|
[PyCharm]: https://www.jetbrains.com/pycharm/
|
||||||
|
[IntelliJ IDEA]: https://www.jetbrains.com/idea/
|
||||||
8
docs/advanced/debugger.md
Normal file
8
docs/advanced/debugger.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
title: Debugger
|
||||||
|
parent: Advanced
|
||||||
|
nav_order: 100
|
||||||
|
---
|
||||||
|
|
||||||
|
{: .warning }
|
||||||
|
> THIS DOCUMENT IS STILL WORK IN PROGRESS!
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: De-Sanitize DCS
|
title: De-Sanitize DCS
|
||||||
parent: Advanced
|
parent: Advanced
|
||||||
nav_order: 2
|
nav_order: 98
|
||||||
---
|
---
|
||||||
# De-Sanitize the DCS scripting environment
|
# De-Sanitize the DCS scripting environment
|
||||||
{: .no_toc }
|
{: .no_toc }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
parent: Advanced
|
parent: Advanced
|
||||||
nav_order: 1
|
nav_order: 97
|
||||||
---
|
---
|
||||||
# Eclipse Installation
|
# Eclipse Installation
|
||||||
{: .no_toc }
|
{: .no_toc }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
parent: Advanced
|
parent: Advanced
|
||||||
nav_order: 2
|
nav_order: 99
|
||||||
---
|
---
|
||||||
# Text to Speech
|
# Text to Speech
|
||||||
{: .no_toc }
|
{: .no_toc }
|
||||||
|
|||||||
102
docs/beginner/ask-for-help.md
Normal file
102
docs/beginner/ask-for-help.md
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
---
|
||||||
|
parent: Beginner
|
||||||
|
nav_order: 06
|
||||||
|
---
|
||||||
|
# How to ask for help
|
||||||
|
{: .no_toc }
|
||||||
|
|
||||||
|
1. Table of contents
|
||||||
|
{:toc}
|
||||||
|
|
||||||
|
After you have tried to solve the problem on your own, you can also get help
|
||||||
|
from the community.
|
||||||
|
|
||||||
|
{: .highlight }
|
||||||
|
> But it is important to follow certain rules! Read them below.
|
||||||
|
|
||||||
|
## Communities
|
||||||
|
|
||||||
|
There are two ways to communicate with the community.
|
||||||
|
The fastest way is to use Discord:
|
||||||
|
|
||||||
|
- <https://discord.gg/gj68fm969S>{:target="_blank"}
|
||||||
|
|
||||||
|
But if you don't like Discord, you are able to post in the DCS forum.
|
||||||
|
Check out the MOOSE thread here:
|
||||||
|
|
||||||
|
- <https://forums.eagle.ru/showthread.php?t=138043>
|
||||||
|
|
||||||
|
## How to post requests
|
||||||
|
|
||||||
|
MOOSE is a community project and support is community based.
|
||||||
|
|
||||||
|
Please remember when posting a question:
|
||||||
|
|
||||||
|
- Before posting anything follow the [troubleshooting steps].
|
||||||
|
- **Read your logs**.
|
||||||
|
|
||||||
|
### Formulate a good description
|
||||||
|
|
||||||
|
A post should contain the following:
|
||||||
|
|
||||||
|
- A description what you expected to happen and what actually happened.
|
||||||
|
- Do not use vague words this stuff is hard to help with! Be specific.
|
||||||
|
|
||||||
|
- Describe what happens instead.
|
||||||
|
- The less detail you offer, the less chance you can be helped.
|
||||||
|
- Don't say it doesn't work. Or is it broken. Say what it actually does.
|
||||||
|
|
||||||
|
### Format your code
|
||||||
|
|
||||||
|
The easier your code is to read, the more likely you are to get a helpful answer. If your code is hard to read, some
|
||||||
|
people who could help you may not even bother to read your code. Syntax Highlighting makes the code much clearer and
|
||||||
|
easier to understand. Therefore:
|
||||||
|
|
||||||
|
- Post your code in Discord as formatted code:
|
||||||
|
|
||||||
|
- Wrap a single line of code in backticks \` like this:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- Multiple lines of code should be posted like this:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Do not post a screenshot of your code
|
||||||
|
|
||||||
|
Your code is easy to read on a screenshot if you are using a good text editor or IDE, but if someone discovers an error
|
||||||
|
in your code and wants to post a corrected version, they will have to type out the entire code. This could lead to them
|
||||||
|
not helping you because it's too much work for them.
|
||||||
|
|
||||||
|
### Post your log
|
||||||
|
|
||||||
|
If the error message in the `dcs.log` does not tell you anything, then post it in the Discord.
|
||||||
|
|
||||||
|
- Post the important log lines with the error or warning messages. Format them like this:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Send your mission when requested
|
||||||
|
|
||||||
|
Please don't just send your mission file. You have to manually extract the script from the file.
|
||||||
|
It is better to send your script code and log lines beforehand.
|
||||||
|
If this does not help, you may be asked to send your mission.
|
||||||
|
|
||||||
|
- Some complex problems need the mission (.miz file) also.
|
||||||
|
|
||||||
|
- But post your mission only when requested.
|
||||||
|
- Try to simplify your mission if it is complex!
|
||||||
|
- Try to avoid or delete MODs, because could prevent people from helping you.
|
||||||
|
|
||||||
|
There are people in the Discord and in the forum, who spend their free time to
|
||||||
|
help you. <br />
|
||||||
|
It is your responsibility to make their "work" as easy as possible.
|
||||||
|
|
||||||
|
Welcome to MOOSE and good luck!
|
||||||
|
|
||||||
|
## Next step
|
||||||
|
|
||||||
|
Last but not least some [tipps and tricks].
|
||||||
|
|
||||||
|
[troubleshooting steps]: problems.md
|
||||||
|
[tipps and tricks]: tipps-and-tricks.md
|
||||||
58
docs/beginner/demo-missions.md
Normal file
58
docs/beginner/demo-missions.md
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
---
|
||||||
|
parent: Beginner
|
||||||
|
nav_order: 04
|
||||||
|
---
|
||||||
|
|
||||||
|
# Demo missions
|
||||||
|
{: .no_toc }
|
||||||
|
|
||||||
|
1. Table of contents
|
||||||
|
{:toc}
|
||||||
|
|
||||||
|
The best way to get comfortable with a Moose class is to try the demo missions
|
||||||
|
of the class you want to learn. The Moose team created a lot of demo missions
|
||||||
|
for most of the classes.
|
||||||
|
|
||||||
|
## Download demo missions
|
||||||
|
|
||||||
|
Go to the repository [MOOSE_MISSIONS]{:target="_blank"}, search the folder of
|
||||||
|
the class, download the mission (`.miz`) and run them.
|
||||||
|
|
||||||
|
## Read the mission script
|
||||||
|
|
||||||
|
In the same folder a `.lua` file with the same name is placed which is the
|
||||||
|
included mission script. You can watch these mission scripts easily online at
|
||||||
|
GitHub to understand what is happening in the mission.
|
||||||
|
|
||||||
|
## Read documentation
|
||||||
|
|
||||||
|
Next step is to read the [documentation]{:target="_blank"} of the class to
|
||||||
|
understand the code of the demo mission.
|
||||||
|
|
||||||
|
{: .note }
|
||||||
|
> The documentation is quite long and might be confusing for beginners.
|
||||||
|
> Start by looking at the description at the top of the documentation of a
|
||||||
|
> class. It often contains examples and explanations. <br /><br />
|
||||||
|
> Then search for the function names and look at the description of the
|
||||||
|
> functions and its parameters.
|
||||||
|
|
||||||
|
## Make small changes to the script
|
||||||
|
|
||||||
|
Download the `.lua` file, change the parameters to suit your needs in
|
||||||
|
[Notepad++]{:target="_blank"}, add it to the mission and rerun the mission.
|
||||||
|
Observe what happens and adapt the code.
|
||||||
|
|
||||||
|
If you want to use more functions combine them all up.
|
||||||
|
|
||||||
|
{: .note }
|
||||||
|
> But it is wise to do this in small steps. So it is easier to find errors.
|
||||||
|
|
||||||
|
## Next step
|
||||||
|
|
||||||
|
If the mission does not show the expected behaviour take a look at section
|
||||||
|
[problems].
|
||||||
|
|
||||||
|
[MOOSE_MISSIONS]: https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop
|
||||||
|
[documentation]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/index.html
|
||||||
|
[Notepad++]: https://notepad-plus-plus.org/downloads/
|
||||||
|
[problems]: problems.md
|
||||||
181
docs/beginner/hello-world-build.md
Normal file
181
docs/beginner/hello-world-build.md
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
---
|
||||||
|
parent: Beginner
|
||||||
|
nav_order: 03
|
||||||
|
---
|
||||||
|
|
||||||
|
# Create your own Hello world
|
||||||
|
{: .no_toc }
|
||||||
|
|
||||||
|
1. Table of contents
|
||||||
|
{:toc}
|
||||||
|
|
||||||
|
This page will lead you step by step through the process of creating a mission
|
||||||
|
with MOOSE. This time we include a simple mission script, which sends only
|
||||||
|
a "Hello world" message to all players. But the steps are the same to add
|
||||||
|
another mission script, which will do whatever class(es) you want to use.
|
||||||
|
|
||||||
|
## Create Mission script
|
||||||
|
|
||||||
|
At first we will create the mission script. It is a simple text file and can be
|
||||||
|
changed with a lot of different tools. Theoretically even the Microsoft Notepad
|
||||||
|
editor can be used. But it lacks a lot of features, which helps you to avoid
|
||||||
|
errors.
|
||||||
|
|
||||||
|
For this guide we suggest you to download, install and use [Notepad++]{:target="_blank"}.
|
||||||
|
|
||||||
|
{: .important }
|
||||||
|
> Windows hides filename extensions by default. So when you create a text file
|
||||||
|
> and name it `hello-world.lua` it's name is `hello-world.lua.txt` in reality.
|
||||||
|
> You must activate the display of the file name extension.
|
||||||
|
> Open a `File Explorer`, switch to menu `View` and find the option
|
||||||
|
> `File name extensions` in the section `Show/hide`. Activate it.
|
||||||
|
|
||||||
|
- Open a File Explorer.
|
||||||
|
- Go to the subfolder `Missions` of your [Saved Games folder]{:target="_blank"}.
|
||||||
|
- Create a new text file and name it `hello-world.lua`.
|
||||||
|
- Add the following content and save the file:
|
||||||
|
|
||||||
|
`MESSAGE:New( "Hello World! This messages is printed by MOOSE", 35, "INFO" ):ToAll()`
|
||||||
|
|
||||||
|
## Get Moose
|
||||||
|
|
||||||
|
To download Moose click on the following link:
|
||||||
|
|
||||||
|
- [Moose_.lua from develop branch]{:target="_blank"}
|
||||||
|
|
||||||
|
Press `Ctrl + S` to save the file on your hard disk next to your mission script.
|
||||||
|
|
||||||
|
## Create the mission
|
||||||
|
|
||||||
|
- Start DCS.
|
||||||
|
- In the main menu choose `MISSION EDITOR`.
|
||||||
|
- Click on `create new mission`.
|
||||||
|
- In the dialog `NEW MISSION SETTINGS`:
|
||||||
|
- Choose map `Caucasus`.
|
||||||
|
- In the drop box upper left choose `Modern` as coalition preset.
|
||||||
|
- Click on `OK`.
|
||||||
|
- The mission editor will load with a fresh new and empty mission.
|
||||||
|
- Click on `File` in the menu bar and `SAVE` or Press `Ctrl + S`.
|
||||||
|
- Open `My Missions` and save the file with the name `hello-world.miz`.
|
||||||
|
|
||||||
|
## Add Moose to the mission
|
||||||
|
|
||||||
|
- On the left side activate `TRIGGERS`:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- On the right side the `TRIGGERS` dialog opens with a lot of options.
|
||||||
|
- Click on `NEW`, choose `4 MISSION START` as **TYPE**.
|
||||||
|
- Give it the `Load MOOSE` as **NAME**.
|
||||||
|
- Leave the **EVENT** option set to `NO EVENT`.
|
||||||
|
- Optional: Choose a color for easy recognition (e.g. yellow).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- In the middle part the `CONDITIONS` will be shown.
|
||||||
|
For this trigger we do not configure any conditions.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
{: .important }
|
||||||
|
> The trigger type `4 MISSION START` does not support `CONDITIONS`. <br />
|
||||||
|
> So `CONDITIONS` must left blank when using it. <br />
|
||||||
|
> **If you add a condition the trigger will never be executed!**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- On the right side `ACTIONS` is shown.
|
||||||
|
- We need to click on `NEW`.
|
||||||
|
- Choose **ACTION** `Do SCRIPT FILE` and ignore all other actions.
|
||||||
|
- Click **OPEN** and navigate to the downloaded `Moose_.lua` file.
|
||||||
|
- The result should look like this:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Add the mission script
|
||||||
|
|
||||||
|
- Click on `NEW`, choose `1 ONCE` as **TYPE**.
|
||||||
|
- Give it the `Load Mission Script` as **NAME**.
|
||||||
|
- Leave the **EVENT** option set to `NO EVENT`.
|
||||||
|
- Optional: Choose a color for easy recognition (e.g. green).
|
||||||
|
- The result should look like this:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- Switch to the middle part, the `CONDITIONS` section. <br />
|
||||||
|
For this trigger we add one condition:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- The combination of `1 ONCE` with `TIME MORE(1)` will ensure, that the mission
|
||||||
|
script is executed 1 second after the mission is started.
|
||||||
|
|
||||||
|
- On the right side under `ACTIONS` you need to add the script:
|
||||||
|
- Click on `NEW`.
|
||||||
|
- Choose **ACTION** `Do SCRIPT FILE`.
|
||||||
|
- Click **OPEN** and navigate to the created `hello-world.lua` file.
|
||||||
|
|
||||||
|
{: .important }
|
||||||
|
> Most important is the fact, that the mission script (`hello-world.lua`)
|
||||||
|
> is executed **after** `Moose_.lua`, because the mission script needs the
|
||||||
|
> classes defined in `Moose_.lua`. And they are only available when `Moose_.lua`
|
||||||
|
> is executed before the mission script.
|
||||||
|
|
||||||
|
## Test the mission
|
||||||
|
|
||||||
|
- Save the mission again.
|
||||||
|
- Click on the green **Fly mission** cirlce on the left tool side bar.
|
||||||
|
- It is an empty mission, so skip `BRIEFING` with `START` and then `FLY`.
|
||||||
|
- You spawn as a spectator. After some seconds you will see this message in
|
||||||
|
the upper right corner:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This is the same result as already seen in the last chapter, but this time you
|
||||||
|
have create everything on your own.
|
||||||
|
|
||||||
|
{: .note }
|
||||||
|
> You can use this mission as a template for your own missions. So you don't
|
||||||
|
> need to do alle these steps again and again.
|
||||||
|
|
||||||
|
## Update mission script
|
||||||
|
|
||||||
|
- Open the `hello-world.lua` with Notepad++ again.
|
||||||
|
- Change the text a little bit, like `Hello Dude! ...` and save the file.
|
||||||
|
- Run the mission again.
|
||||||
|
- The text will not be changed in the mission. Why?
|
||||||
|
|
||||||
|
{: .important }
|
||||||
|
The mission editor copies the script into the mission file when you add it.
|
||||||
|
Every change on the script file on your hard disk is not recognized by mission
|
||||||
|
editor. **You have to add the file after each change again!**
|
||||||
|
|
||||||
|
There is also another method available to dynamically load mission scripts.
|
||||||
|
But this method has some brawbacks and will be explained in the advanced section.
|
||||||
|
|
||||||
|
Now we add the mission script again:
|
||||||
|
|
||||||
|
- On the left side of the `TRIGGERS` dialog click on `Load Mission Script`.
|
||||||
|
- On the right side under `ACTIONS` you need to add the script again:
|
||||||
|
- Click **OPEN** and navigate to the created `hello-world.lua` file.
|
||||||
|
- Save the mission and test it again.
|
||||||
|
- Now the new text should be shown.
|
||||||
|
|
||||||
|
## Update Moose
|
||||||
|
|
||||||
|
Moose is constantly being developed so that new functionallity is added or
|
||||||
|
existing errors are corrected. Also from time to time changes of the DCS
|
||||||
|
scripting engine comes with a new DCS version. It may therefore be useful or
|
||||||
|
necessary to update Moose.
|
||||||
|
|
||||||
|
- To update Moose download it again and add it again in the same way you did
|
||||||
|
with the mission script in the last step.
|
||||||
|
|
||||||
|
## Next step
|
||||||
|
|
||||||
|
Let's move on to the [demo missions].
|
||||||
|
|
||||||
|
[Notepad++]: https://notepad-plus-plus.org/downloads/
|
||||||
|
[Saved Games folder]: tipps-and-tricks.md#find-the-saved-games-folder
|
||||||
|
[Moose_.lua from develop branch]: https://raw.githubusercontent.com/FlightControl-Master/MOOSE_INCLUDE/develop/Moose_Include_Static/Moose_.lua
|
||||||
|
[demo missions]: demo-missions.md
|
||||||
178
docs/beginner/hello-world.md
Normal file
178
docs/beginner/hello-world.md
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
---
|
||||||
|
parent: Beginner
|
||||||
|
nav_order: 02
|
||||||
|
---
|
||||||
|
|
||||||
|
# Hello world mission
|
||||||
|
{: .no_toc }
|
||||||
|
|
||||||
|
1. Table of contents
|
||||||
|
{:toc}
|
||||||
|
|
||||||
|
## Let's see MOOSE in action
|
||||||
|
|
||||||
|
It is tradition that the first piece of code is a very simple example on showing
|
||||||
|
a "Hello world!" to the user. We have prepared this example mission for you. So
|
||||||
|
you can download and run it. Later on we will analyze it to explain the basics
|
||||||
|
on how to add MOOSE to your own missions.
|
||||||
|
|
||||||
|
- Download the demo mission [001-hello-world.miz] by clicking on the link.
|
||||||
|
- Put the .miz file into your Missions subfolder of your [Saved Games folder].
|
||||||
|
- Start DCS, choose `MISSION` in the menu on the right side:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- Click on `My Missions`, choose the `hello-world` mission and click on `OK`.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- It is an empty mission, so skip `BRIEFING` with `START` and then `FLY`.
|
||||||
|
- You spawn as a spectator. After some seconds you will see this message in
|
||||||
|
the upper right corner:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Ok, that's all. There is nothing more to see in this mission. This is not
|
||||||
|
particularly impressive and can also be achieved using standard Lua in DCS
|
||||||
|
(i.e. without MOOSE), but we want to keep it simple at the beginning.
|
||||||
|
|
||||||
|
{: .note }
|
||||||
|
> If the text don't show up, the mission might be corrupted. Please contact the
|
||||||
|
> team on Discord for futher instructions.
|
||||||
|
|
||||||
|
## Let's take a look under the hood
|
||||||
|
|
||||||
|
- Go back to the main window and open the `MISSION EDITOR`.
|
||||||
|
- Choose `open mission` navigate to `My Missions` and open 001-hello-world.miz.
|
||||||
|
- On the left side activate `TRIGGERS`:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- On the right side the `TRIGGERS` dialog opens with a lot of options.
|
||||||
|
- First take a look at the available triggers:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- You will see two:
|
||||||
|
- One in yellow with type `4 MISSION START` and name `Load MOOSE` and
|
||||||
|
- one in green with type `1 ONCE` and name `Load Mission Script`.
|
||||||
|
|
||||||
|
### Execution of Moose
|
||||||
|
|
||||||
|
- Click on the yellow one to show all of it options.
|
||||||
|
|
||||||
|
- In the middle part the `CONDITIONS` will be shown.
|
||||||
|
For this trigger there are no conditions configured.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
{: .important }
|
||||||
|
> The trigger type `4 MISSION START` does not support `CONDITIONS`. <br />
|
||||||
|
> So `CONDITIONS` must left blank when using it. <br />
|
||||||
|
> **If you add a condition the trigger will never be executed!**
|
||||||
|
|
||||||
|
- On the right side the `ACTIONS` will be shown:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- A `DO SCRIPT FILE` is configured, which executes the file `Moose_.lua`
|
||||||
|
|
||||||
|
{: .highlight }
|
||||||
|
> This is the execution of the Moose framework included in the mission as one single file. <br />
|
||||||
|
> The difference between `Moose_.lua` and `Moose.lua` will be explained later. <br />
|
||||||
|
> This doesn't matter at this time.
|
||||||
|
|
||||||
|
{: .important }
|
||||||
|
> The trigger `4 MISSION START` will be executed **before** the mission is started! <br />
|
||||||
|
> This is important, because Moose **must** be executed before other scripts, that want to use Moose!
|
||||||
|
|
||||||
|
### Execution of the mission script
|
||||||
|
|
||||||
|
- Now move back to the left `TRIGGERS` area and click on the green trigger <br />
|
||||||
|
`1 ONCE (Load Mission Script ...)`
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- The configured options will be shown. <br />
|
||||||
|
In the middle part the `CONDITIONS` will be shown. <br />
|
||||||
|
For this trigger there is one condition configured:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- The combination of `1 ONCE` with `TIME MORE(1)` will ensure, that the mission
|
||||||
|
script is executed 1 second after the mission is started.
|
||||||
|
|
||||||
|
- On the right side the `ACTIONS` will be shown:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- A `DO SCRIPT FILE` is configured, which executes the file `001-hello-world.lua`.
|
||||||
|
|
||||||
|
{: .highlight }
|
||||||
|
> This is the execution of the mission script, which you will create in the future.
|
||||||
|
|
||||||
|
{: .important }
|
||||||
|
> Most important is the fact, that the mission script (`001-hello-world.lua`)
|
||||||
|
> is executed **after** `Moose_.lua`, because the mission script needs the
|
||||||
|
> classes defined in `Moose_.lua`. And they are only available when `Moose_.lua`
|
||||||
|
> is executed before the mission script.
|
||||||
|
|
||||||
|
### Inspect the code of the mission script
|
||||||
|
|
||||||
|
The file `001-hello-world.lua` consists of following code:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
--
|
||||||
|
-- Simple example mission to show the very basics of MOOSE
|
||||||
|
--
|
||||||
|
MESSAGE:New( "Hello World! This messages is printed by MOOSE", 35, "INFO" ):ToAll()
|
||||||
|
```
|
||||||
|
|
||||||
|
- The first three lines starting with `--` are comments and will be ignored.
|
||||||
|
|
||||||
|
- Line 4 is the one with the "magic":
|
||||||
|
|
||||||
|
- With `MESSAGE` we use the class [Core.Message].
|
||||||
|
|
||||||
|
The part before the dot (Core) is the section where the class is placed.
|
||||||
|
It is important for the Moose programmes to have a structure where the classes
|
||||||
|
are placed. But in the code itself it is not used.
|
||||||
|
|
||||||
|
#### What is a class?
|
||||||
|
|
||||||
|
{: .highlight }
|
||||||
|
> In object-oriented programming, a class is an extensible program-code-template
|
||||||
|
> for creating objects, providing initial values for state (member variables)
|
||||||
|
> and implementations of behavior (member functions or methods). <br />
|
||||||
|
> *Source [Wikipedia:Class]{:target="_blank"}*
|
||||||
|
|
||||||
|
After the class name we call a method of that class. We do this with semicolon
|
||||||
|
followed by the name of the method and a pair of round brackets.
|
||||||
|
Here we call the method `New`, which creates a new MESSAGE object.
|
||||||
|
|
||||||
|
We give it three parameters within the round brackets, which are divided by commas:
|
||||||
|
1. The text we want to show: `"Hello World! ..."`
|
||||||
|
1. The time in seconds the messages should be visible: `35`
|
||||||
|
1. And the type of message: `"INFO"`
|
||||||
|
|
||||||
|
- With `New` the MESSAGE object is created, but the message is still not printed
|
||||||
|
to the screen.
|
||||||
|
- This is done by `:ToAll()`. Another method of [Core.Message] which sends the
|
||||||
|
message to all players, no matter if they belong to the RED or BLUE coalition.
|
||||||
|
|
||||||
|
If you you want to read more about [Core.Message] click on the link.
|
||||||
|
The page with all the Methods and Fields is very long and this might be
|
||||||
|
daunting, but for the copy and paste approach, you won't need it often.
|
||||||
|
|
||||||
|
And if you want to learn how to use more of that stuff, you will become
|
||||||
|
compftable in filtering these informations fast.
|
||||||
|
|
||||||
|
## Next step
|
||||||
|
|
||||||
|
Now it is time to [create your own Hello world] mission.
|
||||||
|
|
||||||
|
[Saved Games folder]: ../beginner/tipps-and-tricks.md#find-the-saved-games-folder
|
||||||
|
[hello-world demo mission]: https://raw.githubusercontent.com/FlightControl-Master/MOOSE_MISSIONS/master/Core/Message/001-hello-world.miz
|
||||||
|
[Core.Message]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Message.html
|
||||||
|
[Wikipedia:Class]: https://en.wikipedia.org/wiki/Class_(computer_programming)
|
||||||
|
[create your own Hello world]: hello-world-build.md
|
||||||
106
docs/beginner/introduction.md
Normal file
106
docs/beginner/introduction.md
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
---
|
||||||
|
parent: Beginner
|
||||||
|
nav_order: 01
|
||||||
|
---
|
||||||
|
# Introduction
|
||||||
|
{: .no_toc }
|
||||||
|
|
||||||
|
1. Table of contents
|
||||||
|
{:toc}
|
||||||
|
|
||||||
|
This very short chapter is for people identifying as a consumer of MOOSE and not
|
||||||
|
wishing to learn to script. This is a condensed FAQ and set of links to get you
|
||||||
|
up and running. It specifically avoids any complexity.
|
||||||
|
|
||||||
|
## What is MOOSE?
|
||||||
|
|
||||||
|
[DCS] has included a [Simulator Scripting Engine] (short SSE). This SSE gives
|
||||||
|
mission designers access to objects in the game using [Lua] scripts.
|
||||||
|
|
||||||
|
**M**ission **O**bject **O**riented **S**cripting **E**nvironment, is a
|
||||||
|
scripting framework written in [Lua] that attempts to make the scripting of
|
||||||
|
missions within DCS easier, simpler and shorter than with the standard methods.
|
||||||
|
|
||||||
|
MOOSE is over 5 MB of code, with as many words as the Bible and the core of it
|
||||||
|
was written over several years by one person.
|
||||||
|
|
||||||
|
MOOSE is the brain-child of an talented programmer with the alias FlightControl.
|
||||||
|
If you want to know more about this topic, check out FC’s [MOOSE for Dummies]
|
||||||
|
videos on YouTube.
|
||||||
|
|
||||||
|
{: .note }
|
||||||
|
> We recommend video playback at 1.5x speed, as FC speaks slowly and distinctly.
|
||||||
|
|
||||||
|
## What is Lua?
|
||||||
|
|
||||||
|
[Lua] is a lightweight, programming language designed primarily to be embedded
|
||||||
|
in applications. It's main advantages are:
|
||||||
|
|
||||||
|
- It is fast,
|
||||||
|
- it is portable (Windows, Linux, MacOS),
|
||||||
|
- it is easy to use.
|
||||||
|
|
||||||
|
[Lua] is embedded in DCS, so we can use it without any modification to the game.
|
||||||
|
|
||||||
|
## What are scripts, frameworks and classes?
|
||||||
|
|
||||||
|
A script is a set of instructions in plain text read by a computer and processed
|
||||||
|
on the fly. Scripts do not need to be compiled before execution, unlike exe
|
||||||
|
files.
|
||||||
|
|
||||||
|
A framework is a structure that you can build software (or in this case missions)
|
||||||
|
on. It serves as a foundation, so you're not starting entirely from scratch.
|
||||||
|
It takes a lot of work off your hands because someone else has thought about it
|
||||||
|
and provides ready-made building blocks for many situations.
|
||||||
|
|
||||||
|
These building blocks are called classes in object oriented programming.
|
||||||
|
|
||||||
|
## What can MOOSE do for me?
|
||||||
|
|
||||||
|
Whilst MOOSE can be used to write customised [Lua] scripts, you are probably not
|
||||||
|
caring for learning [Lua] right now. Instead you can use a MOOSE script written
|
||||||
|
by someone else by just copy and paste it. You can configure the basic settings
|
||||||
|
of the classes to fit your needs in your mission.
|
||||||
|
|
||||||
|
Here are a few suggestions for well-known and popular classes:
|
||||||
|
|
||||||
|
- [Ops.Airboss] manages recoveries of human pilots and AI aircraft on aircraft
|
||||||
|
carriers.
|
||||||
|
- [Functional.RAT] creates random airtraffic in your missions.
|
||||||
|
- [Functional.Range] (which counts hits on targets so you can practice),
|
||||||
|
- [Functional.Fox] to practice to evade missiles without being destroyed.
|
||||||
|
- and many more!
|
||||||
|
|
||||||
|
You will need to look through examples to know what functionallity you want to
|
||||||
|
add to your missions.
|
||||||
|
|
||||||
|
## What if I don’t want to learn scripting?
|
||||||
|
|
||||||
|
The good news for you: You don't need to become a professional [Lua] programmer
|
||||||
|
to use MOOSE. As explained already, you can copy and paste the code from example
|
||||||
|
missions. You need some basics how to add triggers in the mission editor. But we
|
||||||
|
will cover this later.
|
||||||
|
|
||||||
|
If you want to modify the behaviour of the classes slightly, some basics about
|
||||||
|
the [Lua] synthax (the rules how to write the code) will help you to avoid
|
||||||
|
errors.
|
||||||
|
|
||||||
|
The more customizations you want to make, the more knowledge about [Lua] you
|
||||||
|
will need. But you can learn this step by step.
|
||||||
|
|
||||||
|
## Next step
|
||||||
|
|
||||||
|
We will start with a very simple demonstartion of MOOSE in the next section
|
||||||
|
[Hello world mission].
|
||||||
|
|
||||||
|
[DCS]: https://www.digitalcombatsimulator.com/en/
|
||||||
|
[Simulator Scripting Engine]: https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation
|
||||||
|
[Lua]: https://www.lua.org/
|
||||||
|
[MOOSE for Dummies]: https://www.youtube.com/watch?v=ZqvdUFhKX4o&list=PL7ZUrU4zZUl04jBoOSX_rmqE6cArquhM4&index=2&t=618s
|
||||||
|
|
||||||
|
[Ops.Airboss]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Ops.Airboss.html
|
||||||
|
[Functional.RAT]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Functional.RAT.html
|
||||||
|
[Functional.Range]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Functional.Range.html
|
||||||
|
[Functional.Fox]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Functional.Fox.html
|
||||||
|
|
||||||
|
[Hello world mission]: hello-world.md
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user