mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Compare commits
532 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4d1118c88 | ||
|
|
dcc15afb89 | ||
|
|
be3db86470 | ||
|
|
67b43e2c68 | ||
|
|
577fefab3a | ||
|
|
2ad111dd50 | ||
|
|
523375c765 | ||
|
|
ac42b56b8e | ||
|
|
5b8416d5fd | ||
|
|
874fa7ad69 | ||
|
|
a105ddba3d | ||
|
|
70c29de695 | ||
|
|
8bd39b41f4 | ||
|
|
b263cddc07 | ||
|
|
a712d74e2e | ||
|
|
613d33d731 | ||
|
|
c7e694dfb8 | ||
|
|
d6c9195555 | ||
|
|
50298e4109 | ||
|
|
3389d3284a | ||
|
|
b10819220c | ||
|
|
244abe2bbb | ||
|
|
4b1a1cbcff | ||
|
|
378e76e45b | ||
|
|
f7f28877da | ||
|
|
e3d2dec91f | ||
|
|
470c4ef13c | ||
|
|
241b31fcec | ||
|
|
3dd069d7d6 | ||
|
|
77c4fd7696 | ||
|
|
aca4e4d7ca | ||
|
|
dcd278e2a1 | ||
|
|
2f81fcb0c0 | ||
|
|
8cf11de774 | ||
|
|
b62f2afd8d | ||
|
|
176bd0eb8b | ||
|
|
70ee6a1121 | ||
|
|
10edd2f9d0 | ||
|
|
408321decf | ||
|
|
11acb578f6 | ||
|
|
383eff4cd6 | ||
|
|
6cda61c9dd | ||
|
|
4d8abe7f57 | ||
|
|
c6bb7c8bbd | ||
|
|
bd3042410b | ||
|
|
7c9cf96d2e | ||
|
|
ef30bd36a5 | ||
|
|
5286926609 | ||
|
|
ab14fbd11c | ||
|
|
5bde0c7605 | ||
|
|
4f2d8144e9 | ||
|
|
cb61177252 | ||
|
|
736204d163 | ||
|
|
1e15509001 | ||
|
|
cca6b0cf55 | ||
|
|
bfa8719ec3 | ||
|
|
fd0e6053ee | ||
|
|
f99eac0de4 | ||
|
|
89b06fb7a6 | ||
|
|
3652376d42 | ||
|
|
3d1207a079 | ||
|
|
3953f0e7fc | ||
|
|
3e727f7777 | ||
|
|
5621579b5e | ||
|
|
091083b5aa | ||
|
|
b0d0fb9ae1 | ||
|
|
57ce6bcec2 | ||
|
|
7a1cfa9fe3 | ||
|
|
71b5492903 | ||
|
|
5ff4d84a9a | ||
|
|
c71d0ed7cf | ||
|
|
d64dadd9a9 | ||
|
|
370bfc893d | ||
|
|
0f30f3b1a0 | ||
|
|
50e55e1df2 | ||
|
|
51911d3292 | ||
|
|
bff60bdb69 | ||
|
|
219353faad | ||
|
|
4c4ecccb01 | ||
|
|
0e1cbe45b9 | ||
|
|
aac3f64638 | ||
|
|
34937c2cf6 | ||
|
|
74c19f1058 | ||
|
|
42ca05af57 | ||
|
|
1cbdafda65 | ||
|
|
960746245f | ||
|
|
595b9132e8 | ||
|
|
4b50d8f16f | ||
|
|
c320f1a0a7 | ||
|
|
82b5269040 | ||
|
|
45aebff48e | ||
|
|
80bf992806 | ||
|
|
f2e22579ed | ||
|
|
2dc908d926 | ||
|
|
1f9725530f | ||
|
|
d3e6b0366b | ||
|
|
1545add510 | ||
|
|
c85f575888 | ||
|
|
9f8428c7ba | ||
|
|
5eef138507 | ||
|
|
8c6c1e481b | ||
|
|
14d6085b69 | ||
|
|
d13173e336 | ||
|
|
ced01a993d | ||
|
|
fa80f0a162 | ||
|
|
02e59b23c5 | ||
|
|
5b86bf9605 | ||
|
|
c5ece16753 | ||
|
|
4c2a89ee29 | ||
|
|
4505b60859 | ||
|
|
e8c75b8795 | ||
|
|
7e21a1070a | ||
|
|
2ce9f26e26 | ||
|
|
bfaca9dd5f | ||
|
|
30819dad72 | ||
|
|
e946916fc0 | ||
|
|
2eeca4451c | ||
|
|
ee17d3e995 | ||
|
|
a48e09b434 | ||
|
|
27ea85ea57 | ||
|
|
3baf52d307 | ||
|
|
0faa0036ee | ||
|
|
79189d4d93 | ||
|
|
f859522052 | ||
|
|
8d886a75d6 | ||
|
|
5a772ad05e | ||
|
|
a16e22818d | ||
|
|
0cc959bf34 | ||
|
|
aa948b57d8 | ||
|
|
6ca459b38c | ||
|
|
79da4cbf27 | ||
|
|
e5a60a2ef1 | ||
|
|
7e2ae60e43 | ||
|
|
51f134538d | ||
|
|
0ee7a38c61 | ||
|
|
15dd2cf735 | ||
|
|
e895642157 | ||
|
|
154026fbf8 | ||
|
|
d7969e9455 | ||
|
|
7dcff7ec9c | ||
|
|
0e6bf1f46b | ||
|
|
67e52120d4 | ||
|
|
4b84d227f0 | ||
|
|
df0dbc9108 | ||
|
|
4307ddcad3 | ||
|
|
daa734009e | ||
|
|
86e13df303 | ||
|
|
65cf53ce28 | ||
|
|
2e167358bb | ||
|
|
78d1a215e4 | ||
|
|
14daca9a72 | ||
|
|
48dba742ad | ||
|
|
2ca847e845 | ||
|
|
11c74ddc17 | ||
|
|
c38917fa2f | ||
|
|
1847a2372c | ||
|
|
fd155f8277 | ||
|
|
531132e8a7 | ||
|
|
7464406a17 | ||
|
|
bd5c1af335 | ||
|
|
53f556a4e6 | ||
|
|
0ddf8762c2 | ||
|
|
2893bfb290 | ||
|
|
d984a1b142 | ||
|
|
f02b774242 | ||
|
|
5ede860361 | ||
|
|
d0d52246f4 | ||
|
|
748aa131e4 | ||
|
|
1b4e170271 | ||
|
|
a3d56b6d1b | ||
|
|
33bd928076 | ||
|
|
23df6bbc2a | ||
|
|
f2fc321ded | ||
|
|
0b3fc515e0 | ||
|
|
e50d54f6bc | ||
|
|
6e60a66d0c | ||
|
|
11f0b2899d | ||
|
|
581138b5bc | ||
|
|
0ce3a189c3 | ||
|
|
08f2c29014 | ||
|
|
9208d7a70d | ||
|
|
4076ff5bb5 | ||
|
|
dcd4d0ab62 | ||
|
|
056b761ebc | ||
|
|
298c569f93 | ||
|
|
32dbb520d6 | ||
|
|
6af66db4c3 | ||
|
|
ff84d682bd | ||
|
|
d2b7d46227 | ||
|
|
58f4eead1c | ||
|
|
f3bafd5803 | ||
|
|
bb07e1935e | ||
|
|
2946c2e225 | ||
|
|
088436c5ce | ||
|
|
2e386be2f6 | ||
|
|
797bf0047b | ||
|
|
9c0c93507a | ||
|
|
f29d055ca3 | ||
|
|
baf7123364 | ||
|
|
1468641563 | ||
|
|
f6b6a6a577 | ||
|
|
4d7d34b71f | ||
|
|
82bea9d5ff | ||
|
|
35d91c9c94 | ||
|
|
8b08942c4d | ||
|
|
a44ad5c755 | ||
|
|
b7236eeb58 | ||
|
|
eb84ad3cee | ||
|
|
09933b307b | ||
|
|
91a34ac4d8 | ||
|
|
21babb548c | ||
|
|
11967bd608 | ||
|
|
ea6e63dc9b | ||
|
|
28c8d99878 | ||
|
|
547579ffb0 | ||
|
|
4fda8cc5fb | ||
|
|
697042eac6 | ||
|
|
30d6936f1d | ||
|
|
4ac583e434 | ||
|
|
b315375ade | ||
|
|
e26647c2ca | ||
|
|
4ddd278471 | ||
|
|
72e31b90a9 | ||
|
|
fa762fe0fc | ||
|
|
aca5846209 | ||
|
|
4fd7d7cba9 | ||
|
|
677d888d96 | ||
|
|
06c3ca0079 | ||
|
|
9280a1224d | ||
|
|
406dbb707a | ||
|
|
4758af61c2 | ||
|
|
729c1f5e33 | ||
|
|
fce7b07014 | ||
|
|
8386fe5f67 | ||
|
|
4696569f83 | ||
|
|
2c695e187f | ||
|
|
048ab6acfe | ||
|
|
84230e2360 | ||
|
|
f2783c46c2 | ||
|
|
ca9913e38b | ||
|
|
df1bc5c55d | ||
|
|
ff951c69d9 | ||
|
|
e53a80783e | ||
|
|
a1fb09285b | ||
|
|
f2f7c88299 | ||
|
|
e2bf1f727d | ||
|
|
65315251b5 | ||
|
|
2a9e98c21e | ||
|
|
b40c1e4575 | ||
|
|
a9befc4d96 | ||
|
|
f5d6d31b10 | ||
|
|
65fb22b6cc | ||
|
|
d0346c4aa3 | ||
|
|
96da09b9e0 | ||
|
|
c1d468b35f | ||
|
|
109270d717 | ||
|
|
f80e7a2166 | ||
|
|
9b95e71d75 | ||
|
|
de6c7d636b | ||
|
|
f57beab6d2 | ||
|
|
29414bfd21 | ||
|
|
60b8a5f5af | ||
|
|
db6dc7b77e | ||
|
|
aaf3553597 | ||
|
|
4e50bd213c | ||
|
|
c813e2dbc4 | ||
|
|
4c81333a0a | ||
|
|
761d83a68f | ||
|
|
3d93c268b3 | ||
|
|
79b1f1615f | ||
|
|
d6a0fff993 | ||
|
|
8d45ea00e8 | ||
|
|
47f010cb28 | ||
|
|
2d17c4d21a | ||
|
|
d14b7e8f4c | ||
|
|
d8b046491b | ||
|
|
d9748ef147 | ||
|
|
b20eb84d19 | ||
|
|
64d7946c06 | ||
|
|
c2be4fbcf1 | ||
|
|
b052fc6243 | ||
|
|
8385b1d21a | ||
|
|
58d9637c5d | ||
|
|
d4f4465b0a | ||
|
|
5fe77956cb | ||
|
|
e0a108e00d | ||
|
|
d640acc7cc | ||
|
|
acf37f6133 | ||
|
|
8dcd22f18c | ||
|
|
2d086a62f0 | ||
|
|
47ad2499d4 | ||
|
|
5d510807c9 | ||
|
|
dd771a089c | ||
|
|
3f927b16e5 | ||
|
|
5ba8f9e0e8 | ||
|
|
833a0561c3 | ||
|
|
0338fd5d33 | ||
|
|
ea2175bba8 | ||
|
|
cf48b21073 | ||
|
|
0835022c5c | ||
|
|
a70ad71689 | ||
|
|
f306361317 | ||
|
|
0347e42fc7 | ||
|
|
7557e79c0c | ||
|
|
9cc32ff8dc | ||
|
|
1b7eef5419 | ||
|
|
029bdc3bd1 | ||
|
|
b052d99349 | ||
|
|
93acd870ea | ||
|
|
4fe1318e7c | ||
|
|
93cdb92e76 | ||
|
|
6ffe69484c | ||
|
|
39b89d937e | ||
|
|
501ab70992 | ||
|
|
b488d43d78 | ||
|
|
6ac46addf0 | ||
|
|
33259be4d9 | ||
|
|
e4cea7b3c4 | ||
|
|
3bdf4b4c76 | ||
|
|
6f5f89a0ee | ||
|
|
46f70dd8a6 | ||
|
|
e2e9bd7de0 | ||
|
|
1b01b89343 | ||
|
|
4e36ed170b | ||
|
|
bf0ad93bf7 | ||
|
|
a51afeda14 | ||
|
|
e46b148721 | ||
|
|
8765ebe2c6 | ||
|
|
b55b11be09 | ||
|
|
2a7dbad02a | ||
|
|
aeac2eb3d7 | ||
|
|
e83c8c3ee0 | ||
|
|
d65042c640 | ||
|
|
c72cdd8f0b | ||
|
|
7e2f8771b5 | ||
|
|
3ccfcdbd0f | ||
|
|
44b3f41ae4 | ||
|
|
c5dec374c8 | ||
|
|
3f384d72ab | ||
|
|
1d5952b4a5 | ||
|
|
8eec7fcc9e | ||
|
|
db7e94d879 | ||
|
|
16f3dcbbb4 | ||
|
|
f482dac491 | ||
|
|
f6f3189504 | ||
|
|
73fa021476 | ||
|
|
071554bfc5 | ||
|
|
cd8abd97c5 | ||
|
|
1527b53c76 | ||
|
|
e25eeee0cc | ||
|
|
bbc7f7e14c | ||
|
|
0261020796 | ||
|
|
b9830a8437 | ||
|
|
257530d421 | ||
|
|
caaee4f551 | ||
|
|
5f7115f4fe | ||
|
|
9ec92a8fca | ||
|
|
a14435ce54 | ||
|
|
e82e4f7dd7 | ||
|
|
c7ef270d4d | ||
|
|
7cc040c234 | ||
|
|
9227ba9ecd | ||
|
|
a9a56b3738 | ||
|
|
e7fb073bab | ||
|
|
0d1fc2fbf2 | ||
|
|
f86b3505b2 | ||
|
|
e89b921f3e | ||
|
|
0d18ce086c | ||
|
|
8fb126682f | ||
|
|
63a0224ea4 | ||
|
|
ebe486c69a | ||
|
|
69fa6f4ee6 | ||
|
|
702ec75935 | ||
|
|
1c4e3cb801 | ||
|
|
465ec216ea | ||
|
|
ab516e0cd8 | ||
|
|
d803b51e84 | ||
|
|
53f89fd42c | ||
|
|
c72f109553 | ||
|
|
f2ba2022c2 | ||
|
|
92e03522db | ||
|
|
9716162739 | ||
|
|
4eea8fcadd | ||
|
|
5b7e0ce375 | ||
|
|
0ae9be49da | ||
|
|
c250712e53 | ||
|
|
bda4efc634 | ||
|
|
566ebb67e3 | ||
|
|
e84e16f58b | ||
|
|
55ffe37a79 | ||
|
|
6c21dfa48c | ||
|
|
b31fc3ed44 | ||
|
|
68548f4581 | ||
|
|
42fd2322d2 | ||
|
|
8382eb9cd8 | ||
|
|
585901dc7d | ||
|
|
2a7213c1b7 | ||
|
|
f837e9dec7 | ||
|
|
cd4fb0c6c5 | ||
|
|
b8d44643c1 | ||
|
|
230d9d82bf | ||
|
|
47d01f18c1 | ||
|
|
c089e56060 | ||
|
|
8a1c9c0e54 | ||
|
|
87f1a5ed0d | ||
|
|
a4fd55e87d | ||
|
|
d2d6fac7df | ||
|
|
5243a408cc | ||
|
|
bc3f9ed7c0 | ||
|
|
b224739df3 | ||
|
|
0f4162a9a9 | ||
|
|
ff26e4d1dc | ||
|
|
6b270916c4 | ||
|
|
1f17fd89a4 | ||
|
|
b3a006096c | ||
|
|
a8e35a552d | ||
|
|
6903e252d2 | ||
|
|
6ee1afc670 | ||
|
|
ff6704f123 | ||
|
|
3b8bbdd4c1 | ||
|
|
c770f4cb68 | ||
|
|
7e5a97e7c7 | ||
|
|
9ce1d360d6 | ||
|
|
f342ba758e | ||
|
|
6f473faa92 | ||
|
|
dd37a42470 | ||
|
|
018d8eecf6 | ||
|
|
fe9d841af5 | ||
|
|
88e1bbd60d | ||
|
|
d0491b3b5a | ||
|
|
e078e48853 | ||
|
|
f789fbac70 | ||
|
|
bc3a5271dc | ||
|
|
4d4b8862c2 | ||
|
|
31b75b7d17 | ||
|
|
fac7a5fdc6 | ||
|
|
cca5a5d55d | ||
|
|
3243c92331 | ||
|
|
49191fb144 | ||
|
|
eab37d5e48 | ||
|
|
f739062463 | ||
|
|
e838431b28 | ||
|
|
c22304f2b0 | ||
|
|
1c10bfea92 | ||
|
|
c97d2ecaba | ||
|
|
2dc9f19d78 | ||
|
|
89a9d1d0a4 | ||
|
|
cf7d41cd7f | ||
|
|
fd191be274 | ||
|
|
31bdde130a | ||
|
|
afe542cc63 | ||
|
|
494550fe91 | ||
|
|
29c0d81c27 | ||
|
|
e79c2481da | ||
|
|
89a902fd57 | ||
|
|
460ad9db39 | ||
|
|
ae604fd847 | ||
|
|
099f059eec | ||
|
|
c3bba7d1fc | ||
|
|
db71610d72 | ||
|
|
4b8d120f20 | ||
|
|
1dc31cc852 | ||
|
|
68b97773fe | ||
|
|
3c0e977584 | ||
|
|
f03a48b118 | ||
|
|
c489a88106 | ||
|
|
4747dae51a | ||
|
|
b1e8ba74a8 | ||
|
|
641707f37b | ||
|
|
67924c894d | ||
|
|
52ed645f6c | ||
|
|
7c8f212b03 | ||
|
|
9f41cc51be | ||
|
|
85c73cb0a5 | ||
|
|
1b1f8e0d2c | ||
|
|
f87126f22c | ||
|
|
6390b223b0 | ||
|
|
b635490e47 | ||
|
|
62e8302753 | ||
|
|
cac7b39823 | ||
|
|
cc79dc74d4 | ||
|
|
af3c579a03 | ||
|
|
a508c63279 | ||
|
|
427a11bd0f | ||
|
|
6f3133d48c | ||
|
|
4f4e8b17c1 | ||
|
|
aa7f26ac79 | ||
|
|
084caad5d7 | ||
|
|
0850796368 | ||
|
|
343bf05c2c | ||
|
|
ff58649954 | ||
|
|
bbf793febe | ||
|
|
3e40d72e25 | ||
|
|
1c1daa4ebe | ||
|
|
fdcda6e5f3 | ||
|
|
a50dde7f2b | ||
|
|
1fb4cb1c4f | ||
|
|
cd0f854f41 | ||
|
|
52c2401d93 | ||
|
|
f071c674d0 | ||
|
|
02a87d9fe0 | ||
|
|
3c53f627c2 | ||
|
|
12d68a41ca | ||
|
|
2dfde7d1fd | ||
|
|
c011d38313 | ||
|
|
6c4a64601f | ||
|
|
68350d6824 | ||
|
|
434f985e77 | ||
|
|
2e6cac7bee | ||
|
|
ba1dcfcdba | ||
|
|
b346dabdf8 | ||
|
|
a0429458d0 | ||
|
|
1376a16812 | ||
|
|
847dc1839f | ||
|
|
4267314260 | ||
|
|
b5110c8554 | ||
|
|
0dd4da1db4 | ||
|
|
1f1d1e4f2f | ||
|
|
4d4f8e9d61 | ||
|
|
522eb8b256 | ||
|
|
6fe883a17a | ||
|
|
b662ecc76b | ||
|
|
fbbdac9b7e | ||
|
|
6dd69eb6db | ||
|
|
1b6aeff005 | ||
|
|
de380614fb | ||
|
|
4287774d9f | ||
|
|
f6fdff927b | ||
|
|
58ce4b001e | ||
|
|
6bba2fec0b | ||
|
|
5d2656d679 | ||
|
|
9a360a3bd5 |
8
.github/workflows/build-includes.yml
vendored
8
.github/workflows/build-includes.yml
vendored
@@ -95,10 +95,6 @@ jobs:
|
||||
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"
|
||||
|
||||
- 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
|
||||
#########################################################################
|
||||
@@ -108,6 +104,10 @@ jobs:
|
||||
run: |
|
||||
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
|
||||
#########################################################################
|
||||
|
||||
12
.github/workflows/gh-pages.yml
vendored
12
.github/workflows/gh-pages.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
working-directory: docs/
|
||||
- name: Setup Pages
|
||||
id: pages
|
||||
uses: actions/configure-pages@v3
|
||||
uses: actions/configure-pages@v4
|
||||
- name: Build with Jekyll
|
||||
# Outputs to the './_site' directory by default
|
||||
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
working-directory: docs/
|
||||
- name: Upload artifact
|
||||
# Automatically uploads an artifact from the './_site' directory by default
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: docs/_site/
|
||||
|
||||
@@ -66,13 +66,13 @@ jobs:
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v1
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
needs: deploy
|
||||
steps:
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
- 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
@@ -228,6 +228,9 @@ pip-log.txt
|
||||
#Goodsync
|
||||
_gsdata_/
|
||||
|
||||
# PyCharm
|
||||
.idea
|
||||
|
||||
#GITHUB
|
||||
Moose Test Missions/MOOSE_Test_Template.miz
|
||||
Moose Development/Moose/.vscode/launch.json
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
--
|
||||
-- ## 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.
|
||||
-- **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.
|
||||
--
|
||||
@@ -333,7 +333,7 @@ do -- AI_A2A_DISPATCHER
|
||||
-- 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.**
|
||||
--
|
||||
-- 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:
|
||||
--
|
||||
@@ -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.
|
||||
-- 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:
|
||||
--
|
||||
@@ -1233,7 +1233,7 @@ do -- AI_A2A_DISPATCHER
|
||||
--
|
||||
-- **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 #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.
|
||||
-- **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 #number GciRadius (Optional, Default = 200000) The radius to ground control intercept detected targets from the nearest airbase.
|
||||
@@ -3257,7 +3257,8 @@ do -- AI_A2A_DISPATCHER
|
||||
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 )
|
||||
if Defender and Defender:IsAlive() then
|
||||
self:F( { "CAP Home", Defender:GetName() } )
|
||||
@@ -3505,7 +3506,8 @@ do -- AI_A2A_DISPATCHER
|
||||
Dispatcher:ClearDefenderTaskTarget( DefenderGroup )
|
||||
end
|
||||
|
||||
--- @param #AI_A2A_DISPATCHER self
|
||||
--- function Fsm:onafterLostControl
|
||||
-- @param #AI_A2A_DISPATCHER self
|
||||
function Fsm:onafterLostControl( Defender, From, Event, To )
|
||||
self:F( { "GCI LostControl", Defender:GetName() } )
|
||||
self:GetParent( self ).onafterHome( self, Defender, From, Event, To )
|
||||
@@ -3518,7 +3520,8 @@ do -- AI_A2A_DISPATCHER
|
||||
end
|
||||
end
|
||||
|
||||
--- @param #AI_A2A_DISPATCHER self
|
||||
--- function Fsm:onafterHome
|
||||
-- @param #AI_A2A_DISPATCHER self
|
||||
function Fsm:onafterHome( DefenderGroup, From, Event, To, Action )
|
||||
self:F( { "GCI Home", DefenderGroup:GetName() } )
|
||||
self:GetParent( self ).onafterHome( self, DefenderGroup, From, Event, To )
|
||||
@@ -3959,7 +3962,7 @@ do
|
||||
--
|
||||
-- # 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
--
|
||||
-- ## 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
--
|
||||
-- ## 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -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
|
||||
end
|
||||
|
||||
--- @param #AI_BALANCER self
|
||||
--- AI_BALANCER:onenterSpawning
|
||||
-- @param #AI_BALANCER self
|
||||
-- @param Core.Set#SET_GROUP SetGroup
|
||||
-- @param #string ClientName
|
||||
-- @param Wrapper.Group#GROUP AIGroup
|
||||
@@ -190,7 +191,8 @@ function AI_BALANCER:onenterSpawning( SetGroup, From, Event, To, ClientName )
|
||||
end
|
||||
end
|
||||
|
||||
--- @param #AI_BALANCER self
|
||||
--- AI_BALANCER:onenterDestroying
|
||||
-- @param #AI_BALANCER self
|
||||
-- @param Core.Set#SET_GROUP SetGroup
|
||||
-- @param Wrapper.Group#GROUP 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
|
||||
|
||||
|
||||
--- @param #AI_BALANCER self
|
||||
--- AI_BALANCER:onenterMonitoring
|
||||
-- @param #AI_BALANCER self
|
||||
function AI_BALANCER:onenterMonitoring( SetGroup )
|
||||
|
||||
self:T2( { self.SetClient:Count() } )
|
||||
--self.SetClient:Flush()
|
||||
|
||||
self.SetClient:ForEachClient(
|
||||
--- @param Wrapper.Client#CLIENT Client
|
||||
--- SetClient:ForEachClient
|
||||
-- @param Wrapper.Client#CLIENT Client
|
||||
function( Client )
|
||||
self:T3(Client.ClientName)
|
||||
|
||||
@@ -264,7 +267,8 @@ function AI_BALANCER:onenterMonitoring( SetGroup )
|
||||
self:T2( RangeZone )
|
||||
|
||||
_DATABASE:ForEachPlayerUnit(
|
||||
--- @param Wrapper.Unit#UNIT RangeTestUnit
|
||||
--- Nameless function
|
||||
-- @param Wrapper.Unit#UNIT RangeTestUnit
|
||||
function( RangeTestUnit, RangeZone, AIGroup, PlayerInRange )
|
||||
self:T2( { PlayerInRange, RangeTestUnit.UnitName, RangeZone.ZoneName } )
|
||||
if RangeTestUnit:IsInZone( RangeZone ) == true then
|
||||
@@ -276,7 +280,8 @@ function AI_BALANCER:onenterMonitoring( SetGroup )
|
||||
end
|
||||
end,
|
||||
|
||||
--- @param Core.Zone#ZONE_RADIUS RangeZone
|
||||
--- Nameless function
|
||||
-- @param Core.Zone#ZONE_RADIUS RangeZone
|
||||
-- @param Wrapper.Group#GROUP AIGroup
|
||||
function( RangeZone, AIGroup, PlayerInRange )
|
||||
if PlayerInRange.Value == false then
|
||||
@@ -307,6 +312,3 @@ function AI_BALANCER:onenterMonitoring( SetGroup )
|
||||
|
||||
self:__Monitor( 10 )
|
||||
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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
--
|
||||
-- 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -572,7 +572,7 @@
|
||||
-- A home zone can be specified to where the Carriers will move when there isn't any cargo left for pickup.
|
||||
-- Use @{#AI_CARGO_DISPATCHER.SetHomeZone}() to specify the home zone.
|
||||
--
|
||||
-- If no home zone is specified, the carriers will wait near the deploy zone for a new pickup command.
|
||||
-- If no home zone is specified, the carriers will wait near the deploy zone for a new pickup command.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -583,10 +583,12 @@ AI_CARGO_DISPATCHER = {
|
||||
PickupCargo = {}
|
||||
}
|
||||
|
||||
--- @field #list
|
||||
--- List of AI_Cargo
|
||||
-- @field #list
|
||||
AI_CARGO_DISPATCHER.AI_Cargo = {}
|
||||
|
||||
--- @field #list
|
||||
--- List of PickupCargo
|
||||
-- @field #list
|
||||
AI_CARGO_DISPATCHER.PickupCargo = {}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
--
|
||||
-- ## 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
--
|
||||
-- ## 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
-- * Assign a group leader that will guide the large formation path.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/FOR%20-%20AI%20Group%20Formation)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### [YouTube Playlist](https://www.youtube.com/playlist?list=PL7ZUrU4zZUl0bFIJ9jIdYM22uaWmIN4oz)
|
||||
--
|
||||
--
|
||||
-- ## 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)
|
||||
-- * **Guides:** None
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **FlightControl**
|
||||
|
||||
@@ -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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -370,7 +370,7 @@ CARGOS = {}
|
||||
|
||||
do -- CARGO
|
||||
|
||||
--- @type CARGO
|
||||
-- @type CARGO
|
||||
-- @extends Core.Fsm#FSM_PROCESS
|
||||
-- @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.
|
||||
@@ -433,7 +433,7 @@ do -- CARGO
|
||||
Reported = {},
|
||||
}
|
||||
|
||||
--- @type CARGO.CargoObjects
|
||||
-- @type CARGO.CargoObjects
|
||||
-- @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.
|
||||
@@ -447,7 +447,7 @@ do -- CARGO
|
||||
function CARGO:New( Type, Name, Weight, LoadRadius, NearRadius ) --R2.1
|
||||
|
||||
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:AddTransition( { "UnLoaded", "Boarding" }, "Board", "Boarding" )
|
||||
@@ -711,7 +711,7 @@ do -- CARGO
|
||||
-- @param #CARGO self
|
||||
-- @return #CARGO
|
||||
function CARGO:Spawn( PointVec2 )
|
||||
self:F()
|
||||
self:T()
|
||||
|
||||
end
|
||||
|
||||
@@ -812,7 +812,7 @@ do -- CARGO
|
||||
-- @param Core.Point#COORDINATE Coordinate
|
||||
-- @return #boolean true if the CargoGroup is within the loading radius.
|
||||
function CARGO:IsInLoadRadius( Coordinate )
|
||||
self:F( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||
self:T( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||
|
||||
local Distance = 0
|
||||
if self:IsUnLoaded() then
|
||||
@@ -832,7 +832,7 @@ do -- CARGO
|
||||
-- @param Core.Point#COORDINATE Coordinate
|
||||
-- @return #boolean true if the Cargo can report itself.
|
||||
function CARGO:IsInReportRadius( Coordinate )
|
||||
self:F( { Coordinate } )
|
||||
self:T( { Coordinate } )
|
||||
|
||||
local Distance = 0
|
||||
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).
|
||||
-- @return #boolean
|
||||
function CARGO:IsNear( Coordinate, NearRadius )
|
||||
--self:F( { PointVec2 = PointVec2, NearRadius = NearRadius } )
|
||||
--self:T( { PointVec2 = PointVec2, NearRadius = NearRadius } )
|
||||
|
||||
if self.CargoObject:IsAlive() then
|
||||
--local Distance = PointVec2:Get2DDistance( self.CargoObject:GetPointVec2() )
|
||||
--self:F( { CargoObjectName = self.CargoObject:GetName() } )
|
||||
--self:F( { CargoObjectVec2 = self.CargoObject:GetVec2() } )
|
||||
--self:F( { PointVec2 = PointVec2:GetVec2() } )
|
||||
--self:T( { CargoObjectName = self.CargoObject:GetName() } )
|
||||
--self:T( { CargoObjectVec2 = self.CargoObject:GetVec2() } )
|
||||
--self:T( { PointVec2 = PointVec2:GetVec2() } )
|
||||
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
|
||||
--self:F( { PointVec2 = PointVec2, NearRadius = NearRadius, IsNear = true } )
|
||||
--self:T( { PointVec2 = PointVec2, NearRadius = NearRadius, IsNear = true } )
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--self:F( { PointVec2 = PointVec2, NearRadius = NearRadius, IsNear = false } )
|
||||
--self:T( { PointVec2 = PointVec2, NearRadius = NearRadius, IsNear = false } )
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -878,12 +878,12 @@ do -- CARGO
|
||||
-- @param Core.Zone#ZONE_BASE Zone
|
||||
-- @return #boolean **true** if cargo is in the Zone, **false** if cargo is not in the Zone.
|
||||
function CARGO:IsInZone( Zone )
|
||||
--self:F( { Zone } )
|
||||
--self:T( { Zone } )
|
||||
|
||||
if self:IsLoaded() then
|
||||
return Zone:IsPointVec2InZone( self.CargoCarrier:GetPointVec2() )
|
||||
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
|
||||
return Zone:IsPointVec2InZone( self.CargoObject:GetPointVec2() )
|
||||
else
|
||||
@@ -1034,7 +1034,7 @@ end -- CARGO
|
||||
|
||||
do -- CARGO_REPRESENTABLE
|
||||
|
||||
--- @type CARGO_REPRESENTABLE
|
||||
-- @type CARGO_REPRESENTABLE
|
||||
-- @extends #CARGO
|
||||
-- @field test
|
||||
|
||||
@@ -1056,7 +1056,7 @@ do -- CARGO_REPRESENTABLE
|
||||
|
||||
-- Inherit CARGO.
|
||||
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.
|
||||
local Desc=CargoObject:GetDesc()
|
||||
@@ -1086,7 +1086,7 @@ do -- CARGO_REPRESENTABLE
|
||||
function CARGO_REPRESENTABLE:Destroy()
|
||||
|
||||
-- Cargo objects are deleted from the _DATABASE and SET_CARGO objects.
|
||||
self:F( { CargoName = self:GetName() } )
|
||||
self:T( { CargoName = self:GetName() } )
|
||||
--_EVENTDISPATCHER:CreateEventDeleteCargo( self )
|
||||
|
||||
return self
|
||||
@@ -1123,12 +1123,12 @@ do -- CARGO_REPRESENTABLE
|
||||
CoordinateZone:Scan( { Object.Category.UNIT } )
|
||||
for _, DCSUnit in pairs( CoordinateZone:GetScannedUnits() ) do
|
||||
local NearUnit = UNIT:Find( DCSUnit )
|
||||
self:F({NearUnit=NearUnit})
|
||||
self:T({NearUnit=NearUnit})
|
||||
local NearUnitCoalition = NearUnit:GetCoalition()
|
||||
local CargoCoalition = self:GetCoalition()
|
||||
if NearUnitCoalition == CargoCoalition then
|
||||
local Attributes = NearUnit:GetDesc()
|
||||
self:F({Desc=Attributes})
|
||||
self:T({Desc=Attributes})
|
||||
if NearUnit:HasAttribute( "Trucks" ) then
|
||||
MESSAGE:New( Message, 20, NearUnit:GetCallsign() .. " reporting - Cargo " .. self:GetName() ):ToGroup( TaskGroup )
|
||||
break
|
||||
@@ -1142,7 +1142,7 @@ end -- CARGO_REPRESENTABLE
|
||||
|
||||
do -- CARGO_REPORTABLE
|
||||
|
||||
--- @type CARGO_REPORTABLE
|
||||
-- @type CARGO_REPORTABLE
|
||||
-- @extends #CARGO
|
||||
CARGO_REPORTABLE = {
|
||||
ClassName = "CARGO_REPORTABLE"
|
||||
@@ -1158,7 +1158,7 @@ do -- CARGO_REPORTABLE
|
||||
-- @return #CARGO_REPORTABLE
|
||||
function CARGO_REPORTABLE:New( Type, Name, Weight, LoadRadius, NearRadius )
|
||||
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
|
||||
end
|
||||
@@ -1178,7 +1178,7 @@ end
|
||||
|
||||
do -- CARGO_PACKAGE
|
||||
|
||||
--- @type CARGO_PACKAGE
|
||||
-- @type CARGO_PACKAGE
|
||||
-- @extends #CARGO_REPRESENTABLE
|
||||
CARGO_PACKAGE = {
|
||||
ClassName = "CARGO_PACKAGE"
|
||||
@@ -1195,7 +1195,7 @@ do -- CARGO_PACKAGE
|
||||
-- @return #CARGO_PACKAGE
|
||||
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
|
||||
self:F( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||
self:T( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||
|
||||
self:T( CargoCarrier )
|
||||
self.CargoCarrier = CargoCarrier
|
||||
@@ -1213,7 +1213,7 @@ end
|
||||
-- @param #number BoardDistance
|
||||
-- @param #number Angle
|
||||
function CARGO_PACKAGE:onafterOnBoard( From, Event, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
|
||||
self:F()
|
||||
self:T()
|
||||
|
||||
self.CargoInAir = self.CargoCarrier:InAir()
|
||||
|
||||
@@ -1246,7 +1246,7 @@ end
|
||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||
-- @return #boolean
|
||||
function CARGO_PACKAGE:IsNear( CargoCarrier )
|
||||
self:F()
|
||||
self:T()
|
||||
|
||||
local CargoCarrierPoint = CargoCarrier:GetCoordinate()
|
||||
|
||||
@@ -1271,7 +1271,7 @@ end
|
||||
-- @param #number LoadDistance
|
||||
-- @param #number Angle
|
||||
function CARGO_PACKAGE:onafterOnBoarded( From, Event, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
|
||||
self:F()
|
||||
self:T()
|
||||
|
||||
if self:IsNear( CargoCarrier ) then
|
||||
self:__Load( 1, CargoCarrier, Speed, LoadDistance, Angle )
|
||||
@@ -1292,7 +1292,7 @@ end
|
||||
-- @param #number Radius
|
||||
-- @param #number Angle
|
||||
function CARGO_PACKAGE:onafterUnBoard( From, Event, To, CargoCarrier, Speed, UnLoadDistance, UnBoardDistance, Radius, Angle )
|
||||
self:F()
|
||||
self:T()
|
||||
|
||||
self.CargoInAir = self.CargoCarrier:InAir()
|
||||
|
||||
@@ -1331,7 +1331,7 @@ end
|
||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||
-- @param #number Speed
|
||||
function CARGO_PACKAGE:onafterUnBoarded( From, Event, To, CargoCarrier, Speed )
|
||||
self:F()
|
||||
self:T()
|
||||
|
||||
if self:IsNear( CargoCarrier ) then
|
||||
self:__UnLoad( 1, CargoCarrier, Speed )
|
||||
@@ -1350,7 +1350,7 @@ end
|
||||
-- @param #number LoadDistance
|
||||
-- @param #number Angle
|
||||
function CARGO_PACKAGE:onafterLoad( From, Event, To, CargoCarrier, Speed, LoadDistance, Angle )
|
||||
self:F()
|
||||
self:T()
|
||||
|
||||
self.CargoCarrier = CargoCarrier
|
||||
|
||||
@@ -1378,7 +1378,7 @@ end
|
||||
-- @param #number Distance
|
||||
-- @param #number Angle
|
||||
function CARGO_PACKAGE:onafterUnLoad( From, Event, To, CargoCarrier, Speed, Distance, Angle )
|
||||
self:F()
|
||||
self:T()
|
||||
|
||||
local StartPointVec2 = self.CargoCarrier:GetPointVec2()
|
||||
local CargoCarrierHeading = self.CargoCarrier:GetHeading() -- Get Heading of object in degrees.
|
||||
|
||||
@@ -59,7 +59,7 @@ do -- CARGO_CRATE
|
||||
-- @return #CARGO_CRATE
|
||||
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
|
||||
self:F( { Type, Name, NearRadius } )
|
||||
self:T( { Type, Name, NearRadius } )
|
||||
|
||||
self.CargoObject = CargoStatic -- Wrapper.Static#STATIC
|
||||
|
||||
@@ -116,7 +116,7 @@ do -- CARGO_CRATE
|
||||
-- @param #string To
|
||||
-- @param Core.Point#POINT_VEC2
|
||||
function CARGO_CRATE:onenterUnLoaded( From, Event, To, ToPointVec2 )
|
||||
--self:F( { ToPointVec2, From, Event, To } )
|
||||
--self:T( { ToPointVec2, From, Event, To } )
|
||||
|
||||
local Angle = 180
|
||||
local Speed = 10
|
||||
@@ -153,7 +153,7 @@ do -- CARGO_CRATE
|
||||
-- @param #string To
|
||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||
function CARGO_CRATE:onenterLoaded( From, Event, To, CargoCarrier )
|
||||
--self:F( { From, Event, To, CargoCarrier } )
|
||||
--self:T( { From, Event, To, CargoCarrier } )
|
||||
|
||||
self.CargoCarrier = CargoCarrier
|
||||
|
||||
@@ -190,7 +190,7 @@ do -- CARGO_CRATE
|
||||
-- @param Core.Point#COORDINATE Coordinate
|
||||
-- @return #boolean true if the Cargo Crate is within the report radius.
|
||||
function CARGO_CRATE:IsInReportRadius( Coordinate )
|
||||
--self:F( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||
--self:T( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||
|
||||
local Distance = 0
|
||||
if self:IsUnLoaded() then
|
||||
@@ -210,7 +210,7 @@ do -- CARGO_CRATE
|
||||
-- @param Core.Point#Coordinate Coordinate
|
||||
-- @return #boolean true if the Cargo Crate is within the loading radius.
|
||||
function CARGO_CRATE:IsInLoadRadius( Coordinate )
|
||||
--self:F( { Coordinate, LoadRadius = self.NearRadius } )
|
||||
--self:T( { Coordinate, LoadRadius = self.NearRadius } )
|
||||
|
||||
local Distance = 0
|
||||
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 #nil There is no valid Cargo in the CargoGroup.
|
||||
function CARGO_CRATE:GetCoordinate()
|
||||
--self:F()
|
||||
--self:T()
|
||||
|
||||
return self.CargoObject:GetCoordinate()
|
||||
end
|
||||
@@ -261,7 +261,7 @@ do -- CARGO_CRATE
|
||||
-- @param #CARGO_CRATE self
|
||||
-- @param Core.Point#COORDINATE Coordinate
|
||||
function CARGO_CRATE:RouteTo( Coordinate )
|
||||
self:F( {Coordinate = Coordinate } )
|
||||
self:T( {Coordinate = Coordinate } )
|
||||
|
||||
end
|
||||
|
||||
@@ -274,7 +274,7 @@ do -- CARGO_CRATE
|
||||
-- @return #boolean The Cargo is near to the Carrier.
|
||||
-- @return #nil The Cargo is not near to the Carrier.
|
||||
function CARGO_CRATE:IsNear( CargoCarrier, NearRadius )
|
||||
self:F( {NearRadius = NearRadius } )
|
||||
self:T( {NearRadius = NearRadius } )
|
||||
|
||||
return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius )
|
||||
end
|
||||
@@ -283,7 +283,7 @@ do -- CARGO_CRATE
|
||||
-- @param #CARGO_CRATE self
|
||||
function CARGO_CRATE:Respawn()
|
||||
|
||||
self:F( { "Respawning crate " .. self:GetName() } )
|
||||
self:T( { "Respawning crate " .. self:GetName() } )
|
||||
|
||||
|
||||
-- Respawn the group...
|
||||
@@ -300,7 +300,7 @@ do -- CARGO_CRATE
|
||||
-- @param #CARGO_CRATE self
|
||||
function CARGO_CRATE:onafterReset()
|
||||
|
||||
self:F( { "Reset crate " .. self:GetName() } )
|
||||
self:T( { "Reset crate " .. self:GetName() } )
|
||||
|
||||
|
||||
-- Respawn the group...
|
||||
|
||||
@@ -64,7 +64,7 @@ do -- CARGO_GROUP
|
||||
|
||||
-- Inherit CAROG_REPORTABLE
|
||||
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.CargoGroup = CargoGroup
|
||||
@@ -146,7 +146,7 @@ do -- CARGO_GROUP
|
||||
-- @param #CARGO_GROUP self
|
||||
function CARGO_GROUP:Respawn()
|
||||
|
||||
self:F( { "Respawning" } )
|
||||
self:T( { "Respawning" } )
|
||||
|
||||
for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do
|
||||
local Cargo = CargoData -- Cargo.Cargo#CARGO
|
||||
@@ -227,7 +227,7 @@ do -- CARGO_GROUP
|
||||
-- @param #CARGO_GROUP self
|
||||
function CARGO_GROUP:Regroup()
|
||||
|
||||
self:F("Regroup")
|
||||
self:T("Regroup")
|
||||
|
||||
if self.Grouped == false then
|
||||
|
||||
@@ -241,7 +241,7 @@ do -- CARGO_GROUP
|
||||
for CargoUnitName, CargoUnit in pairs( self.CargoSet:GetSet() ) do
|
||||
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
|
||||
|
||||
@@ -258,7 +258,7 @@ do -- CARGO_GROUP
|
||||
-- Then we register the new group in the database
|
||||
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.
|
||||
self.CargoObject = _DATABASE:Spawn( GroupTemplate )
|
||||
@@ -271,7 +271,7 @@ do -- CARGO_GROUP
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
function CARGO_GROUP:OnEventCargoDead( EventData )
|
||||
|
||||
self:E(EventData)
|
||||
self:T(EventData)
|
||||
|
||||
local Destroyed = false
|
||||
|
||||
@@ -296,7 +296,7 @@ do -- CARGO_GROUP
|
||||
|
||||
if Destroyed then
|
||||
self:Destroyed()
|
||||
self:E( { "Cargo group destroyed" } )
|
||||
self:T( { "Cargo group destroyed" } )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -309,14 +309,14 @@ do -- CARGO_GROUP
|
||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||
-- @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, ... )
|
||||
self:F( { CargoCarrier.UnitName, From, Event, To, NearRadius = NearRadius } )
|
||||
self:T( { CargoCarrier.UnitName, From, Event, To, NearRadius = NearRadius } )
|
||||
|
||||
NearRadius = NearRadius or self.NearRadius
|
||||
|
||||
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
|
||||
self.CargoSet:ForEach(
|
||||
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
|
||||
CargoGroup:OptionAlarmStateGreen()
|
||||
Cargo:__Board( 1, CargoCarrier, NearRadius, ... )
|
||||
@@ -334,7 +334,7 @@ do -- CARGO_GROUP
|
||||
-- @param #string To
|
||||
-- @param Wrapper.Unit#UNIT 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
|
||||
-- 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 #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||
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 Cancelled = false
|
||||
@@ -393,7 +393,7 @@ do -- CARGO_GROUP
|
||||
if not Boarded then
|
||||
self:__Boarding( -5, CargoCarrier, NearRadius, ... )
|
||||
else
|
||||
self:F("Group Cargo is loaded")
|
||||
self:T("Group Cargo is loaded")
|
||||
self:__Load( 1, CargoCarrier, ... )
|
||||
end
|
||||
else
|
||||
@@ -413,7 +413,7 @@ do -- CARGO_GROUP
|
||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||
-- @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, ... )
|
||||
self:F( {From, Event, To, ToPointVec2, NearRadius } )
|
||||
self:T( {From, Event, To, ToPointVec2, NearRadius } )
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
@@ -456,7 +456,7 @@ do -- CARGO_GROUP
|
||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||
-- @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, ... )
|
||||
--self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
||||
--self:T( { From, Event, To, ToPointVec2, NearRadius } )
|
||||
|
||||
--local NearRadius = NearRadius or 25
|
||||
|
||||
@@ -493,7 +493,7 @@ do -- CARGO_GROUP
|
||||
-- @param #string To
|
||||
-- @param Core.Point#POINT_VEC2 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
|
||||
|
||||
@@ -611,7 +611,7 @@ do -- CARGO_GROUP
|
||||
-- @param #CARGO_GROUP self
|
||||
-- @param Core.Point#COORDINATE 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
|
||||
self.CargoSet:ForEach(
|
||||
@@ -629,13 +629,13 @@ do -- CARGO_GROUP
|
||||
-- @param #number NearRadius
|
||||
-- @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 )
|
||||
self:F( {NearRadius = NearRadius } )
|
||||
self:T( {NearRadius = NearRadius } )
|
||||
|
||||
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
||||
if Cargo:IsAlive() then
|
||||
if Cargo:IsNear( CargoCarrier:GetCoordinate(), NearRadius ) then
|
||||
self:F( "Near" )
|
||||
self:T( "Near" )
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -649,7 +649,7 @@ do -- CARGO_GROUP
|
||||
-- @param Core.Point#COORDINATE Coordinate
|
||||
-- @return #boolean true if the Cargo Group is within the load radius.
|
||||
function CARGO_GROUP:IsInLoadRadius( Coordinate )
|
||||
--self:F( { Coordinate } )
|
||||
--self:T( { Coordinate } )
|
||||
|
||||
local Cargo = self:GetFirstAlive() -- Cargo.Cargo#CARGO
|
||||
|
||||
@@ -669,7 +669,7 @@ do -- CARGO_GROUP
|
||||
return false
|
||||
end
|
||||
|
||||
self:F( { Distance = Distance, LoadRadius = self.LoadRadius } )
|
||||
self:T( { Distance = Distance, LoadRadius = self.LoadRadius } )
|
||||
if Distance <= self.LoadRadius then
|
||||
return true
|
||||
else
|
||||
@@ -687,12 +687,12 @@ do -- CARGO_GROUP
|
||||
-- @param Core.Point#Coordinate Coordinate
|
||||
-- @return #boolean true if the Cargo Group is within the report radius.
|
||||
function CARGO_GROUP:IsInReportRadius( Coordinate )
|
||||
--self:F( { Coordinate } )
|
||||
--self:T( { Coordinate } )
|
||||
|
||||
local Cargo = self:GetFirstAlive() -- Cargo.Cargo#CARGO
|
||||
|
||||
if Cargo then
|
||||
self:F( { Cargo } )
|
||||
self:T( { Cargo } )
|
||||
local Distance = 0
|
||||
if Cargo:IsUnLoaded() then
|
||||
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 **false** if there is no element of the CargoGroup in the Zone.
|
||||
function CARGO_GROUP:IsInZone( Zone )
|
||||
--self:F( { Zone } )
|
||||
--self:T( { Zone } )
|
||||
|
||||
local Cargo = self.CargoSet:GetFirst() -- Cargo.Cargo#CARGO
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ do -- CARGO_SLINGLOAD
|
||||
-- @return #CARGO_SLINGLOAD
|
||||
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
|
||||
self:F( { Type, Name, NearRadius } )
|
||||
self:T( { Type, Name, NearRadius } )
|
||||
|
||||
self.CargoObject = CargoStatic
|
||||
|
||||
@@ -130,7 +130,7 @@ do -- CARGO_SLINGLOAD
|
||||
-- @param Core.Point#COORDINATE Coordinate
|
||||
-- @return #boolean true if the Cargo Crate is within the report radius.
|
||||
function CARGO_SLINGLOAD:IsInReportRadius( Coordinate )
|
||||
--self:F( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||
--self:T( { Coordinate, LoadRadius = self.LoadRadius } )
|
||||
|
||||
local Distance = 0
|
||||
if self:IsUnLoaded() then
|
||||
@@ -149,7 +149,7 @@ do -- CARGO_SLINGLOAD
|
||||
-- @param Core.Point#COORDINATE Coordinate
|
||||
-- @return #boolean true if the Cargo Slingload is within the loading radius.
|
||||
function CARGO_SLINGLOAD:IsInLoadRadius( Coordinate )
|
||||
--self:F( { Coordinate } )
|
||||
--self:T( { Coordinate } )
|
||||
|
||||
local Distance = 0
|
||||
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 #nil There is no valid Cargo in the CargoGroup.
|
||||
function CARGO_SLINGLOAD:GetCoordinate()
|
||||
--self:F()
|
||||
--self:T()
|
||||
|
||||
return self.CargoObject:GetCoordinate()
|
||||
end
|
||||
@@ -199,7 +199,7 @@ do -- CARGO_SLINGLOAD
|
||||
-- @param #CARGO_SLINGLOAD self
|
||||
-- @param Core.Point#COORDINATE Coordinate
|
||||
function CARGO_SLINGLOAD:RouteTo( Coordinate )
|
||||
--self:F( {Coordinate = Coordinate } )
|
||||
--self:T( {Coordinate = Coordinate } )
|
||||
|
||||
end
|
||||
|
||||
@@ -212,7 +212,7 @@ do -- CARGO_SLINGLOAD
|
||||
-- @return #boolean The Cargo is near to the Carrier.
|
||||
-- @return #nil The Cargo is not near to the Carrier.
|
||||
function CARGO_SLINGLOAD:IsNear( CargoCarrier, NearRadius )
|
||||
--self:F( {NearRadius = NearRadius } )
|
||||
--self:T( {NearRadius = NearRadius } )
|
||||
|
||||
return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius )
|
||||
end
|
||||
@@ -222,7 +222,7 @@ do -- CARGO_SLINGLOAD
|
||||
-- @param #CARGO_SLINGLOAD self
|
||||
function CARGO_SLINGLOAD:Respawn()
|
||||
|
||||
--self:F( { "Respawning slingload " .. self:GetName() } )
|
||||
--self:T( { "Respawning slingload " .. self:GetName() } )
|
||||
|
||||
|
||||
-- Respawn the group...
|
||||
@@ -239,7 +239,7 @@ do -- CARGO_SLINGLOAD
|
||||
-- @param #CARGO_SLINGLOAD self
|
||||
function CARGO_SLINGLOAD:onafterReset()
|
||||
|
||||
--self:F( { "Reset slingload " .. self:GetName() } )
|
||||
--self:T( { "Reset slingload " .. self:GetName() } )
|
||||
|
||||
|
||||
-- Respawn the group...
|
||||
|
||||
@@ -75,7 +75,7 @@ do -- CARGO_UNIT
|
||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||
-- @param #number NearRadius (optional) Defaut 25 m.
|
||||
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 Speed = 60
|
||||
@@ -114,7 +114,7 @@ do -- CARGO_UNIT
|
||||
else
|
||||
self.CargoObject:ReSpawnAt( FromPointVec2, CargoDeployHeading )
|
||||
end
|
||||
self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
|
||||
self:T( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
|
||||
self.CargoCarrier = nil
|
||||
|
||||
local Points = {}
|
||||
@@ -148,7 +148,7 @@ do -- CARGO_UNIT
|
||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||
-- @param #number NearRadius (optional) Defaut 100 m.
|
||||
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 Speed = 10
|
||||
@@ -174,7 +174,7 @@ do -- CARGO_UNIT
|
||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||
-- @param #number NearRadius (optional) Defaut 100 m.
|
||||
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()
|
||||
|
||||
@@ -199,7 +199,7 @@ do -- CARGO_UNIT
|
||||
-- @param #string To
|
||||
-- @param Core.Point#POINT_VEC2
|
||||
function CARGO_UNIT:onenterUnLoaded( From, Event, To, ToPointVec2 )
|
||||
self:F( { ToPointVec2, From, Event, To } )
|
||||
self:T( { ToPointVec2, From, Event, To } )
|
||||
|
||||
local Angle = 180
|
||||
local Speed = 10
|
||||
@@ -236,7 +236,7 @@ do -- CARGO_UNIT
|
||||
-- @param Wrapper.Group#GROUP CargoCarrier
|
||||
-- @param #number 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()
|
||||
|
||||
@@ -244,7 +244,7 @@ do -- CARGO_UNIT
|
||||
local MaxSpeed = Desc.speedMaxOffRoad
|
||||
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
|
||||
|
||||
@@ -298,9 +298,9 @@ do -- CARGO_UNIT
|
||||
-- @param Wrapper.Client#CLIENT CargoCarrier
|
||||
-- @param #number NearRadius Default 25 m.
|
||||
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:IsAir() and not CargoCarrier:InAir()) or true then
|
||||
@@ -321,7 +321,7 @@ do -- CARGO_UNIT
|
||||
local Angle = 180
|
||||
local Distance = 0
|
||||
|
||||
--self:F({Unit=self.CargoObject:GetName()})
|
||||
--self:T({Unit=self.CargoObject:GetName()})
|
||||
|
||||
local CargoCarrierPointVec2 = CargoCarrier:GetPointVec2()
|
||||
local CargoCarrierHeading = CargoCarrier:GetHeading() -- Get Heading of object in degrees.
|
||||
@@ -348,7 +348,7 @@ do -- CARGO_UNIT
|
||||
self.CargoObject:SetCommand( self.CargoObject:CommandStopRoute( true ) )
|
||||
end
|
||||
else
|
||||
self:E("Something is wrong")
|
||||
self:T("Something is wrong")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -361,11 +361,11 @@ do -- CARGO_UNIT
|
||||
-- @param #string To
|
||||
-- @param Wrapper.Unit#UNIT 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: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).
|
||||
if self.CargoObject then
|
||||
|
||||
@@ -1144,6 +1144,19 @@ function BASE:TraceClassMethod( Class, Method )
|
||||
self:I( "Tracing method " .. Method .. " of class " .. Class )
|
||||
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.
|
||||
-- @param #BASE self
|
||||
-- @param Arguments A #table or any field.
|
||||
@@ -1168,7 +1181,7 @@ function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
|
||||
if DebugInfoFrom then
|
||||
LineFrom = DebugInfoFrom.currentline
|
||||
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
|
||||
@@ -1242,7 +1255,7 @@ function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
|
||||
if DebugInfoFrom then
|
||||
LineFrom = DebugInfoFrom.currentline
|
||||
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
|
||||
@@ -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 ) ) )
|
||||
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
|
||||
@@ -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 ) ) )
|
||||
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
|
||||
|
||||
--- 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
|
||||
--
|
||||
-- @module Core.Beacon
|
||||
@@ -286,6 +290,7 @@ end
|
||||
-- myBeacon:AATACAN(20, "TEXACO", true) -- Activate the beacon
|
||||
function BEACON:AATACAN(TACANChannel, Message, Bearing, BeaconDuration)
|
||||
self:F({TACANChannel, Message, Bearing, BeaconDuration})
|
||||
self:E("This method is DEPRECATED! Please use ActivateTACAN() instead.")
|
||||
|
||||
local IsValid = true
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ CLIENTMENU_ID = 0
|
||||
|
||||
--- Create an new CLIENTMENU object.
|
||||
-- @param #CLIENTMENU self
|
||||
-- @param Wrapper.Client#CLIENT Client The client for whom this entry is.
|
||||
-- @param Wrapper.Client#CLIENT Client The client for whom this entry is. Leave as nil for a generic entry.
|
||||
-- @param #string Text Text of the F10 menu entry.
|
||||
-- @param #CLIENTMENU Parent The parent menu entry.
|
||||
-- @param #string Function (optional) Function to call when the entry is used.
|
||||
@@ -324,6 +324,22 @@ end
|
||||
--
|
||||
-- Many functions can either change the tree for one client or for all clients.
|
||||
--
|
||||
-- ## Conceptual remarks
|
||||
--
|
||||
-- There's a couple of things to fully understand:
|
||||
--
|
||||
-- 1) **CLIENTMENUMANAGER** manages a set of entries from **CLIENTMENU**, it's main purpose is to administer the *shadow menu tree*, ie. a menu structure which is not
|
||||
-- (yet) visible to any client
|
||||
-- 2) The entries are **CLIENTMENU** objects, which are linked in a tree form. There's two ways to create them:
|
||||
-- A) in the manager with ":NewEntry()" which initially
|
||||
-- adds it to the shadow menu **only**
|
||||
-- B) stand-alone directly as `CLIENTMENU:NewEntry()` - here it depends on whether or not you gave a CLIENT object if the entry is created as generic entry or pushed
|
||||
-- a **specific** client. **Be aware** though that the entries are not managed by the CLIENTMANAGER before the next step!
|
||||
-- A generic entry can be added to the manager (and the shadow tree) with `:AddEntry()` - this will also push it to all clients(!) if no client is given, or a specific client only.
|
||||
-- 3) Pushing only works for alive clients.
|
||||
-- 4) Live and shadow tree entries are managed via the CLIENTMENUMANAGER object.
|
||||
-- 5) `Propagate()`refreshes the menu tree for all, or a single client.
|
||||
--
|
||||
-- ## Create a base reference tree and send to all clients
|
||||
--
|
||||
-- local clientset = SET_CLIENT:New():FilterStart()
|
||||
@@ -396,7 +412,7 @@ end
|
||||
CLIENTMENUMANAGER = {
|
||||
ClassName = "CLIENTMENUMANAGER",
|
||||
lid = "",
|
||||
version = "0.1.3",
|
||||
version = "0.1.4",
|
||||
name = nil,
|
||||
clientset = nil,
|
||||
menutree = {},
|
||||
@@ -439,18 +455,18 @@ function CLIENTMENUMANAGER:_EventHandler(EventData)
|
||||
--self:I(self.lid.."_EventHandler: "..tostring(EventData.IniPlayerName))
|
||||
if EventData.id == EVENTS.PlayerLeaveUnit or EventData.id == EVENTS.Ejection or EventData.id == EVENTS.Crash or EventData.id == EVENTS.PilotDead then
|
||||
self:T(self.lid.."Leave event for player: "..tostring(EventData.IniPlayerName))
|
||||
local Client = _DATABASE:FindClient( EventData.IniPlayerName )
|
||||
local Client = _DATABASE:FindClient( EventData.IniUnitName )
|
||||
if Client then
|
||||
self:ResetMenu(Client)
|
||||
end
|
||||
elseif (EventData.id == EVENTS.PlayerEnterAircraft) and EventData.IniCoalition == self.Coalition then
|
||||
if EventData.IniPlayerName and EventData.IniGroup then
|
||||
if (not self.clientset:IsIncludeObject(_DATABASE:FindClient( EventData.IniPlayerName ))) then
|
||||
if (not self.clientset:IsIncludeObject(_DATABASE:FindClient( EventData.IniUnitName ))) then
|
||||
self:T(self.lid.."Client not in SET: "..EventData.IniPlayerName)
|
||||
return self
|
||||
end
|
||||
--self:I(self.lid.."Join event for player: "..EventData.IniPlayerName)
|
||||
local player = _DATABASE:FindClient( EventData.IniPlayerName )
|
||||
local player = _DATABASE:FindClient( EventData.IniUnitName )
|
||||
self:Propagate(player)
|
||||
end
|
||||
elseif EventData.id == EVENTS.PlayerEnterUnit then
|
||||
@@ -492,7 +508,7 @@ function CLIENTMENUMANAGER:_EventHandler(EventData)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set this Client Manager to auto-propagate menus to newly joined players. Useful if you have **one** menu structure only.
|
||||
--- Set this Client Manager to auto-propagate menus **once** to newly joined players. Useful if you have **one** menu structure only. Does not automatically push follow-up changes to the client(s).
|
||||
-- @param #CLIENTMENUMANAGER self
|
||||
-- @return #CLIENTMENUMANAGER self
|
||||
function CLIENTMENUMANAGER:InitAutoPropagation()
|
||||
@@ -507,7 +523,7 @@ function CLIENTMENUMANAGER:InitAutoPropagation()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Create a new entry in the generic structure.
|
||||
--- Create a new entry in the **generic** structure.
|
||||
-- @param #CLIENTMENUMANAGER self
|
||||
-- @param #string Text Text of the F10 menu entry.
|
||||
-- @param #CLIENTMENU Parent The parent menu entry.
|
||||
@@ -668,7 +684,7 @@ function CLIENTMENUMANAGER:Propagate(Client)
|
||||
for _,_client in pairs(Set) do
|
||||
local client = _client -- Wrapper.Client#CLIENT
|
||||
if client and client:IsAlive() then
|
||||
local playername = client:GetPlayerName()
|
||||
local playername = client:GetPlayerName() or "none"
|
||||
if not self.playertree[playername] then
|
||||
self.playertree[playername] = {}
|
||||
end
|
||||
@@ -695,7 +711,7 @@ function CLIENTMENUMANAGER:Propagate(Client)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Push a single previously created entry into the menu structure of all clients.
|
||||
--- Push a single previously created entry into the F10 menu structure of all clients.
|
||||
-- @param #CLIENTMENUMANAGER self
|
||||
-- @param #CLIENTMENU Entry The entry to add.
|
||||
-- @param Wrapper.Client#CLIENT Client (optional) If given, make this change only for this client.
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
-- @field #table Templates Templates: Units, Groups, Statics, ClientsByName, ClientsByID.
|
||||
-- @field #table CLIENTS Clients.
|
||||
-- @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
|
||||
|
||||
--- Contains collections of wrapper objects defined within MOOSE that reflect objects within the simulator.
|
||||
@@ -93,6 +95,8 @@ DATABASE = {
|
||||
OPSZONES = {},
|
||||
PATHLINES = {},
|
||||
STORAGES = {},
|
||||
STNS={},
|
||||
SADL={},
|
||||
}
|
||||
|
||||
local _DATABASECoalition =
|
||||
@@ -449,10 +453,10 @@ do -- Zones and Pathlines
|
||||
|
||||
-- Loop over layers.
|
||||
for layerID, layerData in pairs(env.mission.drawings.layers or {}) do
|
||||
|
||||
|
||||
-- Loop over objects in layers.
|
||||
for objectID, objectData in pairs(layerData.objects or {}) do
|
||||
|
||||
|
||||
-- Check for polygon which has at least 4 points (we would need 3 but the origin seems to be there twice)
|
||||
if objectData.polygonMode and (objectData.polygonMode=="free") and objectData.points and #objectData.points>=4 then
|
||||
|
||||
@@ -488,10 +492,32 @@ do -- Zones and Pathlines
|
||||
|
||||
-- Create new polygon zone.
|
||||
local Zone=ZONE_POLYGON:NewFromPointsArray(ZoneName, points)
|
||||
|
||||
|
||||
--Zone.DrawID = objectID
|
||||
|
||||
-- Set color.
|
||||
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.
|
||||
self.ZONENAMES[ZoneName] = ZoneName
|
||||
|
||||
@@ -532,7 +558,26 @@ do -- Zones and Pathlines
|
||||
|
||||
-- Set color.
|
||||
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.
|
||||
self.ZONENAMES[ZoneName] = ZoneName
|
||||
|
||||
@@ -756,7 +801,7 @@ end -- cargo
|
||||
|
||||
--- Finds a CLIENT based on the ClientName.
|
||||
-- @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.
|
||||
function DATABASE:FindClient( ClientName )
|
||||
|
||||
@@ -887,7 +932,7 @@ function DATABASE:Spawn( SpawnTemplate )
|
||||
SpawnTemplate.CountryID = nil
|
||||
SpawnTemplate.CategoryID = nil
|
||||
|
||||
self:_RegisterGroupTemplate( SpawnTemplate, SpawnCoalitionID, SpawnCategoryID, SpawnCountryID )
|
||||
self:_RegisterGroupTemplate( SpawnTemplate, SpawnCoalitionID, SpawnCategoryID, SpawnCountryID, SpawnTemplate.name )
|
||||
|
||||
self:T3( SpawnTemplate )
|
||||
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
||||
@@ -988,10 +1033,31 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, Category
|
||||
self.Templates.ClientsByName[UnitTemplate.name].CountryID = CountryID
|
||||
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
-- Debug info.
|
||||
self:T( { Group = self.Templates.Groups[GroupTemplateName].GroupName,
|
||||
Coalition = self.Templates.Groups[GroupTemplateName].CoalitionID,
|
||||
@@ -1002,6 +1068,80 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, Category
|
||||
)
|
||||
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)
|
||||
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)
|
||||
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.
|
||||
-- @param #DATABASE self
|
||||
-- @param #string GroupName Group name.
|
||||
@@ -1302,9 +1442,17 @@ function DATABASE:_RegisterAirbase(airbase)
|
||||
|
||||
-- Unique ID.
|
||||
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.
|
||||
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
|
||||
if airbase.NparkingTerminal and airbase.NparkingTerminal[terminalType] then
|
||||
text=text..string.format("%d=%d ", terminalType, airbase.NparkingTerminal[terminalType])
|
||||
@@ -1852,7 +2000,7 @@ end
|
||||
|
||||
--- Add a flight control to the data base.
|
||||
-- @param #DATABASE self
|
||||
-- @param Ops.FlightControl#FLIGHTCONTROL flightcontrol
|
||||
-- @param OPS.FlightControl#FLIGHTCONTROL flightcontrol
|
||||
function DATABASE:AddFlightControl(flightcontrol)
|
||||
self:F2( { flightcontrol } )
|
||||
self.FLIGHTCONTROLS[flightcontrol.airbasename]=flightcontrol
|
||||
@@ -1861,7 +2009,7 @@ end
|
||||
--- Get a flight control object from the data base.
|
||||
-- @param #DATABASE self
|
||||
-- @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)
|
||||
return self.FLIGHTCONTROLS[airbasename]
|
||||
end
|
||||
|
||||
@@ -261,6 +261,15 @@ EVENTS = {
|
||||
SimulationStart = world.event.S_EVENT_SIMULATION_START or -1,
|
||||
WeaponRearm = world.event.S_EVENT_WEAPON_REARM 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
|
||||
@@ -636,6 +645,55 @@ local _EVENTMETA = {
|
||||
Event = "OnEventWeaponDrop",
|
||||
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
|
||||
@@ -1245,11 +1303,14 @@ function EVENT:onEvent( Event )
|
||||
Event.TgtDCSUnit = Event.target
|
||||
if Event.target:isExist() and Event.id ~= 33 then -- leave out ejected seat object
|
||||
Event.TgtDCSUnitName = Event.TgtDCSUnit:getName()
|
||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||
Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName, false )
|
||||
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
||||
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
||||
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
||||
-- Workaround for borked target info on cruise missiles
|
||||
if Event.TgtDCSUnitName and Event.TgtDCSUnitName ~= "" then
|
||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||
Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName, false )
|
||||
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
||||
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
||||
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
||||
end
|
||||
else
|
||||
Event.TgtDCSUnitName = string.format("No target object for Event ID %s", tostring(Event.id))
|
||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||
@@ -1287,7 +1348,8 @@ function EVENT:onEvent( Event )
|
||||
Event.Weapon = Event.weapon
|
||||
Event.WeaponName = Event.Weapon:getTypeName()
|
||||
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.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category
|
||||
Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName()
|
||||
@@ -1316,6 +1378,7 @@ function EVENT:onEvent( Event )
|
||||
Event.MarkCoordinate=COORDINATE:NewFromVec3(Event.pos)
|
||||
Event.MarkText=Event.text
|
||||
Event.MarkCoalition=Event.coalition
|
||||
Event.IniCoalition=Event.coalition
|
||||
Event.MarkGroupID = Event.groupID
|
||||
end
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ do -- FSM
|
||||
--
|
||||
-- ### 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.
|
||||
-- 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**
|
||||
--
|
||||
-- Date: 5 May 2021
|
||||
-- Last Update: Feb 2023
|
||||
-- Last Update: Mar 2023
|
||||
--
|
||||
-- ===
|
||||
---
|
||||
@@ -50,7 +50,7 @@ MARKEROPS_BASE = {
|
||||
ClassName = "MARKEROPS",
|
||||
Tag = "mytag",
|
||||
Keywords = {},
|
||||
version = "0.1.1",
|
||||
version = "0.1.3",
|
||||
debug = false,
|
||||
Casesensitive = true,
|
||||
}
|
||||
@@ -114,6 +114,8 @@ function MARKEROPS_BASE:New(Tagname,Keywords,Casesensitive)
|
||||
-- @param #string Text The text on the marker
|
||||
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||
-- @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.
|
||||
-- @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 #table Keywords Table of matching keywords found in the Event text
|
||||
-- @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.
|
||||
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkDeleted
|
||||
@@ -133,7 +136,7 @@ function MARKEROPS_BASE:New(Tagname,Keywords,Casesensitive)
|
||||
-- @param #string Event The Event called
|
||||
-- @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
|
||||
|
||||
end
|
||||
@@ -155,29 +158,30 @@ function MARKEROPS_BASE:OnEventMark(Event)
|
||||
local text = tostring(Event.text)
|
||||
local m = MESSAGE:New(string.format("Mark added at %s with text: %s",coordtext,text),10,"Info",false):ToAll()
|
||||
end
|
||||
local coalition = Event.MarkCoalition
|
||||
-- decision
|
||||
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
|
||||
local Eventtext = tostring(Event.text)
|
||||
if Eventtext~=nil then
|
||||
if self:_MatchTag(Eventtext) then
|
||||
local matchtable = self:_MatchKeywords(Eventtext)
|
||||
self:MarkAdded(Eventtext,matchtable,coord)
|
||||
self:MarkAdded(Eventtext,matchtable,coord,Event.idx,coalition)
|
||||
end
|
||||
end
|
||||
elseif Event.id==world.event.S_EVENT_MARK_CHANGE then
|
||||
self:T({event="S_EVENT_MARK_CHANGE", carrier=self.groupname, vec3=Event.pos})
|
||||
self:T({event="S_EVENT_MARK_CHANGE", carrier=Event.IniGroupName, vec3=Event.pos})
|
||||
-- Handle event.
|
||||
local Eventtext = tostring(Event.text)
|
||||
if Eventtext~=nil then
|
||||
if self:_MatchTag(Eventtext) then
|
||||
local matchtable = self:_MatchKeywords(Eventtext)
|
||||
self:MarkChanged(Eventtext,matchtable,coord,Event.idx)
|
||||
self:MarkChanged(Eventtext,matchtable,coord,Event.idx,coalition)
|
||||
end
|
||||
end
|
||||
elseif Event.id==world.event.S_EVENT_MARK_REMOVED then
|
||||
self:T({event="S_EVENT_MARK_REMOVED", carrier=self.groupname, vec3=Event.pos})
|
||||
self:T({event="S_EVENT_MARK_REMOVED", carrier=Event.IniGroupName, vec3=Event.pos})
|
||||
-- Hande event.
|
||||
local Eventtext = tostring(Event.text)
|
||||
if Eventtext~=nil then
|
||||
@@ -230,8 +234,10 @@ end
|
||||
-- @param #string To The To state
|
||||
-- @param #string Text The text on the marker
|
||||
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||
-- @param #number MarkerID Id of this marker
|
||||
-- @param #number CoalitionNumber Coalition of the marker creator
|
||||
-- @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()})
|
||||
end
|
||||
|
||||
@@ -242,8 +248,10 @@ end
|
||||
-- @param #string To The To state
|
||||
-- @param #string Text The text on the marker
|
||||
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||
-- @param #number MarkerID Id of this marker
|
||||
-- @param #number CoalitionNumber Coalition of the marker creator
|
||||
-- @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()})
|
||||
end
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ function MESSAGE:ToCoalition( CoalitionSide, Settings )
|
||||
if CoalitionSide then
|
||||
if self.MessageDuration ~= 0 then
|
||||
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
|
||||
|
||||
@@ -459,14 +459,14 @@ end
|
||||
|
||||
_MESSAGESRS = {}
|
||||
|
||||
--- Set up MESSAGE generally to allow Text-To-Speech via SRS and TTS functions.
|
||||
-- @param #string PathToSRS Path to SRS Folder, defaults to "C:\\\\Program Files\\\\DCS-SimpleRadio-Standalone".
|
||||
-- @param #number Port Port number of SRS, defaults to 5002.
|
||||
-- @param #string PathToCredentials (optional) Path to credentials file for e.g. Google.
|
||||
--- 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 (optional) Path to SRS Folder, defaults to "C:\\\\Program Files\\\\DCS-SimpleRadio-Standalone" or your configuration file setting.
|
||||
-- @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 Google.
|
||||
-- @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 #string Gender (optional) Gender, i.e. "male" or "female", defaults to "female".
|
||||
-- @param #string Culture (optional) Culture, e.g. "en-US", defaults to "en-GB"
|
||||
-- @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" 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 #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).
|
||||
@@ -480,45 +480,51 @@ _MESSAGESRS = {}
|
||||
-- MESSAGE:New("Test message!",15,"SPAWN"):ToSRS()
|
||||
--
|
||||
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.modulation = Modulation or radio.modulation.AM
|
||||
_MESSAGESRS.PathToSRS = PathToSRS or MSRS.path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
|
||||
_MESSAGESRS.MSRS:SetCoalition(Coalition or coalition.side.NEUTRAL)
|
||||
_MESSAGESRS.coalition = Coalition or coalition.side.NEUTRAL
|
||||
_MESSAGESRS.frequency = Frequency or MSRS.frequencies or 243
|
||||
_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.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.Culture = Culture or "en-GB"
|
||||
|
||||
_MESSAGESRS.Gender = Gender or MSRS.gender or "female"
|
||||
_MESSAGESRS.MSRS:SetGender(Gender)
|
||||
_MESSAGESRS.Gender = Gender or "female"
|
||||
|
||||
_MESSAGESRS.MSRS:SetGoogle(PathToCredentials)
|
||||
_MESSAGESRS.google = PathToCredentials
|
||||
|
||||
_MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE")
|
||||
_MESSAGESRS.label = Label or "MESSAGE"
|
||||
|
||||
_MESSAGESRS.MSRS:SetPort(Port or 5002)
|
||||
_MESSAGESRS.port = Port or 5002
|
||||
if PathToCredentials then
|
||||
_MESSAGESRS.MSRS:SetProviderOptionsGoogle(PathToCredentials)
|
||||
_MESSAGESRS.MSRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
|
||||
_MESSAGESRS.volume = Volume or 1
|
||||
_MESSAGESRS.label = Label or MSRS.Label or "MESSAGE"
|
||||
_MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE")
|
||||
|
||||
_MESSAGESRS.port = Port or MSRS.port or 5002
|
||||
_MESSAGESRS.MSRS:SetPort(Port or 5002)
|
||||
|
||||
_MESSAGESRS.volume = Volume or MSRS.volume or 1
|
||||
_MESSAGESRS.MSRS:SetVolume(_MESSAGESRS.volume)
|
||||
|
||||
if Voice then _MESSAGESRS.MSRS:SetVoice(Voice) end
|
||||
|
||||
_MESSAGESRS.voice = 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.voice = Voice or MSRS.voice --or MSRS.Voices.Microsoft.Hedda
|
||||
|
||||
_MESSAGESRS.SRSQ = MSRSQUEUE:New(Label or "MESSAGE")
|
||||
_MESSAGESRS.SRSQ = MSRSQUEUE:New(_MESSAGESRS.label)
|
||||
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 #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.
|
||||
@@ -546,7 +552,7 @@ function MESSAGE:ToSRS(frequency,modulation,gender,culture,voice,coalition,volum
|
||||
_MESSAGESRS.MSRS:SetCoordinate(coordinate)
|
||||
end
|
||||
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
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ PATHLINE = {
|
||||
|
||||
--- PATHLINE class version.
|
||||
-- @field #string version
|
||||
PATHLINE.version="0.1.0"
|
||||
PATHLINE.version="0.1.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- 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.
|
||||
-- @param #PATHLINE self
|
||||
-- @return <Core.Point#COORDINATE> List of COORDINATES points.
|
||||
function PATHLINE:GetCoordinats()
|
||||
function PATHLINE:GetCoordinates()
|
||||
|
||||
local vecs={}
|
||||
|
||||
for _,_point in pairs(self.points) do
|
||||
local point=_point --#PATHLINE.Point
|
||||
local coord=COORDINATE:NewFromVec3(point.vec3)
|
||||
table.insert(vecs,coord)
|
||||
end
|
||||
|
||||
return vecs
|
||||
@@ -262,7 +263,7 @@ function PATHLINE:GetPointFromIndex(n)
|
||||
local point=nil --#PATHLINE.Point
|
||||
|
||||
if n>=1 and n<=N then
|
||||
point=self.point[n]
|
||||
point=self.points[n]
|
||||
else
|
||||
self:E(self.lid..string.format("ERROR: No point in pathline for N=%s", tostring(n)))
|
||||
end
|
||||
@@ -367,4 +368,4 @@ 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:
|
||||
--
|
||||
-- * FlightControl (Design & Programming)
|
||||
@@ -40,8 +24,9 @@
|
||||
|
||||
|
||||
do -- COORDINATE
|
||||
|
||||
--- @type COORDINATE
|
||||
|
||||
---
|
||||
-- @type COORDINATE
|
||||
-- @field #string ClassName Name of the class
|
||||
-- @field #number x 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.ToStringBRA}(): Generates a Bearing, Range & Altitude text.
|
||||
-- * @{#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.ToStringLLDDM}(): Generates a Lat, Lon, Degree, decimal Minute text.
|
||||
-- * @{#COORDINATE.ToStringMGRS}(): Generates a MGRS grid coordinate text.
|
||||
@@ -717,8 +702,9 @@ do -- COORDINATE
|
||||
-- @param #COORDINATE PointVec2Reference The reference @{#COORDINATE}.
|
||||
-- @return DCS#Distance The distance from the reference @{#COORDINATE} in meters.
|
||||
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
|
||||
|
||||
self:T2( Distance )
|
||||
@@ -920,7 +906,7 @@ do -- COORDINATE
|
||||
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 DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
|
||||
-- @return #number DirectionRadians The angle in radians.
|
||||
@@ -933,10 +919,12 @@ do -- COORDINATE
|
||||
return DirectionRadians
|
||||
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 DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
|
||||
-- @return #number DirectionRadians The angle in degrees.
|
||||
-- @usage
|
||||
-- local directionAngle = currentCoordinate:GetAngleDegrees(currentCoordinate:GetDirectionVec3(sourceCoordinate:GetVec3()))
|
||||
function COORDINATE:GetAngleDegrees( DirectionVec3 )
|
||||
local AngleRadians = self:GetAngleRadians( DirectionVec3 )
|
||||
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
|
||||
local s=string.format("trigger.action.markupToAll(7, %d, %d,", Coalition, MarkID)
|
||||
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
|
||||
s=s..string.format("%s, %s, %s, %s", UTILS._OneLineSerialize(Color), UTILS._OneLineSerialize(FillColor), tostring(LineType), tostring(ReadOnly))
|
||||
if Text and Text~="" then
|
||||
s=s..string.format(", \"%s\"", Text)
|
||||
s=s..string.format("{%.3f, %.3f, %.3f, %.3f},", Color[1], Color[2], Color[3], Color[4])
|
||||
s=s..string.format("{%.3f, %.3f, %.3f, %.3f},", FillColor[1], FillColor[2], FillColor[3], FillColor[4])
|
||||
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
|
||||
s=s..")"
|
||||
|
||||
|
||||
-- Execute string command
|
||||
local success=UTILS.DoString(s)
|
||||
|
||||
@@ -2565,7 +2556,7 @@ do -- COORDINATE
|
||||
|
||||
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()
|
||||
FromVec3.y = FromVec3.y + Offset
|
||||
|
||||
@@ -2966,10 +2957,10 @@ do -- COORDINATE
|
||||
end
|
||||
|
||||
-- corrected Track to be direction of travel of bogey (self in this case)
|
||||
local track = "Maneuver"
|
||||
|
||||
if self.Heading then
|
||||
track = UTILS.BearingToCardinal(self.Heading) or "North"
|
||||
local track = "Maneuver"
|
||||
|
||||
if self.Heading then
|
||||
track = UTILS.BearingToCardinal(self.Heading) or "North"
|
||||
end
|
||||
|
||||
if rangeNM > 3 then
|
||||
@@ -3021,6 +3012,16 @@ do -- COORDINATE
|
||||
return BRAANATO
|
||||
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.
|
||||
-- @param #COORDINATE self
|
||||
-- @param DCS#coalition.side Coalition The coalition.
|
||||
@@ -3071,6 +3072,18 @@ do -- COORDINATE
|
||||
return coord.LOtoLL( self:GetVec3() )
|
||||
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.
|
||||
-- @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.
|
||||
@@ -3104,6 +3117,50 @@ do -- COORDINATE
|
||||
local MGRS = coord.LLtoMGRS( lat, lon )
|
||||
return "MGRS " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy )
|
||||
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:
|
||||
-- * Uses default settings in COORDINATE.
|
||||
@@ -3617,7 +3674,7 @@ end
|
||||
|
||||
do -- POINT_VEC2
|
||||
|
||||
--- @type POINT_VEC2
|
||||
-- @type POINT_VEC2
|
||||
-- @field DCS#Distance x The x coordinate in meters.
|
||||
-- @field DCS#Distance y the y coordinate in meters.
|
||||
-- @extends Core.Point#COORDINATE
|
||||
|
||||
@@ -14,17 +14,13 @@
|
||||
--
|
||||
-- # Demo Missions
|
||||
--
|
||||
-- ### [SCHEDULER Demo Missions source code](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCH%20-%20Scheduler)
|
||||
--
|
||||
-- ### [SCHEDULER Demo Missions, only for beta testers](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCH%20-%20Scheduler)
|
||||
--
|
||||
-- ### [ALL Demo Missions pack of the last release](https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases)
|
||||
-- ### [SCHEDULER Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Core/Scheduler)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # YouTube Channel
|
||||
--
|
||||
-- ### [SCHEDULER YouTube Channel (none)]()
|
||||
-- ### None
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -146,7 +146,45 @@ do -- SET_BASE
|
||||
|
||||
return self
|
||||
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.
|
||||
-- @param #SET_BASE self
|
||||
-- @param #boolean TriggerEvent If `true`, an event remove is triggered for each group that is removed from the set.
|
||||
@@ -417,13 +455,34 @@ do -- SET_BASE
|
||||
|
||||
--- Gets a random object from the @{Core.Set#SET_BASE} and derived classes.
|
||||
-- @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()
|
||||
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)]]
|
||||
self:T3( { RandomItem } )
|
||||
return RandomItem
|
||||
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.
|
||||
-- @param #SET_BASE self
|
||||
@@ -561,10 +620,12 @@ do -- SET_BASE
|
||||
return self
|
||||
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 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.
|
||||
-- @usage
|
||||
-- myset:FindNearestObjectFromPointVec2( ZONE:New("Test Zone"):GetCoordinate() )
|
||||
function SET_BASE:FindNearestObjectFromPointVec2( PointVec2 )
|
||||
self:F2( PointVec2 )
|
||||
|
||||
@@ -961,6 +1022,7 @@ do
|
||||
-- * @{#SET_GROUP.FilterCategoryShip}: Builds the SET_GROUP from ships.
|
||||
-- * @{#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.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:
|
||||
--
|
||||
@@ -1034,6 +1096,8 @@ do
|
||||
Countries = nil,
|
||||
GroupPrefixes = nil,
|
||||
Zones = nil,
|
||||
Functions = nil,
|
||||
Alive = nil,
|
||||
},
|
||||
FilterMeta = {
|
||||
Coalitions = {
|
||||
@@ -1065,8 +1129,15 @@ do
|
||||
self:FilterActive( false )
|
||||
|
||||
return self
|
||||
|
||||
--- Filter the set once
|
||||
-- @function [parent=#SET_GROUP] FilterOnce
|
||||
-- @param #SET_GROUP self
|
||||
-- @return #SET_GROUP self
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Get a *new* set that only contains alive groups.
|
||||
-- @param #SET_GROUP self
|
||||
-- @return #SET_GROUP Set of alive groups.
|
||||
@@ -1134,7 +1205,7 @@ do
|
||||
if not DontSetCargoBayLimit then
|
||||
-- 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?
|
||||
for UnitID, UnitData in pairs( group:GetUnits() ) do
|
||||
for UnitID, UnitData in pairs( group:GetUnits() or {} ) do
|
||||
if UnitData and UnitData:IsAlive() then
|
||||
UnitData:SetCargoBayWeightLimit()
|
||||
end
|
||||
@@ -1240,7 +1311,26 @@ do
|
||||
|
||||
return self
|
||||
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.
|
||||
-- Possible current coalitions are red, blue and neutral.
|
||||
-- @param #SET_GROUP self
|
||||
@@ -1381,7 +1471,7 @@ do
|
||||
|
||||
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.
|
||||
-- @param #SET_GROUP self
|
||||
-- @param #boolean Active (Optional) Include only active groups to the set.
|
||||
@@ -1406,6 +1496,14 @@ do
|
||||
self.Filter.Active = Active
|
||||
return self
|
||||
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.
|
||||
-- @param #SET_GROUP self
|
||||
@@ -1489,7 +1587,7 @@ do
|
||||
function SET_GROUP:AddInDatabase( Event )
|
||||
self:F3( { Event } )
|
||||
|
||||
if Event.IniObjectCategory == 1 then
|
||||
if Event.IniObjectCategory == Object.Category.UNIT then
|
||||
if not self.Database[Event.IniDCSGroupName] then
|
||||
self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName )
|
||||
self:T3( self.Database[Event.IniDCSGroupName] )
|
||||
@@ -1904,7 +2002,16 @@ do
|
||||
function SET_GROUP:IsIncludeObject( MGroup )
|
||||
self:F2( MGroup )
|
||||
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
|
||||
local MGroupActive = false
|
||||
self:F( { Active = self.Filter.Active } )
|
||||
@@ -1914,7 +2021,7 @@ do
|
||||
MGroupInclude = MGroupInclude and MGroupActive
|
||||
end
|
||||
|
||||
if self.Filter.Coalitions then
|
||||
if self.Filter.Coalitions and MGroupInclude then
|
||||
local MGroupCoalition = false
|
||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||
self:T3( { "Coalition:", MGroup:GetCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||
@@ -1925,7 +2032,7 @@ do
|
||||
MGroupInclude = MGroupInclude and MGroupCoalition
|
||||
end
|
||||
|
||||
if self.Filter.Categories then
|
||||
if self.Filter.Categories and MGroupInclude then
|
||||
local MGroupCategory = false
|
||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||
self:T3( { "Category:", MGroup:GetCategory(), self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||
@@ -1936,7 +2043,7 @@ do
|
||||
MGroupInclude = MGroupInclude and MGroupCategory
|
||||
end
|
||||
|
||||
if self.Filter.Countries then
|
||||
if self.Filter.Countries and MGroupInclude then
|
||||
local MGroupCountry = false
|
||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||
self:T3( { "Country:", MGroup:GetCountry(), CountryName } )
|
||||
@@ -1947,7 +2054,7 @@ do
|
||||
MGroupInclude = MGroupInclude and MGroupCountry
|
||||
end
|
||||
|
||||
if self.Filter.GroupPrefixes then
|
||||
if self.Filter.GroupPrefixes and MGroupInclude then
|
||||
local MGroupPrefix = false
|
||||
for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do
|
||||
self:T3( { "Prefix:", string.find( MGroup:GetName(), GroupPrefix, 1 ), GroupPrefix } )
|
||||
@@ -1958,7 +2065,7 @@ do
|
||||
MGroupInclude = MGroupInclude and MGroupPrefix
|
||||
end
|
||||
|
||||
if self.Filter.Zones then
|
||||
if self.Filter.Zones and MGroupInclude then
|
||||
local MGroupZone = false
|
||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||
--self:T( "Zone:", ZoneName )
|
||||
@@ -1968,6 +2075,12 @@ do
|
||||
end
|
||||
MGroupInclude = MGroupInclude and MGroupZone
|
||||
end
|
||||
|
||||
if self.Filter.Functions and MGroupInclude then
|
||||
local MGroupFunc = false
|
||||
MGroupFunc = self:_EvalFilterFunctions(MGroup)
|
||||
MGroupInclude = MGroupInclude and MGroupFunc
|
||||
end
|
||||
|
||||
self:T2( MGroupInclude )
|
||||
return MGroupInclude
|
||||
@@ -1976,6 +2089,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.
|
||||
-- @param #SET_GROUP self
|
||||
-- @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 #number Distance in meters to the closest group.
|
||||
function SET_GROUP:GetClosestGroup(Coordinate, Coalitions)
|
||||
@@ -2066,6 +2180,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)
|
||||
-- * @{#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.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:
|
||||
--
|
||||
@@ -2144,6 +2259,7 @@ do -- SET_UNIT
|
||||
Countries = nil,
|
||||
UnitPrefixes = nil,
|
||||
Zones = nil,
|
||||
Functions = nil,
|
||||
},
|
||||
FilterMeta = {
|
||||
Coalitions = {
|
||||
@@ -2425,6 +2541,26 @@ do -- SET_UNIT
|
||||
return CountU
|
||||
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
|
||||
-- @param #SET_UNIT self
|
||||
-- @return #SET_UNIT self
|
||||
@@ -2495,6 +2631,25 @@ do -- SET_UNIT
|
||||
return self
|
||||
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.
|
||||
-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event!
|
||||
-- @param #SET_UNIT self
|
||||
@@ -2504,7 +2659,7 @@ do -- SET_UNIT
|
||||
function SET_UNIT:AddInDatabase( Event )
|
||||
self:F3( { Event } )
|
||||
|
||||
if Event.IniObjectCategory == 1 then
|
||||
if Event.IniObjectCategory == Object.Category.UNIT then
|
||||
if not self.Database[Event.IniDCSUnitName] then
|
||||
self.Database[Event.IniDCSUnitName] = UNIT:Register( Event.IniDCSUnitName )
|
||||
self:T3( self.Database[Event.IniDCSUnitName] )
|
||||
@@ -2819,53 +2974,51 @@ do -- SET_UNIT
|
||||
-- @param #SET_UNIT self
|
||||
-- @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()
|
||||
|
||||
local Coordinate = self:GetRandom():GetCoordinate()
|
||||
--self:F({Coordinate:GetVec3()})
|
||||
|
||||
|
||||
local x1 = Coordinate.x
|
||||
local x2 = Coordinate.x
|
||||
local y1 = Coordinate.y
|
||||
local y2 = Coordinate.y
|
||||
local z1 = Coordinate.z
|
||||
local z2 = Coordinate.z
|
||||
local MaxVelocity = 0
|
||||
local AvgHeading = nil
|
||||
local MovingCount = 0
|
||||
|
||||
for UnitName, UnitData in pairs( self:GetSet() ) do
|
||||
|
||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||
local Coordinate = Unit:GetCoordinate()
|
||||
|
||||
x1 = (Coordinate.x < x1) and Coordinate.x or x1
|
||||
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
|
||||
local function GetSetVec3(units)
|
||||
-- Init.
|
||||
local x=0
|
||||
local y=0
|
||||
local z=0
|
||||
local n=0
|
||||
-- Loop over all units.
|
||||
for _,unit in pairs(units) do
|
||||
local vec3=nil --DCS#Vec3
|
||||
if unit and unit:IsAlive() then
|
||||
vec3 = unit:GetVec3()
|
||||
end
|
||||
if vec3 then
|
||||
-- Sum up posits.
|
||||
x=x+vec3.x
|
||||
y=y+vec3.y
|
||||
z=z+vec3.z
|
||||
-- Increase counter.
|
||||
n=n+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
|
||||
|
||||
local Coordinate = nil
|
||||
local Vec3 = GetSetVec3(self.Set)
|
||||
if Vec3 then
|
||||
Coordinate = COORDINATE:NewFromVec3(Vec3)
|
||||
end
|
||||
|
||||
AvgHeading = AvgHeading and (AvgHeading / MovingCount)
|
||||
if Coordinate then
|
||||
local heading = self:GetHeading() or 0
|
||||
local velocity = self:GetVelocity() or 0
|
||||
Coordinate:SetHeading( heading )
|
||||
Coordinate:SetVelocity( velocity )
|
||||
self:T(UTILS.PrintTableToLog(Coordinate))
|
||||
end
|
||||
|
||||
Coordinate.x = (x2 - x1) / 2 + x1
|
||||
Coordinate.y = (y2 - y1) / 2 + y1
|
||||
Coordinate.z = (z2 - z1) / 2 + z1
|
||||
Coordinate:SetHeading( AvgHeading )
|
||||
Coordinate:SetVelocity( MaxVelocity )
|
||||
|
||||
self:F( { Coordinate = Coordinate } )
|
||||
return Coordinate
|
||||
|
||||
end
|
||||
|
||||
--- Get the maximum velocity of the SET_UNIT.
|
||||
@@ -3074,7 +3227,7 @@ do -- SET_UNIT
|
||||
MUnitInclude = MUnitInclude and MUnitActive
|
||||
end
|
||||
|
||||
if self.Filter.Coalitions then
|
||||
if self.Filter.Coalitions and MUnitInclude then
|
||||
local MUnitCoalition = false
|
||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||
self:F( { "Coalition:", MUnit:GetCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||
@@ -3085,7 +3238,7 @@ do -- SET_UNIT
|
||||
MUnitInclude = MUnitInclude and MUnitCoalition
|
||||
end
|
||||
|
||||
if self.Filter.Categories then
|
||||
if self.Filter.Categories and MUnitInclude then
|
||||
local MUnitCategory = false
|
||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||
self:T3( { "Category:", MUnit:GetDesc().category, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||
@@ -3096,7 +3249,7 @@ do -- SET_UNIT
|
||||
MUnitInclude = MUnitInclude and MUnitCategory
|
||||
end
|
||||
|
||||
if self.Filter.Types then
|
||||
if self.Filter.Types and MUnitInclude then
|
||||
local MUnitType = false
|
||||
for TypeID, TypeName in pairs( self.Filter.Types ) do
|
||||
self:T3( { "Type:", MUnit:GetTypeName(), TypeName } )
|
||||
@@ -3107,7 +3260,7 @@ do -- SET_UNIT
|
||||
MUnitInclude = MUnitInclude and MUnitType
|
||||
end
|
||||
|
||||
if self.Filter.Countries then
|
||||
if self.Filter.Countries and MUnitInclude then
|
||||
local MUnitCountry = false
|
||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||
self:T3( { "Country:", MUnit:GetCountry(), CountryName } )
|
||||
@@ -3118,7 +3271,7 @@ do -- SET_UNIT
|
||||
MUnitInclude = MUnitInclude and MUnitCountry
|
||||
end
|
||||
|
||||
if self.Filter.UnitPrefixes then
|
||||
if self.Filter.UnitPrefixes and MUnitInclude then
|
||||
local MUnitPrefix = false
|
||||
for UnitPrefixId, UnitPrefix in pairs( self.Filter.UnitPrefixes ) do
|
||||
self:T3( { "Prefix:", string.find( MUnit:GetName(), UnitPrefix, 1 ), UnitPrefix } )
|
||||
@@ -3129,7 +3282,7 @@ do -- SET_UNIT
|
||||
MUnitInclude = MUnitInclude and MUnitPrefix
|
||||
end
|
||||
|
||||
if self.Filter.RadarTypes then
|
||||
if self.Filter.RadarTypes and MUnitInclude then
|
||||
local MUnitRadar = false
|
||||
for RadarTypeID, RadarType in pairs( self.Filter.RadarTypes ) do
|
||||
self:T3( { "Radar:", RadarType } )
|
||||
@@ -3143,7 +3296,7 @@ do -- SET_UNIT
|
||||
MUnitInclude = MUnitInclude and MUnitRadar
|
||||
end
|
||||
|
||||
if self.Filter.SEAD then
|
||||
if self.Filter.SEAD and MUnitInclude then
|
||||
local MUnitSEAD = false
|
||||
if MUnit:HasSEAD() == true then
|
||||
self:T3( "SEAD Found" )
|
||||
@@ -3153,7 +3306,7 @@ do -- SET_UNIT
|
||||
end
|
||||
end
|
||||
|
||||
if self.Filter.Zones then
|
||||
if self.Filter.Zones and MUnitInclude then
|
||||
local MGroupZone = false
|
||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||
self:T3( "Zone:", ZoneName )
|
||||
@@ -3164,6 +3317,11 @@ do -- SET_UNIT
|
||||
MUnitInclude = MUnitInclude and MGroupZone
|
||||
end
|
||||
|
||||
if self.Filter.Functions and MUnitInclude then
|
||||
local MUnitFunc = self:_EvalFilterFunctions(MUnit)
|
||||
MUnitInclude = MUnitInclude and MUnitFunc
|
||||
end
|
||||
|
||||
self:T2( MUnitInclude )
|
||||
return MUnitInclude
|
||||
end
|
||||
@@ -3245,6 +3403,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.
|
||||
-- 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.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:
|
||||
--
|
||||
@@ -3447,7 +3606,25 @@ do -- SET_STATIC
|
||||
end
|
||||
return self
|
||||
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.
|
||||
-- Possible current countries are those known within DCS world.
|
||||
-- @param #SET_STATIC self
|
||||
@@ -4004,6 +4181,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)
|
||||
-- * @{#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.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:
|
||||
--
|
||||
@@ -4317,6 +4495,8 @@ do -- SET_CLIENT
|
||||
self:UnHandleEvent(EVENTS.Birth)
|
||||
self:UnHandleEvent(EVENTS.Dead)
|
||||
self:UnHandleEvent(EVENTS.Crash)
|
||||
--self:UnHandleEvent(EVENTS.PlayerEnterUnit)
|
||||
--self:UnHandleEvent(EVENTS.PlayerLeaveUnit)
|
||||
|
||||
if self.Filter.Zones and self.ZoneTimer and self.ZoneTimer:IsRunning() then
|
||||
self.ZoneTimer:Stop()
|
||||
@@ -4335,6 +4515,9 @@ do -- SET_CLIENT
|
||||
self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
|
||||
self:HandleEvent( EVENTS.Dead, 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
|
||||
self.ZoneTimer = TIMER:New(self._ContinousZoneFilter,self)
|
||||
local timing = self.ZoneTimerInterval or 30
|
||||
@@ -4345,6 +4528,43 @@ do -- SET_CLIENT
|
||||
|
||||
return self
|
||||
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.
|
||||
-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event!
|
||||
@@ -4464,6 +4684,25 @@ do -- SET_CLIENT
|
||||
return AliveSet.Set or {}
|
||||
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 Wrapper.Client#CLIENT MClient
|
||||
@@ -4485,7 +4724,7 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientActive
|
||||
end
|
||||
|
||||
if self.Filter.Coalitions then
|
||||
if self.Filter.Coalitions and MClientInclude then
|
||||
local MClientCoalition = false
|
||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||
local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName )
|
||||
@@ -4498,7 +4737,7 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientCoalition
|
||||
end
|
||||
|
||||
if self.Filter.Categories then
|
||||
if self.Filter.Categories and MClientInclude then
|
||||
local MClientCategory = false
|
||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||
local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName )
|
||||
@@ -4511,7 +4750,7 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientCategory
|
||||
end
|
||||
|
||||
if self.Filter.Types then
|
||||
if self.Filter.Types and MClientInclude then
|
||||
local MClientType = false
|
||||
for TypeID, TypeName in pairs( self.Filter.Types ) do
|
||||
self:T3( { "Type:", MClient:GetTypeName(), TypeName } )
|
||||
@@ -4523,7 +4762,7 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientType
|
||||
end
|
||||
|
||||
if self.Filter.Countries then
|
||||
if self.Filter.Countries and MClientInclude then
|
||||
local MClientCountry = false
|
||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||
local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName )
|
||||
@@ -4536,7 +4775,7 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientCountry
|
||||
end
|
||||
|
||||
if self.Filter.ClientPrefixes then
|
||||
if self.Filter.ClientPrefixes and MClientInclude then
|
||||
local MClientPrefix = false
|
||||
for ClientPrefixId, ClientPrefix in pairs( self.Filter.ClientPrefixes ) do
|
||||
self:T3( { "Prefix:", string.find( MClient.UnitName, ClientPrefix, 1 ), ClientPrefix } )
|
||||
@@ -4548,7 +4787,7 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientPrefix
|
||||
end
|
||||
|
||||
if self.Filter.Zones then
|
||||
if self.Filter.Zones and MClientInclude then
|
||||
local MClientZone = false
|
||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||
self:T3( "Zone:", ZoneName )
|
||||
@@ -4560,7 +4799,7 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientZone
|
||||
end
|
||||
|
||||
if self.Filter.Playernames then
|
||||
if self.Filter.Playernames and MClientInclude then
|
||||
local MClientPlayername = false
|
||||
local playername = MClient:GetPlayerName() or "Unknown"
|
||||
--self:T(playername)
|
||||
@@ -4573,7 +4812,7 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientPlayername
|
||||
end
|
||||
|
||||
if self.Filter.Callsigns then
|
||||
if self.Filter.Callsigns and MClientInclude then
|
||||
local MClientCallsigns = false
|
||||
local callsign = MClient:GetCallsign()
|
||||
--self:I(callsign)
|
||||
@@ -4586,6 +4825,11 @@ do -- SET_CLIENT
|
||||
MClientInclude = MClientInclude and MClientCallsigns
|
||||
end
|
||||
|
||||
if self.Filter.Functions and MClientInclude then
|
||||
local MClientFunc = self:_EvalFilterFunctions(MClient)
|
||||
MClientInclude = MClientInclude and MClientFunc
|
||||
end
|
||||
|
||||
end
|
||||
self:T2( MClientInclude )
|
||||
return MClientInclude
|
||||
@@ -5179,7 +5423,7 @@ do -- SET_AIRBASE
|
||||
function SET_AIRBASE:GetRandomAirbase()
|
||||
|
||||
local RandomAirbase = self:GetRandom()
|
||||
self:F( { RandomAirbase = RandomAirbase:GetName() } )
|
||||
--self:F( { RandomAirbase = RandomAirbase:GetName() } )
|
||||
|
||||
return RandomAirbase
|
||||
end
|
||||
@@ -5345,7 +5589,7 @@ do -- SET_AIRBASE
|
||||
MAirbaseInclude = MAirbaseInclude and MAirbaseCoalition
|
||||
end
|
||||
|
||||
if self.Filter.Categories then
|
||||
if self.Filter.Categories and MAirbaseInclude then
|
||||
local MAirbaseCategory = false
|
||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||
local AirbaseCategoryID = _DATABASE:GetCategoryFromAirbase( MAirbaseName )
|
||||
@@ -7611,6 +7855,28 @@ do -- SET_OPSGROUP
|
||||
return self
|
||||
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.
|
||||
-- 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
|
||||
@@ -7631,12 +7897,12 @@ do -- SET_OPSGROUP
|
||||
--- 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!
|
||||
-- @param #SET_OPSGROUP self
|
||||
-- @param Core.Event#EVENTDATA Event
|
||||
-- @return #string The name of the GROUP
|
||||
-- @return #table The GROUP
|
||||
-- @param Core.Event#EVENTDATA Event Event data.
|
||||
-- @return #string The name of the GROUP.
|
||||
-- @return Wrapper.Group#GROUP The GROUP object.
|
||||
function SET_OPSGROUP:AddInDatabase( Event )
|
||||
|
||||
if Event.IniObjectCategory==1 then
|
||||
if Event.IniObjectCategory==Object.Category.UNIT then
|
||||
|
||||
if not self.Database[Event.IniDCSGroupName] then
|
||||
self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName )
|
||||
@@ -7651,8 +7917,8 @@ do -- SET_OPSGROUP
|
||||
-- This is required, because sometimes the _DATABASE event gets called later than the SET_BASE event or vise versa!
|
||||
-- @param #SET_OPSGROUP self
|
||||
-- @param Core.Event#EVENTDATA Event Event data table.
|
||||
-- @return #string The name of the GROUP
|
||||
-- @return #table The GROUP
|
||||
-- @return #string The name of the GROUP.
|
||||
-- @return Wrapper.Group#GROUP The GROUP object.
|
||||
function SET_OPSGROUP:FindInDatabase(Event)
|
||||
return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName]
|
||||
end
|
||||
@@ -7691,7 +7957,7 @@ do -- SET_OPSGROUP
|
||||
end
|
||||
|
||||
-- Filter coalitions.
|
||||
if self.Filter.Coalitions then
|
||||
if self.Filter.Coalitions and MGroupInclude then
|
||||
|
||||
local MGroupCoalition = false
|
||||
|
||||
@@ -7705,7 +7971,7 @@ do -- SET_OPSGROUP
|
||||
end
|
||||
|
||||
-- Filter categories.
|
||||
if self.Filter.Categories then
|
||||
if self.Filter.Categories and MGroupInclude then
|
||||
|
||||
local MGroupCategory = false
|
||||
|
||||
@@ -7719,7 +7985,7 @@ do -- SET_OPSGROUP
|
||||
end
|
||||
|
||||
-- Filter countries.
|
||||
if self.Filter.Countries then
|
||||
if self.Filter.Countries and MGroupInclude then
|
||||
local MGroupCountry = false
|
||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||
if country.id[CountryName] == MGroup:GetCountry() then
|
||||
@@ -7730,12 +7996,12 @@ do -- SET_OPSGROUP
|
||||
end
|
||||
|
||||
-- Filter "prefixes".
|
||||
if self.Filter.GroupPrefixes then
|
||||
if self.Filter.GroupPrefixes and MGroupInclude then
|
||||
|
||||
local MGroupPrefix = false
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -7971,7 +8237,7 @@ do -- SET_SCENERY
|
||||
end
|
||||
|
||||
--- Get a table of alive objects.
|
||||
-- @param #SET_GROUP self
|
||||
-- @param #SET_SCENERY self
|
||||
-- @return #table Table of alive objects
|
||||
-- @return Core.Set#SET_SCENERY SET of alive objects
|
||||
function SET_SCENERY:GetAliveSet()
|
||||
@@ -8006,9 +8272,15 @@ do -- SET_SCENERY
|
||||
-- @param #SET_SCENERY self
|
||||
-- @return Core.Point#COORDINATE The center coordinate of all the objects in the set.
|
||||
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 x2 = Coordinate.x
|
||||
local y1 = Coordinate.y
|
||||
@@ -8145,7 +8417,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.
|
||||
-- **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.
|
||||
-- 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
|
||||
-- @return #number LifePoints
|
||||
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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -199,6 +199,22 @@
|
||||
--
|
||||
-- * @{#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.
|
||||
--
|
||||
-- ### 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
|
||||
--
|
||||
@@ -320,7 +336,7 @@ function SPAWN:New( SpawnTemplatePrefix )
|
||||
self.AIOnOff = true -- The AI is on by default when spawning a group.
|
||||
self.SpawnUnControlled = false
|
||||
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.SpawnInitLivery = nil -- No special livery.
|
||||
self.SpawnInitSkill = nil -- No special skill.
|
||||
@@ -332,6 +348,7 @@ function SPAWN:New( SpawnTemplatePrefix )
|
||||
self.SpawnInitModexPostfix = nil
|
||||
self.SpawnInitAirbase = nil
|
||||
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.
|
||||
else
|
||||
@@ -519,7 +536,7 @@ function SPAWN:NewFromTemplate( SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPr
|
||||
end
|
||||
|
||||
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.SpawnAliasPrefix = SpawnAliasPrefix or SpawnTemplatePrefix
|
||||
self.SpawnTemplate.name = SpawnTemplatePrefix
|
||||
@@ -723,7 +740,7 @@ end
|
||||
-- @param #number Country Country id as number or enumerator:
|
||||
--
|
||||
-- * @{DCS#country.id.RUSSIA}
|
||||
-- * @{DCS#county.id.USA}
|
||||
-- * @{DCS#country.id.USA}
|
||||
--
|
||||
-- @return #SPAWN self
|
||||
function SPAWN:InitCountry( Country )
|
||||
@@ -779,6 +796,82 @@ function SPAWN:InitSkill( Skill )
|
||||
return self
|
||||
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.
|
||||
-- @param #SPAWN self
|
||||
-- @param #number switch If true (or nil), enables the radio communication. If false, disables the radio for the spawned group.
|
||||
@@ -1099,6 +1192,30 @@ function SPAWN:InitRandomizeZones( SpawnZoneTable )
|
||||
return self
|
||||
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)
|
||||
self.SpawnInitCallSign = true
|
||||
self.SpawnInitCallSignID = ID or 1
|
||||
self.SpawnInitCallSignMinor = Minor or 1
|
||||
self.SpawnInitCallSignMajor = Major or 1
|
||||
self.SpawnInitCallSignName = string.lower(Name) or "enfield"
|
||||
return self
|
||||
end
|
||||
|
||||
--- This method sets a spawn position for the group that is different from the location of the template.
|
||||
-- @param #SPAWN self
|
||||
-- @param Core.Point#COORDINATE Coordinate The position to spawn from
|
||||
@@ -1433,6 +1550,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
||||
else
|
||||
|
||||
local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate
|
||||
local SpawnZone = self.SpawnGroups[self.SpawnIndex].SpawnZone
|
||||
self:T( SpawnTemplate.name )
|
||||
|
||||
if SpawnTemplate then
|
||||
@@ -1458,6 +1576,23 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
||||
if self.SpawnRandomizeUnits then
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
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].y = RandomVec2.y
|
||||
self:T( 'SpawnTemplate.units[' .. UnitID .. '].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units[' .. UnitID .. '].y = ' .. SpawnTemplate.units[UnitID].y )
|
||||
@@ -1509,12 +1644,14 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
||||
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
|
||||
if UnitID > 1 then -- don't rotate position of unit #1
|
||||
local unitXOff = SpawnTemplate.units[UnitID].x - pivotX -- rotate position offset around unit #1
|
||||
local unitYOff = SpawnTemplate.units[UnitID].y - pivotY
|
||||
if not self.SpawnRandomizeUnits then
|
||||
if UnitID > 1 then -- don't rotate position of unit #1
|
||||
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].y = pivotY + (unitYOff * cosHeading) + (unitXOff * sinHeading)
|
||||
SpawnTemplate.units[UnitID].x = pivotX + (unitXOff * cosHeading) - (unitYOff * sinHeading)
|
||||
SpawnTemplate.units[UnitID].y = pivotY + (unitYOff * cosHeading) + (unitXOff * sinHeading)
|
||||
end
|
||||
end
|
||||
|
||||
-- adjust heading of all units, including unit #1
|
||||
@@ -1644,8 +1781,8 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
||||
|
||||
-- If there is a SpawnFunction hook defined, call it.
|
||||
if self.SpawnFunctionHook then
|
||||
-- delay calling this for .1 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 )
|
||||
-- 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.3 )
|
||||
end
|
||||
-- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats.
|
||||
-- if self.Repeat then
|
||||
@@ -1654,6 +1791,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
||||
end
|
||||
|
||||
self.SpawnGroups[self.SpawnIndex].Spawned = true
|
||||
self.SpawnGroups[self.SpawnIndex].Group.TemplateDonor = self.SpawnTemplatePrefix
|
||||
return self.SpawnGroups[self.SpawnIndex].Group
|
||||
else
|
||||
-- self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
|
||||
@@ -2783,7 +2921,7 @@ end
|
||||
-- @return Wrapper.Group#GROUP that was spawned or #nil if nothing was spawned.
|
||||
-- @usage
|
||||
--
|
||||
-- local SpawnPointVec2 = ZONE:New( ZoneName ):GetPointVec2()
|
||||
-- local SpawnPointVec2 = ZONE:New( ZoneName ):GetPointVec2()
|
||||
--
|
||||
-- -- Spawn at the zone center position at the height specified in the ME of the group template!
|
||||
-- SpawnAirplanes:SpawnFromPointVec2( SpawnPointVec2 )
|
||||
@@ -3258,7 +3396,7 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if self.SpawnInitKeepUnitNames == false then
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
|
||||
@@ -3266,31 +3404,197 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
||||
end
|
||||
else
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
local UnitPrefix, Rest = string.match( SpawnTemplate.units[UnitID].name, "^([^#]+)#?" ):gsub( "^%s*(.-)%s*$", "%1" )
|
||||
self:T( { UnitPrefix, Rest } )
|
||||
|
||||
local SpawnInitKeepUnitIFF = false
|
||||
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" )
|
||||
self:T( { UnitPrefix, Rest } )
|
||||
else
|
||||
UnitPrefix=SpawnTemplate.units[UnitID].name
|
||||
end
|
||||
SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
||||
SpawnTemplate.units[UnitID].unitId = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Callsign
|
||||
|
||||
if self.SpawnRandomCallsign and SpawnTemplate.units[1].callsign then
|
||||
if type( SpawnTemplate.units[1].callsign ) ~= "number" then
|
||||
-- change callsign
|
||||
local min = 1
|
||||
local max = 8
|
||||
local ctable = CALLSIGN.Aircraft
|
||||
if string.find(SpawnTemplate.units[1].type, "A-10",1,true) then
|
||||
max = 12
|
||||
end
|
||||
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
|
||||
|
||||
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" then -- blue callsign
|
||||
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]
|
||||
else
|
||||
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 } )
|
||||
--UTILS.PrintTableToLog(SpawnTemplate,1)
|
||||
return SpawnTemplate
|
||||
|
||||
end
|
||||
@@ -3432,6 +3736,7 @@ function SPAWN:_RandomizeZones( SpawnIndex )
|
||||
self:T( { SpawnVec2 = SpawnVec2 } )
|
||||
|
||||
local SpawnTemplate = self.SpawnGroups[SpawnIndex].SpawnTemplate
|
||||
self.SpawnGroups[SpawnIndex].SpawnZone = SpawnZone
|
||||
|
||||
self:T( { Route = SpawnTemplate.route } )
|
||||
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
--- **Core** - Spawn statics.
|
||||
--
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
--
|
||||
-- ## Features:
|
||||
--
|
||||
--
|
||||
-- * Spawn new statics from a static already defined in the mission editor.
|
||||
-- * Spawn new statics from a given template.
|
||||
-- * Spawn new statics from a given type.
|
||||
-- * Spawn with a custom heading and location.
|
||||
-- * Spawn within a zone.
|
||||
-- * Spawn statics linked to units, .e.g on aircraft carriers.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # Demo Missions
|
||||
--
|
||||
-- ## [SPAWNSTATIC Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SPS%20-%20Spawning%20Statics)
|
||||
--
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
--
|
||||
-- # Demo Missions
|
||||
--
|
||||
-- ## [SPAWNSTATIC Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Core/SpawnStatic)
|
||||
--
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # YouTube Channel
|
||||
--
|
||||
-- ## [SPAWNSTATIC YouTube Channel]() [No videos yet!]
|
||||
--
|
||||
--
|
||||
-- ## No videos yet!
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
--
|
||||
-- ### Author: **FlightControl**
|
||||
-- ### Contributions: **funkyfranky**
|
||||
--
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
--
|
||||
-- @module Core.SpawnStatic
|
||||
-- @image Core_Spawnstatic.JPG
|
||||
|
||||
@@ -58,37 +58,37 @@
|
||||
|
||||
|
||||
--- Allows to spawn dynamically new @{Wrapper.Static}s into your mission.
|
||||
--
|
||||
-- Through creating a copy of an existing static object template as defined in the Mission Editor (ME), SPAWNSTATIC can retireve the properties of the defined static object template (like type, category etc),
|
||||
--
|
||||
-- Through creating a copy of an existing static object template as defined in the Mission Editor (ME), SPAWNSTATIC can retireve the properties of the defined static object template (like type, category etc),
|
||||
-- and "copy" these properties to create a new static object and place it at the desired coordinate.
|
||||
--
|
||||
-- New spawned @{Wrapper.Static}s get **the same name** as the name of the template Static, or gets the given name when a new name is provided at the Spawn method.
|
||||
--
|
||||
-- New spawned @{Wrapper.Static}s get **the same name** as the name of the template Static, or gets the given name when a new name is provided at the Spawn method.
|
||||
-- By default, spawned @{Wrapper.Static}s will follow a naming convention at run-time:
|
||||
--
|
||||
--
|
||||
-- * Spawned @{Wrapper.Static}s will have the name _StaticName_#_nnn_, where _StaticName_ is the name of the **Template Static**, and _nnn_ is a **counter from 0 to 99999**.
|
||||
--
|
||||
--
|
||||
-- # SPAWNSTATIC Constructors
|
||||
--
|
||||
--
|
||||
-- Firstly, we need to create a SPAWNSTATIC object that will be used to spawn new statics into the mission. There are three ways to do this.
|
||||
--
|
||||
--
|
||||
-- ## Use another Static
|
||||
--
|
||||
--
|
||||
-- A new SPAWNSTATIC object can be created using another static by the @{#SPAWNSTATIC.NewFromStatic}() function. All parameters such as position, heading, country will be initialized
|
||||
-- from the static.
|
||||
--
|
||||
--
|
||||
-- ## From a Template
|
||||
--
|
||||
--
|
||||
-- A SPAWNSTATIC object can also be created from a template table using the @{#SPAWNSTATIC.NewFromTemplate}(SpawnTemplate, CountryID) function. All parameters are taken from the template.
|
||||
--
|
||||
--
|
||||
-- ## From a Type
|
||||
--
|
||||
--
|
||||
-- A very basic method is to create a SPAWNSTATIC object by just giving the type of the static. All parameters must be initialized from the InitXYZ functions described below. Otherwise default values
|
||||
-- are used. For example, if no spawn coordinate is given, the static will be created at the origin of the map.
|
||||
--
|
||||
--
|
||||
-- # Setting Parameters
|
||||
--
|
||||
--
|
||||
-- Parameters such as the spawn position, heading, country etc. can be set via :Init*XYZ* functions. Note that these functions must be given before the actual spawn command!
|
||||
--
|
||||
--
|
||||
-- * @{#SPAWNSTATIC.InitCoordinate}(Coordinate) Sets the coordinate where the static is spawned. Statics are always spawnd on the ground.
|
||||
-- * @{#SPAWNSTATIC.InitHeading}(Heading) sets the orientation of the static.
|
||||
-- * @{#SPAWNSTATIC.InitLivery}(LiveryName) sets the livery of the static. Not all statics support this.
|
||||
@@ -99,17 +99,17 @@
|
||||
-- * @{#SPAWNSTATIC.InitLinkToUnit}(Unit, OffsetX, OffsetY, OffsetAngle) links the static to a unit, e.g. to an aircraft carrier.
|
||||
--
|
||||
-- # Spawning the Statics
|
||||
--
|
||||
--
|
||||
-- Once the SPAWNSTATIC object is created and parameters are initialized, the spawn command can be given. There are different methods where some can be used to directly set parameters
|
||||
-- such as position and heading.
|
||||
--
|
||||
--
|
||||
-- * @{#SPAWNSTATIC.Spawn}(Heading, NewName) spawns the static with the set parameters. Optionally, heading and name can be given. The name **must be unique**!
|
||||
-- * @{#SPAWNSTATIC.SpawnFromCoordinate}(Coordinate, Heading, NewName) spawn the static at the given coordinate. Optionally, heading and name can be given. The name **must be unique**!
|
||||
-- * @{#SPAWNSTATIC.SpawnFromPointVec2}(PointVec2, Heading, NewName) spawns the static at a POINT_VEC2 coordinate. Optionally, heading and name can be given. The name **must be unique**!
|
||||
-- * @{#SPAWNSTATIC.SpawnFromZone}(Zone, Heading, NewName) spawns the static at the center of a @{Core.Zone}. Optionally, heading and name can be given. The name **must be unique**!
|
||||
--
|
||||
--
|
||||
-- @field #SPAWNSTATIC SPAWNSTATIC
|
||||
--
|
||||
--
|
||||
SPAWNSTATIC = {
|
||||
ClassName = "SPAWNSTATIC",
|
||||
SpawnIndex = 0,
|
||||
@@ -139,9 +139,9 @@ SPAWNSTATIC = {
|
||||
function SPAWNSTATIC:NewFromStatic(SpawnTemplateName, SpawnCountryID)
|
||||
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- #SPAWNSTATIC
|
||||
|
||||
|
||||
local TemplateStatic, CoalitionID, CategoryID, CountryID = _DATABASE:GetStaticGroupTemplate(SpawnTemplateName)
|
||||
|
||||
|
||||
if TemplateStatic then
|
||||
self.SpawnTemplatePrefix = SpawnTemplateName
|
||||
self.TemplateStaticUnit = UTILS.DeepCopy(TemplateStatic.units[1])
|
||||
@@ -166,11 +166,11 @@ end
|
||||
function SPAWNSTATIC:NewFromTemplate(SpawnTemplate, CountryID)
|
||||
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- #SPAWNSTATIC
|
||||
|
||||
|
||||
self.TemplateStaticUnit = UTILS.DeepCopy(SpawnTemplate)
|
||||
self.SpawnTemplatePrefix = SpawnTemplate.name
|
||||
self.CountryID = CountryID or country.id.USA
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -189,7 +189,7 @@ function SPAWNSTATIC:NewFromType(StaticType, StaticCategory, CountryID)
|
||||
self.InitStaticCategory=StaticCategory
|
||||
self.CountryID=CountryID or country.id.USA
|
||||
self.SpawnTemplatePrefix=self.InitStaticType
|
||||
|
||||
|
||||
self.InitStaticCoordinate=COORDINATE:New(0, 0, 0)
|
||||
self.InitStaticHeading=0
|
||||
|
||||
@@ -291,7 +291,7 @@ function SPAWNSTATIC:InitCountry(CountryID)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Initialize name prefix statics get. This will be appended by "#0001", "#0002" etc.
|
||||
--- Initialize name prefix statics get. This will be appended by "#0001", "#0002" etc.
|
||||
-- @param #SPAWNSTATIC self
|
||||
-- @param #string NamePrefix Name prefix of statics spawned. Will append #0001, etc to the name.
|
||||
-- @return #SPAWNSTATIC self
|
||||
@@ -327,13 +327,13 @@ function SPAWNSTATIC:Spawn(Heading, NewName)
|
||||
if Heading then
|
||||
self.InitStaticHeading=Heading
|
||||
end
|
||||
|
||||
|
||||
if NewName then
|
||||
self.InitStaticName=NewName
|
||||
end
|
||||
|
||||
return self:_SpawnStatic(self.TemplateStaticUnit, self.CountryID)
|
||||
|
||||
|
||||
end
|
||||
|
||||
--- Creates a new @{Wrapper.Static} from a POINT_VEC2.
|
||||
@@ -347,7 +347,7 @@ function SPAWNSTATIC:SpawnFromPointVec2(PointVec2, Heading, NewName)
|
||||
local vec2={x=PointVec2:GetX(), y=PointVec2:GetY()}
|
||||
|
||||
local Coordinate=COORDINATE:NewFromVec2(vec2)
|
||||
|
||||
|
||||
return self:SpawnFromCoordinate(Coordinate, Heading, NewName)
|
||||
end
|
||||
|
||||
@@ -362,11 +362,11 @@ function SPAWNSTATIC:SpawnFromCoordinate(Coordinate, Heading, NewName)
|
||||
|
||||
-- Set up coordinate.
|
||||
self.InitStaticCoordinate=Coordinate
|
||||
|
||||
|
||||
if Heading then
|
||||
self.InitStaticHeading=Heading
|
||||
end
|
||||
|
||||
|
||||
if NewName then
|
||||
self.InitStaticName=NewName
|
||||
end
|
||||
@@ -385,7 +385,7 @@ function SPAWNSTATIC:SpawnFromZone(Zone, Heading, NewName)
|
||||
|
||||
-- Spawn the new static at the center of the zone.
|
||||
local Static = self:SpawnFromPointVec2( Zone:GetPointVec2(), Heading, NewName )
|
||||
|
||||
|
||||
return Static
|
||||
end
|
||||
|
||||
@@ -399,45 +399,45 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID)
|
||||
Template=Template or {}
|
||||
|
||||
local CountryID=CountryID or self.CountryID
|
||||
|
||||
|
||||
if self.InitStaticType then
|
||||
Template.type=self.InitStaticType
|
||||
end
|
||||
|
||||
|
||||
if self.InitStaticCategory then
|
||||
Template.category=self.InitStaticCategory
|
||||
end
|
||||
|
||||
if self.InitStaticCoordinate then
|
||||
Template.x = self.InitStaticCoordinate.x
|
||||
|
||||
if self.InitStaticCoordinate then
|
||||
Template.x = self.InitStaticCoordinate.x
|
||||
Template.y = self.InitStaticCoordinate.z
|
||||
Template.alt = self.InitStaticCoordinate.y
|
||||
Template.alt = self.InitStaticCoordinate.y
|
||||
end
|
||||
|
||||
|
||||
if self.InitStaticHeading then
|
||||
Template.heading = math.rad(self.InitStaticHeading)
|
||||
Template.heading = math.rad(self.InitStaticHeading)
|
||||
end
|
||||
|
||||
if self.InitStaticShape then
|
||||
Template.shape_name=self.InitStaticShape
|
||||
end
|
||||
|
||||
|
||||
if self.InitStaticLivery then
|
||||
Template.livery_id=self.InitStaticLivery
|
||||
end
|
||||
|
||||
|
||||
if self.InitStaticDead~=nil then
|
||||
Template.dead=self.InitStaticDead
|
||||
end
|
||||
|
||||
|
||||
if self.InitStaticCargo~=nil then
|
||||
Template.canCargo=self.InitStaticCargo
|
||||
end
|
||||
|
||||
|
||||
if self.InitStaticCargoMass~=nil then
|
||||
Template.mass=self.InitStaticCargoMass
|
||||
end
|
||||
|
||||
|
||||
if self.InitLinkUnit then
|
||||
Template.linkUnit=self.InitLinkUnit:GetID()
|
||||
Template.linkOffset=true
|
||||
@@ -446,45 +446,45 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID)
|
||||
Template.offsets.x=self.InitOffsetX
|
||||
Template.offsets.angle=self.InitOffsetAngle and math.rad(self.InitOffsetAngle) or 0
|
||||
end
|
||||
|
||||
|
||||
if self.InitFarp then
|
||||
Template.heliport_callsign_id = self.InitFarpCallsignID
|
||||
Template.heliport_frequency = self.InitFarpFreq
|
||||
Template.heliport_modulation = self.InitFarpModu
|
||||
Template.unitId=nil
|
||||
end
|
||||
|
||||
|
||||
-- Increase spawn index counter.
|
||||
self.SpawnIndex = self.SpawnIndex + 1
|
||||
|
||||
|
||||
-- Name of the spawned static.
|
||||
Template.name = self.InitStaticName or string.format("%s#%05d", self.SpawnTemplatePrefix, self.SpawnIndex)
|
||||
|
||||
-- Add and register the new static.
|
||||
local mystatic=_DATABASE:AddStatic(Template.name)
|
||||
|
||||
|
||||
-- Debug output.
|
||||
self:T(Template)
|
||||
|
||||
|
||||
-- Add static to the game.
|
||||
local Static=nil --DCS#StaticObject
|
||||
|
||||
|
||||
if self.InitFarp then
|
||||
|
||||
local TemplateGroup={}
|
||||
|
||||
local TemplateGroup={}
|
||||
TemplateGroup.units={}
|
||||
TemplateGroup.units[1]=Template
|
||||
|
||||
|
||||
TemplateGroup.visible=true
|
||||
TemplateGroup.hidden=false
|
||||
TemplateGroup.x=Template.x
|
||||
TemplateGroup.y=Template.y
|
||||
TemplateGroup.name=Template.name
|
||||
|
||||
self:T("Spawning FARP")
|
||||
self:T("Spawning FARP")
|
||||
self:T({Template=Template})
|
||||
self:T({TemplateGroup=TemplateGroup})
|
||||
|
||||
|
||||
-- ED's dirty way to spawn FARPS.
|
||||
Static=coalition.addGroup(CountryID, -1, TemplateGroup)
|
||||
|
||||
@@ -499,10 +499,10 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID)
|
||||
world.onEvent(Event)
|
||||
|
||||
else
|
||||
self:T("Spawning Static")
|
||||
self:T2({Template=Template})
|
||||
self:T("Spawning Static")
|
||||
self:T2({Template=Template})
|
||||
Static=coalition.addStaticObject(CountryID, Template)
|
||||
end
|
||||
|
||||
|
||||
return mystatic
|
||||
end
|
||||
|
||||
@@ -329,14 +329,14 @@ do
|
||||
if self.Lasing 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:__Lasing(0.2)
|
||||
elseif self.TargetCoord then
|
||||
|
||||
-- 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
|
||||
|
||||
self.SpotIR:setPoint(irvec3)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,9 +16,9 @@
|
||||
-- ===
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/CSR-001%20-%20Basics).
|
||||
--
|
||||
--
|
||||
-- Demo missions can be found on [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Functional/AICSAR).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **Applevangelist**
|
||||
@@ -527,7 +527,7 @@ end
|
||||
--- [User] Switch sound output on and use SRS output for sound files.
|
||||
-- @param #AICSAR self
|
||||
-- @param #boolean OnOff Switch on (true) or off (false).
|
||||
-- @param #string Path Path to your SRS Server Component, e.g. "E:\\\\Program Files\\\\DCS-SimpleRadio-Standalone"
|
||||
-- @param #string Path Path to your SRS Server Component, e.g. "C:\\\\Program Files\\\\DCS-SimpleRadio-Standalone"
|
||||
-- @param #number Frequency Defaults to 243 (guard)
|
||||
-- @param #number Modulation Radio modulation. Defaults to radio.modulation.AM
|
||||
-- @param #string SoundPath Where to find the audio files. Defaults to nil, i.e. add messages via "Sound to..." in the Mission Editor.
|
||||
@@ -538,13 +538,13 @@ function AICSAR:SetSRSRadio(OnOff,Path,Frequency,Modulation,SoundPath,Port)
|
||||
self.SRSRadio = OnOff and true
|
||||
self.SRSTTSRadio = false
|
||||
self.SRSFrequency = Frequency or 243
|
||||
self.SRSPath = Path or "c:\\"
|
||||
self.SRSPath = Path or MSRS.path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
self.SRS:SetLabel("ACSR")
|
||||
self.SRS:SetCoalition(self.coalition)
|
||||
self.SRSModulation = Modulation or radio.modulation.AM
|
||||
local soundpath = os.getenv('TMP') .. "\\DCS\\Mission\\l10n\\DEFAULT" -- defaults to "l10n/DEFAULT/", i.e. add messages by "Sound to..." in the ME
|
||||
self.SRSSoundPath = SoundPath or soundpath
|
||||
self.SRSPort = Port or 5002
|
||||
self.SRSPort = Port or MSRS.port or 5002
|
||||
if OnOff then
|
||||
self.SRS = MSRS:New(Path,Frequency,Modulation)
|
||||
self.SRS:SetPort(self.SRSPort)
|
||||
@@ -570,11 +570,11 @@ function AICSAR:SetSRSTTSRadio(OnOff,Path,Frequency,Modulation,Port,Voice,Cultur
|
||||
self.SRSTTSRadio = OnOff and true
|
||||
self.SRSRadio = false
|
||||
self.SRSFrequency = Frequency or 243
|
||||
self.SRSPath = Path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
self.SRSPath = Path or MSRS.path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
self.SRSModulation = Modulation or radio.modulation.AM
|
||||
self.SRSPort = Port or 5002
|
||||
self.SRSPort = Port or MSRS.port or 5002
|
||||
if OnOff then
|
||||
self.SRS = MSRS:New(Path,Frequency,Modulation,1)
|
||||
self.SRS = MSRS:New(self.SRSPath,Frequency,Modulation)
|
||||
self.SRS:SetPort(self.SRSPort)
|
||||
self.SRS:SetCoalition(self.coalition)
|
||||
self.SRS:SetLabel("ACSR")
|
||||
@@ -582,7 +582,8 @@ function AICSAR:SetSRSTTSRadio(OnOff,Path,Frequency,Modulation,Port,Voice,Cultur
|
||||
self.SRS:SetCulture(Culture)
|
||||
self.SRS:SetGender(Gender)
|
||||
if GoogleCredentials then
|
||||
self.SRS:SetGoogle(GoogleCredentials)
|
||||
self.SRS:SetProviderOptionsGoogle(GoogleCredentials,GoogleCredentials)
|
||||
self.SRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||
self.SRSGoogle = true
|
||||
end
|
||||
self.SRSQ = MSRSQUEUE:New(self.alias)
|
||||
@@ -600,14 +601,16 @@ end
|
||||
function AICSAR:SetPilotTTSVoice(Voice,Culture,Gender)
|
||||
self:T(self.lid .. "SetPilotTTSVoice")
|
||||
self.SRSPilotVoice = true
|
||||
self.SRSPilot = MSRS:New(self.SRSPath,self.SRSFrequency,self.SRSModulation,1)
|
||||
self.SRSPilot = MSRS:New(self.SRSPath,self.SRSFrequency,self.SRSModulation)
|
||||
self.SRSPilot:SetCoalition(self.coalition)
|
||||
self.SRSPilot:SetVoice(Voice)
|
||||
self.SRSPilot:SetCulture(Culture or "en-US")
|
||||
self.SRSPilot:SetGender(Gender or "male")
|
||||
self.SRSPilot:SetLabel("PILOT")
|
||||
if self.SRS.google then
|
||||
self.SRSPilot:SetGoogle(self.SRS.google)
|
||||
if self.SRSGoogle then
|
||||
local poptions = self.SRS:GetProviderOptions(MSRS.Provider.GOOGLE) -- Sound.SRS#MSRS.ProviderOptions
|
||||
self.SRSPilot:SetProviderOptionsGoogle(poptions.credentials,poptions.key)
|
||||
self.SRSPilot:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
return self
|
||||
end
|
||||
@@ -622,14 +625,16 @@ end
|
||||
function AICSAR:SetOperatorTTSVoice(Voice,Culture,Gender)
|
||||
self:T(self.lid .. "SetOperatorTTSVoice")
|
||||
self.SRSOperatorVoice = true
|
||||
self.SRSOperator = MSRS:New(self.SRSPath,self.SRSFrequency,self.SRSModulation,1)
|
||||
self.SRSOperator = MSRS:New(self.SRSPath,self.SRSFrequency,self.SRSModulation)
|
||||
self.SRSOperator:SetCoalition(self.coalition)
|
||||
self.SRSOperator:SetVoice(Voice)
|
||||
self.SRSOperator:SetCulture(Culture or "en-GB")
|
||||
self.SRSOperator:SetGender(Gender or "female")
|
||||
self.SRSPilot:SetLabel("RESCUE")
|
||||
if self.SRS.google then
|
||||
self.SRSOperator:SetGoogle(self.SRS.google)
|
||||
self.SRSOperator:SetLabel("RESCUE")
|
||||
if self.SRSGoogle then
|
||||
local poptions = self.SRS:GetProviderOptions(MSRS.Provider.GOOGLE) -- Sound.SRS#MSRS.ProviderOptions
|
||||
self.SRSOperator:SetProviderOptionsGoogle(poptions.credentials,poptions.key)
|
||||
self.SRSOperator:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Missions:
|
||||
--
|
||||
-- [ABP - Airbase Police](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ABP%20-%20Airbase%20Police)
|
||||
-- ## Missions: None
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -20,13 +18,15 @@
|
||||
-- ### Author: FlightControl - Framework Design & Programming
|
||||
-- ### Refactoring to use the Runway auto-detection: Applevangelist
|
||||
-- @date August 2022
|
||||
-- Last Update Nov 2023
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @module Functional.ATC_Ground
|
||||
-- @image Air_Traffic_Control_Ground_Operations.JPG
|
||||
|
||||
--- @type ATC_GROUND
|
||||
---
|
||||
-- @type ATC_GROUND
|
||||
-- @field Core.Set#SET_CLIENT SetClient
|
||||
-- @extends Core.Base#BASE
|
||||
|
||||
@@ -39,7 +39,8 @@ ATC_GROUND = {
|
||||
AirbaseNames = nil,
|
||||
}
|
||||
|
||||
--- @type ATC_GROUND.AirbaseNames
|
||||
---
|
||||
-- @type ATC_GROUND.AirbaseNames
|
||||
-- @list <#string>
|
||||
|
||||
|
||||
@@ -51,7 +52,7 @@ function ATC_GROUND:New( Airbases, AirbaseList )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- #ATC_GROUND
|
||||
self:E( { self.ClassName, Airbases } )
|
||||
self:T( { self.ClassName, Airbases } )
|
||||
|
||||
self.Airbases = Airbases
|
||||
self.AirbaseList = AirbaseList
|
||||
@@ -82,7 +83,7 @@ function ATC_GROUND:New( Airbases, AirbaseList )
|
||||
end
|
||||
|
||||
self.SetClient:ForEachClient(
|
||||
--- @param Wrapper.Client#CLIENT Client
|
||||
-- @param Wrapper.Client#CLIENT Client
|
||||
function( Client )
|
||||
Client:SetState( self, "Speeding", false )
|
||||
Client:SetState( self, "Warnings", 0)
|
||||
@@ -246,11 +247,11 @@ function ATC_GROUND:SetMaximumKickSpeedMiph( MaximumKickSpeedMiph, Airbase )
|
||||
return self
|
||||
end
|
||||
|
||||
--- @param #ATC_GROUND self
|
||||
-- @param #ATC_GROUND self
|
||||
function ATC_GROUND:_AirbaseMonitor()
|
||||
|
||||
self.SetClient:ForEachClient(
|
||||
--- @param Wrapper.Client#CLIENT Client
|
||||
-- @param Wrapper.Client#CLIENT Client
|
||||
function( Client )
|
||||
|
||||
if Client:IsAlive() then
|
||||
@@ -258,7 +259,7 @@ function ATC_GROUND:_AirbaseMonitor()
|
||||
local IsOnGround = Client:InAir() == false
|
||||
|
||||
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
|
||||
|
||||
@@ -271,7 +272,7 @@ function ATC_GROUND:_AirbaseMonitor()
|
||||
|
||||
if IsOnGround then
|
||||
local Taxi = Client:GetState( self, "Taxi" )
|
||||
self:E( Taxi )
|
||||
self:T( Taxi )
|
||||
if Taxi == false then
|
||||
local Velocity = VELOCITY:New( AirbaseMeta.KickSpeed or self.KickSpeed )
|
||||
Client:Message( "Welcome to " .. AirbaseID .. ". The maximum taxiing speed is " ..
|
||||
@@ -331,7 +332,7 @@ function ATC_GROUND:_AirbaseMonitor()
|
||||
Client:SetState( self, "Warnings", SpeedingWarnings + 1 )
|
||||
else
|
||||
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:SetState( self, "Speeding", false )
|
||||
Client:SetState( self, "Warnings", 0 )
|
||||
@@ -363,7 +364,7 @@ function ATC_GROUND:_AirbaseMonitor()
|
||||
Client:SetState( self, "OffRunwayWarnings", OffRunwayWarnings + 1 )
|
||||
else
|
||||
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:SetState( self, "IsOffRunway", false )
|
||||
Client:SetState( self, "OffRunwayWarnings", 0 )
|
||||
@@ -424,13 +425,20 @@ ATC_GROUND_UNIVERSAL = {
|
||||
|
||||
--- Creates a new ATC\_GROUND\_UNIVERSAL object. This works on any map.
|
||||
-- @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
|
||||
-- @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)
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- #ATC_GROUND
|
||||
self:E( { self.ClassName } )
|
||||
self:T( { self.ClassName } )
|
||||
|
||||
self.Airbases = {}
|
||||
|
||||
@@ -440,6 +448,13 @@ function ATC_GROUND_UNIVERSAL:New(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()
|
||||
|
||||
|
||||
@@ -460,8 +475,9 @@ function ATC_GROUND_UNIVERSAL:New(AirbaseList)
|
||||
self.Airbases[AirbaseName].Monitor = true
|
||||
end
|
||||
|
||||
|
||||
self.SetClient:ForEachClient(
|
||||
--- @param Wrapper.Client#CLIENT Client
|
||||
-- @param Wrapper.Client#CLIENT Client
|
||||
function( Client )
|
||||
Client:SetState( self, "Speeding", false )
|
||||
Client:SetState( self, "Warnings", 0)
|
||||
@@ -679,9 +695,10 @@ end
|
||||
-- @param #ATC_GROUND_UNIVERSAL self
|
||||
-- @return #ATC_GROUND_UNIVERSAL self
|
||||
function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
||||
|
||||
self:I("_AirbaseMonitor")
|
||||
self.SetClient:ForEachClient(
|
||||
--- @param Wrapper.Client#CLIENT Client
|
||||
--- Nameless function
|
||||
-- @param Wrapper.Client#CLIENT Client
|
||||
function( Client )
|
||||
|
||||
if Client:IsAlive() then
|
||||
@@ -689,7 +706,7 @@ function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
||||
local IsOnGround = Client:InAir() == false
|
||||
|
||||
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
|
||||
|
||||
@@ -706,7 +723,7 @@ function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
||||
|
||||
if IsOnGround then
|
||||
local Taxi = Client:GetState( self, "Taxi" )
|
||||
self:E( Taxi )
|
||||
self:T( Taxi )
|
||||
if Taxi == false then
|
||||
local Velocity = VELOCITY:New( AirbaseMeta.KickSpeed or self.KickSpeed )
|
||||
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 )
|
||||
else
|
||||
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:SetState( self, "Speeding", false )
|
||||
Client:SetState( self, "Warnings", 0 )
|
||||
@@ -798,7 +815,7 @@ function ATC_GROUND_UNIVERSAL:_AirbaseMonitor()
|
||||
Client:SetState( self, "OffRunwayWarnings", OffRunwayWarnings + 1 )
|
||||
else
|
||||
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:SetState( self, "IsOffRunway", false )
|
||||
Client:SetState( self, "OffRunwayWarnings", 0 )
|
||||
@@ -838,15 +855,16 @@ end
|
||||
|
||||
--- Start SCHEDULER for ATC_GROUND_UNIVERSAL object.
|
||||
-- @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
|
||||
function ATC_GROUND_UNIVERSAL:Start( RepeatScanSeconds )
|
||||
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
|
||||
end
|
||||
|
||||
--- @type ATC_GROUND_CAUCASUS
|
||||
---
|
||||
-- @type ATC_GROUND_CAUCASUS
|
||||
-- @extends #ATC_GROUND
|
||||
|
||||
--- # ATC\_GROUND\_CAUCASUS, extends @{#ATC_GROUND_UNIVERSAL}
|
||||
@@ -981,12 +999,12 @@ end
|
||||
-- @return nothing
|
||||
function ATC_GROUND_CAUCASUS:Start( RepeatScanSeconds )
|
||||
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
|
||||
|
||||
|
||||
|
||||
--- @type ATC_GROUND_NEVADA
|
||||
---
|
||||
-- @type ATC_GROUND_NEVADA
|
||||
-- @extends #ATC_GROUND
|
||||
|
||||
|
||||
@@ -1120,11 +1138,11 @@ end
|
||||
-- @return nothing
|
||||
function ATC_GROUND_NEVADA:Start( RepeatScanSeconds )
|
||||
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
|
||||
|
||||
|
||||
--- @type ATC_GROUND_NORMANDY
|
||||
---
|
||||
-- @type ATC_GROUND_NORMANDY
|
||||
-- @extends #ATC_GROUND
|
||||
|
||||
|
||||
@@ -1277,10 +1295,11 @@ end
|
||||
-- @return nothing
|
||||
function ATC_GROUND_NORMANDY:Start( RepeatScanSeconds )
|
||||
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
|
||||
|
||||
--- @type ATC_GROUND_PERSIANGULF
|
||||
---
|
||||
-- @type ATC_GROUND_PERSIANGULF
|
||||
-- @extends #ATC_GROUND
|
||||
|
||||
|
||||
@@ -1419,11 +1438,11 @@ end
|
||||
-- @return nothing
|
||||
function ATC_GROUND_PERSIANGULF:Start( RepeatScanSeconds )
|
||||
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
|
||||
|
||||
|
||||
--- @type ATC_GROUND_MARIANAISLANDS
|
||||
-- @type ATC_GROUND_MARIANAISLANDS
|
||||
-- @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.SetMaximumKickSpeedMiph}(): Set the maximum speed allowed at an airbase in miles per hour.
|
||||
--
|
||||
---- @field #ATC_GROUND_MARIANAISLANDS
|
||||
-- @field #ATC_GROUND_MARIANAISLANDS
|
||||
ATC_GROUND_MARIANAISLANDS = {
|
||||
ClassName = "ATC_GROUND_MARIANAISLANDS",
|
||||
}
|
||||
@@ -1529,7 +1548,7 @@ ATC_GROUND_MARIANAISLANDS = {
|
||||
function ATC_GROUND_MARIANAISLANDS:New( AirbaseNames )
|
||||
|
||||
-- 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:SetMaximumKickSpeedKmph( 150 )
|
||||
@@ -1543,5 +1562,5 @@ end
|
||||
-- @return nothing
|
||||
function ATC_GROUND_MARIANAISLANDS:Start( RepeatScanSeconds )
|
||||
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
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
--
|
||||
-- ## Missions:
|
||||
--
|
||||
-- ### [AmmoTruck](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/AMT%20-%20AmmoTruck/AmmoTruck%20100%20-%20NTTR%20-%20Basic)
|
||||
-- Demo missions can be found on [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Functional/AmmoTruck)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -20,7 +20,7 @@
|
||||
-- Last update: July 2023
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
--- **AMMOTRUCK** class, extends Core.FSM#FSM
|
||||
--- **AMMOTRUCK** class, extends Core.Fsm#FSM
|
||||
-- @type AMMOTRUCK
|
||||
-- @field #string ClassName Class Name
|
||||
-- @field #string lid Lid for log entries
|
||||
@@ -41,7 +41,7 @@
|
||||
-- @field #number waitingtime Max waiting time in seconds
|
||||
-- @field #boolean routeonroad Route truck on road if true (default)
|
||||
-- @field #number reloads Number of reloads a single truck can do before he must return home
|
||||
-- @extends Core.FSM#FSM
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- *Amateurs talk about tactics, but professionals study logistics.* - General Robert H Barrow, USMC
|
||||
--
|
||||
|
||||
@@ -3546,7 +3546,7 @@ end
|
||||
-- @param #string To To state.
|
||||
function ARTY:onafterRespawn(Controllable, From, Event, To)
|
||||
self:_EventFromTo("onafterRespawn", Event, From, To)
|
||||
|
||||
self:I("Respawning arty group")
|
||||
local group=self.Controllable --Wrapper.Group#GROUP
|
||||
|
||||
-- Respawn group.
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
-- **AUOTLASE** - Autolase targets in the field.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
--
|
||||
-- ## Missions:
|
||||
--
|
||||
-- ### [Autolase](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/)
|
||||
--
|
||||
-- None yet.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- **Main Features:**
|
||||
@@ -74,7 +74,7 @@
|
||||
-- @image Designation.JPG
|
||||
--
|
||||
-- Date: 24 Oct 2021
|
||||
-- Last Update: Oct 2023
|
||||
-- Last Update: Jan 2024
|
||||
--
|
||||
--- Class AUTOLASE
|
||||
-- @type AUTOLASE
|
||||
@@ -87,6 +87,7 @@
|
||||
-- @field Core.Set#SET_GROUP RecceSet
|
||||
-- @field #table LaserCodes
|
||||
-- @field #table playermenus
|
||||
-- @field #boolean smokemenu
|
||||
-- @extends Ops.Intel#INTEL
|
||||
|
||||
---
|
||||
@@ -97,6 +98,7 @@ AUTOLASE = {
|
||||
verbose = 0,
|
||||
alias = "",
|
||||
debug = false,
|
||||
smokemenu = true,
|
||||
}
|
||||
|
||||
--- Laser spot info
|
||||
@@ -115,7 +117,7 @@ AUTOLASE = {
|
||||
|
||||
--- AUTOLASE class version.
|
||||
-- @field #string version
|
||||
AUTOLASE.version = "0.1.22"
|
||||
AUTOLASE.version = "0.1.23"
|
||||
|
||||
-------------------------------------------------------------------
|
||||
-- Begin Functional.Autolase.lua
|
||||
@@ -202,6 +204,7 @@ function AUTOLASE:New(RecceSet, Coalition, Alias, PilotSet)
|
||||
self.blacklistattributes = {}
|
||||
self:SetLaserCodes( { 1688, 1130, 4785, 6547, 1465, 4578 } ) -- set self.LaserCodes
|
||||
self.playermenus = {}
|
||||
self.smokemenu = true
|
||||
|
||||
-- Set some string id for output to DCS.log file.
|
||||
self.lid=string.format("AUTOLASE %s (%s) | ", self.alias, self.coalition and UTILS.GetCoalitionName(self.coalition) or "unknown")
|
||||
@@ -329,9 +332,11 @@ function AUTOLASE:SetPilotMenu()
|
||||
local lasetopm = MENU_GROUP:New(Group,"Autolase",nil)
|
||||
self.playermenus[unitname] = lasetopm
|
||||
local lasemenu = MENU_GROUP_COMMAND:New(Group,"Status",lasetopm,self.ShowStatus,self,Group,Unit)
|
||||
local smoke = (self.smoketargets == true) and "off" or "on"
|
||||
local smoketext = string.format("Switch smoke targets to %s",smoke)
|
||||
local smokemenu = MENU_GROUP_COMMAND:New(Group,smoketext,lasetopm,self.SetSmokeTargets,self,(not self.smoketargets))
|
||||
if self.smokemenu then
|
||||
local smoke = (self.smoketargets == true) and "off" or "on"
|
||||
local smoketext = string.format("Switch smoke targets to %s",smoke)
|
||||
local smokemenu = MENU_GROUP_COMMAND:New(Group,smoketext,lasetopm,self.SetSmokeTargets,self,(not self.smoketargets))
|
||||
end
|
||||
for _,_grp in pairs(self.RecceSet.Set) do
|
||||
local grp = _grp -- Wrapper.Group#GROUP
|
||||
local unit = grp:GetUnit(1)
|
||||
@@ -443,7 +448,7 @@ end
|
||||
-- @param #string Gender (Optional) Defaults to "male"
|
||||
-- @param #string Culture (Optional) Defaults to "en-US"
|
||||
-- @param #number Port (Optional) Defaults to 5002
|
||||
-- @param #string Voice (Optional) Use a specifc voice with the @{Sound.SRS.SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||
-- @param #string Voice (Optional) Use a specifc voice with the @{Sound.SRS#SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||
-- Note that this must be installed on your windows system. Can also be Google voice types, if you are using Google TTS.
|
||||
-- @param #number Volume (Optional) Volume - between 0.0 (silent) and 1.0 (loudest)
|
||||
-- @param #string PathToGoogleKey (Optional) Path to your google key if you want to use google TTS
|
||||
@@ -451,18 +456,18 @@ end
|
||||
function AUTOLASE:SetUsingSRS(OnOff,Path,Frequency,Modulation,Label,Gender,Culture,Port,Voice,Volume,PathToGoogleKey)
|
||||
if OnOff then
|
||||
self.useSRS = true
|
||||
self.SRSPath = Path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
self.SRSPath = Path or MSRS.path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
self.SRSFreq = Frequency or 271
|
||||
self.SRSMod = Modulation or radio.modulation.AM
|
||||
self.Gender = Gender or "male"
|
||||
self.Culture = Culture or "en-US"
|
||||
self.Port = Port or 5002
|
||||
self.Gender = Gender or MSRS.gender or "male"
|
||||
self.Culture = Culture or MSRS.culture or "en-US"
|
||||
self.Port = Port or MSRS.port or 5002
|
||||
self.Voice = Voice
|
||||
self.PathToGoogleKey = PathToGoogleKey
|
||||
self.Volume = Volume or 1.0
|
||||
self.Label = Label
|
||||
-- set up SRS
|
||||
self.SRS = MSRS:New(self.SRSPath,self.SRSFreq,self.SRSMod,self.Volume)
|
||||
self.SRS = MSRS:New(self.SRSPath,self.SRSFreq,self.SRSMod)
|
||||
self.SRS:SetCoalition(self.coalition)
|
||||
self.SRS:SetLabel(self.MenuName or self.Name)
|
||||
self.SRS:SetGender(self.Gender)
|
||||
@@ -470,8 +475,10 @@ function AUTOLASE:SetUsingSRS(OnOff,Path,Frequency,Modulation,Label,Gender,Cultu
|
||||
self.SRS:SetPort(self.Port)
|
||||
self.SRS:SetVoice(self.Voice)
|
||||
self.SRS:SetCoalition(self.coalition)
|
||||
self.SRS:SetVolume(self.Volume)
|
||||
if self.PathToGoogleKey then
|
||||
self.SRS:SetGoogle(self.PathToGoogleKey)
|
||||
self.SRS:SetProviderOptionsGoogle(PathToGoogleKey,PathToGoogleKey)
|
||||
self.SRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
self.SRSQueue = MSRSQUEUE:New(self.alias)
|
||||
else
|
||||
@@ -579,6 +586,23 @@ function AUTOLASE:SetSmokeTargets(OnOff,Color)
|
||||
return self
|
||||
end
|
||||
|
||||
--- (User) Show the "Switch smoke target..." menu entry for pilots. On by default.
|
||||
-- @param #AUTOLASE self
|
||||
-- @return #AUTOLASE self
|
||||
function AUTOLASE:EnableSmokeMenu()
|
||||
self.smokemenu = true
|
||||
return self
|
||||
end
|
||||
|
||||
--- (User) Do not show the "Switch smoke target..." menu entry for pilots.
|
||||
-- @param #AUTOLASE self
|
||||
-- @return #AUTOLASE self
|
||||
function AUTOLASE:DisableSmokeMenu()
|
||||
self.smokemenu = false
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- (Internal) Function to calculate line of sight.
|
||||
-- @param #AUTOLASE self
|
||||
-- @param Wrapper.Unit#UNIT Unit
|
||||
@@ -890,12 +914,12 @@ function AUTOLASE:onafterMonitor(From, Event, To)
|
||||
|
||||
self:SetPilotMenu()
|
||||
|
||||
local detecteditems = self.Contacts or {} -- #table of Ops.Intelligence#INTEL.Contact
|
||||
local detecteditems = self.Contacts or {} -- #table of Ops.Intel#INTEL.Contact
|
||||
local groupsbythreat = {}
|
||||
local report = REPORT:New("Detections")
|
||||
local lines = 0
|
||||
for _,_contact in pairs(detecteditems) do
|
||||
local contact = _contact -- Ops.Intelligence#INTEL.Contact
|
||||
local contact = _contact -- Ops.Intel#INTEL.Contact
|
||||
local grp = contact.group
|
||||
local coord = contact.position
|
||||
local reccename = contact.recce or "none"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
--
|
||||
-- ## 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,10 +15,12 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Missions:
|
||||
--
|
||||
-- [DES - Designation](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/DES%20-%20Designation)
|
||||
--
|
||||
-- ## Additional Material:
|
||||
--
|
||||
-- * **Demo Missions:** [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/Designate)
|
||||
-- * **YouTube videos:** None
|
||||
-- * **Guides:** None
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- Targets detected by recce will be communicated to a group of attacking players.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
--
|
||||
-- ## 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -38,8 +38,9 @@
|
||||
-- @image Detection.JPG
|
||||
|
||||
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 DCS#Distance DetectionRange The range till which targets are accepted to be detected.
|
||||
-- @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 } )
|
||||
--
|
||||
--
|
||||
-- ## 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_BASE derived classes build a list called DetectedItems[], which is essentially a first later
|
||||
@@ -268,11 +274,13 @@ do -- DETECTION_BASE
|
||||
DetectedItems = {},
|
||||
DetectedItemsByIndex = {},
|
||||
}
|
||||
|
||||
--- @type DETECTION_BASE.DetectedObjects
|
||||
|
||||
---
|
||||
-- @type DETECTION_BASE.DetectedObjects
|
||||
-- @list <#DETECTION_BASE.DetectedObject>
|
||||
|
||||
--- @type DETECTION_BASE.DetectedObject
|
||||
---
|
||||
-- @type DETECTION_BASE.DetectedObject
|
||||
-- @field #string Name
|
||||
-- @field #boolean IsVisible
|
||||
-- @field #boolean KnowType
|
||||
@@ -283,8 +291,9 @@ do -- DETECTION_BASE
|
||||
-- @field #number LastTime
|
||||
-- @field #boolean LastPos
|
||||
-- @field #number LastVelocity
|
||||
|
||||
--- @type DETECTION_BASE.DetectedItems
|
||||
|
||||
---
|
||||
-- @type DETECTION_BASE.DetectedItems
|
||||
-- @list <#DETECTION_BASE.DetectedItem>
|
||||
|
||||
--- Detected item data structure.
|
||||
@@ -522,7 +531,7 @@ do -- DETECTION_BASE
|
||||
|
||||
do -- State Transition Handling
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
@@ -530,7 +539,7 @@ do -- DETECTION_BASE
|
||||
self:__Detect( 1 )
|
||||
end
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
@@ -570,7 +579,7 @@ do -- DETECTION_BASE
|
||||
|
||||
end
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number The amount of alive recce.
|
||||
function DETECTION_BASE:CountAliveRecce()
|
||||
|
||||
@@ -578,7 +587,7 @@ do -- DETECTION_BASE
|
||||
|
||||
end
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
function DETECTION_BASE:ForEachAliveRecce( IteratorFunction, ... )
|
||||
self:F2( arg )
|
||||
|
||||
@@ -587,7 +596,7 @@ do -- DETECTION_BASE
|
||||
return self
|
||||
end
|
||||
|
||||
--- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
@@ -712,6 +721,31 @@ do -- DETECTION_BASE
|
||||
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
|
||||
|
||||
if not self.DetectedObjects[DetectedObjectName] and TargetIsVisible and self.DistanceProbability then
|
||||
@@ -1011,7 +1045,24 @@ do -- DETECTION_BASE
|
||||
return self
|
||||
|
||||
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
|
||||
|
||||
do
|
||||
@@ -1354,7 +1405,7 @@ do -- DETECTION_BASE
|
||||
}
|
||||
}
|
||||
|
||||
--- @param DCS#Unit FoundDCSUnit
|
||||
-- @param DCS#Unit FoundDCSUnit
|
||||
-- @param Wrapper.Group#GROUP ReportGroup
|
||||
-- @param Core.Set#SET_GROUP ReportSetGroup
|
||||
local FindNearByFriendlies = function( FoundDCSUnit, ReportGroupData )
|
||||
@@ -1419,7 +1470,7 @@ do -- DETECTION_BASE
|
||||
DetectedItem.PlayersNearBy = nil
|
||||
|
||||
_DATABASE:ForEachPlayer(
|
||||
--- @param Wrapper.Unit#UNIT PlayerUnit
|
||||
-- @param Wrapper.Unit#UNIT PlayerUnit
|
||||
function( PlayerUnitName )
|
||||
local PlayerUnit = UNIT:FindByName( PlayerUnitName )
|
||||
|
||||
@@ -1975,8 +2026,9 @@ do -- DETECTION_BASE
|
||||
end
|
||||
|
||||
do -- DETECTION_UNITS
|
||||
|
||||
--- @type DETECTION_UNITS
|
||||
|
||||
---
|
||||
-- @type DETECTION_UNITS
|
||||
-- @field DCS#Distance DetectionRange The range till which targets are detected.
|
||||
-- @extends Functional.Detection#DETECTION_BASE
|
||||
|
||||
@@ -2231,8 +2283,9 @@ do -- DETECTION_UNITS
|
||||
end
|
||||
|
||||
do -- DETECTION_TYPES
|
||||
|
||||
--- @type DETECTION_TYPES
|
||||
|
||||
---
|
||||
-- @type DETECTION_TYPES
|
||||
-- @extends Functional.Detection#DETECTION_BASE
|
||||
|
||||
--- Will detect units within the battle zone.
|
||||
@@ -2434,8 +2487,9 @@ do -- DETECTION_TYPES
|
||||
end
|
||||
|
||||
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 #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
|
||||
@@ -2961,7 +3015,7 @@ do -- DETECTION_AREAS
|
||||
|
||||
-- DetectedSet:Flush( self )
|
||||
|
||||
DetectedSet:ForEachUnit( --- @param Wrapper.Unit#UNIT DetectedUnit
|
||||
DetectedSet:ForEachUnit( -- @param Wrapper.Unit#UNIT DetectedUnit
|
||||
function( DetectedUnit )
|
||||
if DetectedUnit:IsAlive() then
|
||||
-- self:T( "Detected Set #" .. DetectedItem.ID .. ":" .. DetectedUnit:GetName() )
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
-- * Escort tactical situation reporting.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Missions:
|
||||
--
|
||||
-- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ESC%20-%20Escorting)
|
||||
--
|
||||
--
|
||||
-- ## Additional Material:
|
||||
--
|
||||
-- * **Demo Missions:** [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/Functional/Escort)
|
||||
-- * **YouTube videos:** None
|
||||
-- * **Guides:** None
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- Allows you to interact with escorting AI on your flight and take the lead.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@
|
||||
--
|
||||
-- ## 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
|
||||
-- @image Functional.Mantis.jpg
|
||||
--
|
||||
-- Last Update: Oct 2023
|
||||
-- Last Update: Feb 2024
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
--- **MANTIS** class, extends Core.Base#BASE
|
||||
@@ -94,7 +94,7 @@
|
||||
-- Known SAM types at the time of writing are:
|
||||
--
|
||||
-- * Avenger
|
||||
-- * Chaparrel
|
||||
-- * Chaparral
|
||||
-- * Hawk
|
||||
-- * Linebacker
|
||||
-- * NASAMS
|
||||
@@ -347,17 +347,17 @@ MANTIS.SamType = {
|
||||
-- @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)
|
||||
MANTIS.SamData = {
|
||||
["Hawk"] = { Range=44, Blindspot=0, Height=9, Type="Medium", Radar="Hawk" }, -- measures in km
|
||||
["NASAMS"] = { Range=14, Blindspot=0, Height=3, Type="Short", Radar="NSAMS" },
|
||||
["Patriot"] = { Range=99, Blindspot=0, Height=9, Type="Long", Radar="Patriot" },
|
||||
["Rapier"] = { Range=6, Blindspot=0, Height=3, Type="Short", Radar="rapier" },
|
||||
["Hawk"] = { Range=35, Blindspot=0, Height=12, Type="Medium", Radar="Hawk" }, -- measures in km
|
||||
["NASAMS"] = { Range=14, Blindspot=0, Height=7, Type="Short", Radar="NSAMS" }, -- AIM 120B
|
||||
["Patriot"] = { Range=99, Blindspot=0, Height=25, Type="Long", Radar="Patriot" },
|
||||
["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-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-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-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" },
|
||||
["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" },
|
||||
@@ -365,7 +365,7 @@ MANTIS.SamData = {
|
||||
["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" },
|
||||
["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" },
|
||||
["Silkworm"] = { Range=90, Blindspot=1, Height=0.2, Type="Long", Radar="Silkworm" },
|
||||
-- units from HDS Mod, multi launcher options is tricky
|
||||
@@ -376,7 +376,7 @@ MANTIS.SamData = {
|
||||
["HQ-2"] = { Range=50, Blindspot=6, Height=35, Type="Medium", Radar="HQ_2_Guideline_LN" },
|
||||
["SHORAD"] = { Range=3, Blindspot=0, Height=3, Type="Short", Radar="Igla" },
|
||||
["TAMIR IDFA"] = { Range=20, Blindspot=0.6, Height=12.3, Type="Short", Radar="IRON_DOME_LN" },
|
||||
["STUNNER IDFA"] = { Range=250, Blindspot=1, Height=45, Type="Long", Radar="DAVID_SLING_LN" },
|
||||
["STUNNER IDFA"] = { Range=250, Blindspot=1, Height=45, Type="Long", Radar="DAVID_SLING_LN" },
|
||||
}
|
||||
|
||||
--- SAM data HDS
|
||||
@@ -631,7 +631,7 @@ do
|
||||
|
||||
-- TODO Version
|
||||
-- @field #string version
|
||||
self.version="0.8.15"
|
||||
self.version="0.8.16"
|
||||
self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
|
||||
|
||||
--- FSM Functions ---
|
||||
@@ -799,12 +799,16 @@ do
|
||||
-- @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 #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
|
||||
function MANTIS:AddScootZones(ZoneSet, Number)
|
||||
function MANTIS:AddScootZones(ZoneSet, Number, Random, Formation)
|
||||
self:T(self.lid .. " AddScootZones")
|
||||
self.SkateZones = ZoneSet
|
||||
self.SkateNumber = Number or 3
|
||||
self.shootandscoot = true
|
||||
self.shootandscoot = true
|
||||
self.ScootRandom = Random
|
||||
self.ScootFormation = Formation or "Cone"
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -1145,7 +1149,7 @@ do
|
||||
--self:T(self.lid.." Relocating HQ")
|
||||
local text = self.lid.." Relocating HQ"
|
||||
--local m= MESSAGE:New(text,10,"MANTIS"):ToAll()
|
||||
_hqgrp:RelocateGroundRandomInRadius(20,500,true,true)
|
||||
_hqgrp:RelocateGroundRandomInRadius(20,500,true,true,nil,true)
|
||||
end
|
||||
--relocate EWR
|
||||
-- TODO: maybe dependent on AlarmState? Observed: SA11 SR only relocates if no objects in reach
|
||||
@@ -1159,7 +1163,7 @@ do
|
||||
local text = self.lid.." Relocating EWR ".._grp:GetName()
|
||||
local m= MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug)
|
||||
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
|
||||
@@ -1218,10 +1222,10 @@ do
|
||||
function MANTIS:_PreFilterHeight(height)
|
||||
self:T(self.lid.."_PreFilterHeight")
|
||||
local set = {}
|
||||
local dlink = self.Detection -- Ops.Intelligence#INTEL_DLINK
|
||||
local dlink = self.Detection -- Ops.Intel#INTEL_DLINK
|
||||
local detectedgroups = dlink:GetContactTable()
|
||||
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
|
||||
if grp:IsAlive() then
|
||||
if grp:GetHeight(true) < height then
|
||||
@@ -1773,7 +1777,7 @@ do
|
||||
-- @return #MANTIS self
|
||||
function MANTIS:_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()
|
||||
if not dlink:Is("Running") and (TS - self.DLTimeStamp > 29) then
|
||||
self.DLink = false
|
||||
@@ -1809,8 +1813,8 @@ do
|
||||
self.Shorad.Groupset=self.ShoradGroupSet
|
||||
self.Shorad.debug = self.debug
|
||||
end
|
||||
if self.shootandscoot and self.SkateZones then
|
||||
self.Shorad:AddScootZones(self.SkateZones,self.SkateNumber or 3)
|
||||
if self.shootandscoot and self.SkateZones and self.Shorad then
|
||||
self.Shorad:AddScootZones(self.SkateZones,self.SkateNumber or 3,self.ScootRandom,self.ScootFormation)
|
||||
end
|
||||
self:__Status(-math.random(1,10))
|
||||
return self
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
--
|
||||
-- ## 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # 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)
|
||||
-- * **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
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -170,7 +165,7 @@
|
||||
--
|
||||
-- * 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".
|
||||
-- * 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
|
||||
--
|
||||
@@ -1179,13 +1174,13 @@ function RAT:SetTakeoffAir()
|
||||
return self
|
||||
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 #string departurenames Name or table of names of departure airports or zones.
|
||||
-- @return #RAT RAT self object.
|
||||
-- @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({"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)
|
||||
self:F2(departurenames)
|
||||
|
||||
@@ -2537,7 +2532,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
|
||||
end
|
||||
elseif self:_ZoneExists(_departure) then
|
||||
-- If it's not an airport, check whether it's a zone.
|
||||
departure=ZONE:New(_departure)
|
||||
departure=ZONE:FindByName(_departure)
|
||||
else
|
||||
local text=string.format("ERROR! Specified departure airport %s does not exist for %s.", _departure, self.alias)
|
||||
self:E(RAT.id..text)
|
||||
@@ -2635,7 +2630,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
|
||||
end
|
||||
|
||||
elseif self:_ZoneExists(_destination) then
|
||||
destination=ZONE:New(_destination)
|
||||
destination=ZONE:FindByName(_destination)
|
||||
else
|
||||
local text=string.format("ERROR: Specified destination airport/zone %s does not exist for %s!", _destination, self.alias)
|
||||
self:E(RAT.id.."ERROR: "..text)
|
||||
@@ -3142,7 +3137,7 @@ function RAT:_PickDeparture(takeoff)
|
||||
end
|
||||
elseif self:_ZoneExists(name) then
|
||||
if takeoff==RAT.wp.air then
|
||||
dep=ZONE:New(name)
|
||||
dep=ZONE:FindByName(name)
|
||||
else
|
||||
self:E(RAT.id..string.format("ERROR! Takeoff is not in air. Cannot use %s as departure.", name))
|
||||
end
|
||||
@@ -3254,7 +3249,7 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)
|
||||
end
|
||||
elseif self:_ZoneExists(name) then
|
||||
if landing==RAT.wp.air then
|
||||
dest=ZONE:New(name)
|
||||
dest=ZONE:FindByName(name)
|
||||
else
|
||||
self:E(RAT.id..string.format("ERROR! Landing is not in air. Cannot use zone %s as destination!", name))
|
||||
end
|
||||
@@ -4930,12 +4925,12 @@ function RAT:_AirportExists(name)
|
||||
return false
|
||||
end
|
||||
|
||||
--- Test if a trigger zone defined in the mission editor exists.
|
||||
--- Test if a zone exists.
|
||||
-- @param #RAT self
|
||||
-- @param #string name
|
||||
-- @return #boolean True if zone exsits, false otherwise.
|
||||
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
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -1207,25 +1207,29 @@ end
|
||||
-- @return #RANGE self
|
||||
function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume, PathToGoogleKey)
|
||||
|
||||
if PathToSRS then
|
||||
if PathToSRS or MSRS.path then
|
||||
|
||||
self.useSRS=true
|
||||
|
||||
self.controlmsrs=MSRS:New(PathToSRS, Frequency or 256, Modulation or radio.modulation.AM, Volume or 1.0)
|
||||
self.controlmsrs:SetPort(Port)
|
||||
self.controlmsrs=MSRS:New(PathToSRS or MSRS.path, Frequency or 256, Modulation or radio.modulation.AM)
|
||||
self.controlmsrs:SetPort(Port or MSRS.port)
|
||||
self.controlmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
||||
self.controlmsrs:SetLabel("RANGEC")
|
||||
self.controlmsrs:SetVolume(Volume or 1.0)
|
||||
self.controlsrsQ = MSRSQUEUE:New("CONTROL")
|
||||
|
||||
self.instructmsrs=MSRS:New(PathToSRS, Frequency or 305, Modulation or radio.modulation.AM, Volume or 1.0)
|
||||
self.instructmsrs:SetPort(Port)
|
||||
self.instructmsrs=MSRS:New(PathToSRS or MSRS.path, Frequency or 305, Modulation or radio.modulation.AM)
|
||||
self.instructmsrs:SetPort(Port or MSRS.port)
|
||||
self.instructmsrs:SetCoalition(Coalition or coalition.side.BLUE)
|
||||
self.instructmsrs:SetLabel("RANGEI")
|
||||
self.instructmsrs:SetVolume(Volume or 1.0)
|
||||
self.instructsrsQ = MSRSQUEUE:New("INSTRUCT")
|
||||
|
||||
if PathToGoogleKey then
|
||||
self.controlmsrs:SetGoogle(PathToGoogleKey)
|
||||
self.instructmsrs:SetGoogle(PathToGoogleKey)
|
||||
self.controlmsrs:SetProviderOptionsGoogle(PathToGoogleKey,PathToGoogleKey)
|
||||
self.controlmsrs:SetProvider(MSRS.Provider.GOOGLE)
|
||||
self.instructmsrs:SetProviderOptionsGoogle(PathToGoogleKey,PathToGoogleKey)
|
||||
self.instructmsrs:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
|
||||
else
|
||||
@@ -1234,7 +1238,7 @@ function RANGE:SetSRS(PathToSRS, Port, Coalition, Frequency, Modulation, Volume,
|
||||
return self
|
||||
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 #number frequency Frequency in MHz. Default 256 MHz.
|
||||
-- @param #number modulation Modulation, defaults to radio.modulation.AM.
|
||||
@@ -1244,6 +1248,10 @@ end
|
||||
-- @param #string relayunitname Name of the unit used for transmission location.
|
||||
-- @return #RANGE self
|
||||
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.controlmsrs:SetFrequencies(self.rangecontrolfreq)
|
||||
self.controlmsrs:SetModulations(modulation or radio.modulation.AM)
|
||||
@@ -1259,7 +1267,7 @@ function RANGE:SetSRSRangeControl( frequency, modulation, voice, culture, gender
|
||||
return self
|
||||
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 #number frequency Frequency in MHz. Default 305 MHz.
|
||||
-- @param #number modulation Modulation, defaults to radio.modulation.AM.
|
||||
@@ -1269,6 +1277,10 @@ end
|
||||
-- @param #string relayunitname Name of the unit used for transmission location.
|
||||
-- @return #RANGE self
|
||||
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.instructmsrs:SetFrequencies(self.instructorfreq)
|
||||
self.instructmsrs:SetModulations(modulation or radio.modulation.AM)
|
||||
@@ -1729,7 +1741,9 @@ end
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
function RANGE:OnEventBirth( EventData )
|
||||
self:F( { eventbirth = EventData } )
|
||||
|
||||
|
||||
if not EventData.IniPlayerName then return end
|
||||
|
||||
local _unitName = EventData.IniUnitName
|
||||
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )
|
||||
|
||||
@@ -2179,7 +2193,7 @@ function RANGE:onafterExitRange( From, Event, To, player )
|
||||
|
||||
local text = "You left the bombing range zone. "
|
||||
|
||||
local r=math.random(2)
|
||||
local r=math.random(5)
|
||||
|
||||
if r==1 then
|
||||
text=text.."Have a nice day!"
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
--
|
||||
-- ## 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -78,7 +78,8 @@
|
||||
-- ### Authors: **FlightControl**
|
||||
--
|
||||
-- ### Contributions:
|
||||
--
|
||||
--
|
||||
-- * **Applevangelist**: Additional functionality, fixes.
|
||||
-- * **Wingthor (TAW)**: Testing & Advice.
|
||||
-- * **Dutch-Baron (TAW)**: Testing & 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.
|
||||
-- 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 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" )
|
||||
-- Scoring:AddUnitScore( UNIT:FindByName( "Unit #001" ), 200 )
|
||||
-- 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.
|
||||
-- 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,
|
||||
Players = {},
|
||||
AutoSave = true,
|
||||
version = "1.17.1"
|
||||
version = "1.18.4"
|
||||
}
|
||||
|
||||
local _SCORINGCoalition = {
|
||||
@@ -245,13 +248,15 @@ local _SCORINGCategory = {
|
||||
--- Creates a new SCORING object to administer the scoring achieved by players.
|
||||
-- @param #SCORING self
|
||||
-- @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
|
||||
-- @usage
|
||||
--
|
||||
-- -- Define a new scoring object for the mission Gori Valley.
|
||||
-- ScoringObject = SCORING:New( "Gori Valley" )
|
||||
--
|
||||
function SCORING:New( GameName )
|
||||
function SCORING:New( GameName, SavePath, AutoSave )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- #SCORING
|
||||
@@ -276,9 +281,15 @@ function SCORING:New( GameName )
|
||||
self:SetMessagesZone( true )
|
||||
|
||||
-- Scales
|
||||
|
||||
self:SetScaleDestroyScore( 10 )
|
||||
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).
|
||||
self:SetFratricide( self.ScaleDestroyPenalty * 3 )
|
||||
self.penaltyonfratricide = true
|
||||
@@ -308,7 +319,8 @@ function SCORING:New( GameName )
|
||||
end )
|
||||
|
||||
-- Create the CSV file.
|
||||
self.AutoSave = true
|
||||
self.AutoSavePath = SavePath
|
||||
self.AutoSave = AutoSave or true
|
||||
self:OpenCSV( GameName )
|
||||
|
||||
return self
|
||||
@@ -422,6 +434,31 @@ function SCORING:AddScoreGroup( ScoreGroup, Score )
|
||||
return self
|
||||
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.
|
||||
-- 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.
|
||||
@@ -467,6 +504,16 @@ function SCORING:SetMessagesHit( OnOff )
|
||||
return self
|
||||
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.
|
||||
-- @param #SCORING self
|
||||
-- @return #boolean
|
||||
@@ -885,6 +932,7 @@ function SCORING:OnEventBirth( Event )
|
||||
Event.IniUnit.BirthTime = timer.getTime()
|
||||
if PlayerName then
|
||||
self:_AddPlayerFromUnit( Event.IniUnit )
|
||||
self.Players[PlayerName].PlayerKills = 0
|
||||
self:SetScoringMenu( Event.IniGroup )
|
||||
end
|
||||
end
|
||||
@@ -1013,11 +1061,11 @@ function SCORING:_EventOnHit( Event )
|
||||
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0
|
||||
PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0
|
||||
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
|
||||
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 PlayerHit.ThreatType == nil then
|
||||
if PlayerHit.ThreatType == nil or PlayerHit.ThreatType == "" then
|
||||
PlayerHit.ThreatLevel = 1
|
||||
PlayerHit.ThreatType = "Unknown"
|
||||
end
|
||||
@@ -1025,7 +1073,7 @@ function SCORING:_EventOnHit( Event )
|
||||
PlayerHit.ThreatLevel = PlayerHit.UNIT.ThreatLevel
|
||||
PlayerHit.ThreatType = PlayerHit.UNIT.ThreatType
|
||||
end
|
||||
|
||||
|
||||
-- Only grant hit scores if there was more than one second between the last hit.
|
||||
if timer.getTime() - PlayerHit.TimeStamp > 1 then
|
||||
PlayerHit.TimeStamp = timer.getTime()
|
||||
@@ -1060,10 +1108,8 @@ function SCORING:_EventOnHit( Event )
|
||||
end
|
||||
self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||
else
|
||||
-- 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
|
||||
-- Player.Score = Player.Score + 1
|
||||
-- PlayerHit.Score = PlayerHit.Score + 1
|
||||
Player.Score = Player.Score + self.ScoreIncrementOnHit
|
||||
PlayerHit.Score = PlayerHit.Score + self.ScoreIncrementOnHit
|
||||
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
||||
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. " ..
|
||||
@@ -1126,9 +1172,9 @@ function SCORING:_EventOnHit( Event )
|
||||
PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0
|
||||
PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0
|
||||
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
|
||||
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 PlayerHit.ThreatType == nil then
|
||||
PlayerHit.ThreatLevel = 1
|
||||
@@ -1163,10 +1209,8 @@ function SCORING:_EventOnHit( Event )
|
||||
: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 )
|
||||
else
|
||||
-- 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
|
||||
-- Player.Score = Player.Score + 1
|
||||
-- PlayerHit.Score = PlayerHit.Score + 1
|
||||
Player.Score = Player.Score + self.ScoreIncrementOnHit
|
||||
PlayerHit.Score = PlayerHit.Score + self.ScoreIncrementOnHit
|
||||
PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. Event.WeaponPlayerName .. "' hit enemy target " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " ..
|
||||
"Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty,
|
||||
@@ -1274,13 +1318,18 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
||||
TargetDestroy.Penalty = TargetDestroy.Penalty + ThreatPenalty
|
||||
TargetDestroy.PenaltyDestroy = TargetDestroy.PenaltyDestroy + 1
|
||||
|
||||
|
||||
--self:OnKillPvP(PlayerName, TargetPlayerName, true, TargetThreatLevel, Player.ThreatLevel, ThreatPenalty)
|
||||
|
||||
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 .. " ) " ..
|
||||
"Penalty: -" .. ThreatPenalty .. " = " .. Player.Score - Player.Penalty,
|
||||
MESSAGE.Type.Information )
|
||||
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
||||
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
||||
else
|
||||
self:OnKillPvE(PlayerName, TargetUnitName, true, TargetThreatLevel, Player.ThreatLevel, ThreatPenalty)
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed friendly target " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||
"Penalty: -" .. ThreatPenalty .. " = " .. Player.Score - Player.Penalty,
|
||||
MESSAGE.Type.Information )
|
||||
@@ -1303,12 +1352,19 @@ function SCORING:_EventOnDeadOrCrash( Event )
|
||||
TargetDestroy.Score = TargetDestroy.Score + ThreatScore
|
||||
TargetDestroy.ScoreDestroy = TargetDestroy.ScoreDestroy + 1
|
||||
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 .. " ) " ..
|
||||
"Score: +" .. ThreatScore .. " = " .. Player.Score - Player.Penalty,
|
||||
MESSAGE.Type.Information )
|
||||
:ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() )
|
||||
:ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() )
|
||||
else
|
||||
self:OnKillPvE(PlayerName, TargetUnitName, false, TargetThreatLevel, Player.ThreatLevel, ThreatScore)
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' destroyed enemy " .. TargetUnitCategory .. " ( " .. ThreatTypeTarget .. " ) " ..
|
||||
"Score: +" .. ThreatScore .. " = " .. Player.Score - Player.Penalty,
|
||||
MESSAGE.Type.Information )
|
||||
@@ -1786,10 +1842,11 @@ end
|
||||
function SCORING:OpenCSV( 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
|
||||
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+" )
|
||||
if not self.CSVFile then
|
||||
@@ -1907,3 +1964,26 @@ function SCORING:SwitchAutoSave(OnOff)
|
||||
self.AutoSave = OnOff
|
||||
return self
|
||||
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:
|
||||
--
|
||||
-- [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("*", "CalculateHitZone", "*")
|
||||
|
||||
self:I("*** SEAD - Started Version 0.4.5")
|
||||
self:I("*** SEAD - Started Version 0.4.6")
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -320,9 +320,6 @@ function SEAD:onafterCalculateHitZone(From,Event,To,SEADWeapon,pos0,height,SEADG
|
||||
end
|
||||
|
||||
local seadset = SET_GROUP:New():FilterPrefixes(self.SEADGroupPrefixes):FilterZones({targetzone}):FilterOnce()
|
||||
local tgtcoord = targetzone:GetRandomPointVec2()
|
||||
--if tgtcoord and tgtcoord.ClassName == "COORDINATE" then
|
||||
--local tgtgrp = seadset:FindNearestGroupFromPointVec2(tgtcoord)
|
||||
local tgtgrp = seadset:GetRandom()
|
||||
local _targetgroup = nil
|
||||
local _targetgroupname = "none"
|
||||
@@ -401,7 +398,7 @@ function SEAD:onafterManageEvasion(From,Event,To,_targetskill,_targetgroup,SEADP
|
||||
grp:EnableEmission(false)
|
||||
end
|
||||
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
|
||||
local object = self.CallBack
|
||||
object:SeadSuppressionStart(grp,name,attacker)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
--
|
||||
-- ## 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 #number DefenseLowProb Default 70, minimum 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 shootandscoot
|
||||
-- @field #number SkateNumber
|
||||
-- @field Core.Set#SET_ZONE SkateZones
|
||||
-- @field #boolean UseEmOnOff Decide if we are using Emission on/off (default) or AlarmState red/green
|
||||
-- @field #boolean shootandscoot If true, shoot and scoot between zones
|
||||
-- @field #number SkateNumber Number of zones to consider
|
||||
-- @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
|
||||
|
||||
|
||||
@@ -77,14 +81,15 @@
|
||||
--
|
||||
-- `myshorad = SHORAD:New("RedShorad", "Red SHORAD", SamSet, 25000, 600, "red")`
|
||||
--
|
||||
-- ## Customize options
|
||||
-- ## Customization options
|
||||
--
|
||||
-- * SHORAD:SwitchDebug(debug)
|
||||
-- * SHORAD:SwitchHARMDefense(onoff)
|
||||
-- * SHORAD:SwitchAGMDefense(onoff)
|
||||
-- * SHORAD:SetDefenseLimits(low,high)
|
||||
-- * SHORAD:SetActiveTimer(seconds)
|
||||
-- * SHORAD:SetDefenseRadius(meters)
|
||||
-- * myshorad:SwitchDebug(debug)
|
||||
-- * myshorad:SwitchHARMDefense(onoff)
|
||||
-- * myshorad:SwitchAGMDefense(onoff)
|
||||
-- * myshorad:SetDefenseLimits(low,high)
|
||||
-- * myshorad:SetActiveTimer(seconds)
|
||||
-- * myshorad:SetDefenseRadius(meters)
|
||||
-- * myshorad:AddScootZones(ZoneSet,Number,Random,Formation)
|
||||
--
|
||||
-- @field #SHORAD
|
||||
SHORAD = {
|
||||
@@ -107,6 +112,9 @@ SHORAD = {
|
||||
shootandscoot = false,
|
||||
SkateNumber = 3,
|
||||
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.UseEmOnOff = true -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
||||
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.
|
||||
self.lid=string.format("SHORAD %s | ", self.name)
|
||||
self:_InitState()
|
||||
@@ -219,12 +227,16 @@ do
|
||||
-- @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 #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
|
||||
function SHORAD:AddScootZones(ZoneSet, Number)
|
||||
function SHORAD:AddScootZones(ZoneSet, Number, Random, Formation)
|
||||
self:T(self.lid .. " AddScootZones")
|
||||
self.SkateZones = ZoneSet
|
||||
self.SkateNumber = Number or 3
|
||||
self.shootandscoot = true
|
||||
self.shootandscoot = true
|
||||
self.scootrandomcoord = Random
|
||||
self.scootformation = Formation or "Cone"
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -613,8 +625,8 @@ do
|
||||
function SHORAD:onafterShootAndScoot(From,Event,To,Shorad)
|
||||
self:T( { From,Event,To } )
|
||||
local possibleZones = {}
|
||||
local mindist = 100
|
||||
local maxdist = 3000
|
||||
local mindist = self.minscootdist or 100
|
||||
local maxdist = self.maxscootdist or 3000
|
||||
if Shorad and Shorad:IsAlive() then
|
||||
local NowCoord = Shorad:GetCoordinate()
|
||||
for _,_zone in pairs(self.SkateZones.Set) do
|
||||
@@ -630,7 +642,11 @@ do
|
||||
if rand == 0 then rand = 1 end
|
||||
self:T(self.lid .. " ShootAndScoot to zone "..rand)
|
||||
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
|
||||
return self
|
||||
@@ -731,4 +747,4 @@ do
|
||||
end
|
||||
-----------------------------------------------------------------------
|
||||
-- SHORAD end
|
||||
-----------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
1316
Moose Development/Moose/Functional/Stratego.lua
Normal file
1316
Moose Development/Moose/Functional/Stratego.lua
Normal file
File diff suppressed because it is too large
Load Diff
590
Moose Development/Moose/Functional/Tiresias.lua
Normal file
590
Moose Development/Moose/Functional/Tiresias.lua
Normal file
@@ -0,0 +1,590 @@
|
||||
--- **Functional** - TIRESIAS - manages AI behaviour.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- The @{#TIRESIAS} class is working in the back to keep your large-scale ground units in check.
|
||||
--
|
||||
-- ## Features:
|
||||
--
|
||||
-- * Designed to keep CPU and Network usage lower on missions with a lot of ground units.
|
||||
-- * Does not affect ships to keep the Navy guys happy.
|
||||
-- * Does not affect OpsGroup type groups.
|
||||
-- * Distinguishes between SAM groups, AAA groups and other ground groups.
|
||||
-- * Exceptions can be defined to keep certain actions going.
|
||||
-- * Works coalition-independent in the back
|
||||
-- * Easy setup.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Missions:
|
||||
--
|
||||
-- ### [TIRESIAS](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author : **applevangelist **
|
||||
--
|
||||
-- @module Functional.Tiresias
|
||||
-- @image Functional.Tiresias.jpg
|
||||
--
|
||||
-- Last Update: Dec 2023
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
--- **TIRESIAS** class, extends Core.Base#BASE
|
||||
-- @type TIRESIAS
|
||||
-- @field #string ClassName
|
||||
-- @field #booelan debug
|
||||
-- @field #string version
|
||||
-- @field #number Interval
|
||||
-- @field Core.Set#SET_GROUP GroundSet
|
||||
-- @field #number Coalition
|
||||
-- @field Core.Set#SET_GROUP VehicleSet
|
||||
-- @field Core.Set#SET_GROUP AAASet
|
||||
-- @field Core.Set#SET_GROUP SAMSet
|
||||
-- @field Core.Set#SET_GROUP ExceptionSet
|
||||
-- @field Core.Set#SET_OPSGROUP OpsGroupSet
|
||||
-- @field #number AAARange
|
||||
-- @field #number HeloSwitchRange
|
||||
-- @field #number PlaneSwitchRange
|
||||
-- @field Core.Set#SET_GROUP FlightSet
|
||||
-- @field #boolean SwitchAAA
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
---
|
||||
-- @type TIRESIAS.Data
|
||||
-- @field #string type
|
||||
-- @field #number range
|
||||
-- @field #boolean invisible
|
||||
-- @field #boolean AIOff
|
||||
-- @field #boolean exception
|
||||
|
||||
|
||||
--- *Tiresias, Greek demi-god and shapeshifter, blinded by the Gods, works as oracle for you.* (Wiki)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## TIRESIAS Concept
|
||||
--
|
||||
-- * Designed to keep CPU and Network usage lower on missions with a lot of ground units.
|
||||
-- * Does not affect ships to keep the Navy guys happy.
|
||||
-- * Does not affect OpsGroup type groups.
|
||||
-- * Distinguishes between SAM groups, AAA groups and other ground groups.
|
||||
-- * Exceptions can be defined in SET_GROUP objects to keep certain actions going.
|
||||
-- * Works coalition-independent in the back
|
||||
-- * Easy setup.
|
||||
--
|
||||
-- ## Setup
|
||||
--
|
||||
-- Setup is a one-liner:
|
||||
--
|
||||
-- local blinder = TIRESIAS:New()
|
||||
--
|
||||
-- Optionally you can set up exceptions, e.g. for convoys driving around
|
||||
--
|
||||
-- local exceptionset = SET_GROUP:New():FilterCoalitions("red"):FilterPrefixes("Convoy"):FilterStart()
|
||||
-- local blinder = TIRESIAS:New()
|
||||
-- blinder:AddExceptionSet(exceptionset)
|
||||
--
|
||||
-- Options
|
||||
--
|
||||
-- -- Setup different radius for activation around helo and airplane groups (applies to AI and humans)
|
||||
-- blinder:SetActivationRanges(10,25) -- defaults are 10, and 25
|
||||
--
|
||||
-- -- Setup engagement ranges for AAA (non-advanced SAM units like Flaks etc) and if you want them to be AIOff
|
||||
-- blinder:SetAAARanges(60,true) -- defaults are 60, and true
|
||||
--
|
||||
-- @field #TIRESIAS
|
||||
TIRESIAS = {
|
||||
ClassName = "TIRESIAS",
|
||||
debug = false,
|
||||
version = "0.0.4",
|
||||
Interval = 20,
|
||||
GroundSet = nil,
|
||||
VehicleSet = nil,
|
||||
AAASet = nil,
|
||||
SAMSet = nil,
|
||||
ExceptionSet = nil,
|
||||
AAARange = 60, -- 60%
|
||||
HeloSwitchRange = 10, -- NM
|
||||
PlaneSwitchRange = 25, -- NM
|
||||
SwitchAAA = true,
|
||||
}
|
||||
|
||||
--- [USER] Create a new Tiresias object and start it up.
|
||||
-- @param #TIRESIAS self
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:New()
|
||||
|
||||
-- Inherit everything from FSM class.
|
||||
local self = BASE:Inherit(self, FSM:New()) -- #TIRESIAS
|
||||
|
||||
--- FSM Functions ---
|
||||
|
||||
-- Start State.
|
||||
self:SetStartState("Stopped")
|
||||
|
||||
-- Add FSM transitions.
|
||||
-- From State --> Event --> To State
|
||||
self:AddTransition("Stopped", "Start", "Running") -- Start FSM.
|
||||
self:AddTransition("*", "Status", "*") -- TIRESIAS status update.
|
||||
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||
|
||||
self.ExceptionSet = SET_GROUP:New():Clear(false)
|
||||
|
||||
self:HandleEvent(EVENTS.PlayerEnterAircraft,self._EventHandler)
|
||||
|
||||
self.lid = string.format("TIRESIAS %s | ",self.version)
|
||||
|
||||
self:I(self.lid.."Managing ground groups!")
|
||||
|
||||
--- Triggers the FSM event "Stop". Stops TIRESIAS and all its event handlers.
|
||||
-- @function [parent=#TIRESIAS] Stop
|
||||
-- @param #TIRESIAS self
|
||||
|
||||
--- Triggers the FSM event "Stop" after a delay. Stops TIRESIAS and all its event handlers.
|
||||
-- @function [parent=#TIRESIAS] __Stop
|
||||
-- @param #TIRESIAS self
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
--- Triggers the FSM event "Start". Starts TIRESIAS and all its event handlers. Note - `:New()` already starts the instance.
|
||||
-- @function [parent=#TIRESIAS] Start
|
||||
-- @param #TIRESIAS self
|
||||
|
||||
--- Triggers the FSM event "Start" after a delay. Starts TIRESIAS and all its event handlers. Note - `:New()` already starts the instance.
|
||||
-- @function [parent=#TIRESIAS] __Start
|
||||
-- @param #TIRESIAS self
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
self:__Start(1)
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- Helper Functions
|
||||
--
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
---[USER] Set activation radius for Helos and Planes in Nautical Miles.
|
||||
-- @param #TIRESIAS self
|
||||
-- @param #number HeloMiles Radius around a Helicopter in which AI ground units will be activated. Defaults to 10NM.
|
||||
-- @param #number PlaneMiles Radius around an Airplane in which AI ground units will be activated. Defaults to 25NM.
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:SetActivationRanges(HeloMiles,PlaneMiles)
|
||||
self.HeloSwitchRange = HeloMiles or 10
|
||||
self.PlaneSwitchRange = PlaneMiles or 25
|
||||
return self
|
||||
end
|
||||
|
||||
---[USER] Set AAA Ranges - AAA equals non-SAM systems which qualify as AAA in DCS world.
|
||||
-- @param #TIRESIAS self
|
||||
-- @param #number FiringRange The engagement range that AAA units will be set to. Can be 0 to 100 (percent). Defaults to 60.
|
||||
-- @param #boolean SwitchAAA Decide if these system will have their AI switched off, too. Defaults to true.
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:SetAAARanges(FiringRange,SwitchAAA)
|
||||
self.AAARange = FiringRange or 60
|
||||
self.SwitchAAA = (SwitchAAA == false) and false or true
|
||||
return self
|
||||
end
|
||||
|
||||
--- [USER] Add a SET_GROUP of GROUP objects as exceptions. Can be done multiple times.
|
||||
-- @param #TIRESIAS self
|
||||
-- @param Core.Set#SET_GROUP Set to add to the exception list.
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:AddExceptionSet(Set)
|
||||
self:T(self.lid.."AddExceptionSet")
|
||||
local exceptions = self.ExceptionSet
|
||||
Set:ForEachGroupAlive(
|
||||
function(grp)
|
||||
if not grp.Tiresias then
|
||||
grp.Tiresias = { -- #TIRESIAS.Data
|
||||
type = "Exception",
|
||||
exception = true,
|
||||
}
|
||||
exceptions:AddGroup(grp,true)
|
||||
end
|
||||
BASE:I("TIRESIAS: Added exception group: "..grp:GetName())
|
||||
end
|
||||
)
|
||||
return self
|
||||
end
|
||||
|
||||
--- [INTERNAL] Filter Function
|
||||
-- @param Wrapper.Group#GROUP Group
|
||||
-- @return #boolean isin
|
||||
function TIRESIAS._FilterNotAAA(Group)
|
||||
local grp = Group -- Wrapper.Group#GROUP
|
||||
local isaaa = grp:IsAAA()
|
||||
if isaaa == true and grp:IsGround() and not grp:IsShip() then
|
||||
return false -- remove from SET
|
||||
else
|
||||
return true -- keep in SET
|
||||
end
|
||||
end
|
||||
|
||||
--- [INTERNAL] Filter Function
|
||||
-- @param Wrapper.Group#GROUP Group
|
||||
-- @return #boolean isin
|
||||
function TIRESIAS._FilterNotSAM(Group)
|
||||
local grp = Group -- Wrapper.Group#GROUP
|
||||
local issam = grp:IsSAM()
|
||||
if issam == true and grp:IsGround() and not grp:IsShip() then
|
||||
return false -- remove from SET
|
||||
else
|
||||
return true -- keep in SET
|
||||
end
|
||||
end
|
||||
|
||||
--- [INTERNAL] Filter Function
|
||||
-- @param Wrapper.Group#GROUP Group
|
||||
-- @return #boolean isin
|
||||
function TIRESIAS._FilterAAA(Group)
|
||||
local grp = Group -- Wrapper.Group#GROUP
|
||||
local isaaa = grp:IsAAA()
|
||||
if isaaa == true and grp:IsGround() and not grp:IsShip() then
|
||||
return true -- remove from SET
|
||||
else
|
||||
return false -- keep in SET
|
||||
end
|
||||
end
|
||||
|
||||
--- [INTERNAL] Filter Function
|
||||
-- @param Wrapper.Group#GROUP Group
|
||||
-- @return #boolean isin
|
||||
function TIRESIAS._FilterSAM(Group)
|
||||
local grp = Group -- Wrapper.Group#GROUP
|
||||
local issam = grp:IsSAM()
|
||||
if issam == true and grp:IsGround() and not grp:IsShip() then
|
||||
return true -- remove from SET
|
||||
else
|
||||
return false -- keep in SET
|
||||
end
|
||||
end
|
||||
|
||||
--- [INTERNAL] Init Groups
|
||||
-- @param #TIRESIAS self
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:_InitGroups()
|
||||
self:T(self.lid.."_InitGroups")
|
||||
-- Set all groups invisible/motionless
|
||||
local EngageRange = self.AAARange
|
||||
local SwitchAAA = self.SwitchAAA
|
||||
--- AAA
|
||||
self.AAASet:ForEachGroupAlive(
|
||||
function(grp)
|
||||
if not grp.Tiresias then
|
||||
grp:OptionEngageRange(EngageRange)
|
||||
grp:SetCommandInvisible(true)
|
||||
if SwitchAAA then
|
||||
grp:SetAIOff()
|
||||
grp:EnableEmission(false)
|
||||
end
|
||||
grp.Tiresias = { -- #TIRESIAS.Data
|
||||
type = "AAA",
|
||||
invisible = true,
|
||||
range = EngageRange,
|
||||
exception = false,
|
||||
AIOff = SwitchAAA,
|
||||
}
|
||||
end
|
||||
if grp.Tiresias and (not grp.Tiresias.exception == true) then
|
||||
if grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
||||
grp:SetCommandInvisible(true)
|
||||
grp.Tiresias.invisible = true
|
||||
if SwitchAAA then
|
||||
grp:SetAIOff()
|
||||
grp:EnableEmission(false)
|
||||
grp.Tiresias.AIOff = true
|
||||
end
|
||||
end
|
||||
end
|
||||
--BASE:I(string.format("Init/Switch off AAA %s (Exception %s)",grp:GetName(),tostring(grp.Tiresias.exception)))
|
||||
end
|
||||
)
|
||||
--- Vehicles
|
||||
self.VehicleSet:ForEachGroupAlive(
|
||||
function(grp)
|
||||
if not grp.Tiresias then
|
||||
grp:SetAIOff()
|
||||
grp:SetCommandInvisible(true)
|
||||
grp.Tiresias = { -- #TIRESIAS.Data
|
||||
type = "Vehicle",
|
||||
invisible = true,
|
||||
AIOff = true,
|
||||
exception = false,
|
||||
}
|
||||
end
|
||||
if grp.Tiresias and (not grp.Tiresias.exception == true) then
|
||||
if grp.Tiresias and grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
||||
grp:SetCommandInvisible(true)
|
||||
grp:SetAIOff()
|
||||
grp.Tiresias.invisible = true
|
||||
end
|
||||
end
|
||||
--BASE:I(string.format("Init/Switch off Vehicle %s (Exception %s)",grp:GetName(),tostring(grp.Tiresias.exception)))
|
||||
end
|
||||
)
|
||||
--- SAM
|
||||
self.SAMSet:ForEachGroupAlive(
|
||||
function(grp)
|
||||
if not grp.Tiresias then
|
||||
grp:SetCommandInvisible(true)
|
||||
grp.Tiresias = { -- #TIRESIAS.Data
|
||||
type = "SAM",
|
||||
invisible = true,
|
||||
exception = false,
|
||||
}
|
||||
end
|
||||
if grp.Tiresias and (not grp.Tiresias.exception == true) then
|
||||
if grp.Tiresias and grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
||||
grp:SetCommandInvisible(true)
|
||||
grp.Tiresias.invisible = true
|
||||
end
|
||||
end
|
||||
--BASE:I(string.format("Init/Switch off SAM %s (Exception %s)",grp:GetName(),tostring(grp.Tiresias.exception)))
|
||||
end
|
||||
)
|
||||
return self
|
||||
end
|
||||
|
||||
--- [INTERNAL] Event handler function
|
||||
-- @param #TIRESIAS self
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:_EventHandler(EventData)
|
||||
self:T(string.format("%s Event = %d",self.lid, EventData.id))
|
||||
local event = EventData -- Core.Event#EVENTDATA
|
||||
if event.id == EVENTS.PlayerEnterAircraft or event.id == EVENTS.PlayerEnterUnit then
|
||||
--local _coalition = event.IniCoalition
|
||||
--if _coalition ~= self.Coalition then
|
||||
-- return --ignore!
|
||||
--end
|
||||
local unitname = event.IniUnitName or "none"
|
||||
local _unit = event.IniUnit
|
||||
local _group = event.IniGroup
|
||||
if _group and _group:IsAlive() then
|
||||
local radius = self.PlaneSwitchRange
|
||||
if _group:IsHelicopter() then
|
||||
radius = self.HeloSwitchRange
|
||||
end
|
||||
self:_SwitchOnGroups(_group,radius)
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- [INTERNAL] Switch Groups Behaviour
|
||||
-- @param #TIRESIAS self
|
||||
-- @param Wrapper.Group#GROUP group
|
||||
-- @param #number radius Radius in NM
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:_SwitchOnGroups(group,radius)
|
||||
self:T(self.lid.."_SwitchOnGroups "..group:GetName().." Radius "..radius.." NM")
|
||||
local zone = ZONE_GROUP:New("Zone-"..group:GetName(),group,UTILS.NMToMeters(radius))
|
||||
local ground = SET_GROUP:New():FilterCategoryGround():FilterZones({zone}):FilterOnce()
|
||||
local count = ground:CountAlive()
|
||||
if self.debug then
|
||||
local text = string.format("There are %d groups around this plane or helo!",count)
|
||||
self:I(text)
|
||||
end
|
||||
local SwitchAAA = self.SwitchAAA
|
||||
if ground:CountAlive() > 0 then
|
||||
ground:ForEachGroupAlive(
|
||||
function(grp)
|
||||
if grp.Tiresias and grp.Tiresias.type and (not grp.Tiresias.exception == true ) then
|
||||
if grp.Tiresias.invisible == true then
|
||||
grp:SetCommandInvisible(false)
|
||||
grp.Tiresias.invisible = false
|
||||
end
|
||||
if grp.Tiresias.type == "Vehicle" and grp.Tiresias.AIOff and grp.Tiresias.AIOff == true then
|
||||
grp:SetAIOn()
|
||||
grp.Tiresias.AIOff = false
|
||||
end
|
||||
if SwitchAAA and grp.Tiresias.type == "AAA" and grp.Tiresias.AIOff and grp.Tiresias.AIOff == true then
|
||||
grp:SetAIOn()
|
||||
grp:EnableEmission(true)
|
||||
grp.Tiresias.AIOff = false
|
||||
end
|
||||
--BASE:I(string.format("TIRESIAS - Switch on %s %s (Exception %s)",tostring(grp.Tiresias.type),grp:GetName(),tostring(grp.Tiresias.exception)))
|
||||
else
|
||||
BASE:E("TIRESIAS - This group has not been initialized or is an exception!")
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- FSM Functions
|
||||
--
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- [INTERNAL] FSM Function
|
||||
-- @param #TIRESIAS self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:onafterStart(From, Event, To)
|
||||
self:T({From, Event, To})
|
||||
|
||||
local VehicleSet = SET_GROUP:New():FilterCategoryGround():FilterFunction(TIRESIAS._FilterNotAAA):FilterFunction(TIRESIAS._FilterNotSAM):FilterStart()
|
||||
local AAASet = SET_GROUP:New():FilterCategoryGround():FilterFunction(TIRESIAS._FilterAAA):FilterStart()
|
||||
local SAMSet = SET_GROUP:New():FilterCategoryGround():FilterFunction(TIRESIAS._FilterSAM):FilterStart()
|
||||
local OpsGroupSet = SET_OPSGROUP:New():FilterActive(true):FilterStart()
|
||||
self.FlightSet = SET_GROUP:New():FilterCategories({"plane","helicopter"}):FilterStart()
|
||||
|
||||
local EngageRange = self.AAARange
|
||||
|
||||
local ExceptionSet = self.ExceptionSet
|
||||
if self.ExceptionSet then
|
||||
function ExceptionSet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||
BASE:I("TIRESIAS: EXCEPTION Object Added: "..Object:GetName())
|
||||
if Object and Object:IsAlive() then
|
||||
Object.Tiresias = { -- #TIRESIAS.Data
|
||||
type = "Exception",
|
||||
exception = true,
|
||||
}
|
||||
Object:SetAIOn()
|
||||
Object:SetCommandInvisible(false)
|
||||
Object:EnableEmission(true)
|
||||
end
|
||||
end
|
||||
|
||||
local OGS = OpsGroupSet:GetAliveSet()
|
||||
for _,_OG in pairs(OGS or {}) do
|
||||
local OG = _OG -- Ops.OpsGroup#OPSGROUP
|
||||
local grp = OG:GetGroup()
|
||||
ExceptionSet:AddGroup(grp,true)
|
||||
end
|
||||
|
||||
function OpsGroupSet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||
local grp = Object:GetGroup()
|
||||
ExceptionSet:AddGroup(grp,true)
|
||||
end
|
||||
end
|
||||
|
||||
function VehicleSet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||
BASE:I("TIRESIAS: VEHCILE Object Added: "..Object:GetName())
|
||||
if Object and Object:IsAlive() then
|
||||
Object:SetAIOff()
|
||||
Object:SetCommandInvisible(true)
|
||||
Object.Tiresias = { -- #TIRESIAS.Data
|
||||
type = "Vehicle",
|
||||
invisible = true,
|
||||
AIOff = true,
|
||||
exception = false,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local SwitchAAA = self.SwitchAAA
|
||||
|
||||
function AAASet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||
if Object and Object:IsAlive() then
|
||||
BASE:I("TIRESIAS: AAA Object Added: "..Object:GetName())
|
||||
Object:OptionEngageRange(EngageRange)
|
||||
Object:SetCommandInvisible(true)
|
||||
if SwitchAAA then
|
||||
Object:SetAIOff()
|
||||
Object:EnableEmission(false)
|
||||
end
|
||||
Object.Tiresias = { -- #TIRESIAS.Data
|
||||
type = "AAA",
|
||||
invisible = true,
|
||||
range = EngageRange,
|
||||
exception = false,
|
||||
AIOff = SwitchAAA,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function SAMSet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||
if Object and Object:IsAlive() then
|
||||
BASE:I("TIRESIAS: SAM Object Added: "..Object:GetName())
|
||||
Object:SetCommandInvisible(true)
|
||||
Object.Tiresias = { -- #TIRESIAS.Data
|
||||
type = "SAM",
|
||||
invisible = true,
|
||||
exception = false,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
self.VehicleSet = VehicleSet
|
||||
self.AAASet = AAASet
|
||||
self.SAMSet = SAMSet
|
||||
self.OpsGroupSet = OpsGroupSet
|
||||
|
||||
self:_InitGroups()
|
||||
|
||||
self:__Status(1)
|
||||
return self
|
||||
end
|
||||
|
||||
--- [INTERNAL] FSM Function
|
||||
-- @param #TIRESIAS self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:onbeforeStatus(From, Event, To)
|
||||
self:T({From, Event, To})
|
||||
if self:GetState() == "Stopped" then
|
||||
return false
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- [INTERNAL] FSM Function
|
||||
-- @param #TIRESIAS self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:onafterStatus(From, Event, To)
|
||||
self:T({From, Event, To})
|
||||
if self.debug then
|
||||
local count = self.VehicleSet:CountAlive()
|
||||
local AAAcount = self.AAASet:CountAlive()
|
||||
local SAMcount = self.SAMSet:CountAlive()
|
||||
local text = string.format("Overall: %d | Vehicles: %d | AAA: %d | SAM: %d",count+AAAcount+SAMcount,count,AAAcount,SAMcount)
|
||||
self:I(text)
|
||||
end
|
||||
self:_InitGroups()
|
||||
if self.FlightSet:CountAlive() > 0 then
|
||||
local Set = self.FlightSet:GetAliveSet()
|
||||
for _,_plane in pairs(Set) do
|
||||
local plane = _plane -- Wrapper.Group#GROUP
|
||||
local radius = self.PlaneSwitchRange
|
||||
if plane:IsHelicopter() then
|
||||
radius = self.HeloSwitchRange
|
||||
end
|
||||
self:_SwitchOnGroups(_plane,radius)
|
||||
end
|
||||
end
|
||||
if self:GetState() ~= "Stopped" then
|
||||
self:__Status(self.Interval)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- [INTERNAL] FSM Function
|
||||
-- @param #TIRESIAS self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #TIRESIAS self
|
||||
function TIRESIAS:onafterStop(From, Event, To)
|
||||
self:T({From, Event, To})
|
||||
self:UnHandleEvent(EVENTS.PlayerEnterAircraft)
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- End
|
||||
--
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -87,7 +87,7 @@
|
||||
-- @field #number respawndelay Delay before respawn in seconds.
|
||||
-- @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 Ops.FlightControl#FLIGHTCONTROL flightcontrol Flight control of this warehouse.
|
||||
-- @field OPS.FlightControl#FLIGHTCONTROL flightcontrol Flight control of this warehouse.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- Have your assets at the right place at the right time - or not!
|
||||
@@ -1629,7 +1629,7 @@ WAREHOUSE = {
|
||||
-- @field #boolean arrived If true, asset arrived at its destination.
|
||||
--
|
||||
-- @field #number damage Damage of asset group in percent.
|
||||
-- @field Ops.AirWing#AIRWING.Payload payload The payload of the asset.
|
||||
-- @field Ops.Airwing#AIRWING.Payload payload The payload of the asset.
|
||||
-- @field Ops.OpsGroup#OPSGROUP flightgroup The flightgroup object.
|
||||
-- @field Ops.Cohort#COHORT cohort The cohort this asset belongs to.
|
||||
-- @field Ops.Legion#LEGION legion The legion this asset belonts to.
|
||||
@@ -3414,7 +3414,7 @@ end
|
||||
-- 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 #string From From state.
|
||||
-- @param #string Event Event.
|
||||
@@ -3595,6 +3595,7 @@ function WAREHOUSE:onafterStatus(From, Event, To)
|
||||
local Trepair=self:GetRunwayRepairtime()
|
||||
self:I(self.lid..string.format("Runway destroyed! Will be repaired in %d sec", Trepair))
|
||||
if Trepair==0 then
|
||||
self.runwaydestroyed = nil
|
||||
self:RunwayRepaired()
|
||||
end
|
||||
end
|
||||
@@ -5392,7 +5393,8 @@ function WAREHOUSE:onafterRunwayDestroyed(From, Event, To)
|
||||
self:_InfoMessage(text)
|
||||
|
||||
self.runwaydestroyed=timer.getAbsTime()
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- On after "RunwayRepaired" event.
|
||||
@@ -5407,7 +5409,8 @@ function WAREHOUSE:onafterRunwayRepaired(From, Event, To)
|
||||
self:_InfoMessage(text)
|
||||
|
||||
self.runwaydestroyed=nil
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -7404,6 +7407,8 @@ function WAREHOUSE:_CheckRequestNow(request)
|
||||
|
||||
-- Check if at least one (cargo) asset is available.
|
||||
if _nassets>0 then
|
||||
|
||||
local asset=_assets[1] --#WAREHOUSE.Assetitem
|
||||
|
||||
-- Get the attibute of the requested asset.
|
||||
_assetattribute=_assets[1].attribute
|
||||
@@ -7414,11 +7419,24 @@ function WAREHOUSE:_CheckRequestNow(request)
|
||||
if _assetcategory==Group.Category.AIRPLANE or _assetcategory==Group.Category.HELICOPTER 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 _assetairstart then
|
||||
-- Airstart no need to check parking
|
||||
-- Airstart no need to check parking
|
||||
else
|
||||
|
||||
-- Check parking.
|
||||
@@ -7530,6 +7548,9 @@ function WAREHOUSE:_CheckRequestNow(request)
|
||||
self:_InfoMessage(text, 5)
|
||||
return false
|
||||
end
|
||||
|
||||
elseif _assetcategory==Group.Category.AIRPLANE or _assetcategory==Group.Category.HELICOPTER then
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
--
|
||||
-- ## 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,180 +1,181 @@
|
||||
__Moose.Include( 'Scripts/Moose/Utilities/Enums.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Utilities/FiFo.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Utilities/Socket.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Utilities/STTS.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Utilities/Templates.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Enums.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Utils.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Profiler.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Templates.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/STTS.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/FiFo.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( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Astar.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Beacon.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Condition.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/UserFlag.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Report.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Scheduler.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/ScheduleDispatcher.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Event.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Settings.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Menu.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Zone.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Zone_Detection.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Database.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Set.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Point.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Velocity.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Message.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Fsm.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Spawn.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/SpawnStatic.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Timer.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Goal.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Spot.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/MarkerOps_Base.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/TextAndSound.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/Pathline.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Core/ClientMenu.lua')
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/Core/Astar.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Beacon.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Condition.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/ClientMenu.lua')
|
||||
__Moose.Include( 'Scripts/Moose/Core/Database.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Event.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Fsm.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Goal.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/MarkerOps_Base.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Menu.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Message.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Point.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Report.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/ScheduleDispatcher.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Scheduler.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Set.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Settings.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Spawn.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/SpawnStatic.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Spot.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/TextAndSound.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Timer.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/UserFlag.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Velocity.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Zone_Detection.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Zone.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Core/Pathline.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Object.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Identifiable.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Positionable.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Controllable.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Group.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Unit.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Client.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Static.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Airbase.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Scenery.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Marker.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Weapon.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Net.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Wrapper/Storage.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Airbase.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Client.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Controllable.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Group.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Identifiable.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Marker.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Object.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Positionable.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Scenery.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Static.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Unit.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Weapon.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Net.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Wrapper/Storage.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/Cargo.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/CargoUnit.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/CargoSlingload.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/CargoCrate.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Cargo/CargoGroup.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/Cargo/Cargo.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Cargo/CargoUnit.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Cargo/CargoSlingload.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Cargo/CargoCrate.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Cargo/CargoGroup.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Scoring.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/CleanUp.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Movement.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Sead.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Escort.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/MissileTrainer.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ATC_Ground.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Detection.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/DetectionZones.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Designate.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/RAT.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Range.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ZoneGoal.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ZoneGoalCoalition.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ZoneCaptureCoalition.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Artillery.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Suppression.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/PseudoATC.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Warehouse.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Fox.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Mantis.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Shorad.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/AICSAR.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/AmmoTruck.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Autolase.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ZoneGoalCargo.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Tiresias.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Stratego.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/Functional/AICSAR.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/AmmoTruck.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Artillery.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/ATC_Ground.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Autolase.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/CleanUp.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Designate.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Detection.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/DetectionZones.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Escort.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Fox.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Mantis.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/MissileTrainer.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Movement.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/PseudoATC.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Range.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/RAT.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Scoring.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Sead.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Shorad.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Suppression.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/Warehouse.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/ZoneCaptureCoalition.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/ZoneGoal.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/ZoneGoalCargo.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Functional/ZoneGoalCoalition.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Airboss.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/RecoveryTanker.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/RescueHelo.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/ATIS.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/CTLD.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/CSAR.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/AirWing.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/ArmyGroup.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Auftrag.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Awacs.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Brigade.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Chief.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Cohort.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Commander.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Fleet.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/FlightControl.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/FlightGroup.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Flotilla.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Intelligence.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Legion.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/NavyGroup.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Operation.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/OpsGroup.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/OpsTransport.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/OpsZone.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Platoon.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/PlayerTask.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/PlayerRecce.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Squadron.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Target.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/EasyGCICAP.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Airboss.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/AirWing.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/ArmyGroup.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/ATIS.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Auftrag.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Awacs.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Brigade.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Chief.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Cohort.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Commander.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/CSAR.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/CTLD.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Fleet.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/FlightControl.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/FlightGroup.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Flotilla.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Intelligence.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Legion.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/NavyGroup.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Operation.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/OpsGroup.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/OpsTransport.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/OpsZone.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Platoon.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/PlayerTask.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/PlayerRecce.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/RecoveryTanker.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/RescueHelo.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Squadron.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Target.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/EasyGCICAP.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Balancer.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Air.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Air_Patrol.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Air_Engage.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2A_Patrol.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2A_Cap.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2A_Gci.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2A_Dispatcher.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2G_BAI.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2G_CAS.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2G_SEAD.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_A2G_Dispatcher.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Patrol.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_CAP.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_CAS.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_BAI.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Formation.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Escort.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Escort_Request.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Escort_Dispatcher.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Escort_Dispatcher_Request.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_APC.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Helicopter.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Airplane.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Ship.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher_APC.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher_Airplane.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/AI/AI_Cargo_Dispatcher_Ship.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Balancer.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air_Patrol.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air_Engage.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2A_Patrol.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2A_Cap.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2A_Gci.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2A_Dispatcher.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2G_BAI.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2G_CAS.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2G_SEAD.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_A2G_Dispatcher.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Patrol.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_CAP.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_CAS.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_BAI.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Formation.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Escort.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Escort_Request.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Escort_Dispatcher.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Escort_Dispatcher_Request.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_APC.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Helicopter.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Airplane.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Ship.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher_APC.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher_Airplane.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Cargo_Dispatcher_Ship.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Assign.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Route.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Account.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Actions/Act_Assist.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/Actions/Act_Assign.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Actions/Act_Route.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Actions/Act_Account.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Actions/Act_Assist.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/UserSound.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/SoundOutput.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/Radio.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/RadioQueue.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/RadioSpeech.lua' )
|
||||
__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Sound/SRS.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/Sound/Radio.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Sound/RadioQueue.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Sound/RadioSpeech.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Sound/SoundOutput.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Sound/SRS.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Sound/UserSound.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( 'Scripts/Moose/Tasking/CommandCenter.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Tasking/Mission.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Tasking/Task.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Tasking/TaskInfo.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Tasking/Task_Manager.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Tasking/DetectionManager.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/Globals.lua' )
|
||||
|
||||
@@ -312,10 +312,16 @@
|
||||
--
|
||||
-- atis=ATIS:New("Batumi", 305, radio.modulation.AM)
|
||||
-- atis:SetSRS("D:\\DCS\\_SRS\\", "male", "en-US")
|
||||
-- atis:Start()
|
||||
-- atis:Start()
|
||||
--
|
||||
-- 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
|
||||
--
|
||||
-- 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 =
|
||||
{
|
||||
HOURS = "hours",
|
||||
TIME = "hours",
|
||||
TIME = "Hours",
|
||||
NOCLOUDINFO = "Cloud coverage information not available",
|
||||
OVERCAST = "Overcast",
|
||||
BROKEN = "Broken clouds",
|
||||
@@ -884,13 +890,14 @@ _ATIS = {}
|
||||
|
||||
--- ATIS class version.
|
||||
-- @field #string version
|
||||
ATIS.version = "0.10.3"
|
||||
ATIS.version = "1.0.0"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: Correct fog for elevation.
|
||||
-- DONE: Option to add multiple frequencies for SRS
|
||||
-- DONE: Zulu time --> Zulu in output.
|
||||
-- DONE: Fix for AB not having a runway - Helopost like Naqoura
|
||||
-- DONE: Add new Normandy airfields.
|
||||
@@ -899,7 +906,7 @@ ATIS.version = "0.10.3"
|
||||
-- DONE: Visibility reported twice over SRS
|
||||
-- DONE: Add text report for output.
|
||||
-- DONE: Add stop FMS functions.
|
||||
-- NOGO: Use local time. Not realisitc!
|
||||
-- NOGO: Use local time. Not realistic!
|
||||
-- DONE: Dew point. Approx. done.
|
||||
-- DONE: Metric units.
|
||||
-- DONE: Set UTC correction.
|
||||
@@ -915,8 +922,8 @@ ATIS.version = "0.10.3"
|
||||
--- Create a new ATIS class object for a specific airbase.
|
||||
-- @param #ATIS self
|
||||
-- @param #string AirbaseName Name of the airbase.
|
||||
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz.
|
||||
-- @param #number Modulation Radio modulation: 0=AM, 1=FM. Default 0=AM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators.
|
||||
-- @param #number 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. When using **SRS** this can be passed as a table of multiple modulations.
|
||||
-- @return #ATIS self
|
||||
function ATIS:New(AirbaseName, Frequency, Modulation)
|
||||
|
||||
@@ -1519,34 +1526,62 @@ function ATIS:MarkRunways( markall )
|
||||
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 #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 Culture Culture, e.g. "en-GB" (default).
|
||||
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`.
|
||||
-- @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
|
||||
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.msrs=MSRS:New(PathToSRS, self.frequency, self.modulation)
|
||||
self.msrs:SetGender(Gender)
|
||||
self.msrs:SetCulture(Culture)
|
||||
self.msrs:SetVoice(Voice)
|
||||
self.msrs:SetPort(Port)
|
||||
|
||||
local path = PathToSRS or MSRS.path
|
||||
local gender = Gender or MSRS.gender
|
||||
local culture = Culture or MSRS.culture
|
||||
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: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.msrsQ = MSRSQUEUE:New("ATIS")
|
||||
self.msrsQ:SetTransmitOnlyWithPlayers(self.TransmitOnlyWithPlayers)
|
||||
if self.dTQueueCheck<=10 then
|
||||
self:SetQueueUpdateTime(90)
|
||||
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
|
||||
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
|
||||
return self
|
||||
end
|
||||
@@ -1594,8 +1629,16 @@ function ATIS:onafterStart( From, Event, To )
|
||||
end
|
||||
|
||||
-- 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.
|
||||
if not self.useSRS then
|
||||
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
|
||||
|
||||
-- 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
|
||||
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
|
||||
@@ -2919,8 +2972,17 @@ function ATIS:UpdateMarker( information, runact, wind, altimeter, temperature )
|
||||
if self.markerid then
|
||||
self.airbase:GetCoordinate():RemoveMark( self.markerid )
|
||||
end
|
||||
|
||||
local text = string.format( "ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName( self.modulation ), tostring( information ) )
|
||||
local text = ""
|
||||
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( wind ) )
|
||||
text = text .. string.format( "%s\n", tostring( altimeter ) )
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Airwing).
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Airwing).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -56,6 +56,8 @@
|
||||
-- @field #boolean despawnAfterHolding Aircraft are despawned after holding.
|
||||
-- @field #boolean capOptionPatrolRaceTrack Use closer patrol race track or standard orbit auftrag.
|
||||
-- @field #number capFormation If capOptionPatrolRaceTrack is true, set the formation, also.
|
||||
-- @field #number capOptionVaryStartTime If set, vary mission start time for CAP missions generated random between capOptionVaryStartTime and capOptionVaryEndTime
|
||||
-- @field #number capOptionVaryEndTime If set, vary mission start time for CAP missions generated random between capOptionVaryStartTime and capOptionVaryEndTime
|
||||
--
|
||||
-- @extends Ops.Legion#LEGION
|
||||
|
||||
@@ -132,6 +134,8 @@ AIRWING = {
|
||||
markpoints = false,
|
||||
capOptionPatrolRaceTrack = false,
|
||||
capFormation = nil,
|
||||
capOptionVaryStartTime = nil,
|
||||
capOptionVaryEndTime = nil,
|
||||
}
|
||||
|
||||
--- Payload data.
|
||||
@@ -183,7 +187,7 @@ AIRWING = {
|
||||
|
||||
--- AIRWING class version.
|
||||
-- @field #string version
|
||||
AIRWING.version="0.9.4"
|
||||
AIRWING.version="0.9.5"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
@@ -721,6 +725,17 @@ function AIRWING:SetCapCloseRaceTrack(OnOff)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set CAP mission start to vary randomly between Start end End seconds.
|
||||
-- @param #AIRWING self
|
||||
-- @param #number Start
|
||||
-- @param #number End
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:SetCapStartTimeVariation(Start, End)
|
||||
self.capOptionVaryStartTime = Start or 5
|
||||
self.capOptionVaryEndTime = End or 60
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set number of TANKER flights with Boom constantly in the air.
|
||||
-- @param #AIRWING self
|
||||
-- @param #number Nboom Number of flights. Default 1.
|
||||
@@ -1165,6 +1180,14 @@ function AIRWING:CheckCAP()
|
||||
|
||||
end
|
||||
|
||||
if self.capOptionVaryStartTime then
|
||||
|
||||
local ClockStart = math.random(self.capOptionVaryStartTime, self.capOptionVaryEndTime)
|
||||
|
||||
missionCAP:SetTime(ClockStart)
|
||||
|
||||
end
|
||||
|
||||
missionCAP.patroldata=patrol
|
||||
|
||||
patrol.noccupied=patrol.noccupied+1
|
||||
@@ -1398,9 +1421,9 @@ function AIRWING:GetTankerForFlight(flightgroup)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Add the ability to call back an Ops.Awacs#AWACS object with an FSM call "FlightOnMission(FlightGroup, Mission)".
|
||||
--- Add the ability to call back an Ops.AWACS#AWACS object with an FSM call "FlightOnMission(FlightGroup, Mission)".
|
||||
-- @param #AIRWING self
|
||||
-- @param Ops.Awacs#AWACS ConnectecdAwacs
|
||||
-- @param Ops.AWACS#AWACS ConnectecdAwacs
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:SetUsingOpsAwacs(ConnectecdAwacs)
|
||||
self:I(self.lid .. "Added AWACS Object: "..ConnectecdAwacs:GetName() or "unknown")
|
||||
@@ -1409,7 +1432,7 @@ function AIRWING:SetUsingOpsAwacs(ConnectecdAwacs)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Remove the ability to call back an Ops.Awacs#AWACS object with an FSM call "FlightOnMission(FlightGroup, Mission)".
|
||||
--- Remove the ability to call back an Ops.AWACS#AWACS object with an FSM call "FlightOnMission(FlightGroup, Mission)".
|
||||
-- @param #AIRWING self
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:RemoveUsingOpsAwacs()
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
--
|
||||
-- ## 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.
|
||||
--
|
||||
-- ## IMPORTANT
|
||||
@@ -3062,7 +3062,7 @@ function AIRBOSS:EnableSRS(PathToSRS,Port,Culture,Gender,Voice,GoogleCreds,Volum
|
||||
-- SRS
|
||||
local Frequency = self.AirbossRadio.frequency
|
||||
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:SetCoordinate(self:GetCoordinate())
|
||||
self.SRS:SetCulture(Culture or "en-US")
|
||||
@@ -3072,9 +3072,11 @@ function AIRBOSS:EnableSRS(PathToSRS,Port,Culture,Gender,Voice,GoogleCreds,Volum
|
||||
self.SRS:SetPort(Port or 5002)
|
||||
self.SRS:SetLabel(self.AirbossRadio.alias or "AIRBOSS")
|
||||
self.SRS:SetCoordinate(self.carrier:GetCoordinate())
|
||||
self.SRS:SetVolume(Volume or 1)
|
||||
--self.SRS:SetModulations(Modulations)
|
||||
if GoogleCreds then
|
||||
self.SRS:SetGoogle(GoogleCreds)
|
||||
self.SRS:SetProviderOptionsGoogle(GoogleCreds,GoogleCreds)
|
||||
self.SRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
if Voice then
|
||||
self.SRS:SetVoice(Voice)
|
||||
@@ -8212,7 +8214,7 @@ function AIRBOSS:OnEventBirth( EventData )
|
||||
self:E( EventData )
|
||||
return
|
||||
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( EventData )
|
||||
return
|
||||
@@ -9753,7 +9755,7 @@ function AIRBOSS:_Groove( playerData )
|
||||
local glideslopeError = groovedata.GSE
|
||||
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
|
||||
playerData.TIG0 = timer.getTime()
|
||||
@@ -11197,7 +11199,7 @@ function AIRBOSS:_AttitudeMonitor( playerData )
|
||||
end
|
||||
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 )
|
||||
local dist = self:_GetOptLandingCoordinate():Get3DDistance( playerData.unit )
|
||||
local dist = self:_GetOptLandingCoordinate():Get3DDistance( playerData.unit:GetVec3() )
|
||||
-- Get player velocity in km/h.
|
||||
local vplayer = playerData.unit:GetVelocityKMH()
|
||||
-- Get carrier velocity in km/h.
|
||||
@@ -12121,16 +12123,18 @@ function AIRBOSS:_LSOgrade( playerData )
|
||||
local GIC, nIC = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.IC )
|
||||
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.
|
||||
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 Nv=nXX+nIM
|
||||
local nL=count(G, '_')/2
|
||||
local nS=count(G, '%(')
|
||||
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.
|
||||
local Tgroove=playerData.Tgroove
|
||||
@@ -12146,34 +12150,64 @@ function AIRBOSS:_LSOgrade( playerData )
|
||||
G = "Unicorn"
|
||||
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
|
||||
-- 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
|
||||
if vtol then
|
||||
|
||||
-- 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
|
||||
|
||||
-- Replace" )"( and "__"
|
||||
@@ -14957,7 +14991,7 @@ function AIRBOSS:SetSRSPilotVoice( Voice, Gender, Culture )
|
||||
self.PilotRadio.gender = Gender or "male"
|
||||
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
|
||||
end
|
||||
|
||||
@@ -15606,6 +15640,11 @@ function AIRBOSS:_Number2Radio( radio, number, delay, interval, pilotcall )
|
||||
Sender = "PilotCall"
|
||||
end
|
||||
|
||||
if Sender=="" then
|
||||
self:E( self.lid .. string.format( "ERROR: Sender unknown!") )
|
||||
return
|
||||
end
|
||||
|
||||
-- Split string into characters.
|
||||
local numbers = _split( number )
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
-- ===
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Armygroup).
|
||||
--
|
||||
--
|
||||
-- Demo missions can be found on [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Armygroup).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **funkyfranky**
|
||||
@@ -1860,6 +1860,7 @@ function ARMYGROUP:_UpdateEngageTarget()
|
||||
else
|
||||
|
||||
-- Could not get position of target (not alive any more?) ==> Disengage.
|
||||
self:T(self.lid.."Could not get position of target ==> Disengage!")
|
||||
self:Disengage()
|
||||
|
||||
end
|
||||
@@ -1867,6 +1868,7 @@ function ARMYGROUP:_UpdateEngageTarget()
|
||||
else
|
||||
|
||||
-- Target not alive any more ==> Disengage.
|
||||
self:T(self.lid.."Target not ALIVE ==> Disengage!")
|
||||
self:Disengage()
|
||||
|
||||
end
|
||||
@@ -2067,10 +2069,11 @@ function ARMYGROUP:_InitGroup(Template)
|
||||
self.speedMax=self.group:GetSpeedMax()
|
||||
|
||||
-- Is group mobile?
|
||||
if self.speedMax>3.6 then
|
||||
if self.speedMax and self.speedMax>3.6 then
|
||||
self.isMobile=true
|
||||
else
|
||||
self.isMobile=false
|
||||
self.speedMax = 0
|
||||
end
|
||||
|
||||
-- Cruise speed in km/h
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
-- @field #table NassetsLegMax Number of required warehouse assets for each assigned legion.
|
||||
-- @field #table requestID The ID of the queued warehouse request. Necessary to cancel the request if the mission was cancelled before the request is processed.
|
||||
-- @field #table payloads User specified airwing payloads for this mission. Only these will be considered for the job!
|
||||
-- @field Ops.AirWing#AIRWING.PatrolData patroldata Patrol data.
|
||||
-- @field Ops.Airwing#AIRWING.PatrolData patroldata Patrol data.
|
||||
--
|
||||
-- @field #table specialLegions User specified legions assigned for this mission. Only these will be considered for the job!
|
||||
-- @field #table specialCohorts User specified cohorts assigned for this mission. Only these will be considered for the job!
|
||||
@@ -338,7 +338,7 @@
|
||||
--
|
||||
-- ## Legion Level
|
||||
--
|
||||
-- Adding an AUFTRAG to an airwing is done via the @{Ops.AirWing#AIRWING.AddMission} function. See AIRWING docs for further details.
|
||||
-- Adding an AUFTRAG to an airwing is done via the @{Ops.Airwing#AIRWING.AddMission} function. See AIRWING docs for further details.
|
||||
-- Similarly, an AUFTRAG can be added to a brigade via the @{Ops.Brigade#BRIGADE.AddMission} function.
|
||||
--
|
||||
-- ## Commander Level
|
||||
@@ -434,6 +434,7 @@ _AUFTRAGSNR=0
|
||||
-- @field #string ARMORATTACK Armor attack.
|
||||
-- @field #string CASENHANCED Enhanced CAS.
|
||||
-- @field #string HOVER Hover.
|
||||
-- @field #string LANDATCOORDINATE Land at coordinate.
|
||||
-- @field #string GROUNDATTACK Ground attack.
|
||||
-- @field #string CARGOTRANSPORT Cargo transport.
|
||||
-- @field #string RELOCATECOHORT Relocate a cohort from one legion to another.
|
||||
@@ -480,6 +481,7 @@ AUFTRAG.Type={
|
||||
ARMORATTACK="Armor Attack",
|
||||
CASENHANCED="CAS Enhanced",
|
||||
HOVER="Hover",
|
||||
LANDATCOORDINATE="Land at Coordinate",
|
||||
GROUNDATTACK="Ground Attack",
|
||||
CARGOTRANSPORT="Cargo Transport",
|
||||
RELOCATECOHORT="Relocate Cohort",
|
||||
@@ -1052,6 +1054,42 @@ function AUFTRAG:NewHOVER(Coordinate, Altitude, Time, Speed, MissionAlt)
|
||||
return mission
|
||||
end
|
||||
|
||||
--- **[AIR ROTARY]** Create an LANDATCOORDINATE mission.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Point#COORDINATE Coordinate Where to land.
|
||||
-- @param #number OuterRadius (Optional) Vary the coordinate by this many feet, e.g. get a new random coordinate between OuterRadius and (optionally) avoiding InnerRadius of the coordinate.
|
||||
-- @param #number InnerRadius (Optional) Vary the coordinate by this many feet, e.g. get a new random coordinate between OuterRadius and (optionally) avoiding InnerRadius of the coordinate.
|
||||
-- @param #number Time Time in seconds to stay. Default 300 seconds.
|
||||
-- @param #number Speed Speed in knots to fly to the target coordinate. Default 150kn.
|
||||
-- @param #number MissionAlt Altitude to fly towards the mission in feet AGL. Default 1000ft.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewLANDATCOORDINATE(Coordinate, OuterRadius, InnerRadius, Time, Speed, MissionAlt)
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.LANDATCOORDINATE)
|
||||
|
||||
mission:_TargetFromObject(Coordinate)
|
||||
|
||||
mission.stayTime = Time or 300
|
||||
mission.stayAt = Coordinate
|
||||
self:SetMissionSpeed(Speed or 150)
|
||||
self:SetMissionAltitude(MissionAlt or 1000)
|
||||
|
||||
if OuterRadius then
|
||||
mission.stayAt = Coordinate:GetRandomCoordinateInRadius(UTILS.FeetToMeters(OuterRadius),UTILS.FeetToMeters(InnerRadius or 0))
|
||||
end
|
||||
|
||||
-- Mission options:
|
||||
mission.missionFraction=0.9
|
||||
mission.optionROE=ENUMS.ROE.ReturnFire
|
||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||
|
||||
mission.categories={AUFTRAG.Category.HELICOPTER}
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
--- **[AIR]** Create an enhanced orbit race track mission. Planes will keep closer to the track.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Point#COORDINATE Coordinate Where to start the race track.
|
||||
@@ -3696,7 +3734,7 @@ end
|
||||
|
||||
--- Add a required payload for this mission. Only these payloads will be used for this mission. If they are not available, the mission cannot start. Only available for use with an AIRWING.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.AirWing#AIRWING.Payload Payload Required payload.
|
||||
-- @param Ops.Airwing#AIRWING.Payload Payload Required payload.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:AddRequiredPayload(Payload)
|
||||
|
||||
@@ -6443,7 +6481,19 @@ function AUFTRAG:GetDCSMissionTask()
|
||||
param.missionAltitude = self.missionAltitude
|
||||
|
||||
DCStask.params=param
|
||||
|
||||
table.insert(DCStasks, DCStask)
|
||||
|
||||
elseif self.type==AUFTRAG.Type.LANDATCOORDINATE then
|
||||
|
||||
---------------------
|
||||
-- LANDATCOORDINATE Mission
|
||||
---------------------
|
||||
|
||||
local DCStask={}
|
||||
local Vec2 = self.stayAt:GetVec2()
|
||||
local DCStask = CONTROLLABLE.TaskLandAtVec2(nil,Vec2,self.stayTime)
|
||||
|
||||
table.insert(DCStasks, DCStask)
|
||||
|
||||
elseif self.type==AUFTRAG.Type.ONGUARD or self.type==AUFTRAG.Type.ARMOREDGUARD then
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
-- ===
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Awacs/).
|
||||
--
|
||||
--
|
||||
-- Demo missions can be found on [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Awacs/).
|
||||
--
|
||||
-- ## Videos:
|
||||
--
|
||||
-- Demo videos can be found on [Youtube](https://www.youtube.com/watch?v=ocdy8QzTNN4&list=PLFxp425SeXnq-oS0DSjam1HtddywH8i_k)
|
||||
@@ -17,7 +17,7 @@
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **applevangelist**
|
||||
-- @date Last Update July 2023
|
||||
-- @date Last Update Jan 2024
|
||||
-- @module Ops.AWACS
|
||||
-- @image OPS_AWACS.jpg
|
||||
|
||||
@@ -36,7 +36,7 @@ do
|
||||
-- @field #number Frequency
|
||||
-- @field #number Modulation
|
||||
-- @field Wrapper.Airbase#AIRBASE Airbase
|
||||
-- @field Ops.AirWing#AIRWING AirWing
|
||||
-- @field Ops.Airwing#AIRWING AirWing
|
||||
-- @field #number AwacsAngels
|
||||
-- @field Core.Zone#ZONE OrbitZone
|
||||
-- @field #number CallSign
|
||||
@@ -121,6 +121,7 @@ do
|
||||
-- @field #number TacticalIncrFreq
|
||||
-- @field #number TacticalModulation
|
||||
-- @field #number TacticalInterval
|
||||
-- @field Core.Set#SET_GROUP DetectionSet
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
|
||||
@@ -158,10 +159,10 @@ do
|
||||
--
|
||||
-- ## 3 Airwing(s)
|
||||
--
|
||||
-- The AWACS plane, the optional escort planes, and the AI CAP planes work based on the @{Ops.AirWing} class. Read and understand the manual for this class in
|
||||
-- The AWACS plane, the optional escort planes, and the AI CAP planes work based on the @{Ops.Airwing} class. Read and understand the manual for this class in
|
||||
-- order to set everything up correctly. You will at least need one Squadron containing the AWACS plane itself.
|
||||
--
|
||||
-- Set up the AirWing
|
||||
-- Set up the Airwing
|
||||
--
|
||||
-- local AwacsAW = AIRWING:New("AirForce WH-1","AirForce One")
|
||||
-- AwacsAW:SetMarker(false)
|
||||
@@ -225,7 +226,7 @@ do
|
||||
--
|
||||
-- ## 5 Set up AWACS
|
||||
--
|
||||
-- -- Set up AWACS called "AWACS North". It will use the AwacsAW AirWing set up above and be of the "blue" coalition. Homebase is Kutaisi.
|
||||
-- -- Set up AWACS called "AWACS North". It will use the AwacsAW Airwing set up above and be of the "blue" coalition. Homebase is Kutaisi.
|
||||
-- -- The AWACS Orbit Zone is a round zone set in the mission editor named "Awacs Orbit", the FEZ is a Polygon-Zone called "Rock" we have also
|
||||
-- -- set up in the mission editor with a late activated helo named "Rock#ZONE_POLYGON". Note this also sets the BullsEye to be referenced as "Rock".
|
||||
-- -- The CAP station zone is called "Fremont". We will be on 255 AM.
|
||||
@@ -247,7 +248,7 @@ do
|
||||
--
|
||||
-- ### 5.1 Alternative - Set up as GCI (no AWACS plane needed) Theater Air Control System (TACS)
|
||||
--
|
||||
-- -- Set up as TACS called "GCI Senaki". It will use the AwacsAW AirWing set up above and be of the "blue" coalition. Homebase is Senaki.
|
||||
-- -- Set up as TACS called "GCI Senaki". It will use the AwacsAW Airwing set up above and be of the "blue" coalition. Homebase is Senaki.
|
||||
-- -- No need to set the AWACS Orbit Zone; the FEZ is still a Polygon-Zone called "Rock" we have also
|
||||
-- -- set up in the mission editor with a late activated helo named "Rock#ZONE_POLYGON". Note this also sets the BullsEye to be referenced as "Rock".
|
||||
-- -- The CAP station zone is called "Fremont". We will be on 255 AM. Note the Orbit Zone is given as *nil* in the `New()`-Statement
|
||||
@@ -507,7 +508,7 @@ do
|
||||
-- @field #AWACS
|
||||
AWACS = {
|
||||
ClassName = "AWACS", -- #string
|
||||
version = "0.2.58", -- #string
|
||||
version = "0.2.64", -- #string
|
||||
lid = "", -- #string
|
||||
coalition = coalition.side.BLUE, -- #number
|
||||
coalitiontxt = "blue", -- #string
|
||||
@@ -603,6 +604,7 @@ AWACS = {
|
||||
TacticalIncrFreq = 0.5,
|
||||
TacticalModulation = radio.modulation.AM,
|
||||
TacticalInterval = 120,
|
||||
DetectionSet = nil,
|
||||
}
|
||||
|
||||
---
|
||||
@@ -850,8 +852,8 @@ AWACS.Messages = {
|
||||
--- Contact Data
|
||||
-- @type AWACS.ManagedContact
|
||||
-- @field #number CID
|
||||
-- @field Ops.Intelligence#INTEL.Contact Contact
|
||||
-- @field Ops.Intelligence#INTEL.Cluster Cluster
|
||||
-- @field Ops.Intel#INTEL.Contact Contact
|
||||
-- @field Ops.Intel#INTEL.Cluster Cluster
|
||||
-- @field #string IFF -- ID'ed or not (yet)
|
||||
-- @field Ops.Target#TARGET Target
|
||||
-- @field #number LinkedTask --> TID
|
||||
@@ -900,8 +902,8 @@ AWACS.TaskStatus = {
|
||||
-- @field #AWACS.TaskStatus Status
|
||||
-- @field #AWACS.TaskDescription ToDo
|
||||
-- @field #string ScreenText Long descrition
|
||||
-- @field Ops.Intelligence#INTEL.Contact Contact
|
||||
-- @field Ops.Intelligence#INTEL.Cluster Cluster
|
||||
-- @field Ops.Intel#INTEL.Contact Contact
|
||||
-- @field Ops.Intel#INTEL.Cluster Cluster
|
||||
-- @field #number CurrentAuftrag
|
||||
-- @field #number RequestedTimestamp
|
||||
|
||||
@@ -954,7 +956,7 @@ AWACS.TaskStatus = {
|
||||
-- DONE - Shift Change, Change on asset RTB or dead or mission done (done for AWACS and Escorts)
|
||||
-- DONE - TripWire - WIP - Threat (35nm), Meld (45nm, on mission), Merged (<3nm)
|
||||
--
|
||||
-- DONE - Escorts via AirWing not staying on
|
||||
-- DONE - Escorts via Airwing not staying on
|
||||
-- DONE - Borders for INTEL. Optional, i.e. land based defense within borders
|
||||
-- DONE - Use AO as Anchor of Bulls, AO as default
|
||||
-- DONE - SRS TTS output
|
||||
@@ -982,7 +984,7 @@ AWACS.TaskStatus = {
|
||||
--- Set up a new AI AWACS.
|
||||
-- @param #AWACS self
|
||||
-- @param #string Name Name of this AWACS for the radio menu.
|
||||
-- @param #string AirWing The core Ops.AirWing#AIRWING managing the AWACS, Escort and (optionally) AI CAP planes for us.
|
||||
-- @param #string AirWing The core Ops.Airwing#AIRWING managing the AWACS, Escort and (optionally) AI CAP planes for us.
|
||||
-- @param #number Coalition Coalition, e.g. coalition.side.BLUE. Can also be passed as "blue", "red" or "neutral".
|
||||
-- @param #string AirbaseName Name of the home airbase.
|
||||
-- @param #string AwacsOrbit Name of the round, mission editor created zone where this AWACS orbits.
|
||||
@@ -1022,7 +1024,7 @@ function AWACS:New(Name,AirWing,Coalition,AirbaseName,AwacsOrbit,OpsZone,Station
|
||||
|
||||
-- base setup
|
||||
self.Name = Name -- #string
|
||||
self.AirWing = AirWing -- Ops.AirWing#AIRWING object
|
||||
self.AirWing = AirWing -- Ops.Airwing#AIRWING object
|
||||
|
||||
AirWing:SetUsingOpsAwacs(self)
|
||||
|
||||
@@ -1030,7 +1032,7 @@ function AWACS:New(Name,AirWing,Coalition,AirbaseName,AwacsOrbit,OpsZone,Station
|
||||
self.CAPAirwings:Push(AirWing,1)
|
||||
|
||||
self.AwacsFG = nil
|
||||
--self.AwacsPayload = PayLoad -- Ops.AirWing#AIRWING.Payload
|
||||
--self.AwacsPayload = PayLoad -- Ops.Airwing#AIRWING.Payload
|
||||
--self.ModernEra = true -- use of EPLRS
|
||||
self.RadarBlur = 15 -- +/-15% detection precision i.e. 85-115 reported group size
|
||||
if type(OpsZone) == "string" then
|
||||
@@ -1382,7 +1384,7 @@ end
|
||||
-- Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- [User] Set the tactical information option, create 10 radio channels groups can subscribe and get Bogey Dope on a specific frequency automatically.
|
||||
--- [User] Set the tactical information option, create 10 radio channels groups can subscribe and get Bogey Dope on a specific frequency automatically. You **need** to set up SRS first before using this!
|
||||
-- @param #AWACS self
|
||||
-- @param #number BaseFreq Base Frequency to use, defaults to 130.
|
||||
-- @param #number Increase Increase to use, defaults to 0.5, thus channels created are 130, 130.5, 131 .. etc.
|
||||
@@ -1392,6 +1394,10 @@ end
|
||||
-- @return #AWACS self
|
||||
function AWACS:SetTacticalRadios(BaseFreq,Increase,Modulation,Interval,Number)
|
||||
self:T(self.lid.."SetTacticalRadios")
|
||||
if not self.AwacsSRS then
|
||||
MESSAGE:New("AWACS: Setup SRS in your code BEFORE trying to add tac radios please!",30,"ERROR",true):ToLog():ToAll()
|
||||
return self
|
||||
end
|
||||
self.TacticalMenu = true
|
||||
self.TacticalBaseFreq = BaseFreq or 130
|
||||
self.TacticalIncrFreq = Increase or 0.5
|
||||
@@ -1405,15 +1411,18 @@ function AWACS:SetTacticalRadios(BaseFreq,Increase,Modulation,Interval,Number)
|
||||
self.TacticalFrequencies[freq] = freq
|
||||
end
|
||||
if self.AwacsSRS then
|
||||
self.TacticalSRS = MSRS:New(self.PathToSRS,self.TacticalBaseFreq,self.TacticalModulation,self.Volume)
|
||||
self.TacticalSRS = MSRS:New(self.PathToSRS,self.TacticalBaseFreq,self.TacticalModulation,self.Backend)
|
||||
self.TacticalSRS:SetCoalition(self.coalition)
|
||||
self.TacticalSRS:SetGender(self.Gender)
|
||||
self.TacticalSRS:SetCulture(self.Culture)
|
||||
self.TacticalSRS:SetVoice(self.Voice)
|
||||
self.TacticalSRS:SetPort(self.Port)
|
||||
self.TacticalSRS:SetLabel("AWACS")
|
||||
self.TacticalSRS:SetVolume(self.Volume)
|
||||
if self.PathToGoogleKey then
|
||||
self.TacticalSRS:SetGoogle(self.PathToGoogleKey)
|
||||
--self.TacticalSRS:SetGoogle(self.PathToGoogleKey)
|
||||
self.TacticalSRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey)
|
||||
self.TacticalSRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
self.TacticalSRSQ = MSRSQUEUE:New("Tactical AWACS")
|
||||
end
|
||||
@@ -2069,38 +2078,50 @@ function AWACS:AddGroupToDetection(Group)
|
||||
return self
|
||||
end
|
||||
|
||||
--- [User] Set AWACS SRS TTS details - see @{Sound.SRS} for details
|
||||
--- [User] Set AWACS SRS TTS details - see @{Sound.SRS} for details. `SetSRS()` will try to use as many attributes configured with @{Sound.SRS#MSRS.LoadConfigFile}() as possible.
|
||||
-- @param #AWACS self
|
||||
-- @param #string PathToSRS Defaults to "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
-- @param #string Gender Defaults to "male"
|
||||
-- @param #string Culture Defaults to "en-US"
|
||||
-- @param #number Port Defaults to 5002
|
||||
-- @param #string Voice (Optional) Use a specifc voice with the @{Sound.SRS.SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||
-- @param #string Voice (Optional) Use a specifc voice with the @{Sound.SRS#SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||
-- Note that this must be installed on your windows system. Can also be Google voice types, if you are using Google TTS.
|
||||
-- @param #number Volume Volume - between 0.0 (silent) and 1.0 (loudest)
|
||||
-- @param #string PathToGoogleKey Path to your google key if you want to use google TTS
|
||||
-- @param #string PathToGoogleKey (Optional) Path to your google key if you want to use google TTS; if you use a config file for MSRS, hand in nil here.
|
||||
-- @param #string AccessKey (Optional) Your Google API access key. This is necessary if DCS-gRPC is used as backend; if you use a config file for MSRS, hand in nil here.
|
||||
-- @param #string Backend (Optional) Your MSRS Backend if different from your config file settings, e.g. MSRS.Backend.SRSEXE or MSRS.Backend.GRPC
|
||||
-- @return #AWACS self
|
||||
function AWACS:SetSRS(PathToSRS,Gender,Culture,Port,Voice,Volume,PathToGoogleKey)
|
||||
function AWACS:SetSRS(PathToSRS,Gender,Culture,Port,Voice,Volume,PathToGoogleKey,AccessKey,Backend)
|
||||
self:T(self.lid.."SetSRS")
|
||||
self.PathToSRS = PathToSRS or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
self.Gender = Gender or "male"
|
||||
self.Culture = Culture or "en-US"
|
||||
self.Port = Port or 5002
|
||||
self.Voice = Voice
|
||||
self.PathToSRS = PathToSRS or MSRS.path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||
self.Gender = Gender or MSRS.gender or "male"
|
||||
self.Culture = Culture or MSRS.culture or "en-US"
|
||||
self.Port = Port or MSRS.port or 5002
|
||||
self.Voice = Voice or MSRS.voice
|
||||
self.PathToGoogleKey = PathToGoogleKey
|
||||
self.AccessKey = AccessKey
|
||||
self.Volume = Volume or 1.0
|
||||
|
||||
self.AwacsSRS = MSRS:New(self.PathToSRS,self.MultiFrequency,self.MultiModulation,self.Volume)
|
||||
self.Backend = Backend or MSRS.backend
|
||||
BASE:I({backend = self.Backend})
|
||||
self.AwacsSRS = MSRS:New(self.PathToSRS,self.MultiFrequency,self.MultiModulation,self.Backend)
|
||||
self.AwacsSRS:SetCoalition(self.coalition)
|
||||
self.AwacsSRS:SetGender(self.Gender)
|
||||
self.AwacsSRS:SetCulture(self.Culture)
|
||||
self.AwacsSRS:SetVoice(self.Voice)
|
||||
self.AwacsSRS:SetPort(self.Port)
|
||||
self.AwacsSRS:SetLabel("AWACS")
|
||||
self.AwacsSRS:SetVolume(Volume)
|
||||
if self.PathToGoogleKey then
|
||||
self.AwacsSRS:SetGoogle(self.PathToGoogleKey)
|
||||
--self.AwacsSRS:SetGoogle(self.PathToGoogleKey)
|
||||
self.AwacsSRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey)
|
||||
self.AwacsSRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
|
||||
-- Pre-configured Google?
|
||||
if (not PathToGoogleKey) and self.AwacsSRS:GetProvider() == MSRS.Provider.GOOGLE then
|
||||
self.PathToGoogleKey = MSRS.poptions.gcloud.credentials
|
||||
self.Voice = Voice or MSRS.poptions.gcloud.voice
|
||||
self.AccessKey = AccessKey or MSRS.poptions.gcloud.key
|
||||
end
|
||||
self.AwacsSRS:SetVoice(self.Voice)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -2448,7 +2469,7 @@ function AWACS:_UpdateContactFromCluster(CID)
|
||||
|
||||
local function GetFirstAliveContact(table)
|
||||
for _,_contact in pairs (table) do
|
||||
local contact = _contact -- Ops.Intelligence#INTEL.Contact
|
||||
local contact = _contact -- Ops.Intel#INTEL.Contact
|
||||
if contact and contact.group and contact.group:IsAlive() then
|
||||
return contact
|
||||
end
|
||||
@@ -2484,13 +2505,22 @@ function AWACS:_CheckMerges()
|
||||
local cpos = contact.Cluster.coordinate or contact.Contact.position or contact.Contact.group:GetCoordinate()
|
||||
local dist = ppos:Get2DDistance(cpos)
|
||||
local distnm = UTILS.Round(UTILS.MetersToNM(dist),0)
|
||||
if (pilot.IsPlayer or self.debug) and distnm <= 5 and not contact.MergeCallDone then
|
||||
local label = contact.EngagementTag or ""
|
||||
if not contact.MergeCallDone or not string.find(label,pcallsign) then
|
||||
if (pilot.IsPlayer or self.debug) and distnm <= 5 then --and ((not contact.MergeCallDone) or (timer.getTime() - contact.MergeCallDone > 30)) then
|
||||
--local label = contact.EngagementTag or ""
|
||||
--if not contact.MergeCallDone or not string.find(label,pcallsign) then
|
||||
self:T(self.lid.."Merged")
|
||||
self:_MergedCall(_id)
|
||||
contact.MergeCallDone = true
|
||||
end
|
||||
--contact.MergeCallDone = true
|
||||
--end
|
||||
end
|
||||
if (pilot.IsPlayer or self.debug) and distnm >5 and distnm <= self.ThreatDistance then
|
||||
self:_ThreatRangeCall(_id,Contact)
|
||||
end
|
||||
if (pilot.IsPlayer or self.debug) and distnm > self.ThreatDistance and distnm <= self.MeldDistance then
|
||||
self:_MeldRangeCall(_id,Contact)
|
||||
end
|
||||
if (pilot.IsPlayer or self.debug) and distnm > self.MeldDistance and distnm <= self.TacDistance then
|
||||
self:_TACRangeCall(_id,Contact)
|
||||
end
|
||||
end
|
||||
)
|
||||
@@ -2935,7 +2965,7 @@ function AWACS:_Picture(Group,IsGeneral)
|
||||
if not self.intel then
|
||||
-- no intel yet!
|
||||
local picclean = self.gettext:GetEntry("PICCLEAN",self.locale)
|
||||
text = string.format(picclean,self.callsigntxt, gcallsign)
|
||||
text = string.format(picclean,gcallsign,self.callsigntxt)
|
||||
textScreen = text
|
||||
|
||||
self:_NewRadioEntry(text,text,GID,false,true,true,false)
|
||||
@@ -2988,7 +3018,10 @@ function AWACS:_Picture(Group,IsGeneral)
|
||||
|
||||
if clustersAO == 0 and clustersEWR == 0 then
|
||||
-- clean
|
||||
self:_NewRadioEntry(text,textScreen,GID,Outcome,true,true,false)
|
||||
local picclean = self.gettext:GetEntry("PICCLEAN",self.locale)
|
||||
text = string.format(picclean,gcallsign,self.callsigntxt)
|
||||
textScreen = text
|
||||
self:_NewRadioEntry(text,text,GID,Outcome,true,true,false)
|
||||
else
|
||||
|
||||
if clustersAO > 0 then
|
||||
@@ -3081,7 +3114,7 @@ function AWACS:_BogeyDope(Group,Tactical)
|
||||
local clean = self.gettext:GetEntry("CLEAN",self.locale)
|
||||
text = string.format(clean,self:_GetCallSign(Group,GID) or "Ghost 1", self.callsigntxt)
|
||||
|
||||
self:_NewRadioEntry(text,textScreen,GID,Outcome,Outcome,true,false,true,Tactical)
|
||||
self:_NewRadioEntry(text,text,GID,Outcome,Outcome,true,false,true,Tactical)
|
||||
|
||||
else
|
||||
|
||||
@@ -3123,9 +3156,13 @@ end
|
||||
function AWACS:_ShowAwacsInfo(Group)
|
||||
self:T(self.lid.."_ShowAwacsInfo")
|
||||
local report = REPORT:New("Info")
|
||||
local STN = self.STN
|
||||
report:Add("====================")
|
||||
report:Add(string.format("AWACS %s",self.callsigntxt))
|
||||
report:Add(string.format("Radio: %.3f %s",self.Frequency,UTILS.GetModulationName(self.Modulation)))
|
||||
if STN then
|
||||
report:Add(string.format("Link-16 STN: %s",STN))
|
||||
end
|
||||
report:Add(string.format("Bulls Alias: %s",self.AOName))
|
||||
report:Add(string.format("Coordinate: %s",self.AOCoordinate:ToStringLLDDM()))
|
||||
report:Add("====================")
|
||||
@@ -3663,7 +3700,7 @@ function AWACS:_CheckInAI(FlightGroup,Group,AuftragsNr)
|
||||
CAPVoice = self.CapVoices[math.floor(math.random(1,10))]
|
||||
end
|
||||
|
||||
FlightGroup:SetSRS(self.PathToSRS,self.CAPGender,self.CAPCulture,CAPVoice,self.Port,self.PathToGoogleKey,"FLIGHT")
|
||||
FlightGroup:SetSRS(self.PathToSRS,self.CAPGender,self.CAPCulture,CAPVoice,self.Port,self.PathToGoogleKey,"FLIGHT",1)
|
||||
|
||||
local checkai = self.gettext:GetEntry("CHECKINAI",self.locale)
|
||||
text = string.format(checkai,self.callsigntxt, managedgroup.CallSign, self.CAPTimeOnStation, self.AOName)
|
||||
@@ -4242,7 +4279,7 @@ function AWACS:_StartIntel(awacs)
|
||||
|
||||
intel:__Start(5)
|
||||
|
||||
self.intel = intel -- Ops.Intelligence#INTEL
|
||||
self.intel = intel -- Ops.Intel#INTEL
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -4402,8 +4439,8 @@ end
|
||||
-- @param #table Object Object for Ops.Target#TARGET assignment
|
||||
-- @param #AWACS.TaskStatus TaskStatus Status of this task
|
||||
-- @param Ops.Auftrag#AUFTRAG Auftrag The Auftrag for this task if any
|
||||
-- @param Ops.Intelligence#INTEL.Cluster Cluster Intel Cluster for this task
|
||||
-- @param Ops.Intelligence#INTEL.Contact Contact Intel Contact for this task
|
||||
-- @param Ops.Intel#INTEL.Cluster Cluster Intel Cluster for this task
|
||||
-- @param Ops.Intel#INTEL.Contact Contact Intel Contact for this task
|
||||
-- @return #number TID Task ID created
|
||||
function AWACS:_CreateTaskForGroup(GroupID,Description,ScreenText,Object,TaskStatus,Auftrag,Cluster,Contact)
|
||||
self:T(self.lid.."_CreateTaskForGroup "..GroupID .." Description: "..Description)
|
||||
@@ -4602,7 +4639,7 @@ function AWACS:_CheckTaskQueue()
|
||||
|
||||
-- Check ranges for TAC and MELD
|
||||
-- postions relative to CAP position
|
||||
|
||||
--[[
|
||||
local targetgrp = entry.Contact.group
|
||||
local position = entry.Contact.position or entry.Cluster.coordinate
|
||||
if targetgrp and targetgrp:IsAlive() and managedgroup then
|
||||
@@ -4627,6 +4664,7 @@ function AWACS:_CheckTaskQueue()
|
||||
end
|
||||
end
|
||||
end
|
||||
--]]
|
||||
|
||||
local auftrag = entry.Auftrag -- Ops.Auftrag#AUFTRAG
|
||||
local auftragstatus = "Not Known"
|
||||
@@ -4825,6 +4863,7 @@ function AWACS:_CheckTaskQueue()
|
||||
elseif entry.Status == AWACS.TaskStatus.ASSIGNED then
|
||||
self:T("Open Tasks VID ASSIGNED for GroupID "..entry.AssignedGroupID)
|
||||
-- check TAC/MELD ranges
|
||||
--[[
|
||||
local targetgrp = entry.Contact.group
|
||||
local position = entry.Contact.position or entry.Cluster.coordinate
|
||||
if targetgrp and targetgrp:IsAlive() and managedgroup then
|
||||
@@ -4849,6 +4888,7 @@ function AWACS:_CheckTaskQueue()
|
||||
end
|
||||
end
|
||||
end
|
||||
--]]
|
||||
elseif entry.Status == AWACS.TaskStatus.SUCCESS then
|
||||
self:T("Open Tasks VID success for GroupID "..entry.AssignedGroupID)
|
||||
-- outcomes - player ID'd
|
||||
@@ -4960,7 +5000,7 @@ end
|
||||
|
||||
--- [User] Add another AirWing for AI CAP Flights under management
|
||||
-- @param #AWACS self
|
||||
-- @param Ops.AirWing#AIRWING AirWing The AirWing to (also) obtain CAP flights from
|
||||
-- @param Ops.Airwing#AIRWING AirWing The AirWing to (also) obtain CAP flights from
|
||||
-- @param Core.Zone#ZONE_RADIUS Zone (optional) This AirWing has it's own station zone, AI CAP will be send there
|
||||
-- @return #AWACS self
|
||||
function AWACS:AddCAPAirWing(AirWing,Zone)
|
||||
@@ -5045,7 +5085,7 @@ function AWACS:_AnnounceContact(Contact,IsNew,Group,IsBogeyDope,Tag,IsPopup,Repo
|
||||
end
|
||||
|
||||
local cluster = Contact.Cluster
|
||||
local intel = self.intel -- Ops.Intelligence#INTEL
|
||||
local intel = self.intel -- Ops.Intel#INTEL
|
||||
|
||||
local size = self.intel:ClusterCountUnits(cluster)
|
||||
local threatsize, threatsizetext = self:_GetBlurredSize(size)
|
||||
@@ -5447,9 +5487,10 @@ function AWACS:_TACRangeCall(GID,Contact)
|
||||
if not Contact then return self end
|
||||
local pilotcallsign = self:_GetCallSign(nil,GID)
|
||||
local managedgroup = self.ManagedGrps[GID] -- #AWACS.ManagedGroup
|
||||
local contact = Contact.Contact -- Ops.Intelligence#INTEL.Contact
|
||||
local contact = Contact.Contact -- Ops.Intel#INTEL.Contact
|
||||
local contacttag = Contact.TargetGroupNaming
|
||||
if contact and not Contact.TACCallDone then
|
||||
local name = managedgroup.GroupName
|
||||
if contact then --and not Contact.TACCallDone then
|
||||
local position = contact.position -- Core.Point#COORDINATE
|
||||
if position then
|
||||
local distance = position:Get2DDistance(managedgroup.Group:GetCoordinate())
|
||||
@@ -5457,8 +5498,18 @@ function AWACS:_TACRangeCall(GID,Contact)
|
||||
local grptxt = self.gettext:GetEntry("GROUP",self.locale)
|
||||
local miles = self.gettext:GetEntry("MILES",self.locale)
|
||||
local text = string.format("%s. %s. %s %s, %d %s.",self.callsigntxt,pilotcallsign,contacttag,grptxt,distance,miles)
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true)
|
||||
if not self.TacticalSubscribers[name] then
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true)
|
||||
end
|
||||
self:_UpdateContactEngagementTag(Contact.CID,Contact.EngagementTag,true,false,AWACS.TaskStatus.EXECUTING)
|
||||
if GID and GID ~= 0 then
|
||||
--local managedgroup = self.ManagedGrps[GID] -- #AWACS.ManagedGroup
|
||||
if managedgroup and managedgroup.Group and managedgroup.Group:IsAlive() then
|
||||
if self.TacticalSubscribers[name] then
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true,true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return self
|
||||
@@ -5476,9 +5527,10 @@ function AWACS:_MeldRangeCall(GID,Contact)
|
||||
local pilotcallsign = self:_GetCallSign(nil,GID)
|
||||
local managedgroup = self.ManagedGrps[GID] -- #AWACS.ManagedGroup
|
||||
local flightpos = managedgroup.Group:GetCoordinate()
|
||||
local contact = Contact.Contact -- Ops.Intelligence#INTEL.Contact
|
||||
local contacttag = Contact.TargetGroupNaming
|
||||
if contact and not Contact.MeldCallDone then
|
||||
local contact = Contact.Contact -- Ops.Intel#INTEL.Contact
|
||||
local contacttag = Contact.TargetGroupNaming or "Bogey"
|
||||
local name = managedgroup.GroupName
|
||||
if contact then --and not Contact.MeldCallDone then
|
||||
local position = contact.position -- Core.Point#COORDINATE
|
||||
if position then
|
||||
local BRATExt = ""
|
||||
@@ -5489,8 +5541,19 @@ function AWACS:_MeldRangeCall(GID,Contact)
|
||||
end
|
||||
local grptxt = self.gettext:GetEntry("GROUP",self.locale)
|
||||
local text = string.format("%s. %s. %s %s, %s",self.callsigntxt,pilotcallsign,contacttag,grptxt,BRATExt)
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true)
|
||||
if not self.TacticalSubscribers[name] then
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true)
|
||||
end
|
||||
self:_UpdateContactEngagementTag(Contact.CID,Contact.EngagementTag,true,true,AWACS.TaskStatus.EXECUTING)
|
||||
if GID and GID ~= 0 then
|
||||
--local managedgroup = self.ManagedGrps[GID] -- #AWACS.ManagedGroup
|
||||
if managedgroup and managedgroup.Group and managedgroup.Group:IsAlive() then
|
||||
local name = managedgroup.GroupName
|
||||
if self.TacticalSubscribers[name] then
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true,true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return self
|
||||
@@ -5506,8 +5569,10 @@ function AWACS:_ThreatRangeCall(GID,Contact)
|
||||
local pilotcallsign = self:_GetCallSign(nil,GID)
|
||||
local managedgroup = self.ManagedGrps[GID] -- #AWACS.ManagedGroup
|
||||
local flightpos = managedgroup.Group:GetCoordinate() or managedgroup.LastKnownPosition
|
||||
local contact = Contact.Contact -- Ops.Intelligence#INTEL.Contact
|
||||
local contacttag = Contact.TargetGroupNaming
|
||||
local contact = Contact.Contact -- Ops.Intel#INTEL.Contact
|
||||
local contacttag = Contact.TargetGroupNaming or "Bogey"
|
||||
local name = managedgroup.GroupName
|
||||
local IsSub = self.TacticalSubscribers[name] and true or false
|
||||
if contact then
|
||||
local position = contact.position or contact.group:GetCoordinate() -- Core.Point#COORDINATE
|
||||
if position then
|
||||
@@ -5520,7 +5585,18 @@ function AWACS:_ThreatRangeCall(GID,Contact)
|
||||
local grptxt = self.gettext:GetEntry("GROUP",self.locale)
|
||||
local thrt = self.gettext:GetEntry("THREAT",self.locale)
|
||||
local text = string.format("%s. %s. %s %s, %s. %s",self.callsigntxt,pilotcallsign,contacttag,grptxt, thrt, BRATExt)
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true)
|
||||
if IsSub == false then
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true)
|
||||
end
|
||||
if GID and GID ~= 0 then
|
||||
--local managedgroup = self.ManagedGrps[GID] -- #AWACS.ManagedGroup
|
||||
if managedgroup and managedgroup.Group and managedgroup.Group:IsAlive() then
|
||||
local name = managedgroup.GroupName
|
||||
if self.TacticalSubscribers[name] then
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true,true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return self
|
||||
@@ -5536,11 +5612,17 @@ function AWACS:_MergedCall(GID)
|
||||
local pilotcallsign = self:_GetCallSign(nil,GID)
|
||||
local merge = self.gettext:GetEntry("MERGED",self.locale)
|
||||
local text = string.format("%s. %s. %s.",self.callsigntxt,pilotcallsign,merge)
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true)
|
||||
local managedgroup = self.ManagedGrps[GID] -- #AWACS.ManagedGroup
|
||||
local name
|
||||
if managedgroup then
|
||||
name = managedgroup.GroupName or "none"
|
||||
end
|
||||
if not self.TacticalSubscribers[name] then
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true)
|
||||
end
|
||||
if GID and GID ~= 0 then
|
||||
local managedgroup = self.ManagedGrps[GID] -- #AWACS.ManagedGroup
|
||||
if managedgroup and managedgroup.Group and managedgroup.Group:IsAlive() then
|
||||
local name = managedgroup.GroupName
|
||||
if managedgroup and managedgroup.Group and managedgroup.Group:IsAlive() then
|
||||
if self.TacticalSubscribers[name] then
|
||||
self:_NewRadioEntry(text,text,GID,true,self.debug,true,false,true,true)
|
||||
end
|
||||
@@ -5814,7 +5896,7 @@ function AWACS:onafterStart(From, Event, To)
|
||||
|
||||
if not self.GCI then
|
||||
-- set up the AWACS and let it orbit
|
||||
local AwacsAW = self.AirWing -- Ops.AirWing#AIRWING
|
||||
local AwacsAW = self.AirWing -- Ops.Airwing#AIRWING
|
||||
local mission = AUFTRAG:NewORBIT_RACETRACK(self.OrbitZone:GetCoordinate(),self.AwacsAngels*1000,self.Speed,self.Heading,self.Leg)
|
||||
local timeonstation = (self.AwacsTimeOnStation + self.ShiftChangeTime) * 3600
|
||||
mission:SetTime(nil,timeonstation)
|
||||
@@ -5935,6 +6017,10 @@ function AWACS:_CheckAwacsStatus()
|
||||
local awacs = nil -- Wrapper.Group#GROUP
|
||||
if self.AwacsFG then
|
||||
awacs = self.AwacsFG:GetGroup() -- Wrapper.Group#GROUP
|
||||
local unit = awacs:GetUnit(1)
|
||||
if unit then
|
||||
self.STN = tostring(unit:GetSTN())
|
||||
end
|
||||
end
|
||||
|
||||
local monitoringdata = self.MonitoringData -- #AWACS.MonitoringData
|
||||
@@ -6408,7 +6494,7 @@ end
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @param Ops.Intelligence#INTEL.Cluster Cluster
|
||||
-- @param Ops.Intel#INTEL.Cluster Cluster
|
||||
-- @return #AWACS self
|
||||
function AWACS:onafterNewCluster(From,Event,To,Cluster)
|
||||
self:T({From, Event, To, Cluster.index})
|
||||
@@ -6420,7 +6506,7 @@ function AWACS:onafterNewCluster(From,Event,To,Cluster)
|
||||
|
||||
local function GetFirstAliveContact(table)
|
||||
for _,_contact in pairs (table) do
|
||||
local contact = _contact -- Ops.Intelligence#INTEL.Contact
|
||||
local contact = _contact -- Ops.Intel#INTEL.Contact
|
||||
if contact and contact.group and contact.group:IsAlive() then
|
||||
return contact, contact.group
|
||||
end
|
||||
@@ -6428,7 +6514,7 @@ function AWACS:onafterNewCluster(From,Event,To,Cluster)
|
||||
return nil
|
||||
end
|
||||
|
||||
local Contact, Group = GetFirstAliveContact(ContactTable) -- Ops.Intelligence#INTEL.Contact
|
||||
local Contact, Group = GetFirstAliveContact(ContactTable) -- Ops.Intel#INTEL.Contact
|
||||
|
||||
if not Contact then return self end
|
||||
|
||||
@@ -6439,7 +6525,7 @@ function AWACS:onafterNewCluster(From,Event,To,Cluster)
|
||||
local targetset = SET_GROUP:New()
|
||||
-- SET for TARGET
|
||||
for _,_grp in pairs(ContactTable) do
|
||||
local grp = _grp -- Ops.Intelligence#INTEL.Contact
|
||||
local grp = _grp -- Ops.Intel#INTEL.Contact
|
||||
targetset:AddGroup(grp.group, true)
|
||||
end
|
||||
local managedcontact = {} -- #AWACS.ManagedContact
|
||||
@@ -6501,7 +6587,7 @@ end
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @param Ops.Intelligence#INTEL.Contact Contact
|
||||
-- @param Ops.Intel#INTEL.Contact Contact
|
||||
-- @return #AWACS self
|
||||
function AWACS:onafterNewContact(From,Event,To,Contact)
|
||||
self:T({From, Event, To, Contact})
|
||||
@@ -6530,7 +6616,7 @@ end
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @param Ops.Intelligence#INTEL.Contact Contact
|
||||
-- @param Ops.Intel#INTEL.Contact Contact
|
||||
-- @return #AWACS self
|
||||
function AWACS:onafterLostContact(From,Event,To,Contact)
|
||||
self:T({From, Event, To, Contact})
|
||||
@@ -6542,7 +6628,7 @@ end
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @param Ops.Intelligence#INTEL.Cluster Cluster
|
||||
-- @param Ops.Intel#INTEL.Cluster Cluster
|
||||
-- @param Ops.Auftrag#AUFTRAG Mission
|
||||
-- @return #AWACS self
|
||||
function AWACS:onafterLostCluster(From,Event,To,Cluster,Mission)
|
||||
@@ -6595,7 +6681,7 @@ function AWACS:onafterCheckTacticalQueue(From,Event,To)
|
||||
if self.PathToGoogleKey then
|
||||
gtext = string.format("<speak><prosody rate='medium'>%s</prosody></speak>",gtext)
|
||||
end
|
||||
self.TacticalSRSQ:NewTransmission(gtext,nil,self.TacticalSRS,nil,0.5,nil,nil,nil,frequency,self.TacticalModulation,nil,nil,nil,nil,nil)
|
||||
self.TacticalSRSQ:NewTransmission(gtext,nil,self.TacticalSRS,nil,0.5,nil,nil,nil,frequency,self.TacticalModulation)
|
||||
|
||||
self:T(RadioEntry.TextTTS)
|
||||
|
||||
@@ -6614,7 +6700,7 @@ function AWACS:onafterCheckTacticalQueue(From,Event,To)
|
||||
|
||||
end -- end while
|
||||
|
||||
if self:Is("Running") then
|
||||
if not self:Is("Stopped") then
|
||||
self:__CheckTacticalQueue(-self.TacticalInterval)
|
||||
end
|
||||
return self
|
||||
@@ -6743,7 +6829,7 @@ function AWACS:onafterAwacsShiftChange(From,Event,To)
|
||||
self.AwacsTimeStamp = timer.getTime()
|
||||
|
||||
-- set up the AWACS and let it orbit
|
||||
local AwacsAW = self.AirWing -- Ops.AirWing#AIRWING
|
||||
local AwacsAW = self.AirWing -- Ops.Airwing#AIRWING
|
||||
local mission = AUFTRAG:NewORBIT_RACETRACK(self.OrbitZone:GetCoordinate(),self.AwacsAngels*1000,self.Speed,self.Heading,self.Leg)
|
||||
self.CatchAllMissions[#self.CatchAllMissions+1] = mission
|
||||
local timeonstation = (self.AwacsTimeOnStation + self.ShiftChangeTime) * 3600
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Brigade).
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Brigade).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -313,8 +313,8 @@ end
|
||||
--
|
||||
-- local Path = FilePath or "C:\\Users\\<yourname>\\Saved Games\\DCS\\Missions\\" -- example path
|
||||
-- local BlueOpsFilename = BlueFileName or "ExamplePlatoonSave.csv" -- example filename
|
||||
-- local BlueSaveOps = SET_GROUP:New():FilterCoalitions("blue"):FilterPrefixes("AID"):FilterCategoryGround():FilterOnce()
|
||||
-- UTILS.SaveSetOfGroups(BlueSaveOps,Path,BlueOpsFilename)
|
||||
-- local BlueSaveOps = SET_OPSGROUP:New():FilterCoalitions("blue"):FilterCategoryGround():FilterOnce()
|
||||
-- UTILS.SaveSetOfOpsGroups(BlueSaveOps,Path,BlueOpsFilename)
|
||||
--
|
||||
-- where Path and Filename are strings, as chosen by you.
|
||||
-- You can then load back the assets at the start of your next mission run. Be aware that it takes a couple of seconds for the
|
||||
@@ -324,7 +324,7 @@ end
|
||||
-- local Path = FilePath or "C:\\Users\\<yourname>\\Saved Games\\DCS\\Missions\\" -- example path
|
||||
-- local BlueOpsFilename = BlueFileName or "ExamplePlatoonSave.csv" -- example filename
|
||||
-- if UTILS.CheckFileExists(Path,BlueOpsFilename) then
|
||||
-- local loadback = UTILS.LoadSetOfGroups(Path,BlueOpsFilename,false)
|
||||
-- local loadback = UTILS.LoadSetOfOpsGroups(Path,BlueOpsFilename,false)
|
||||
-- for _,_platoondata in pairs (loadback) do
|
||||
-- local groupname = _platoondata.groupname -- #string
|
||||
-- local coordinate = _platoondata.coordinate -- Core.Point#COORDINATE
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
--
|
||||
-- ## 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -31,7 +31,7 @@
|
||||
-- @image OPS_CSAR.jpg
|
||||
|
||||
-- Date: May 2023
|
||||
-- Last: Update Oct 2024
|
||||
-- Last: Update Dec 2024
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
||||
@@ -290,10 +290,11 @@ CSAR.AircraftType["Bell-47"] = 2
|
||||
CSAR.AircraftType["UH-60L"] = 10
|
||||
CSAR.AircraftType["AH-64D_BLK_II"] = 2
|
||||
CSAR.AircraftType["Bronco-OV-10A"] = 2
|
||||
CSAR.AircraftType["MH-60R"] = 10
|
||||
|
||||
--- CSAR class version.
|
||||
-- @field #string version
|
||||
CSAR.version="1.0.18"
|
||||
CSAR.version="1.0.20"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
@@ -536,6 +537,7 @@ function CSAR:New(Coalition, Template, Alias)
|
||||
-- @param #number Frequency Beacon frequency in kHz.
|
||||
-- @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 Playername Player name if any given. Might be nil!
|
||||
|
||||
--- On After "Aproach" event. Heli close to downed Pilot.
|
||||
-- @function [parent=#CSAR] OnAfterApproach
|
||||
@@ -842,7 +844,7 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
|
||||
|
||||
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
|
||||
end
|
||||
@@ -1224,7 +1226,8 @@ end
|
||||
-- @param #string _GroupName Name of the Group
|
||||
-- @param #number _freq Beacon frequency.
|
||||
-- @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")
|
||||
local _leader = _downedGroup:GetUnit(1)
|
||||
local _groupName = _GroupName
|
||||
@@ -1247,7 +1250,7 @@ function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
||||
end
|
||||
|
||||
-- trigger FSM event
|
||||
self:__PilotDown(2,_downedGroup, _freqk, _groupName, _coordinatesText)
|
||||
self:__PilotDown(2,_downedGroup, _freqk, _groupName, _coordinatesText, _playername)
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -1923,7 +1926,7 @@ function CSAR:_DisplayToAllSAR(_message, _side, _messagetime)
|
||||
local messagetime = _messagetime or self.messageTime
|
||||
if self.msrs then
|
||||
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
|
||||
end
|
||||
self:I("Voice = "..voice)
|
||||
@@ -2310,7 +2313,8 @@ function CSAR:onafterStart(From, Event, To)
|
||||
self.msrs:SetVoice(self.SRSVoice)
|
||||
self.msrs:SetGender(self.SRSGender)
|
||||
if self.SRSGPathToCredentials then
|
||||
self.msrs:SetGoogle(self.SRSGPathToCredentials)
|
||||
self.msrs:SetProviderOptionsGoogle(self.SRSGPathToCredentials,self.SRSGPathToCredentials)
|
||||
self.msrs:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
self.msrs:SetVolume(self.SRSVolume)
|
||||
self.msrs:SetLabel("CSAR")
|
||||
@@ -2542,8 +2546,9 @@ end
|
||||
-- @param #number Frequency Beacon frequency in kHz.
|
||||
-- @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.
|
||||
function CSAR:onbeforePilotDown(From, Event, To, Group, Frequency, Leadername, CoordinatesText)
|
||||
self:T({From, Event, To, Group, Frequency, Leadername, CoordinatesText})
|
||||
-- @param #string Playername Player name if any given. Might be nil!
|
||||
function CSAR:onbeforePilotDown(From, Event, To, Group, Frequency, Leadername, CoordinatesText, Playername)
|
||||
self:T({From, Event, To, Group, Frequency, Leadername, CoordinatesText, tostring(Playername)})
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
--
|
||||
-- ## 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
|
||||
-- @image OPS_CTLD.jpg
|
||||
|
||||
-- Last Update October 2023
|
||||
-- Last Update March 2024
|
||||
|
||||
do
|
||||
|
||||
@@ -44,6 +44,8 @@ do
|
||||
-- @field #number PerCrateMass Mass in kg.
|
||||
-- @field #number Stock Number of builds available, -1 for unlimited.
|
||||
-- @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
|
||||
|
||||
---
|
||||
@@ -62,6 +64,8 @@ CTLD_CARGO = {
|
||||
PerCrateMass = 0,
|
||||
Stock = nil,
|
||||
Mark = nil,
|
||||
DontShowInMenu = false,
|
||||
Location = nil,
|
||||
}
|
||||
|
||||
--- Define cargo types.
|
||||
@@ -97,8 +101,10 @@ CTLD_CARGO = {
|
||||
-- @param #number PerCrateMass Mass in kg
|
||||
-- @param #number Stock Number of builds available, nil for unlimited
|
||||
-- @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
|
||||
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.
|
||||
local self=BASE:Inherit(self, BASE:New()) -- #CTLD_CARGO
|
||||
self:T({ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped})
|
||||
@@ -115,8 +121,20 @@ CTLD_CARGO = {
|
||||
self.Stock = Stock or nil --#number
|
||||
self.Mark = nil
|
||||
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
|
||||
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.
|
||||
-- @param #CTLD_CARGO self
|
||||
@@ -656,6 +674,8 @@ do
|
||||
-- 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.
|
||||
-- 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:
|
||||
-- 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.
|
||||
-- -- 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:
|
||||
-- ["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},
|
||||
-- ["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},
|
||||
-- ["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
|
||||
--
|
||||
@@ -1200,14 +1223,14 @@ CTLD.CargoZoneType = {
|
||||
-- @field #CTLD_CARGO.Enum Type Type enumerator (for moves).
|
||||
|
||||
--- Unit capabilities.
|
||||
-- @type CTLD.UnitCapabilities
|
||||
-- @type CTLD.UnitTypeCapabilities
|
||||
-- @field #string type Unit type.
|
||||
-- @field #boolean crates Can transport crate.
|
||||
-- @field #boolean troops Can transport troops.
|
||||
-- @field #number cratelimit Number of crates transportable.
|
||||
-- @field #number trooplimit Number of troop units transportable.
|
||||
-- @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},
|
||||
["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},
|
||||
@@ -1222,13 +1245,15 @@ CTLD.UnitTypes = {
|
||||
["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.
|
||||
["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
|
||||
["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
|
||||
}
|
||||
|
||||
--- CTLD class version.
|
||||
-- @field #string version
|
||||
CTLD.version="1.0.41"
|
||||
CTLD.version="1.0.50"
|
||||
|
||||
--- Instantiate a new CTLD.
|
||||
-- @param #CTLD self
|
||||
@@ -1293,6 +1318,8 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
||||
self:AddTransition("*", "CratesDropped", "*") -- CTLD deploy event.
|
||||
self:AddTransition("*", "CratesBuild", "*") -- CTLD build 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("*", "Save", "*") -- CTLD save event.
|
||||
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||
@@ -1431,7 +1458,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
||||
--- 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
|
||||
-- @param #CTLD self
|
||||
|
||||
@@ -1441,6 +1468,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
--- Triggers the FSM event "Stop". Stops the CTLD and all its event handlers.
|
||||
-- @function [parent=#CTLD] Stop
|
||||
-- @param #CTLD self
|
||||
|
||||
--- Triggers the FSM event "Stop" after a delay. Stops the CTLD and all its event handlers.
|
||||
@@ -1475,7 +1503,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
||||
-- @param #CTLD self
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
--- FSM Function OnBeforeTroopsPickedUp.
|
||||
--- FSM Function OnBeforeTroopsPickedUp.
|
||||
-- @function [parent=#CTLD] OnBeforeTroopsPickedUp
|
||||
-- @param #CTLD self
|
||||
-- @param #string From State.
|
||||
@@ -1627,6 +1655,46 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
||||
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build.
|
||||
-- @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.
|
||||
-- @function [parent=#CTLD] OnAfterCratesRepaired
|
||||
-- @param #CTLD self
|
||||
@@ -1680,7 +1748,7 @@ function CTLD:_GetUnitCapabilities(Unit)
|
||||
self:T(self.lid .. " _GetUnitCapabilities")
|
||||
local _unit = Unit -- Wrapper.Unit#UNIT
|
||||
local unittype = _unit:GetTypeName()
|
||||
local capabilities = self.UnitTypes[unittype] -- #CTLD.UnitCapabilities
|
||||
local capabilities = self.UnitTypeCapabilities[unittype] -- #CTLD.UnitTypeCapabilities
|
||||
if not capabilities or capabilities == {} then
|
||||
-- e.g. ["Ka-50"] = {type="Ka-50", crates=false, troops=false, cratelimit = 0, trooplimit = 0},
|
||||
capabilities = {}
|
||||
@@ -1701,7 +1769,7 @@ end
|
||||
function CTLD:_GenerateUHFrequencies()
|
||||
self:T(self.lid .. " _GenerateUHFrequencies")
|
||||
self.FreeUHFFrequencies = {}
|
||||
self.FreeUHFFrequencies = UTILS.GenerateUHFrequencies()
|
||||
self.FreeUHFFrequencies = UTILS.GenerateUHFrequencies(243,320)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -1871,7 +1939,7 @@ function CTLD:_PreloadCrates(Group, Unit, Cargo, NumberOfCrates)
|
||||
local unitname = unit:GetName()
|
||||
-- see if this heli can load crates
|
||||
local unittype = unit:GetTypeName()
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||
local cancrates = capabilities.crates -- #boolean
|
||||
local cratelimit = capabilities.cratelimit -- #number
|
||||
if not cancrates then
|
||||
@@ -2124,6 +2192,7 @@ function CTLD:_RepairObjectFromCrates(Group,Unit,Crates,Build,Number,Engineering
|
||||
desttimer:Start(self.repairtime - 1)
|
||||
local buildtimer = TIMER:New(self._BuildObjectFromCrates,self,Group,Unit,object,true,NearestGroup:GetCoordinate())
|
||||
buildtimer:Start(self.repairtime)
|
||||
self:__CratesRepairStarted(1,Group,Unit)
|
||||
else
|
||||
if not Engineering then
|
||||
self:_SendMessage("Can't repair this unit with " .. build.Name, 10, false, Group)
|
||||
@@ -2191,7 +2260,7 @@ end
|
||||
local secondarygroups = {}
|
||||
|
||||
for i=1,#distancekeys do
|
||||
local nearestGroup = nearestList[distancekeys[i]]
|
||||
local nearestGroup = nearestList[distancekeys[i]] -- Wrapper.Group#GROUP
|
||||
-- find matching cargo type
|
||||
local groupType = string.match(nearestGroup:GetName(), "(.+)-(.+)$")
|
||||
local Cargotype = nil
|
||||
@@ -2227,20 +2296,31 @@ end
|
||||
self.CargoCounter = self.CargoCounter + 1
|
||||
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})
|
||||
local running = math.floor(nearestDistance / 4)+10 -- time run to helo plus boarding
|
||||
loaded.Troopsloaded = loaded.Troopsloaded + troopsize
|
||||
table.insert(loaded.Cargo,loadcargotype)
|
||||
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:__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:
|
||||
if type(Cargotype.Templates) == "table" and Cargotype.Templates[2] then
|
||||
for _,_key in pairs (Cargotype.Templates) do
|
||||
table.insert(secondarygroups,_key)
|
||||
end
|
||||
end
|
||||
nearestGroup:Destroy(false)
|
||||
nearestGroup:Destroy(false,running)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2250,7 +2330,7 @@ end
|
||||
if _group and _group:IsAlive() then
|
||||
local groupname = string.match(_group:GetName(), "(.+)-(.+)$")
|
||||
if _name == groupname then
|
||||
_group:Destroy(false)
|
||||
_group:Destroy(false,15)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2306,9 +2386,23 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop, pack)
|
||||
self:_SendMessage("You are not close enough to a logistics zone!", 10, false, Group)
|
||||
if not self.debug then return self 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
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||
local canloadcratesno = capabilities.cratelimit
|
||||
local loaddist = self.CrateDistance or 35
|
||||
local nearcrates, numbernearby = self:_FindCratesNearby(Group,Unit,loaddist,true)
|
||||
@@ -2411,11 +2505,13 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop, pack)
|
||||
realcargo = CTLD_CARGO:New(self.CargoCounter,cratename,templ,sorte,true,false,cratesneeded,self.Spawned_Crates[self.CrateCounter],true,cargotype.PerCrateMass,nil,subcat)
|
||||
table.insert(droppedcargo,realcargo)
|
||||
else
|
||||
realcargo = CTLD_CARGO:New(self.CargoCounter,cratename,templ,sorte,false,false,cratesneeded,self.Spawned_Crates[self.CrateCounter],false,cargotype.PerCrateMass,nil,subcat)
|
||||
Cargo:RemoveStock()
|
||||
realcargo = CTLD_CARGO:New(self.CargoCounter,cratename,templ,sorte,false,false,cratesneeded,self.Spawned_Crates[self.CrateCounter],false,cargotype.PerCrateMass,nil,subcat)
|
||||
end
|
||||
table.insert(self.Spawned_Cargo, realcargo)
|
||||
end
|
||||
if not (drop or pack) then
|
||||
Cargo:RemoveStock()
|
||||
end
|
||||
local text = string.format("Crates for %s have been positioned near you!",cratename)
|
||||
if drop then
|
||||
text = string.format("Crates for %s have been dropped!",cratename)
|
||||
@@ -2518,6 +2614,40 @@ function CTLD:_ListCratesNearby( _group, _unit)
|
||||
return self
|
||||
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.
|
||||
-- @param #CTLD self
|
||||
-- @param Core.Point#COORDINATE _point1 Coordinate one
|
||||
@@ -2601,8 +2731,8 @@ function CTLD:_LoadCratesNearby(Group, Unit)
|
||||
local unitname = unit:GetName()
|
||||
-- see if this heli can load crates
|
||||
local unittype = unit:GetTypeName()
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
||||
--local capabilities = self.UnitTypes[unittype] -- #CTLD.UnitCapabilities
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||
--local capabilities = self.UnitTypeCapabilities[unittype] -- #CTLD.UnitTypeCapabilities
|
||||
local cancrates = capabilities.crates -- #boolean
|
||||
local cratelimit = capabilities.cratelimit -- #number
|
||||
local grounded = not self:IsUnitInAir(Unit)
|
||||
@@ -2753,7 +2883,7 @@ function CTLD:_GetMaxLoadableMass(Unit)
|
||||
if not Unit then return 0 end
|
||||
local loadable = 0
|
||||
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
|
||||
loadable = maxmass - loadedmass
|
||||
return loadable
|
||||
@@ -2778,7 +2908,7 @@ function CTLD:_ListCargo(Group, Unit)
|
||||
self:T(self.lid .. " _ListCargo")
|
||||
local unitname = Unit:GetName()
|
||||
local unittype = Unit:GetTypeName()
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||
local trooplimit = capabilities.trooplimit -- #boolean
|
||||
local cratelimit = capabilities.cratelimit -- #number
|
||||
local loadedcargo = self.Loaded_Cargo[unitname] or {} -- #CTLD.LoadedCargo
|
||||
@@ -2933,6 +3063,36 @@ function CTLD:IsHercules(Unit)
|
||||
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.
|
||||
-- @param #CTLD self
|
||||
-- @param Wrapper.Group#GROUP Group
|
||||
@@ -2984,14 +3144,29 @@ function CTLD:_UnloadTroops(Group, Unit)
|
||||
zoneradius = Unit:GetVelocityMPS() or 100
|
||||
end
|
||||
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
|
||||
self.TroopCounter = self.TroopCounter + 1
|
||||
tempcount = tempcount+1
|
||||
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)
|
||||
:InitRandomizeUnits(true,20,2)
|
||||
--:InitRandomizeUnits(true,20,2)
|
||||
--:InitHeading(heading)
|
||||
:InitDelayOff()
|
||||
:SpawnFromVec2(randomcoord)
|
||||
:InitSetUnitAbsolutePositions(Positions)
|
||||
:SpawnFromVec2(randomcoord:GetVec2())
|
||||
self:__TroopsDeployed(1, Group, Unit, self.DroppedTroops[self.TroopCounter],type)
|
||||
end -- template loop
|
||||
cargo:SetWasDropped(true)
|
||||
@@ -3226,6 +3401,7 @@ function CTLD:_BuildCrates(Group, Unit,Engineering)
|
||||
local buildtimer = TIMER:New(self._BuildObjectFromCrates,self,Group,Unit,build,false,Group:GetCoordinate())
|
||||
buildtimer:Start(self.buildtime)
|
||||
self:_SendMessage(string.format("Build started, ready in %d seconds!",self.buildtime),15,false,Group)
|
||||
self:__CratesBuildStarted(1,Group,Unit)
|
||||
else
|
||||
self:_BuildObjectFromCrates(Group,Unit,build)
|
||||
end
|
||||
@@ -3536,13 +3712,19 @@ function CTLD:_RefreshF10Menus()
|
||||
if _group then
|
||||
-- get chopper capabilities
|
||||
local unittype = _unit:GetTypeName()
|
||||
local capabilities = self:_GetUnitCapabilities(_unit) -- #CTLD.UnitCapabilities
|
||||
local capabilities = self:_GetUnitCapabilities(_unit) -- #CTLD.UnitTypeCapabilities
|
||||
local cantroops = capabilities.troops
|
||||
local cancrates = capabilities.crates
|
||||
-- top menu
|
||||
local topmenu = MENU_GROUP:New(_group,"CTLD",nil)
|
||||
local toptroops = MENU_GROUP:New(_group,"Manage Troops",topmenu)
|
||||
local topcrates = MENU_GROUP:New(_group,"Manage Crates",topmenu)
|
||||
local toptroops = nil
|
||||
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 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)
|
||||
@@ -3569,14 +3751,20 @@ function CTLD:_RefreshF10Menus()
|
||||
for _,_entry in pairs(self.Cargo_Troops) do
|
||||
local entry = _entry -- #CTLD_CARGO
|
||||
local subcat = entry.Subcategory
|
||||
menucount = menucount + 1
|
||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,entry.Name,subcatmenus[subcat],self._LoadTroops, self, _group, _unit, entry)
|
||||
local noshow = entry.DontShowInMenu
|
||||
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
|
||||
else
|
||||
for _,_entry in pairs(self.Cargo_Troops) do
|
||||
local entry = _entry -- #CTLD_CARGO
|
||||
menucount = menucount + 1
|
||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,entry.Name,troopsmenu,self._LoadTroops, self, _group, _unit, entry)
|
||||
local noshow = entry.DontShowInMenu
|
||||
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
|
||||
local unloadmenu1 = MENU_GROUP_COMMAND:New(_group,"Drop troops",toptroops, self._UnloadTroops, self, _group, _unit):Refresh()
|
||||
@@ -3587,6 +3775,7 @@ function CTLD:_RefreshF10Menus()
|
||||
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 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
|
||||
local subcatmenus = {}
|
||||
@@ -3596,32 +3785,61 @@ function CTLD:_RefreshF10Menus()
|
||||
for _,_entry in pairs(self.Cargo_Crates) do
|
||||
local entry = _entry -- #CTLD_CARGO
|
||||
local subcat = entry.Subcategory
|
||||
menucount = menucount + 1
|
||||
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,subcatmenus[subcat],self._GetCrates, self, _group, _unit, entry)
|
||||
local noshow = entry.DontShowInMenu
|
||||
local zone = entry.Location
|
||||
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
|
||||
for _,_entry in pairs(self.Cargo_Statics) do
|
||||
local entry = _entry -- #CTLD_CARGO
|
||||
local subcat = entry.Subcategory
|
||||
menucount = menucount + 1
|
||||
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,subcatmenus[subcat],self._GetCrates, self, _group, _unit, entry)
|
||||
local noshow = entry.DontShowInMenu
|
||||
local zone = entry.Location
|
||||
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
|
||||
else
|
||||
for _,_entry in pairs(self.Cargo_Crates) do
|
||||
local entry = _entry -- #CTLD_CARGO
|
||||
menucount = menucount + 1
|
||||
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,cratesmenu,self._GetCrates, self, _group, _unit, entry)
|
||||
local noshow = entry.DontShowInMenu
|
||||
local zone = entry.Location
|
||||
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
|
||||
for _,_entry in pairs(self.Cargo_Statics) do
|
||||
local entry = _entry -- #CTLD_CARGO
|
||||
menucount = menucount + 1
|
||||
local menutext = string.format("Crate %s (%dkg)",entry.Name,entry.PerCrateMass or 0)
|
||||
menus[menucount] = MENU_GROUP_COMMAND:New(_group,menutext,cratesmenu,self._GetCrates, self, _group, _unit, entry)
|
||||
local noshow = entry.DontShowInMenu
|
||||
local zone = entry.Location
|
||||
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
|
||||
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)
|
||||
if not self.nobuildmenu then
|
||||
local buildmenu = MENU_GROUP_COMMAND:New(_group,"Build crates",topcrates, self._BuildCrates, self, _group, _unit)
|
||||
@@ -3694,9 +3912,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 #number NoCrates Number of crates needed to build this cargo.
|
||||
-- @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).
|
||||
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")
|
||||
if not self:_CheckTemplates(Templates) then
|
||||
self:E(self.lid .. "Crates Cargo for " .. Name .. " has missing template(s)!" )
|
||||
@@ -3704,7 +3924,7 @@ function CTLD:AddCratesCargo(Name,Templates,Type,NoCrates,PerCrateMass,Stock,Sub
|
||||
end
|
||||
self.CargoCounter = self.CargoCounter + 1
|
||||
-- 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)
|
||||
return self
|
||||
end
|
||||
@@ -3715,13 +3935,15 @@ end
|
||||
-- @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 #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.CargoCounter = self.CargoCounter + 1
|
||||
local type = CTLD_CARGO.Enum.STATIC
|
||||
local template = STATIC:FindByName(Name,true):GetTypeName()
|
||||
-- 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)
|
||||
return self
|
||||
end
|
||||
@@ -3751,7 +3973,9 @@ end
|
||||
-- @param #number PerCrateMass Mass in kg of each crate
|
||||
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
||||
-- @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")
|
||||
if not self:_CheckTemplates(Template) then
|
||||
self:E(self.lid .. "Repair Cargo for " .. Name .. " has a missing template!" )
|
||||
@@ -3759,7 +3983,7 @@ function CTLD:AddCratesRepair(Name,Template,Type,NoCrates, PerCrateMass,Stock,Su
|
||||
end
|
||||
self.CargoCounter = self.CargoCounter + 1
|
||||
-- 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)
|
||||
return self
|
||||
end
|
||||
@@ -4339,7 +4563,7 @@ end
|
||||
-- @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)
|
||||
function CTLD:SetUnitCapabilities(Unittype, Cancrates, Cantroops, Cratelimit, Trooplimit, Length, Maxcargoweight)
|
||||
self:T(self.lid .. " UnitCapabilities")
|
||||
local unittype = nil
|
||||
local unit = nil
|
||||
@@ -4353,13 +4577,13 @@ end
|
||||
end
|
||||
local length = 20
|
||||
local maxcargo = 500
|
||||
local existingcaps = self.UnitTypes[unittype] -- #CTLD.UnitCapabilities
|
||||
local existingcaps = self.UnitTypeCapabilities[unittype] -- #CTLD.UnitTypeCapabilities
|
||||
if existingcaps then
|
||||
length = existingcaps.length or 20
|
||||
maxcargo = existingcaps.cargoweightlimit or 500
|
||||
end
|
||||
-- set capabilities
|
||||
local capabilities = {} -- #CTLD.UnitCapabilities
|
||||
local capabilities = {} -- #CTLD.UnitTypeCapabilities
|
||||
capabilities.type = unittype
|
||||
capabilities.crates = Cancrates or false
|
||||
capabilities.troops = Cantroops or false
|
||||
@@ -4367,10 +4591,26 @@ end
|
||||
capabilities.trooplimit = Trooplimit or 0
|
||||
capabilities.length = Length or length
|
||||
capabilities.cargoweightlimit = Maxcargoweight or maxcargo
|
||||
self.UnitTypes[unittype] = capabilities
|
||||
self.UnitTypeCapabilities[unittype] = capabilities
|
||||
return self
|
||||
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*.
|
||||
-- @param #CTLD self
|
||||
-- @param Wrapper.Unit#UNIT Unit
|
||||
@@ -4523,7 +4763,7 @@ end
|
||||
local unittype = Unit:GetTypeName()
|
||||
local unitname = Unit:GetName()
|
||||
local Group = Unit:GetGroup()
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||
local cancrates = capabilities.crates -- #boolean
|
||||
local cratelimit = capabilities.cratelimit -- #number
|
||||
if cancrates then
|
||||
@@ -5208,19 +5448,19 @@ end
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Internal) FSM Function onbeforeTroopsExtracted.
|
||||
-- @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.
|
||||
-- @param Wrapper.Group#GROUP Troops Troops #GROUP Object.
|
||||
-- @return #CTLD self
|
||||
function CTLD:onbeforeTroopsExtracted(From, Event, To, Group, Unit, Troops)
|
||||
self:T({From, Event, To})
|
||||
return self
|
||||
end
|
||||
--- (Internal) FSM Function onbeforeTroopsExtracted.
|
||||
-- @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.
|
||||
-- @param Wrapper.Group#GROUP Troops Troops #GROUP Object.
|
||||
-- @return #CTLD self
|
||||
function CTLD:onbeforeTroopsExtracted(From, Event, To, Group, Unit, Troops)
|
||||
self:T({From, Event, To})
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- (Internal) FSM Function onbeforeTroopsDeployed.
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
-- @field Ops.Commander#COMMANDER commander Commander of assigned legions.
|
||||
-- @field #number Nsuccess Number of successful missions.
|
||||
-- @field #number Nfailure Number of failed mission.
|
||||
-- @extends Ops.Intelligence#INTEL
|
||||
-- @extends Ops.Intel#INTEL
|
||||
|
||||
--- *In preparing for battle I have always found that plans are useless, but planning is indispensable* -- Dwight D Eisenhower
|
||||
--
|
||||
@@ -126,7 +126,7 @@
|
||||
-- When the chief detects a valid target, he will launch a certain number of selected assets. Only whole groups from SQUADRONs, PLATOONs or FLOTILLAs can be selected.
|
||||
-- In other words, it is not possible to specify the abount of individual *units*.
|
||||
--
|
||||
-- By default, one group is selected for any detected target. This can, however, be customized with the @{CHIEF.SetResponseOnTarget}() function. The number of min and max
|
||||
-- By default, one group is selected for any detected target. This can, however, be customized with the @{#CHIEF.SetResponseOnTarget}() function. The number of min and max
|
||||
-- asset groups can be specified depending on threatlevel, category, mission type, number of units, defcon and strategy.
|
||||
--
|
||||
-- For example:
|
||||
@@ -311,7 +311,7 @@ CHIEF.Strategy = {
|
||||
|
||||
--- Resource list.
|
||||
-- @type CHIEF.Resources
|
||||
-- @field <#CHIEF.Resource> List of resources.
|
||||
-- @field #CHIEF.Resource List of resources.
|
||||
|
||||
--- Resource.
|
||||
-- @type CHIEF.Resource
|
||||
@@ -1096,7 +1096,7 @@ end
|
||||
|
||||
--- Add an AIRWING to the chief's commander.
|
||||
-- @param #CHIEF self
|
||||
-- @param Ops.AirWing#AIRWING Airwing The airwing to add.
|
||||
-- @param Ops.Airwing#AIRWING Airwing The airwing to add.
|
||||
-- @return #CHIEF self
|
||||
function CHIEF:AddAirwing(Airwing)
|
||||
|
||||
@@ -1460,7 +1460,7 @@ end
|
||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @return Ops.AirWing#AIRWING.PatrolZone The CAP zone data.
|
||||
-- @return Ops.Airwing#AIRWING.PatrolZone The CAP zone data.
|
||||
function CHIEF:AddCapZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
|
||||
-- Hand over to commander.
|
||||
@@ -1476,7 +1476,7 @@ end
|
||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @return Ops.AirWing#AIRWING.PatrolZone The CAP zone data.
|
||||
-- @return Ops.Airwing#AIRWING.PatrolZone The CAP zone data.
|
||||
function CHIEF:AddGciCapZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
|
||||
-- Hand over to commander.
|
||||
@@ -1503,7 +1503,7 @@ end
|
||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @return Ops.AirWing#AIRWING.PatrolZone The AWACS zone data.
|
||||
-- @return Ops.Airwing#AIRWING.PatrolZone The AWACS zone data.
|
||||
function CHIEF:AddAwacsZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
|
||||
-- Hand over to commander.
|
||||
@@ -1531,7 +1531,7 @@ end
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @param #number RefuelSystem Refuelling system.
|
||||
-- @return Ops.AirWing#AIRWING.TankerZone The tanker zone data.
|
||||
-- @return Ops.Airwing#AIRWING.TankerZone The tanker zone data.
|
||||
function CHIEF:AddTankerZone(Zone, Altitude, Speed, Heading, Leg, RefuelSystem)
|
||||
|
||||
-- Hand over to commander.
|
||||
@@ -1785,7 +1785,7 @@ function CHIEF:onafterStatus(From, Event, To)
|
||||
|
||||
-- Clean up missions where the contact was lost.
|
||||
for _,_contact in pairs(self.ContactsLost) do
|
||||
local contact=_contact --Ops.Intelligence#INTEL.Contact
|
||||
local contact=_contact --Ops.Intel#INTEL.Contact
|
||||
|
||||
if contact.mission and contact.mission:IsNotOver() then
|
||||
|
||||
@@ -1813,7 +1813,7 @@ function CHIEF:onafterStatus(From, Event, To)
|
||||
-- Create TARGETs for all new contacts.
|
||||
self.Nborder=0 ; self.Nconflict=0 ; self.Nattack=0
|
||||
for _,_contact in pairs(self.Contacts) do
|
||||
local contact=_contact --Ops.Intelligence#INTEL.Contact
|
||||
local contact=_contact --Ops.Intel#INTEL.Contact
|
||||
local group=contact.group --Wrapper.Group#GROUP
|
||||
|
||||
-- Check if contact inside of our borders.
|
||||
@@ -1964,7 +1964,7 @@ function CHIEF:onafterStatus(From, Event, To)
|
||||
if self.verbose>=2 and #self.Contacts>0 then
|
||||
local text="Contacts:"
|
||||
for i,_contact in pairs(self.Contacts) do
|
||||
local contact=_contact --Ops.Intelligence#INTEL.Contact
|
||||
local contact=_contact --Ops.Intel#INTEL.Contact
|
||||
|
||||
local mtext="N/A"
|
||||
if contact.mission then
|
||||
|
||||
@@ -140,7 +140,7 @@ COMMANDER = {
|
||||
|
||||
--- COMMANDER class version.
|
||||
-- @field #string version
|
||||
COMMANDER.version="0.1.3"
|
||||
COMMANDER.version="0.1.4"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@@ -420,7 +420,7 @@ end
|
||||
|
||||
--- Add an AIRWING to the commander.
|
||||
-- @param #COMMANDER self
|
||||
-- @param Ops.AirWing#AIRWING Airwing The airwing to add.
|
||||
-- @param Ops.Airwing#AIRWING Airwing The airwing to add.
|
||||
-- @return #COMMANDER self
|
||||
function COMMANDER:AddAirwing(Airwing)
|
||||
|
||||
@@ -667,15 +667,16 @@ end
|
||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @return Ops.AirWing#AIRWING.PatrolZone The CAP zone data.
|
||||
-- @return Ops.Airwing#AIRWING.PatrolZone The CAP zone data.
|
||||
function COMMANDER:AddCapZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
|
||||
local patrolzone={} --Ops.AirWing#AIRWING.PatrolZone
|
||||
local patrolzone={} --Ops.Airwing#AIRWING.PatrolZone
|
||||
|
||||
patrolzone.zone=Zone
|
||||
patrolzone.altitude=Altitude or 12000
|
||||
patrolzone.heading=Heading or 270
|
||||
patrolzone.speed=UTILS.KnotsToAltKIAS(Speed or 350, patrolzone.altitude)
|
||||
--patrolzone.speed=UTILS.KnotsToAltKIAS(Speed or 350, patrolzone.altitude)
|
||||
patrolzone.speed=Speed or 350
|
||||
patrolzone.leg=Leg or 30
|
||||
patrolzone.mission=nil
|
||||
--patrolzone.marker=MARKER:New(patrolzone.zone:GetCoordinate(), "CAP Zone"):ToCoalition(self:GetCoalition())
|
||||
@@ -692,15 +693,16 @@ end
|
||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @return Ops.AirWing#AIRWING.PatrolZone The CAP zone data.
|
||||
-- @return Ops.Airwing#AIRWING.PatrolZone The CAP zone data.
|
||||
function COMMANDER:AddGciCapZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
|
||||
local patrolzone={} --Ops.AirWing#AIRWING.PatrolZone
|
||||
local patrolzone={} --Ops.Airwing#AIRWING.PatrolZone
|
||||
|
||||
patrolzone.zone=Zone
|
||||
patrolzone.altitude=Altitude or 12000
|
||||
patrolzone.heading=Heading or 270
|
||||
patrolzone.speed=UTILS.KnotsToAltKIAS(Speed or 350, patrolzone.altitude)
|
||||
--patrolzone.speed=UTILS.KnotsToAltKIAS(Speed or 350, patrolzone.altitude)
|
||||
patrolzone.speed=Speed or 350
|
||||
patrolzone.leg=Leg or 30
|
||||
patrolzone.mission=nil
|
||||
--patrolzone.marker=MARKER:New(patrolzone.zone:GetCoordinate(), "GCICAP Zone"):ToCoalition(self:GetCoalition())
|
||||
@@ -715,7 +717,7 @@ end
|
||||
-- @param Core.Zone#ZONE Zone Zone, where the flight orbits.
|
||||
function COMMANDER:RemoveGciCapZone(Zone)
|
||||
|
||||
local patrolzone={} --Ops.AirWing#AIRWING.PatrolZone
|
||||
local patrolzone={} --Ops.Airwing#AIRWING.PatrolZone
|
||||
|
||||
patrolzone.zone=Zone
|
||||
for i,_patrolzone in pairs(self.gcicapZones) do
|
||||
@@ -737,15 +739,17 @@ end
|
||||
-- @param #number Speed Orbit speed in KIAS. Default 350 kts.
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @return Ops.AirWing#AIRWING.PatrolZone The AWACS zone data.
|
||||
-- @return Ops.Airwing#AIRWING.PatrolZone The AWACS zone data.
|
||||
function COMMANDER:AddAwacsZone(Zone, Altitude, Speed, Heading, Leg)
|
||||
|
||||
local awacszone={} --Ops.AirWing#AIRWING.PatrolZone
|
||||
local awacszone={} --Ops.Airwing#AIRWING.PatrolZone
|
||||
|
||||
awacszone.zone=Zone
|
||||
awacszone.altitude=Altitude or 12000
|
||||
awacszone.heading=Heading or 270
|
||||
awacszone.speed=UTILS.KnotsToAltKIAS(Speed or 350, awacszone.altitude)
|
||||
--awacszone.speed=UTILS.KnotsToAltKIAS(Speed or 350, awacszone.altitude)
|
||||
awacszone.speed=Speed or 350
|
||||
awacszone.speed=Speed or 350
|
||||
awacszone.leg=Leg or 30
|
||||
awacszone.mission=nil
|
||||
--awacszone.marker=MARKER:New(awacszone.zone:GetCoordinate(), "AWACS Zone"):ToCoalition(self:GetCoalition())
|
||||
@@ -760,7 +764,7 @@ end
|
||||
-- @param Core.Zone#ZONE Zone Zone, where the flight orbits.
|
||||
function COMMANDER:RemoveAwacsZone(Zone)
|
||||
|
||||
local awacszone={} --Ops.AirWing#AIRWING.PatrolZone
|
||||
local awacszone={} --Ops.Airwing#AIRWING.PatrolZone
|
||||
|
||||
awacszone.zone=Zone
|
||||
for i,_awacszone in pairs(self.awacsZones) do
|
||||
@@ -783,15 +787,16 @@ end
|
||||
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
|
||||
-- @param #number Leg Length of race-track in NM. Default 30 NM.
|
||||
-- @param #number RefuelSystem Refuelling system.
|
||||
-- @return Ops.AirWing#AIRWING.TankerZone The tanker zone data.
|
||||
-- @return Ops.Airwing#AIRWING.TankerZone The tanker zone data.
|
||||
function COMMANDER:AddTankerZone(Zone, Altitude, Speed, Heading, Leg, RefuelSystem)
|
||||
|
||||
local tankerzone={} --Ops.AirWing#AIRWING.TankerZone
|
||||
local tankerzone={} --Ops.Airwing#AIRWING.TankerZone
|
||||
|
||||
tankerzone.zone=Zone
|
||||
tankerzone.altitude=Altitude or 12000
|
||||
tankerzone.heading=Heading or 270
|
||||
tankerzone.speed=UTILS.KnotsToAltKIAS(Speed or 350, tankerzone.altitude)
|
||||
--tankerzone.speed=UTILS.KnotsToAltKIAS(Speed or 350, tankerzone.altitude) -- speed translation to alt will be done by AUFTRAG anyhow
|
||||
tankerzone.speed = Speed or 350
|
||||
tankerzone.leg=Leg or 30
|
||||
tankerzone.refuelsystem=RefuelSystem
|
||||
tankerzone.mission=nil
|
||||
@@ -807,7 +812,7 @@ end
|
||||
-- @param Core.Zone#ZONE Zone Zone, where the flight orbits.
|
||||
function COMMANDER:RemoveTankerZone(Zone)
|
||||
|
||||
local tankerzone={} --Ops.AirWing#AIRWING.PatrolZone
|
||||
local tankerzone={} --Ops.Airwing#AIRWING.PatrolZone
|
||||
|
||||
tankerzone.zone=Zone
|
||||
for i,_tankerzone in pairs(self.tankerZones) do
|
||||
@@ -997,7 +1002,7 @@ function COMMANDER:onafterStatus(From, Event, To)
|
||||
|
||||
-- Check CAP zones.
|
||||
for _,_patrolzone in pairs(self.capZones) do
|
||||
local patrolzone=_patrolzone --Ops.AirWing#AIRWING.PatrolZone
|
||||
local patrolzone=_patrolzone --Ops.Airwing#AIRWING.PatrolZone
|
||||
-- Check if mission is nil or over.
|
||||
if (not patrolzone.mission) or patrolzone.mission:IsOver() then
|
||||
local Coordinate=patrolzone.zone:GetCoordinate()
|
||||
@@ -1008,7 +1013,7 @@ function COMMANDER:onafterStatus(From, Event, To)
|
||||
|
||||
-- Check GCICAP zones.
|
||||
for _,_patrolzone in pairs(self.gcicapZones) do
|
||||
local patrolzone=_patrolzone --Ops.AirWing#AIRWING.PatrolZone
|
||||
local patrolzone=_patrolzone --Ops.Airwing#AIRWING.PatrolZone
|
||||
-- Check if mission is nil or over.
|
||||
if (not patrolzone.mission) or patrolzone.mission:IsOver() then
|
||||
local Coordinate=patrolzone.zone:GetCoordinate()
|
||||
@@ -1019,7 +1024,7 @@ function COMMANDER:onafterStatus(From, Event, To)
|
||||
|
||||
-- Check AWACS zones.
|
||||
for _,_awacszone in pairs(self.awacsZones) do
|
||||
local awacszone=_awacszone --Ops.AirWing#AIRWING.Patrol
|
||||
local awacszone=_awacszone --Ops.Airwing#AIRWING.Patrol
|
||||
-- Check if mission is nil or over.
|
||||
if (not awacszone.mission) or awacszone.mission:IsOver() then
|
||||
local Coordinate=awacszone.zone:GetCoordinate()
|
||||
@@ -1030,7 +1035,7 @@ function COMMANDER:onafterStatus(From, Event, To)
|
||||
|
||||
-- Check Tanker zones.
|
||||
for _,_tankerzone in pairs(self.tankerZones) do
|
||||
local tankerzone=_tankerzone --Ops.AirWing#AIRWING.TankerZone
|
||||
local tankerzone=_tankerzone --Ops.Airwing#AIRWING.TankerZone
|
||||
-- Check if mission is nil or over.
|
||||
if (not tankerzone.mission) or tankerzone.mission:IsOver() then
|
||||
local Coordinate=tankerzone.zone:GetCoordinate()
|
||||
|
||||
@@ -41,13 +41,12 @@
|
||||
-- @field #number coalition
|
||||
-- @field #string alias
|
||||
-- @field #table wings
|
||||
-- @field Ops.Intelligence#INTEL Intel
|
||||
-- @field Ops.Intel#INTEL Intel
|
||||
-- @field #number resurrection
|
||||
-- @field #number capspeed
|
||||
-- @field #number capalt
|
||||
-- @field #number capdir
|
||||
-- @field #number capleg
|
||||
-- @field #number capgrouping
|
||||
-- @field #number maxinterceptsize
|
||||
-- @field #number missionrange
|
||||
-- @field #number noaltert5
|
||||
@@ -65,6 +64,7 @@
|
||||
-- @field #boolean Monitor
|
||||
-- @field #boolean TankerInvisible
|
||||
-- @field #number CapFormation
|
||||
-- @field #table ReadyFlightGroups
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- *“Airspeed, altitude, and brains. Two are always needed to successfully complete the flight.”* -- Unknown.
|
||||
@@ -141,14 +141,14 @@
|
||||
-- -- **Note** If you need different tanker types, i.e. Boom and Drogue, set them up at different AirWings!
|
||||
-- -- Add a tanker point
|
||||
-- mywing:AddPatrolPointTanker(AIRBASE.Caucasus.Kutaisi,ZONE:FindByName("Blue Zone Tanker"):GetCoordinate(),20000,280,270,50)
|
||||
-- -- Add an AWACS squad - Radio 251 AM, TACAN 51Y
|
||||
-- -- Add a tanker squad - Radio 251 AM, TACAN 51Y
|
||||
-- mywing:AddTankerSquadron("Blue Tanker","Tanker Ops Kutaisi",AIRBASE.Caucasus.Kutaisi,20,AI.Skill.EXCELLENT,602,nil,251,radio.modulation.AM,51)
|
||||
--
|
||||
-- ### Add an AWACS (optional)
|
||||
--
|
||||
-- -- Add an AWACS point
|
||||
-- mywing:AddPatrolPointAwacs(AIRBASE.Caucasus.Kutaisi,ZONE:FindByName("Blue Zone AWACS"):GetCoordinate(),25000,300,270,50)
|
||||
-- -- Add a tanker squad - Radio 251 AM, TACAN 51Y
|
||||
-- -- Add an AWACS squad - Radio 251 AM, TACAN 51Y
|
||||
-- mywing:AddAWACSSquadron("Blue AWACS","AWACS Ops Kutaisi",AIRBASE.Caucasus.Kutaisi,20,AI.Skill.AVERAGE,702,nil,271,radio.modulation.AM)
|
||||
--
|
||||
-- # Fine-Tuning
|
||||
@@ -190,7 +190,6 @@ EASYGCICAP = {
|
||||
capalt = 25000,
|
||||
capdir = 45,
|
||||
capleg = 15,
|
||||
capgrouping = 2,
|
||||
maxinterceptsize = 2,
|
||||
missionrange = 100,
|
||||
noaltert5 = 4,
|
||||
@@ -209,6 +208,7 @@ EASYGCICAP = {
|
||||
Monitor = false,
|
||||
TankerInvisible = true,
|
||||
CapFormation = nil,
|
||||
ReadyFlightGroups = {},
|
||||
}
|
||||
|
||||
--- Internal Squadron data type
|
||||
@@ -244,7 +244,7 @@ EASYGCICAP = {
|
||||
|
||||
--- EASYGCICAP class version.
|
||||
-- @field #string version
|
||||
EASYGCICAP.version="0.0.9"
|
||||
EASYGCICAP.version="0.1.10"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@@ -258,10 +258,10 @@ EASYGCICAP.version="0.0.9"
|
||||
|
||||
--- Create a new GCICAP Manager
|
||||
-- @param #EASYGCICAP self
|
||||
-- @param #string Alias
|
||||
-- @param #string AirbaseName
|
||||
-- @param #string Coalition
|
||||
-- @param #string EWRName
|
||||
-- @param #string Alias A Name for this GCICAP
|
||||
-- @param #string AirbaseName Name of the Home Airbase
|
||||
-- @param #string Coalition Coalition, e.g. "blue" or "red"
|
||||
-- @param #string EWRName (Partial) group name of the EWR system of the coalition, e.g. "Red EWR"
|
||||
-- @return #EASYGCICAP self
|
||||
function EASYGCICAP:New(Alias, AirbaseName, Coalition, EWRName)
|
||||
-- Inherit everything from FSM class.
|
||||
@@ -321,6 +321,7 @@ end
|
||||
-- @param #number Formation Formation to fly, defaults to ENUMS.Formation.FixedWing.FingerFour.Group
|
||||
-- @return #EASYGCICAP self
|
||||
function EASYGCICAP:SetCAPFormation(Formation)
|
||||
self:T(self.lid.."SetCAPFormation")
|
||||
self.CapFormation = Formation
|
||||
return self
|
||||
end
|
||||
@@ -428,7 +429,7 @@ end
|
||||
--- Set default number of airframes standing by for intercept tasks (visible on the airfield)
|
||||
-- @param #EASYGCICAP self
|
||||
-- @param #number Airframes defaults to 2
|
||||
-- @return #EASYGCICAP selfAirframes
|
||||
-- @return #EASYGCICAP self
|
||||
function EASYGCICAP:SetDefaultNumberAlter5Standby(Airframes)
|
||||
self:T(self.lid.."SetDefaultNumberAlter5Standby")
|
||||
self.noaltert5 = math.abs(Airframes) or 2
|
||||
@@ -438,13 +439,36 @@ end
|
||||
--- Set default engage range for intruders detected by CAP flights in NM.
|
||||
-- @param #EASYGCICAP self
|
||||
-- @param #number Range defaults to 50NM
|
||||
-- @return #EASYGCICAP selfAirframes
|
||||
-- @return #EASYGCICAP self
|
||||
function EASYGCICAP:SetDefaultEngageRange(Range)
|
||||
self:T(self.lid.."SetDefaultNumberAlter5Standby")
|
||||
self.engagerange = Range or 50
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set default overhead for intercept calculations
|
||||
-- @param #EASYGCICAP self
|
||||
-- @param #number Overhead The overhead to use.
|
||||
-- @return #EASYGCICAP self
|
||||
-- @usage Either a CAP Plane or a newly spawned GCI plane will take care of intruders. Standard overhead is 0.75, i.e. a group of 3 intrudes will
|
||||
-- be managed by 2 planes from the assigned AirWing. There is an maximum missions limitation per AirWing, so we do not spam the skies.
|
||||
function EASYGCICAP:SetDefaultOverhead(Overhead)
|
||||
self:T(self.lid.."SetDefaultOverhead")
|
||||
self.overhead = Overhead or 0.75
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set CAP mission start to vary randomly between Start end End seconds.
|
||||
-- @param #EASYGCICAP self
|
||||
-- @param #number Start
|
||||
-- @param #number End
|
||||
-- @return #EASYGCICAP self
|
||||
function EASYGCICAP:SetCapStartTimeVariation(Start, End)
|
||||
self.capOptionVaryStartTime = Start or 5
|
||||
self.capOptionVaryEndTime = End or 60
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add an AirWing to the manager
|
||||
-- @param #EASYGCICAP self
|
||||
-- @param #string Airbasename
|
||||
@@ -491,13 +515,18 @@ function EASYGCICAP:_AddAirwing(Airbasename, Alias)
|
||||
|
||||
-- Create Airwing
|
||||
local CAP_Wing = AIRWING:New(Airbasename,Alias)
|
||||
CAP_Wing:SetVerbosityLevel(3)
|
||||
CAP_Wing:SetVerbosityLevel(0)
|
||||
CAP_Wing:SetReportOff()
|
||||
CAP_Wing:SetMarker(false)
|
||||
CAP_Wing:SetAirbase(AIRBASE:FindByName(Airbasename))
|
||||
CAP_Wing:SetRespawnAfterDestroyed()
|
||||
CAP_Wing:SetNumberCAP(self.capgrouping)
|
||||
CAP_Wing:SetCapCloseRaceTrack(true)
|
||||
|
||||
if self.capOptionVaryStartTime then
|
||||
CAP_Wing:SetCapStartTimeVariation(self.capOptionVaryStartTime,self.capOptionVaryEndTime)
|
||||
end
|
||||
|
||||
if CapFormation then
|
||||
CAP_Wing:SetCAPFormation(CapFormation)
|
||||
end
|
||||
@@ -528,6 +557,7 @@ function EASYGCICAP:_AddAirwing(Airbasename, Alias)
|
||||
flightgroup:SetDespawnAfterHolding()
|
||||
flightgroup:SetDestinationbase(AIRBASE:FindByName(Airbasename))
|
||||
flightgroup:GetGroup():CommandEPLRS(true,5)
|
||||
flightgroup:GetGroup():SetOptionRadarUsingForContinousSearch()
|
||||
if Mission.type ~= AUFTRAG.Type.TANKER and Mission.type ~= AUFTRAG.Type.AWACS and Mission.type ~= AUFTRAG.Type.RECON then
|
||||
flightgroup:SetDetection(true)
|
||||
flightgroup:SetEngageDetectedOn(self.engagerange,{"Air"},self.GoZoneSet,self.NoGoZoneSet)
|
||||
@@ -548,7 +578,7 @@ function EASYGCICAP:_AddAirwing(Airbasename, Alias)
|
||||
flightgroup:SetFuelLowRTB(true)
|
||||
Intel:AddAgent(flightgroup)
|
||||
function flightgroup:OnAfterHolding(From,Event,To)
|
||||
self:ClearToLand(5)
|
||||
self:Despawn(1,true)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -672,7 +702,7 @@ function EASYGCICAP:_SetTankerPatrolPoints()
|
||||
self:T(self.lid.."_SetTankerPatrolPoints")
|
||||
for _,_data in pairs(self.ManagedTK) do
|
||||
local data = _data --#EASYGCICAP.CapPoint
|
||||
local Wing = self.wings[data.AirbaseName][1] -- Ops.AirWing#AIRWING
|
||||
local Wing = self.wings[data.AirbaseName][1] -- Ops.Airwing#AIRWING
|
||||
local Coordinate = data.Coordinate
|
||||
local Altitude = data.Altitude
|
||||
local Speed = data.Speed
|
||||
@@ -691,7 +721,7 @@ function EASYGCICAP:_SetAwacsPatrolPoints()
|
||||
self:T(self.lid.."_SetAwacsPatrolPoints")
|
||||
for _,_data in pairs(self.ManagedEWR) do
|
||||
local data = _data --#EASYGCICAP.CapPoint
|
||||
local Wing = self.wings[data.AirbaseName][1] -- Ops.AirWing#AIRWING
|
||||
local Wing = self.wings[data.AirbaseName][1] -- Ops.Airwing#AIRWING
|
||||
local Coordinate = data.Coordinate
|
||||
local Altitude = data.Altitude
|
||||
local Speed = data.Speed
|
||||
@@ -710,7 +740,7 @@ function EASYGCICAP:_SetCAPPatrolPoints()
|
||||
self:T(self.lid.."_SetCAPPatrolPoints")
|
||||
for _,_data in pairs(self.ManagedCP) do
|
||||
local data = _data --#EASYGCICAP.CapPoint
|
||||
local Wing = self.wings[data.AirbaseName][1] -- Ops.AirWing#AIRWING
|
||||
local Wing = self.wings[data.AirbaseName][1] -- Ops.Airwing#AIRWING
|
||||
local Coordinate = data.Coordinate
|
||||
local Altitude = data.Altitude
|
||||
local Speed = data.Speed
|
||||
@@ -729,7 +759,7 @@ function EASYGCICAP:_SetReconPatrolPoints()
|
||||
self:T(self.lid.."_SetReconPatrolPoints")
|
||||
for _,_data in pairs(self.ManagedREC) do
|
||||
local data = _data --#EASYGCICAP.CapPoint
|
||||
local Wing = self.wings[data.AirbaseName][1] -- Ops.AirWing#AIRWING
|
||||
local Wing = self.wings[data.AirbaseName][1] -- Ops.Airwing#AIRWING
|
||||
local Coordinate = data.Coordinate
|
||||
local Altitude = data.Altitude
|
||||
local Speed = data.Speed
|
||||
@@ -917,7 +947,7 @@ function EASYGCICAP:_AddSquadron(TemplateName, SquadName, AirbaseName, AirFrames
|
||||
Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE)
|
||||
Squadron_One:SetMissionRange(self.missionrange)
|
||||
|
||||
local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING
|
||||
local wing = self.wings[AirbaseName][1] -- Ops.Airwing#AIRWING
|
||||
|
||||
wing:AddSquadron(Squadron_One)
|
||||
wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.CAP, AUFTRAG.Type.GCICAP, AUFTRAG.Type.INTERCEPT, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5},75)
|
||||
@@ -948,7 +978,7 @@ function EASYGCICAP:_AddReconSquadron(TemplateName, SquadName, AirbaseName, AirF
|
||||
Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE)
|
||||
Squadron_One:SetMissionRange(self.missionrange)
|
||||
|
||||
local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING
|
||||
local wing = self.wings[AirbaseName][1] -- Ops.Airwing#AIRWING
|
||||
|
||||
wing:AddSquadron(Squadron_One)
|
||||
wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.RECON},75)
|
||||
@@ -984,7 +1014,7 @@ function EASYGCICAP:_AddTankerSquadron(TemplateName, SquadName, AirbaseName, Air
|
||||
Squadron_One:SetRadio(Frequency,Modulation)
|
||||
Squadron_One:AddTacanChannel(TACAN,TACAN)
|
||||
|
||||
local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING
|
||||
local wing = self.wings[AirbaseName][1] -- Ops.Airwing#AIRWING
|
||||
|
||||
wing:AddSquadron(Squadron_One)
|
||||
wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.TANKER},75)
|
||||
@@ -1017,7 +1047,7 @@ function EASYGCICAP:_AddAWACSSquadron(TemplateName, SquadName, AirbaseName, AirF
|
||||
Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE)
|
||||
Squadron_One:SetMissionRange(self.missionrange)
|
||||
Squadron_One:SetRadio(Frequency,Modulation)
|
||||
local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING
|
||||
local wing = self.wings[AirbaseName][1] -- Ops.Airwing#AIRWING
|
||||
|
||||
wing:AddSquadron(Squadron_One)
|
||||
wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.AWACS},75)
|
||||
@@ -1045,6 +1075,172 @@ function EASYGCICAP:AddRejectZone(Zone)
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Internal) Try to assign the intercept to a FlightGroup already in air and ready.
|
||||
-- @param #EASYGCICAP self
|
||||
-- @param #table ReadyFlightGroups ReadyFlightGroups
|
||||
-- @param Ops.Auftrag#AUFTRAG InterceptAuftrag The Auftrag
|
||||
-- @param Wrapper.Group#GROUP Group The Target
|
||||
-- @param #number WingSize Calculated number of Flights
|
||||
-- @return #boolean assigned
|
||||
-- @return #number leftover
|
||||
function EASYGCICAP:_TryAssignIntercept(ReadyFlightGroups,InterceptAuftrag,Group,WingSize)
|
||||
self:I("_TryAssignIntercept for size "..WingSize or 1)
|
||||
local assigned = false
|
||||
local wingsize = WingSize or 1
|
||||
local mindist = 0
|
||||
local disttable = {}
|
||||
if Group and Group:IsAlive() then
|
||||
local gcoord = Group:GetCoordinate() or COORDINATE:New(0,0,0)
|
||||
self:I(self.lid..string.format("Assignment for %s",Group:GetName()))
|
||||
for _name,_FG in pairs(ReadyFlightGroups or {}) do
|
||||
local FG = _FG -- Ops.FlightGroup#FLIGHTGROUP
|
||||
local fcoord = FG:GetCoordinate()
|
||||
local dist = math.floor(UTILS.Round(fcoord:Get2DDistance(gcoord)/1000,1))
|
||||
self:I(self.lid..string.format("FG %s Distance %dkm",_name,dist))
|
||||
disttable[#disttable+1] = { FG=FG, dist=dist}
|
||||
if dist>mindist then mindist=dist end
|
||||
end
|
||||
|
||||
local function sortDistance(a, b)
|
||||
return a.dist < b.dist
|
||||
end
|
||||
|
||||
table.sort(disttable, sortDistance)
|
||||
|
||||
for _,_entry in ipairs(disttable) do
|
||||
local FG = _entry.FG -- Ops.FlightGroup#FLIGHTGROUP
|
||||
FG:AddMission(InterceptAuftrag)
|
||||
local cm = FG:GetMissionCurrent()
|
||||
if cm then cm:Cancel() end
|
||||
wingsize = wingsize - 1
|
||||
self:I(self.lid..string.format("Assigned to FG %s Distance %dkm",FG:GetName(),_entry.dist))
|
||||
if wingsize == 0 then
|
||||
assigned = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return assigned, wingsize
|
||||
end
|
||||
|
||||
--- Add a zone to the rejected zones set.
|
||||
-- @param #EASYGCICAP self
|
||||
-- @param Ops.Intel#INTEL.Cluster Cluster
|
||||
-- @return #EASYGCICAP self
|
||||
function EASYGCICAP:_AssignIntercept(Cluster)
|
||||
-- Here, we'll decide if we need to launch an intercepting flight, and from where
|
||||
local overhead = self.overhead
|
||||
local capspeed = self.capspeed + 100
|
||||
local capalt = self.capalt
|
||||
local maxsize = self.maxinterceptsize
|
||||
local repeatsonfailure = self.repeatsonfailure
|
||||
|
||||
local wings = self.wings
|
||||
local ctlpts = self.ManagedCP
|
||||
local MaxAliveMissions = self.MaxAliveMissions * self.capgrouping
|
||||
local nogozoneset = self.NoGoZoneSet
|
||||
local ReadyFlightGroups = self.ReadyFlightGroups
|
||||
|
||||
-- Aircraft?
|
||||
if Cluster.ctype ~= INTEL.Ctype.AIRCRAFT then return end
|
||||
-- Threatlevel 0..10
|
||||
local contact = self.Intel:GetHighestThreatContact(Cluster)
|
||||
local name = contact.groupname --#string
|
||||
local threat = contact.threatlevel --#number
|
||||
local position = self.Intel:CalcClusterFuturePosition(Cluster,300)
|
||||
-- calculate closest zone
|
||||
local bestdistance = 2000*1000 -- 2000km
|
||||
local targetairwing = nil -- Ops.Airwing#AIRWING
|
||||
local targetawname = "" -- #string
|
||||
local clustersize = self.Intel:ClusterCountUnits(Cluster) or 1
|
||||
local wingsize = math.abs(overhead * (clustersize+1))
|
||||
if wingsize > maxsize then wingsize = maxsize end
|
||||
-- existing mission, and if so - done?
|
||||
local retrymission = true
|
||||
if Cluster.mission and (not Cluster.mission:IsOver()) then
|
||||
retrymission = false
|
||||
end
|
||||
if (retrymission) and (wingsize >= 1) then
|
||||
MESSAGE:New(string.format("**** %s Interceptors need wingsize %d", UTILS.GetCoalitionName(self.coalition), wingsize),15,"CAPGCI"):ToAllIf(self.debug):ToLog()
|
||||
for _,_data in pairs (wings) do
|
||||
local airwing = _data[1] -- Ops.Airwing#AIRWING
|
||||
local zone = _data[2] -- Core.Zone#ZONE
|
||||
local zonecoord = zone:GetCoordinate()
|
||||
local name = _data[3] -- #string
|
||||
local distance = position:DistanceFromPointVec2(zonecoord)
|
||||
local airframes = airwing:CountAssets(true)
|
||||
if distance < bestdistance and airframes >= wingsize then
|
||||
bestdistance = distance
|
||||
targetairwing = airwing
|
||||
targetawname = name
|
||||
end
|
||||
end
|
||||
for _,_data in pairs (ctlpts) do
|
||||
--local airwing = _data[1] -- Ops.Airwing#AIRWING
|
||||
--local zone = _data[2] -- Core.Zone#ZONE
|
||||
--local zonecoord = zone:GetCoordinate()
|
||||
--local name = _data[3] -- #string
|
||||
|
||||
local data = _data -- #EASYGCICAP.CapPoint
|
||||
local name = data.AirbaseName
|
||||
local zonecoord = data.Coordinate
|
||||
local airwing = wings[name][1]
|
||||
|
||||
local distance = position:DistanceFromPointVec2(zonecoord)
|
||||
local airframes = airwing:CountAssets(true)
|
||||
if distance < bestdistance and airframes >= wingsize then
|
||||
bestdistance = distance
|
||||
targetairwing = airwing -- Ops.Airwing#AIRWING
|
||||
targetawname = name
|
||||
end
|
||||
end
|
||||
local text = string.format("Closest Airwing is %s", targetawname)
|
||||
local m = MESSAGE:New(text,10,"CAPGCI"):ToAllIf(self.debug):ToLog()
|
||||
-- Do we have a matching airwing?
|
||||
if targetairwing then
|
||||
local AssetCount = targetairwing:CountAssetsOnMission(MissionTypes,Cohort)
|
||||
-- Enough airframes on mission already?
|
||||
self:T(self.lid.." Assets on Mission "..AssetCount)
|
||||
if AssetCount <= MaxAliveMissions then
|
||||
local repeats = repeatsonfailure
|
||||
local InterceptAuftrag = AUFTRAG:NewINTERCEPT(contact.group)
|
||||
:SetMissionRange(150)
|
||||
:SetPriority(1,true,1)
|
||||
--:SetRequiredAssets(wingsize)
|
||||
:SetRepeatOnFailure(repeats)
|
||||
:SetMissionSpeed(UTILS.KnotsToAltKIAS(capspeed,capalt))
|
||||
:SetMissionAltitude(capalt)
|
||||
|
||||
if nogozoneset:Count() > 0 then
|
||||
InterceptAuftrag:AddConditionSuccess(
|
||||
function(group,zoneset)
|
||||
local success = false
|
||||
if group and group:IsAlive() then
|
||||
local coord = group:GetCoordinate()
|
||||
if coord and zoneset:IsCoordinateInZone(coord) then
|
||||
success = true
|
||||
end
|
||||
end
|
||||
return success
|
||||
end,
|
||||
contact.group,
|
||||
nogozoneset
|
||||
)
|
||||
end
|
||||
local assigned, rest = self:_TryAssignIntercept(ReadyFlightGroups,InterceptAuftrag,contact.group,wingsize)
|
||||
if not assigned then
|
||||
InterceptAuftrag:SetRequiredAssets(rest)
|
||||
targetairwing:AddMission(InterceptAuftrag)
|
||||
end
|
||||
Cluster.mission = InterceptAuftrag
|
||||
end
|
||||
else
|
||||
MESSAGE:New("**** Not enough airframes available or max mission limit reached!",15,"CAPGCI"):ToAllIf(self.debug):ToLog()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- (Internal) Start detection.
|
||||
-- @param #EASYGCICAP self
|
||||
-- @return #EASYGCICAP self
|
||||
@@ -1068,131 +1264,16 @@ function EASYGCICAP:_StartIntel()
|
||||
BlueIntel.debug = true
|
||||
end
|
||||
|
||||
-- Here, we'll decide if we need to launch an intercepting flight, and from where
|
||||
|
||||
local overhead = self.overhead
|
||||
local capspeed = self.capspeed + 100
|
||||
local capalt = self.capalt
|
||||
local maxsize = self.maxinterceptsize
|
||||
local repeatsonfailure = self.repeatsonfailure
|
||||
|
||||
local wings = self.wings
|
||||
local ctlpts = self.ManagedCP
|
||||
local MaxAliveMissions = self.MaxAliveMissions * self.capgrouping
|
||||
local nogozoneset = self.NoGoZoneSet
|
||||
local function AssignCluster(Cluster)
|
||||
self:_AssignIntercept(Cluster)
|
||||
end
|
||||
|
||||
function BlueIntel:OnAfterNewCluster(From,Event,To,Cluster)
|
||||
-- Aircraft?
|
||||
if Cluster.ctype ~= INTEL.Ctype.AIRCRAFT then return end
|
||||
-- Threatlevel 0..10
|
||||
local contact = self:GetHighestThreatContact(Cluster)
|
||||
local name = contact.groupname --#string
|
||||
local threat = contact.threatlevel --#number
|
||||
local position = self:CalcClusterFuturePosition(Cluster,300)
|
||||
-- calculate closest zone
|
||||
local bestdistance = 2000*1000 -- 2000km
|
||||
local targetairwing = nil -- Ops.AirWing#AIRWING
|
||||
local targetawname = "" -- #string
|
||||
local clustersize = self:ClusterCountUnits(Cluster) or 1
|
||||
local wingsize = math.abs(overhead * (clustersize+1))
|
||||
if wingsize > maxsize then wingsize = maxsize end
|
||||
-- existing mission, and if so - done?
|
||||
local retrymission = true
|
||||
if Cluster.mission and (not Cluster.mission:IsOver()) then
|
||||
retrymission = false
|
||||
end
|
||||
if (retrymission) and (wingsize >= 1) then
|
||||
MESSAGE:New(string.format("**** %s Interceptors need wingsize %d", UTILS.GetCoalitionName(self.coalition), wingsize),15,"CAPGCI"):ToAllIf(self.debug):ToLog()
|
||||
for _,_data in pairs (wings) do
|
||||
local airwing = _data[1] -- Ops.AirWing#AIRWING
|
||||
local zone = _data[2] -- Core.Zone#ZONE
|
||||
local zonecoord = zone:GetCoordinate()
|
||||
local name = _data[3] -- #string
|
||||
local distance = position:DistanceFromPointVec2(zonecoord)
|
||||
local airframes = airwing:CountAssets(true)
|
||||
if distance < bestdistance and airframes >= wingsize then
|
||||
bestdistance = distance
|
||||
targetairwing = airwing
|
||||
targetawname = name
|
||||
end
|
||||
end
|
||||
for _,_data in pairs (ctlpts) do
|
||||
--local airwing = _data[1] -- Ops.AirWing#AIRWING
|
||||
--local zone = _data[2] -- Core.Zone#ZONE
|
||||
--local zonecoord = zone:GetCoordinate()
|
||||
--local name = _data[3] -- #string
|
||||
|
||||
local data = _data -- #EASYGCICAP.CapPoint
|
||||
local name = data.AirbaseName
|
||||
local zonecoord = data.Coordinate
|
||||
local airwing = wings[name][1]
|
||||
|
||||
local distance = position:DistanceFromPointVec2(zonecoord)
|
||||
local airframes = airwing:CountAssets(true)
|
||||
if distance < bestdistance and airframes >= wingsize then
|
||||
bestdistance = distance
|
||||
targetairwing = airwing -- Ops.AirWing#AIRWING
|
||||
targetawname = name
|
||||
end
|
||||
end
|
||||
local text = string.format("Closest Airwing is %s", targetawname)
|
||||
local m = MESSAGE:New(text,10,"CAPGCI"):ToAllIf(self.debug):ToLog()
|
||||
-- Do we have a matching airwing?
|
||||
if targetairwing then
|
||||
local AssetCount = targetairwing:CountAssetsOnMission(MissionTypes,Cohort)
|
||||
--[[
|
||||
local Assets = targetairwing:GetAssetsOnMission(AUFTRAG.Type.GCICAP)
|
||||
for _,_asset in pairs(Assets) do
|
||||
local asset = _asset -- Functional.Warehouse#WAREHOUSE.Assetitem
|
||||
local fg = asset.flightgroup
|
||||
local name = asset.spawngroupname
|
||||
local mission = fg:GetMissionCurrent()
|
||||
local mtype = mission.type
|
||||
local distance = position:Get3DDistance(fg:GetCoordinate()) or 1000*1000
|
||||
distance = distance / 1000
|
||||
local text = string.format("FlightGroup %s on mission %s with distance %d km",name,mtype,distance)
|
||||
local m = MESSAGE:New(text,15,"GCICAP"):ToAllIf(self.debug):ToLog()
|
||||
end
|
||||
--]]
|
||||
-- Enough airframes on mission already?
|
||||
self:T(self.lid.." Assets on Mission "..AssetCount)
|
||||
if AssetCount <= MaxAliveMissions then
|
||||
local repeats = repeatsonfailure
|
||||
local InterceptAuftrag = AUFTRAG:NewINTERCEPT(contact.group)
|
||||
:SetMissionRange(150)
|
||||
:SetPriority(1,true,1)
|
||||
:SetRequiredAssets(wingsize)
|
||||
:SetRepeatOnFailure(repeats)
|
||||
:SetMissionSpeed(UTILS.KnotsToAltKIAS(capspeed,capalt))
|
||||
:SetMissionAltitude(capalt)
|
||||
|
||||
if nogozoneset:Count() > 0 then
|
||||
InterceptAuftrag:AddConditionSuccess(
|
||||
function(group,zoneset)
|
||||
local success = false
|
||||
if group and group:IsAlive() then
|
||||
local coord = group:GetCoordinate()
|
||||
if coord and zoneset:IsCoordinateInZone(coord) then
|
||||
success = true
|
||||
end
|
||||
end
|
||||
return success
|
||||
end,
|
||||
contact.group,
|
||||
nogozoneset
|
||||
)
|
||||
end
|
||||
|
||||
targetairwing:AddMission(InterceptAuftrag)
|
||||
Cluster.mission = InterceptAuftrag
|
||||
end
|
||||
else
|
||||
MESSAGE:New("**** Not enough airframes available or max mission limit reached!",15,"CAPGCI"):ToAllIf(self.debug):ToLog()
|
||||
end
|
||||
end
|
||||
AssignCluster(Cluster)
|
||||
end
|
||||
self.Intel = BlueIntel
|
||||
return self
|
||||
|
||||
self.Intel = BlueIntel
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
@@ -1266,6 +1347,24 @@ function EASYGCICAP:onafterStatus(From,Event,To)
|
||||
tankermission = tankermission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.TANKER})
|
||||
assets = assets + count
|
||||
instock = instock + count2
|
||||
local assetsonmission = _wing[1]:GetAssetsOnMission({AUFTRAG.Type.GCICAP,AUFTRAG.Type.PATROLRACETRACK})
|
||||
-- update ready groups
|
||||
self.ReadyFlightGroups = nil
|
||||
self.ReadyFlightGroups = {}
|
||||
for _,_asset in pairs(assetsonmission or {}) do
|
||||
local asset = _asset -- Functional.Warehouse#WAREHOUSE.Assetitem
|
||||
local FG = asset.flightgroup -- Ops.FlightGroup#FLIGHTGROUP
|
||||
if FG then
|
||||
local name = FG:GetName()
|
||||
local engage = FG:IsEngaging()
|
||||
local hasmissiles = FG:IsOutOfMissiles() == nil and true or false
|
||||
local ready = hasmissiles and FG:IsFuelGood() and FG:IsAirborne()
|
||||
--self:I(string.format("Flightgroup %s Engaging = %s Ready = %s",tostring(name),tostring(engage),tostring(ready)))
|
||||
if ready then
|
||||
self.ReadyFlightGroups[name] = FG
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.Monitor then
|
||||
local threatcount = #self.Intel.Clusters or 0
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Fleet).
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Fleet).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20FlightControl).
|
||||
-- Demo missions: None
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -207,9 +207,9 @@
|
||||
-- landing is `21L`.
|
||||
--
|
||||
-- By default, the runways for landing and takeoff are determined from the wind direction as described above. For cases where this gives wrong results, you can set the active runways manually. This is
|
||||
-- done via @{Wrappper.Airbase#AIRBASE} class.
|
||||
-- done via @{Wrapper.Airbase#AIRBASE} class.
|
||||
--
|
||||
-- More specifically, you can use the @{Wrappper.Airbase#AIRBASE.SetActiveRunwayLanding} function to set the landing runway and the @{Wrappper.Airbase#AIRBASE.SetActiveRunwayTakeoff} function to set
|
||||
-- More specifically, you can use the @{Wrapper.Airbase#AIRBASE.SetActiveRunwayLanding} function to set the landing runway and the @{Wrapper.Airbase#AIRBASE.SetActiveRunwayTakeoff} function to set
|
||||
-- the runway for takeoff.
|
||||
--
|
||||
-- ## Example for Nellis AFB
|
||||
@@ -223,7 +223,7 @@
|
||||
--
|
||||
-- # DCS ATC
|
||||
--
|
||||
-- You can disable the DCS ATC with the @{Wrappper.Airbase#AIRBASE.SetRadioSilentMode}(*true*). This does not remove the DCS ATC airbase from the F10 menu but makes the ATC unresponsive.
|
||||
-- You can disable the DCS ATC with the @{Wrapper.Airbase#AIRBASE.SetRadioSilentMode}(*true*). This does not remove the DCS ATC airbase from the F10 menu but makes the ATC unresponsive.
|
||||
--
|
||||
--
|
||||
-- # Examples
|
||||
@@ -411,26 +411,36 @@ function FLIGHTCONTROL:New(AirbaseName, Frequency, Modulation, PathToSRS, Port,
|
||||
self:SetRunwayRepairtime()
|
||||
self.nosubs = false
|
||||
|
||||
-- Set SRS Port
|
||||
self:SetSRSPort(Port or 5002)
|
||||
|
||||
-- Set Callsign Options
|
||||
self:SetCallSignOptions(true,true)
|
||||
|
||||
-- Init msrs queue.
|
||||
self.msrsqueue=MSRSQUEUE:New(self.alias)
|
||||
|
||||
-- Init msrs bases
|
||||
local path = PathToSRS or MSRS.path
|
||||
local port = Port or MSRS.port or 5002
|
||||
|
||||
-- Set SRS Port
|
||||
self:SetSRSPort(port)
|
||||
|
||||
-- SRS for Tower.
|
||||
self.msrsTower=MSRS:New(PathToSRS, Frequency, Modulation)
|
||||
self.msrsTower:SetPort(self.Port)
|
||||
self.msrsTower:SetGoogle(GoogleKey)
|
||||
self.msrsTower=MSRS:New(path, Frequency, Modulation)
|
||||
self.msrsTower:SetPort(port)
|
||||
if GoogleKey then
|
||||
self.msrsTower:SetProviderOptionsGoogle(GoogleKey,GoogleKey)
|
||||
self.msrsTower:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
self.msrsTower:SetCoordinate(self:GetCoordinate())
|
||||
self:SetSRSTower()
|
||||
|
||||
-- SRS for Pilot.
|
||||
self.msrsPilot=MSRS:New(PathToSRS, Frequency, Modulation)
|
||||
self.msrsPilot:SetPort(self.Port)
|
||||
self.msrsPilot:SetGoogle(GoogleKey)
|
||||
if GoogleKey then
|
||||
self.msrsPilot:SetProviderOptionsGoogle(GoogleKey,GoogleKey)
|
||||
self.msrsPilot:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
self.msrsTower:SetCoordinate(self:GetCoordinate())
|
||||
self:SetSRSPilot()
|
||||
|
||||
@@ -633,7 +643,6 @@ function FLIGHTCONTROL:_SetSRSOptions(msrs, Gender, Culture, Voice, Volume, Labe
|
||||
msrs:SetVoice(Voice)
|
||||
msrs:SetVolume(Volume)
|
||||
msrs:SetLabel(Label)
|
||||
msrs:SetGoogle(PathToGoogleCredentials)
|
||||
msrs:SetCoalition(self:GetCoalition())
|
||||
msrs:SetPort(Port or self.Port or 5002)
|
||||
end
|
||||
@@ -648,12 +657,11 @@ end
|
||||
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`. See [Google Voices](https://cloud.google.com/text-to-speech/docs/voices).
|
||||
-- @param #number Volume Volume. Default 1.0.
|
||||
-- @param #string Label Name under which SRS transmits. Default `self.alias`.
|
||||
-- @param #string PathToGoogleCredentials Path to google credentials json file.
|
||||
-- @return #FLIGHTCONTROL self
|
||||
function FLIGHTCONTROL:SetSRSTower(Gender, Culture, Voice, Volume, Label, PathToGoogleCredentials)
|
||||
function FLIGHTCONTROL:SetSRSTower(Gender, Culture, Voice, Volume, Label)
|
||||
|
||||
if self.msrsTower then
|
||||
self:_SetSRSOptions(self.msrsTower, Gender or "female", Culture or "en-GB", Voice, Volume, Label or self.alias, PathToGoogleCredentials)
|
||||
self:_SetSRSOptions(self.msrsTower, Gender or "female", Culture or "en-GB", Voice, Volume, Label or self.alias)
|
||||
end
|
||||
|
||||
return self
|
||||
@@ -666,12 +674,11 @@ end
|
||||
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`.
|
||||
-- @param #number Volume Volume. Default 1.0.
|
||||
-- @param #string Label Name under which SRS transmits. Default "Pilot".
|
||||
-- @param #string PathToGoogleCredentials Path to google credentials json file.
|
||||
-- @return #FLIGHTCONTROL self
|
||||
function FLIGHTCONTROL:SetSRSPilot(Gender, Culture, Voice, Volume, Label, PathToGoogleCredentials)
|
||||
function FLIGHTCONTROL:SetSRSPilot(Gender, Culture, Voice, Volume, Label)
|
||||
|
||||
if self.msrsPilot then
|
||||
self:_SetSRSOptions(self.msrsPilot, Gender or "male", Culture or "en-US", Voice, Volume, Label or "Pilot", PathToGoogleCredentials)
|
||||
self:_SetSRSOptions(self.msrsPilot, Gender or "male", Culture or "en-US", Voice, Volume, Label or "Pilot")
|
||||
end
|
||||
|
||||
return self
|
||||
@@ -876,7 +883,7 @@ end
|
||||
|
||||
--- Set ATIS.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @param Ops.Atis#ATIS Atis ATIS.
|
||||
-- @param Ops.ATIS#ATIS Atis ATIS.
|
||||
-- @return #FLIGHTCONTROL self
|
||||
function FLIGHTCONTROL:SetATIS(Atis)
|
||||
self.atis=Atis
|
||||
@@ -2811,7 +2818,11 @@ function FLIGHTCONTROL:_PlayerInfoATIS(groupname)
|
||||
|
||||
-- Radio message.
|
||||
self:TransmissionPilot(rtext, flight)
|
||||
self:TransmissionTower(srstxt,flight,10)
|
||||
if self.atis then
|
||||
self:TransmissionTower(srstxt,flight,10)
|
||||
else
|
||||
self:TransmissionTower(text,flight,10)
|
||||
end
|
||||
|
||||
else
|
||||
self:E(self.lid..string.format("Cannot find flight group %s.", tostring(groupname)))
|
||||
@@ -4420,14 +4431,11 @@ end
|
||||
-- Misc Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Add parking guard in front of a parking aircraft.
|
||||
--- [INTERNAL] Add parking guard in front of a parking aircraft - delayed for MP.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @param Wrapper.Unit#UNIT unit The aircraft.
|
||||
function FLIGHTCONTROL:SpawnParkingGuard(unit)
|
||||
|
||||
if unit and self.parkingGuard then
|
||||
|
||||
-- Position of the unit.
|
||||
function FLIGHTCONTROL:_SpawnParkingGuard(unit)
|
||||
-- Position of the unit.
|
||||
local coordinate=unit:GetCoordinate()
|
||||
|
||||
-- Parking spot.
|
||||
@@ -4474,6 +4482,17 @@ function FLIGHTCONTROL:SpawnParkingGuard(unit)
|
||||
else
|
||||
self:E(self.lid.."ERROR: Parking Guard already exists!")
|
||||
end
|
||||
end
|
||||
|
||||
--- Add parking guard in front of a parking aircraft.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @param Wrapper.Unit#UNIT unit The aircraft.
|
||||
function FLIGHTCONTROL:SpawnParkingGuard(unit)
|
||||
|
||||
if unit and self.parkingGuard then
|
||||
|
||||
-- Schedule delay so in MP we get the heading of the client's plane
|
||||
self:ScheduleOnce(1,FLIGHTCONTROL._SpawnParkingGuard,self,unit)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Flightgroup).
|
||||
-- Demo missions can be found on [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Flightgroup).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -44,7 +44,7 @@
|
||||
-- @field #boolean fuelcritical Fuel critical switch.
|
||||
-- @field #number fuelcriticalthresh Critical fuel threshold in percent.
|
||||
-- @field #boolean fuelcriticalrtb RTB on critical fuel switch.
|
||||
-- @field Ops.FlightControl#FLIGHTCONTROL flightcontrol The flightcontrol handling this group.
|
||||
-- @field OPS.FlightControl#FLIGHTCONTROL flightcontrol The flightcontrol handling this group.
|
||||
-- @field Ops.Airboss#AIRBOSS airboss The airboss handling this group.
|
||||
-- @field Core.UserFlag#USERFLAG flaghold Flag for holding.
|
||||
-- @field #number Tholding Abs. mission time stamp when the group reached the holding point.
|
||||
@@ -54,7 +54,7 @@
|
||||
-- @field #boolean despawnAfterLanding If `true`, group is despawned after landed at an airbase.
|
||||
-- @field #boolean despawnAfterHolding If `true`, group is despawned after reaching the holding point.
|
||||
-- @field #number RTBRecallCount Number that counts RTB calls.
|
||||
-- @field Ops.FlightControl#FLIGHTCONTROL.HoldingStack stack Holding stack.
|
||||
-- @field OPS.FlightControl#FLIGHTCONTROL.HoldingStack stack Holding stack.
|
||||
-- @field #boolean isReadyTO Flight is ready for takeoff. This is for FLIGHTCONTROL.
|
||||
-- @field #boolean prohibitAB Disallow (true) or allow (false) AI to use the afterburner.
|
||||
-- @field #boolean jettisonEmptyTanks Allow (true) or disallow (false) AI to jettison empty fuel tanks.
|
||||
@@ -695,7 +695,7 @@ end
|
||||
|
||||
--- Get airwing the flight group belongs to.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @return Ops.AirWing#AIRWING The AIRWING object (if any).
|
||||
-- @return Ops.Airwing#AIRWING The AIRWING object (if any).
|
||||
function FLIGHTGROUP:GetAirwing()
|
||||
return self.legion
|
||||
end
|
||||
@@ -793,7 +793,7 @@ end
|
||||
|
||||
--- Set the FLIGHTCONTROL controlling this flight group.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param Ops.FlightControl#FLIGHTCONTROL flightcontrol The FLIGHTCONTROL object.
|
||||
-- @param OPS.FlightControl#FLIGHTCONTROL flightcontrol The FLIGHTCONTROL object.
|
||||
-- @return #FLIGHTGROUP self
|
||||
function FLIGHTGROUP:SetFlightControl(flightcontrol)
|
||||
|
||||
@@ -822,7 +822,7 @@ end
|
||||
|
||||
--- Get the FLIGHTCONTROL controlling this flight group.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @return Ops.FlightControl#FLIGHTCONTROL The FLIGHTCONTROL object.
|
||||
-- @return OPS.FlightControl#FLIGHTCONTROL The FLIGHTCONTROL object.
|
||||
function FLIGHTGROUP:GetFlightControl()
|
||||
return self.flightcontrol
|
||||
end
|
||||
@@ -2333,7 +2333,8 @@ function FLIGHTGROUP:onafterCruise(From, Event, To)
|
||||
-- CLIENT
|
||||
---
|
||||
|
||||
--self:_UpdateMenu(0.1)
|
||||
-- Had this commented out (forgot why, probably because it was not necessary) but re-enabling it because of carrier launch.
|
||||
self:_UpdateMenu(0.1)
|
||||
|
||||
end
|
||||
|
||||
@@ -2863,8 +2864,11 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime)
|
||||
end
|
||||
|
||||
else
|
||||
-- Check if not parking (could be on ALERT5 and just spawned (current mission=nil)
|
||||
if not self:IsParking() then
|
||||
self:T(self.lid..string.format("Passed Final WP but Tasks=%d or Missions=%d left in the queue. Wait!", nTasks, nMissions))
|
||||
self:__Wait(-1)
|
||||
end
|
||||
end
|
||||
else
|
||||
self:T(self.lid..string.format("Passed Final WP but still have current Task (#%s) or Mission (#%s) left to do", tostring(self.taskcurrent), tostring(self.currentmission)))
|
||||
@@ -3227,13 +3231,22 @@ function FLIGHTGROUP:_LandAtAirbase(airbase, SpeedTo, SpeedHold, SpeedLand)
|
||||
local TaskFinal = self.group:TaskFunction("FLIGHTGROUP._OnFinal", self)
|
||||
|
||||
-- Final approach waypoint.
|
||||
local papp=airbase:GetCoordinate():Translate(x1, runway.heading-180):SetAltitude(h1)
|
||||
local rheading
|
||||
if runway then
|
||||
rheading = runway.heading-180
|
||||
else
|
||||
-- AB HeloBase w/o runway eg Naqoura
|
||||
local wind = airbase:GetCoordinate():GetWind()
|
||||
rheading = -wind
|
||||
end
|
||||
|
||||
local papp=airbase:GetCoordinate():Translate(x1, rheading):SetAltitude(h1)
|
||||
wp[#wp+1]=papp:WaypointAirTurningPoint("BARO", UTILS.KnotsToKmph(SpeedLand), {TaskFinal}, "Final Approach")
|
||||
|
||||
-- Okay, it looks like it's best to specify the coordinates not at the airbase but a bit away. This causes a more direct landing approach.
|
||||
local pland=airbase:GetCoordinate():Translate(x2, runway.heading-180):SetAltitude(h2)
|
||||
local pland=airbase:GetCoordinate():Translate(x2, rheading):SetAltitude(h2)
|
||||
wp[#wp+1]=pland:WaypointAirLanding(UTILS.KnotsToKmph(SpeedLand), airbase, {}, "Landing")
|
||||
|
||||
|
||||
elseif airbase:IsShip() or airbase:IsHelipad() then
|
||||
|
||||
---
|
||||
@@ -3786,10 +3799,11 @@ function FLIGHTGROUP:_InitGroup(Template)
|
||||
self.speedMax=group:GetSpeedMax()
|
||||
|
||||
-- Is group mobile?
|
||||
if self.speedMax>3.6 then
|
||||
if self.speedMax and self.speedMax>3.6 then
|
||||
self.isMobile=true
|
||||
else
|
||||
self.isMobile=false
|
||||
self.speedMax = 0
|
||||
end
|
||||
|
||||
-- Cruise speed limit 380 kts for fixed and 110 knots for rotary wings.
|
||||
@@ -4858,7 +4872,7 @@ function FLIGHTGROUP:_UpdateMenu(delay)
|
||||
-- Get all FLIGHTCONTROLS
|
||||
local fc={}
|
||||
for airbasename,_flightcontrol in pairs(_DATABASE.FLIGHTCONTROLS) do
|
||||
local flightcontrol=_flightcontrol --Ops.FlightControl#FLIGHTCONTROL
|
||||
local flightcontrol=_flightcontrol --OPS.FlightControl#FLIGHTCONTROL
|
||||
|
||||
-- Get coord of airbase.
|
||||
local coord=flightcontrol:GetCoordinate()
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
-- @field #table filterCategoryGroup Filter for group categories.
|
||||
-- @field Core.Set#SET_ZONE acceptzoneset Set of accept zones. If defined, only contacts in these zones are considered.
|
||||
-- @field Core.Set#SET_ZONE rejectzoneset Set of reject zones. Contacts in these zones are not considered, even if they are in accept zones.
|
||||
-- @field Core.Set#SET_ZONE conflictzoneset Set of conflict zones. Contacts in these zones are considered, even if they are not in accept zones or if they are in reject zones.
|
||||
-- @field #table Contacts Table of detected items.
|
||||
-- @field #table ContactsLost Table of lost detected items.
|
||||
-- @field #table ContactsUnknown Table of new detected items.
|
||||
@@ -159,13 +160,12 @@ INTEL.Ctype={
|
||||
|
||||
--- INTEL class version.
|
||||
-- @field #string version
|
||||
INTEL.version="0.3.5"
|
||||
INTEL.version="0.3.6"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: Make forget times user input. Currently these are hard coded.
|
||||
-- TODO: Add min cluster size. Only create new clusters if they have a certain group size.
|
||||
-- TODO: process detected set asynchroniously for better performance.
|
||||
-- DONE: Add statics.
|
||||
@@ -266,6 +266,7 @@ function INTEL:New(DetectionSet, Coalition, Alias)
|
||||
self:SetForgetTime()
|
||||
self:SetAcceptZones()
|
||||
self:SetRejectZones()
|
||||
self:SetConflictZones()
|
||||
|
||||
------------------------
|
||||
--- Pseudo Functions ---
|
||||
@@ -416,7 +417,7 @@ function INTEL:RemoveAcceptZone(AcceptZone)
|
||||
end
|
||||
|
||||
--- Set reject zones. Contacts detected in this/these zone(s) are rejected and not reported by the detection.
|
||||
-- Note that reject zones overrule accept zones, i.e. if a unit is inside and accept zone and inside a reject zone, it is rejected.
|
||||
-- Note that reject zones overrule accept zones, i.e. if a unit is inside an accept zone and inside a reject zone, it is rejected.
|
||||
-- @param #INTEL self
|
||||
-- @param Core.Set#SET_ZONE RejectZoneSet Set of reject zone(s).
|
||||
-- @return #INTEL self
|
||||
@@ -426,7 +427,7 @@ function INTEL:SetRejectZones(RejectZoneSet)
|
||||
end
|
||||
|
||||
--- Add a reject zone. Contacts detected in this zone are rejected and not reported by the detection.
|
||||
-- Note that reject zones overrule accept zones, i.e. if a unit is inside and accept zone and inside a reject zone, it is rejected.
|
||||
-- Note that reject zones overrule accept zones, i.e. if a unit is inside an accept zone and inside a reject zone, it is rejected.
|
||||
-- @param #INTEL self
|
||||
-- @param Core.Zone#ZONE RejectZone Add a zone to the reject zone set.
|
||||
-- @return #INTEL self
|
||||
@@ -444,6 +445,36 @@ function INTEL:RemoveRejectZone(RejectZone)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set conflict zones. Contacts detected in this/these zone(s) are reported by the detection.
|
||||
-- Note that conflict zones overrule all other zones, i.e. if a unit is outside of an accept zone and inside a reject zone, it is still reported if inside a conflict zone.
|
||||
-- @param #INTEL self
|
||||
-- @param Core.Set#SET_ZONE ConflictZoneSet Set of conflict zone(s).
|
||||
-- @return #INTEL self
|
||||
function INTEL:SetConflictZones(ConflictZoneSet)
|
||||
self.conflictzoneset=ConflictZoneSet or SET_ZONE:New()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add a conflict zone. Contacts detected in this zone are conflicted and not reported by the detection.
|
||||
-- Note that conflict zones overrule all other zones, i.e. if a unit is outside of an accept zone and inside a reject zone, it is still reported if inside a conflict zone.
|
||||
-- @param #INTEL self
|
||||
-- @param Core.Zone#ZONE ConflictZone Add a zone to the conflict zone set.
|
||||
-- @return #INTEL self
|
||||
function INTEL:AddConflictZone(ConflictZone)
|
||||
self.conflictzoneset:AddZone(ConflictZone)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Remove a conflict zone from the conflict zone set.
|
||||
-- Note that conflict zones overrule all other zones, i.e. if a unit is outside of an accept zone and inside a reject zone, it is still reported if inside a conflict zone.
|
||||
-- @param #INTEL self
|
||||
-- @param Core.Zone#ZONE ConflictZone Remove a zone from the conflict zone set.
|
||||
-- @return #INTEL self
|
||||
function INTEL:RemoveConflictZone(ConflictZone)
|
||||
self.conflictzoneset:Remove(ConflictZone:GetName(), true)
|
||||
return self
|
||||
end
|
||||
|
||||
--- **OBSOLETE, will be removed in next version!** Set forget contacts time interval.
|
||||
-- Previously known contacts that are not detected any more, are "lost" after this time.
|
||||
-- This avoids fast oscillations between a contact being detected and undetected.
|
||||
@@ -481,6 +512,33 @@ function INTEL:SetFilterCategory(Categories)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Method to make the radar detection less accurate, e.g. for WWII scenarios.
|
||||
-- @param #INTEL 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 #INTEL self
|
||||
function INTEL: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
|
||||
|
||||
--- Set the accept range in kilometers from each of the recce. Only object closer than this range will be detected.
|
||||
-- @param #INTEL self
|
||||
-- @param #number Range Range in kilometers
|
||||
-- @return #INTEL self
|
||||
function INTEL:SetAcceptRange(Range)
|
||||
self.RadarAcceptRange = true
|
||||
self.RadarAcceptRangeKilometers = Range or 75
|
||||
return self
|
||||
end
|
||||
|
||||
--- Filter group categories. Valid categories are:
|
||||
--
|
||||
-- * Group.Category.AIRPLANE
|
||||
@@ -520,7 +578,7 @@ function INTEL:AddAgent(AgentGroup)
|
||||
end
|
||||
|
||||
-- Add to detection set.
|
||||
self.detectionset:AddGroup(AgentGroup)
|
||||
self.detectionset:AddGroup(AgentGroup,true)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -780,7 +838,19 @@ function INTEL:UpdateIntel()
|
||||
local remove={}
|
||||
for unitname,_unit in pairs(DetectedUnits) do
|
||||
local unit=_unit --Wrapper.Unit#UNIT
|
||||
|
||||
|
||||
local inconflictzone=false
|
||||
-- Check if unit is in any of the conflict zones.
|
||||
if self.conflictzoneset:Count()>0 then
|
||||
for _,_zone in pairs(self.conflictzoneset.Set) do
|
||||
local zone=_zone --Core.Zone#ZONE
|
||||
if unit:IsInZone(zone) then
|
||||
inconflictzone=true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if unit is in any of the accept zones.
|
||||
if self.acceptzoneset:Count()>0 then
|
||||
local inzone=false
|
||||
@@ -793,7 +863,7 @@ function INTEL:UpdateIntel()
|
||||
end
|
||||
|
||||
-- Unit is not in accept zone ==> remove!
|
||||
if not inzone then
|
||||
if (not inzone) and (not inconflictzone) then
|
||||
table.insert(remove, unitname)
|
||||
end
|
||||
end
|
||||
@@ -810,7 +880,7 @@ function INTEL:UpdateIntel()
|
||||
end
|
||||
|
||||
-- Unit is inside a reject zone ==> remove!
|
||||
if inzone then
|
||||
if inzone and (not inconflictzone) then
|
||||
table.insert(remove, unitname)
|
||||
end
|
||||
end
|
||||
@@ -1036,8 +1106,8 @@ function INTEL:CreateDetectedItems(DetectedGroups, DetectedStatics, RecceDetecti
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Internal) Return the detected target groups of the controllable as a @{SET_GROUP}.
|
||||
-- The optional parametes specify the detection methods that can be applied.
|
||||
--- (Internal) Return the detected target groups of the controllable as a @{Core.Set#SET_GROUP}.
|
||||
-- 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.
|
||||
-- @param #INTEL self
|
||||
-- @param Wrapper.Unit#UNIT Unit The unit detecting.
|
||||
@@ -1053,6 +1123,7 @@ function INTEL:GetDetectedUnits(Unit, DetectedUnits, RecceDetecting, DetectVisua
|
||||
|
||||
-- Get detected DCS units.
|
||||
local reccename = Unit:GetName()
|
||||
|
||||
local detectedtargets=Unit:GetDetectedTargets(DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK)
|
||||
|
||||
for DetectionObjectID, Detection in pairs(detectedtargets or {}) do
|
||||
@@ -1071,11 +1142,47 @@ function INTEL:GetDetectedUnits(Unit, DetectedUnits, RecceDetecting, DetectVisua
|
||||
if status then
|
||||
|
||||
local unit=UNIT:FindByName(name)
|
||||
|
||||
|
||||
if unit and unit:IsAlive() then
|
||||
DetectedUnits[name]=unit
|
||||
RecceDetecting[name]=reccename
|
||||
self:T(string.format("Unit %s detect by %s", name, reccename))
|
||||
local DetectionAccepted = true
|
||||
|
||||
if self.RadarAcceptRange then
|
||||
local reccecoord = Unit:GetCoordinate()
|
||||
local coord = unit:GetCoordinate()
|
||||
local dist = math.floor(coord:Get2DDistance(reccecoord)/1000) -- km
|
||||
if dist > self.RadarAcceptRangeKilometers then DetectionAccepted = false end
|
||||
end
|
||||
|
||||
if self.RadarBlur then
|
||||
local reccecoord = Unit:GetCoordinate()
|
||||
local coord = unit:GetCoordinate()
|
||||
local dist = math.floor(coord:Get2DDistance(reccecoord)/1000) -- km
|
||||
local AGL = unit:GetAltitude(true)
|
||||
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)
|
||||
if fblur > thresblur then DetectionAccepted = false end
|
||||
if AGL <= minheight and fheight < thresheight then DetectionAccepted = false end
|
||||
if self.debug or self.verbose > 1 then
|
||||
MESSAGE:New("Radar Blur",10):ToLogIf(self.debug):ToAllIf(self.verbose>1)
|
||||
MESSAGE:New("Unit "..name.." is at "..math.floor(AGL).."m. Distance "..math.floor(dist).."km.",10):ToLogIf(self.debug):ToAllIf(self.verbose>1)
|
||||
MESSAGE:New(string.format("fheight = %d/%d | fblur = %d/%d",fheight,thresheight,fblur,thresblur),10):ToLogIf(self.debug):ToAllIf(self.verbose>1)
|
||||
MESSAGE:New("Detection Accepted = "..tostring(DetectionAccepted),10):ToLogIf(self.debug):ToAllIf(self.verbose>1)
|
||||
end
|
||||
end
|
||||
|
||||
if DetectionAccepted then
|
||||
DetectedUnits[name]=unit
|
||||
RecceDetecting[name]=reccename
|
||||
self:T(string.format("Unit %s detect by %s", name, reccename))
|
||||
end
|
||||
else
|
||||
if self.detectStatics then
|
||||
local static=STATIC:FindByName(name, false)
|
||||
@@ -1093,7 +1200,6 @@ function INTEL:GetDetectedUnits(Unit, DetectedUnits, RecceDetecting, DetectVisua
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -2166,7 +2272,7 @@ function INTEL:GetHighestThreatContact(Cluster)
|
||||
|
||||
for _,_contact in pairs(Cluster.Contacts) do
|
||||
|
||||
local contact=_contact --Ops.Intelligence#INTEL.Contact
|
||||
local contact=_contact --Ops.Intel#INTEL.Contact
|
||||
|
||||
if contact.threatlevel>threatlevel then
|
||||
threatlevel=contact.threatlevel
|
||||
@@ -2206,8 +2312,8 @@ end
|
||||
-- @field #string alias Alias name for logging.
|
||||
-- @field #number cachetime Number of seconds to keep an object.
|
||||
-- @field #number interval Number of seconds between collection runs.
|
||||
-- @field #table contacts Table of Ops.Intelligence#INTEL.Contact contacts.
|
||||
-- @field #table clusters Table of Ops.Intelligence#INTEL.Cluster clusters.
|
||||
-- @field #table contacts Table of Ops.Intel#INTEL.Contact contacts.
|
||||
-- @field #table clusters Table of Ops.Intel#INTEL.Cluster clusters.
|
||||
-- @field #table contactcoords Table of contacts' Core.Point#COORDINATE objects.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
@@ -2231,7 +2337,7 @@ INTEL_DLINK.version = "0.0.1"
|
||||
|
||||
--- Function to instantiate a new object
|
||||
-- @param #INTEL_DLINK self
|
||||
-- @param #table Intels Table of Ops.Intelligence#INTEL objects.
|
||||
-- @param #table Intels Table of Ops.Intel#INTEL objects.
|
||||
-- @param #string Alias (optional) Name of this instance. Default "SPECTRE"
|
||||
-- @param #number Interval (optional) When to query #INTEL objects for detected items (default 20 seconds).
|
||||
-- @param #number Cachetime (optional) How long to cache detected items (default 300 seconds).
|
||||
@@ -2343,7 +2449,7 @@ end
|
||||
|
||||
--- Function to add an #INTEL object to the aggregator
|
||||
-- @param #INTEL_DLINK self
|
||||
-- @param Ops.Intelligence#INTEL Intel the #INTEL object to add
|
||||
-- @param Ops.Intel#INTEL Intel the #INTEL object to add
|
||||
-- @return #INTEL_DLINK self
|
||||
function INTEL_DLINK:AddIntel(Intel)
|
||||
self:T(self.lid .. "AddIntel")
|
||||
|
||||
@@ -2265,7 +2265,7 @@ function LEGION:RecruitAssetsForMission(Mission)
|
||||
end
|
||||
end
|
||||
|
||||
self:T(self.lid..string.format("Largest cargo bay available=%.1f", MaxWeight))
|
||||
self:T(self.lid..string.format("Largest cargo bay available=%.1f", MaxWeight or 0))
|
||||
end
|
||||
|
||||
|
||||
@@ -2745,7 +2745,7 @@ function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt,
|
||||
end
|
||||
|
||||
-- Now we have a long list with assets.
|
||||
LEGION._OptimizeAssetSelection(Assets, MissionTypeOpt, TargetVec2, false)
|
||||
LEGION._OptimizeAssetSelection(Assets, MissionTypeOpt, TargetVec2, false, TotalWeight)
|
||||
|
||||
|
||||
-- Get payloads for air assets.
|
||||
@@ -2770,7 +2770,7 @@ function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt,
|
||||
end
|
||||
|
||||
-- Now find the best asset for the given payloads.
|
||||
LEGION._OptimizeAssetSelection(Assets, MissionTypeOpt, TargetVec2, true)
|
||||
LEGION._OptimizeAssetSelection(Assets, MissionTypeOpt, TargetVec2, true, TotalWeight)
|
||||
|
||||
-- Number of assets. At most NreqMax.
|
||||
local Nassets=math.min(#Assets, NreqMax)
|
||||
@@ -3114,8 +3114,9 @@ end
|
||||
-- @param #string MissionType Mission type for which the best assets are desired.
|
||||
-- @param DCS#Vec2 TargetVec2 Target 2D vector.
|
||||
-- @param #boolean IncludePayload If `true`, include the payload in the calulation if the asset has one attached.
|
||||
-- @param #number TotalWeight The total weight of the cargo to be transported, if applicable.
|
||||
-- @return #number Mission score.
|
||||
function LEGION.CalculateAssetMissionScore(asset, MissionType, TargetVec2, IncludePayload)
|
||||
function LEGION.CalculateAssetMissionScore(asset, MissionType, TargetVec2, IncludePayload, TotalWeight)
|
||||
|
||||
-- Mission score.
|
||||
local score=0
|
||||
@@ -3189,14 +3190,14 @@ function LEGION.CalculateAssetMissionScore(asset, MissionType, TargetVec2, Inclu
|
||||
elseif (currmission.type==AUFTRAG.Type.ONGUARD or currmission.type==AUFTRAG.Type.PATROLZONE) and (MissionType==AUFTRAG.Type.ARTY or MissionType==AUFTRAG.Type.GROUNDATTACK) then
|
||||
score=score+25
|
||||
elseif currmission.type==AUFTRAG.Type.NOTHING then
|
||||
score=score+25
|
||||
score=score+30
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if MissionType==AUFTRAG.Type.OPSTRANSPORT or MissionType==AUFTRAG.Type.AMMOSUPPLY or MissionType==AUFTRAG.Type.AWACS or MissionType==AUFTRAG.Type.FUELSUPPLY or MissionType==AUFTRAG.Type.TANKER then
|
||||
-- TODO: need to check for missions that do not require ammo like transport, recon, awacs, tanker etc.
|
||||
-- We better take a fresh asset. Sometimes spawned assets to something else, which is difficult to check.
|
||||
-- We better take a fresh asset. Sometimes spawned assets do something else, which is difficult to check.
|
||||
score=score-10
|
||||
else
|
||||
-- Combat mission.
|
||||
@@ -3209,8 +3210,18 @@ function LEGION.CalculateAssetMissionScore(asset, MissionType, TargetVec2, Inclu
|
||||
|
||||
-- TRANSPORT specific.
|
||||
if MissionType==AUFTRAG.Type.OPSTRANSPORT then
|
||||
-- Add 1 score point for each 10 kg of cargo bay.
|
||||
score=score+UTILS.Round(asset.cargobaymax/10, 0)
|
||||
if TotalWeight then
|
||||
-- Add 1 score point for each 10 kg of cargo bay capacity up to the total cargo weight,
|
||||
-- and then subtract 1 score point for each excess 10kg of cargo bay capacity.
|
||||
if asset.cargobaymax < TotalWeight then
|
||||
score=score+UTILS.Round(asset.cargobaymax/10, 0)
|
||||
else
|
||||
score=score+UTILS.Round(TotalWeight/10, 0)
|
||||
end
|
||||
else
|
||||
-- Add 1 score point for each 10 kg of cargo bay.
|
||||
score=score+UTILS.Round(asset.cargobaymax/10, 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: This could be vastly improved. Need to gather ideas during testing.
|
||||
@@ -3231,14 +3242,15 @@ end
|
||||
-- @param #string MissionType Mission type.
|
||||
-- @param DCS#Vec2 TargetVec2 Target position as 2D vector.
|
||||
-- @param #boolean IncludePayload If `true`, include the payload in the calulation if the asset has one attached.
|
||||
function LEGION._OptimizeAssetSelection(assets, MissionType, TargetVec2, IncludePayload)
|
||||
-- @param #number TotalWeight The total weight of the cargo to be transported, if applicable.
|
||||
function LEGION._OptimizeAssetSelection(assets, MissionType, TargetVec2, IncludePayload, TotalWeight)
|
||||
|
||||
-- Calculate the mission score of all assets.
|
||||
for _,_asset in pairs(assets) do
|
||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||
|
||||
-- Calculate the asset score.
|
||||
asset.score=LEGION.CalculateAssetMissionScore(asset, MissionType, TargetVec2, IncludePayload)
|
||||
asset.score=LEGION.CalculateAssetMissionScore(asset, MissionType, TargetVec2, IncludePayload, TotalWeight)
|
||||
|
||||
if IncludePayload then
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
-- ===
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Navygroup)
|
||||
--
|
||||
--
|
||||
-- Demo missions can be found on [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Navygroup)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **funkyfranky**
|
||||
@@ -1800,10 +1800,11 @@ function NAVYGROUP:_InitGroup(Template)
|
||||
self.speedMax=self.group:GetSpeedMax()
|
||||
|
||||
-- Is group mobile?
|
||||
if self.speedMax>3.6 then
|
||||
if self.speedMax and self.speedMax>3.6 then
|
||||
self.isMobile=true
|
||||
else
|
||||
self.isMobile=false
|
||||
self.speedMax = 0
|
||||
end
|
||||
|
||||
-- Cruise speed: 70% of max speed.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Operation).
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Operation).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
--
|
||||
-- @field #OPSGROUP.Radio radio Current radio settings.
|
||||
-- @field #OPSGROUP.Radio radioDefault Default radio settings.
|
||||
-- @field Core.RadioQueue#RADIOQUEUE radioQueue Radio queue.
|
||||
-- @field Sound.Radio#RADIOQUEUE radioQueue Radio queue.
|
||||
--
|
||||
-- @field #OPSGROUP.Beacon tacan Current TACAN settings.
|
||||
-- @field #OPSGROUP.Beacon tacanDefault Default TACAN settings.
|
||||
@@ -508,7 +508,7 @@ OPSGROUP.CargoStatus={
|
||||
|
||||
--- OpsGroup version.
|
||||
-- @field #string version
|
||||
OPSGROUP.version="1.0.0"
|
||||
OPSGROUP.version="1.0.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@@ -535,7 +535,7 @@ OPSGROUP.version="1.0.0"
|
||||
-- @param Wrapper.Group#GROUP group The GROUP object. Can also be given by its group name as `#string`.
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:New(group)
|
||||
|
||||
|
||||
-- Inherit everything from FSM class.
|
||||
local self=BASE:Inherit(self, FSM:New()) -- #OPSGROUP
|
||||
|
||||
@@ -554,10 +554,15 @@ function OPSGROUP:New(group)
|
||||
-- Check if group exists.
|
||||
if self.group then
|
||||
if not self:IsExist() then
|
||||
self:T(self.lid.."ERROR: GROUP does not exist! Returning nil")
|
||||
self:E(self.lid.."ERROR: GROUP does not exist! Returning nil")
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
if UTILS.IsInstanceOf(group,"OPSGROUP") then
|
||||
self:E(self.lid.."ERROR: GROUP is already an OPSGROUP: "..tostring(self.groupname).."!")
|
||||
return group
|
||||
end
|
||||
|
||||
-- Set the template.
|
||||
self:_SetTemplate()
|
||||
@@ -591,33 +596,34 @@ function OPSGROUP:New(group)
|
||||
|
||||
if units then
|
||||
local masterunit=units[1] --Wrapper.Unit#UNIT
|
||||
|
||||
-- Get Descriptors.
|
||||
self.descriptors=masterunit:GetDesc()
|
||||
|
||||
-- Set type name.
|
||||
self.actype=masterunit:GetTypeName()
|
||||
|
||||
-- Is this a submarine.
|
||||
self.isSubmarine=masterunit:HasAttribute("Submarines")
|
||||
|
||||
-- Has this a datalink?
|
||||
self.isEPLRS=masterunit:HasAttribute("Datalink")
|
||||
|
||||
if self:IsFlightgroup() then
|
||||
|
||||
self.rangemax=self.descriptors.range and self.descriptors.range*1000 or 500*1000
|
||||
|
||||
self.ceiling=self.descriptors.Hmax
|
||||
|
||||
self.tankertype=select(2, masterunit:IsTanker())
|
||||
self.refueltype=select(2, masterunit:IsRefuelable())
|
||||
|
||||
--env.info("DCS Unit BOOM_AND_RECEPTACLE="..tostring(Unit.RefuelingSystem.BOOM_AND_RECEPTACLE))
|
||||
--env.info("DCS Unit PROBE_AND_DROGUE="..tostring(Unit.RefuelingSystem.PROBE_AND_DROGUE))
|
||||
|
||||
|
||||
if unit then
|
||||
-- Get Descriptors.
|
||||
self.descriptors=masterunit:GetDesc()
|
||||
|
||||
-- Set type name.
|
||||
self.actype=masterunit:GetTypeName()
|
||||
|
||||
-- Is this a submarine.
|
||||
self.isSubmarine=masterunit:HasAttribute("Submarines")
|
||||
|
||||
-- Has this a datalink?
|
||||
self.isEPLRS=masterunit:HasAttribute("Datalink")
|
||||
|
||||
if self:IsFlightgroup() then
|
||||
|
||||
self.rangemax=self.descriptors.range and self.descriptors.range*1000 or 500*1000
|
||||
|
||||
self.ceiling=self.descriptors.Hmax
|
||||
|
||||
self.tankertype=select(2, masterunit:IsTanker())
|
||||
self.refueltype=select(2, masterunit:IsRefuelable())
|
||||
|
||||
--env.info("DCS Unit BOOM_AND_RECEPTACLE="..tostring(Unit.RefuelingSystem.BOOM_AND_RECEPTACLE))
|
||||
--env.info("DCS Unit PROBE_AND_DROGUE="..tostring(Unit.RefuelingSystem.PROBE_AND_DROGUE))
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Init set of detected units.
|
||||
@@ -2314,14 +2320,17 @@ end
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:SetSRS(PathToSRS, Gender, Culture, Voice, Port, PathToGoogleKey, Label, Volume)
|
||||
self.useSRS=true
|
||||
self.msrs=MSRS:New(PathToSRS, self.frequency, self.modulation)
|
||||
local path = PathToSRS or MSRS.path
|
||||
local port = Port or MSRS.port
|
||||
self.msrs=MSRS:New(path, self.frequency, self.modulation)
|
||||
self.msrs:SetGender(Gender)
|
||||
self.msrs:SetCulture(Culture)
|
||||
self.msrs:SetVoice(Voice)
|
||||
self.msrs:SetPort(Port)
|
||||
self.msrs:SetPort(port)
|
||||
self.msrs:SetLabel(Label)
|
||||
if PathToGoogleKey then
|
||||
self.msrs:SetGoogle(PathToGoogleKey)
|
||||
self.msrs:SetProviderOptionsGoogle(PathToGoogleKey,PathToGoogleKey)
|
||||
self.msrs:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
self.msrs:SetCoalition(self:GetCoalition())
|
||||
self.msrs:SetVolume(Volume)
|
||||
@@ -3472,10 +3481,9 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
||||
|
||||
-- Could be that the waypoint we are currently moving to was the LAST waypoint. Then we now passed the final waypoint.
|
||||
if (self.adinfinitum or istemp) then
|
||||
self:_PassedFinalWaypoint(false, "Removed PASSED temporary waypoint ")
|
||||
end
|
||||
|
||||
|
||||
self:_PassedFinalWaypoint(false, "Removed PASSED temporary waypoint")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -5801,6 +5809,27 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
|
||||
end
|
||||
end
|
||||
|
||||
if self.legion and self.legionReturn==false and self.waypoints and #self.waypoints==1 then
|
||||
---
|
||||
-- This is the case where a group was send on a mission (which is over now), has no addional
|
||||
-- waypoints or tasks and should NOT return to its legion.
|
||||
-- We create a new waypoint at the current position and let it hold here.
|
||||
---
|
||||
|
||||
local Coordinate=self:GetCoordinate()
|
||||
|
||||
if self.isArmygroup then
|
||||
ARMYGROUP.AddWaypoint(self, Coordinate, 0, nil, nil, false)
|
||||
elseif self.isNavygroup then
|
||||
NAVYGROUP.AddWaypoint(self,Coordinate, 0, nil, nil, false)
|
||||
end
|
||||
|
||||
-- Remove original waypoint.
|
||||
self:RemoveWaypoint(1)
|
||||
|
||||
self:_PassedFinalWaypoint(true, "Passed final waypoint as group is done with mission but should NOT return to its legion")
|
||||
end
|
||||
|
||||
-- Check if group is done.
|
||||
self:_CheckGroupDone(delay)
|
||||
|
||||
@@ -7153,7 +7182,7 @@ function OPSGROUP:SetLaserTarget(Target)
|
||||
|
||||
-- Scenery as target. Treat it like a coordinate. Set offset to 1 meter above ground.
|
||||
self.spot.TargetType=0
|
||||
self.spot.offsetTarget={x=0, y=1, z=0}
|
||||
self.spot.offsetTarget={x=0, y=3, z=0}
|
||||
|
||||
elseif Target:IsInstanceOf("POSITIONABLE") then
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Transport).
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/Transport).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -605,6 +605,16 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo, DisembarkActi
|
||||
self:AddCargoGroups(group, TransportZoneCombo, DisembarkActivation)
|
||||
|
||||
end
|
||||
|
||||
-- Use FSM function to keep the SET up-to-date. Note that it overwrites the user FMS function, which cannot be used any more now.
|
||||
local groupset=GroupSet --Core.Set#SET_OPSGROUP
|
||||
function groupset.OnAfterAdded(groupset, From, Event, To, ObjectName, Object)
|
||||
|
||||
self:T(self.lid..string.format("Adding Cargo Group %s", tostring(ObjectName)))
|
||||
self:AddCargoGroups(Object, TransportZoneCombo, DisembarkActivation, DisembarkZone, DisembarkCarriers)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
|
||||
@@ -97,7 +97,7 @@ OPSZONE.ZoneType={
|
||||
|
||||
--- OPSZONE class version.
|
||||
-- @field #string version
|
||||
OPSZONE.version="0.6.0"
|
||||
OPSZONE.version="0.6.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
@@ -1277,7 +1277,7 @@ function OPSZONE:EvaluateZone()
|
||||
|
||||
if Nblu>0 then
|
||||
|
||||
if not self:IsAttacked() then
|
||||
if not self:IsAttacked() and self.Tnut>=self.threatlevelCapture then
|
||||
self:Attacked(coalition.side.BLUE)
|
||||
end
|
||||
|
||||
@@ -1329,7 +1329,7 @@ function OPSZONE:EvaluateZone()
|
||||
|
||||
if Nred>0 then
|
||||
|
||||
if not self:IsAttacked() then
|
||||
if not self:IsAttacked() and self.Tnut>=self.threatlevelCapture then
|
||||
-- Red is attacking blue zone.
|
||||
self:Attacked(coalition.side.RED)
|
||||
end
|
||||
@@ -1483,11 +1483,11 @@ function OPSZONE:_GetZoneColor()
|
||||
local color={0,0,0}
|
||||
|
||||
if self.ownerCurrent==coalition.side.NEUTRAL then
|
||||
color={1, 1, 1}
|
||||
color=self.ZoneOwnerNeutral or {1, 1, 1}
|
||||
elseif self.ownerCurrent==coalition.side.BLUE then
|
||||
color={0, 0, 1}
|
||||
color=self.ZoneOwnerBlue or {0, 0, 1}
|
||||
elseif self.ownerCurrent==coalition.side.RED then
|
||||
color={1, 0, 0}
|
||||
color=self.ZoneOwnerRed or {1, 0, 0}
|
||||
else
|
||||
|
||||
end
|
||||
@@ -1495,6 +1495,21 @@ function OPSZONE:_GetZoneColor()
|
||||
return color
|
||||
end
|
||||
|
||||
--- Set custom RGB color of zone depending on current owner.
|
||||
-- @param #OPSZONE self
|
||||
-- @param #table Neutral Color is a table of RGB values 0..1 for Red, Green, and Blue respectively, e.g. {1,0,0} for red.
|
||||
-- @param #table Blue Color is a table of RGB values 0..1 for Red, Green, and Blue respectively, e.g. {0,1,0} for green.
|
||||
-- @param #table Red Color is a table of RGB values 0..1 for Red, Green, and Blue respectively, e.g. {0,0,1} for blue.
|
||||
-- @return #OPSZONE self
|
||||
function OPSZONE:SetZoneColor(Neutral, Blue, Red)
|
||||
|
||||
self.ZoneOwnerNeutral = Neutral or {1, 1, 1}
|
||||
self.ZoneOwnerBlue = Blue or {0, 0, 1}
|
||||
self.ZoneOwnerRed = Red or {1, 0, 0}
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Update marker on the F10 map.
|
||||
-- @param #OPSZONE self
|
||||
function OPSZONE:_UpdateMarker()
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
-- @field Utilities.FiFo#FIFO TargetCache
|
||||
-- @field #boolean smokeownposition
|
||||
-- @field #table SmokeOwn
|
||||
-- @field #boolean smokeaveragetargetpos
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
---
|
||||
@@ -104,7 +105,7 @@ PLAYERRECCE = {
|
||||
ClassName = "PLAYERRECCE",
|
||||
verbose = true,
|
||||
lid = nil,
|
||||
version = "0.0.21",
|
||||
version = "0.1.23",
|
||||
ViewZone = {},
|
||||
ViewZoneVisual = {},
|
||||
ViewZoneLaser = {},
|
||||
@@ -130,8 +131,9 @@ PLAYERRECCE = {
|
||||
ReferencePoint = nil,
|
||||
TForget = 600,
|
||||
TargetCache = nil,
|
||||
smokeownposition = true,
|
||||
smokeownposition = false,
|
||||
SmokeOwn = {},
|
||||
smokeaveragetargetpos = false,
|
||||
}
|
||||
|
||||
---
|
||||
@@ -469,8 +471,10 @@ function PLAYERRECCE:_GetClockDirection(unit, target)
|
||||
local _playerPosition = unit:GetCoordinate() -- get position of helicopter
|
||||
local _targetpostions = target:GetCoordinate() -- get position of downed pilot
|
||||
local _heading = unit:GetHeading() -- heading
|
||||
--self:I("Heading = ".._heading)
|
||||
local DirectionVec3 = _playerPosition:GetDirectionVec3( _targetpostions )
|
||||
local Angle = _playerPosition:GetAngleDegrees( DirectionVec3 )
|
||||
--self:I("Angle = "..Angle)
|
||||
local clock = 12
|
||||
local hours = 0
|
||||
if _heading and Angle then
|
||||
@@ -478,10 +482,13 @@ function PLAYERRECCE:_GetClockDirection(unit, target)
|
||||
--if angle == 0 then angle = 360 end
|
||||
clock = _heading-Angle
|
||||
hours = (clock/30)*-1
|
||||
--self:I("hours = "..hours)
|
||||
clock = 12+hours
|
||||
clock = UTILS.Round(clock,0)
|
||||
if clock > 12 then clock = clock-12 end
|
||||
end
|
||||
if clock == 0 then clock = 12 end
|
||||
end
|
||||
--self:I("Clock ="..clock)
|
||||
return clock
|
||||
end
|
||||
|
||||
@@ -709,8 +716,8 @@ function PLAYERRECCE:_GetViewZone(unit, vheading, minview, maxview, angle, camon
|
||||
local heading2 = (vheading-90)%360
|
||||
self:T({heading1,heading2})
|
||||
local startpos = startp:Translate(minview,vheading)
|
||||
local pos1 = startpos:Translate(10,heading1)
|
||||
local pos2 = startpos:Translate(10,heading2)
|
||||
local pos1 = startpos:Translate(12.5,heading1)
|
||||
local pos2 = startpos:Translate(12.5,heading2)
|
||||
local pos3 = pos1:Translate(maxview,vheading)
|
||||
local pos4 = pos2:Translate(maxview,vheading)
|
||||
local array = {}
|
||||
@@ -912,31 +919,49 @@ function PLAYERRECCE:_LaseTarget(client,targetset)
|
||||
else
|
||||
laser = self.LaserSpots[playername]
|
||||
end
|
||||
-- old target
|
||||
if self.LaserTarget[playername] then
|
||||
-- still looking at target?
|
||||
local target=self.LaserTarget[playername] -- Ops.Target#TARGET
|
||||
local oldtarget = target:GetObject() --or laser.Target
|
||||
self:T("Targetstate: "..target:GetState())
|
||||
if not oldtarget or targetset:IsNotInSet(oldtarget) or target:IsDead() or target:IsDestroyed() then
|
||||
self:T("Laser State: "..tostring(laser:IsLasing()))
|
||||
if (not oldtarget) or targetset:IsNotInSet(oldtarget) or target:IsDead() or target:IsDestroyed() then
|
||||
-- lost LOS or dead
|
||||
laser:LaseOff()
|
||||
if target:IsDead() or target:IsDestroyed() or target:GetLife() < 2 then
|
||||
self:__Shack(-1,client,oldtarget)
|
||||
self.LaserTarget[playername] = nil
|
||||
--self.LaserTarget[playername] = nil
|
||||
else
|
||||
self:__TargetLOSLost(-1,client,oldtarget)
|
||||
self.LaserTarget[playername] = nil
|
||||
--self.LaserTarget[playername] = nil
|
||||
end
|
||||
self.LaserTarget[playername] = nil
|
||||
oldtarget = nil
|
||||
self.LaserSpots[playername] = nil
|
||||
elseif oldtarget and laser and (not laser:IsLasing()) then
|
||||
--laser:LaseOff()
|
||||
self:T("Switching laser back on ..")
|
||||
local lasercode = self.UnitLaserCodes[playername] or laser.LaserCode or 1688
|
||||
local lasingtime = self.lasingtime or 60
|
||||
--local targettype = target:GetTypeName()
|
||||
laser:LaseOn(oldtarget,lasercode,lasingtime)
|
||||
--self:__TargetLasing(-1,client,oldtarget,lasercode,lasingtime)
|
||||
else
|
||||
-- we should not be here...
|
||||
self:T("Target alive and laser is on!")
|
||||
--self.LaserSpots[playername] = nil
|
||||
end
|
||||
elseif not laser:IsLasing() and target then
|
||||
-- new target
|
||||
elseif (not laser:IsLasing()) and target then
|
||||
local relativecam = self.LaserRelativePos[client:GetTypeName()]
|
||||
laser:SetRelativeStartPosition(relativecam)
|
||||
local lasercode = self.UnitLaserCodes[playername] or laser.LaserCode or 1688
|
||||
local lasingtime = self.lasingtime or 60
|
||||
local targettype = target:GetTypeName()
|
||||
--local targettype = target:GetTypeName()
|
||||
laser:LaseOn(target,lasercode,lasingtime)
|
||||
self.LaserTarget[playername] = TARGET:New(target)
|
||||
self.LaserTarget[playername].TStatus = 9
|
||||
--self.LaserTarget[playername].TStatus = 9
|
||||
self:__TargetLasing(-1,client,target,lasercode,lasingtime)
|
||||
end
|
||||
return self
|
||||
@@ -1018,6 +1043,13 @@ function PLAYERRECCE:_SwitchLasing(client,group,playername)
|
||||
MESSAGE:New("Lasing is now ON",10,self.Name or "FACA"):ToClient(client)
|
||||
else
|
||||
self.AutoLase[playername] = false
|
||||
if self.LaserSpots[playername] then
|
||||
local laser = self.LaserSpots[playername] -- Core.Spot#SPOT
|
||||
if laser:IsLasing() then
|
||||
laser:LaseOff()
|
||||
end
|
||||
self.LaserSpots[playername] = nil
|
||||
end
|
||||
MESSAGE:New("Lasing is now OFF",10,self.Name or "FACA"):ToClient(client)
|
||||
end
|
||||
if self.ClientMenus[playername] then
|
||||
@@ -1079,9 +1111,8 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername)
|
||||
self:T(self.lid.."_SmokeTargets")
|
||||
local cameraset = self:_GetTargetSet(client,true) -- Core.Set#SET_UNIT
|
||||
local visualset = self:_GetTargetSet(client,false) -- Core.Set#SET_UNIT
|
||||
cameraset:AddSet(visualset)
|
||||
|
||||
if cameraset:CountAlive() > 0 then
|
||||
if cameraset:CountAlive() > 0 or visualset:CountAlive() > 0 then
|
||||
self:__TargetsSmoked(-1,client,playername,cameraset)
|
||||
else
|
||||
return self
|
||||
@@ -1096,25 +1127,31 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername)
|
||||
-- laser targer gets extra smoke
|
||||
if laser and laser.Target and laser.Target:IsAlive() then
|
||||
laser.Target:GetCoordinate():Smoke(lasersmoke)
|
||||
if cameraset:IsInSet(laser.Target) then
|
||||
cameraset:Remove(laser.Target:GetName(),true)
|
||||
end
|
||||
end
|
||||
|
||||
-- smoke everything else
|
||||
local coordinate = cameraset:GetCoordinate()
|
||||
local setthreat = cameraset:CalculateThreatLevelA2G()
|
||||
|
||||
if coordinate then
|
||||
local color = lowsmoke
|
||||
if setthreat > 7 then
|
||||
color = medsmoke
|
||||
elseif setthreat > 2 then
|
||||
color = lowsmoke
|
||||
local coord = visualset:GetCoordinate()
|
||||
if coord and self.smokeaveragetargetpos then
|
||||
coord:SetAtLandheight()
|
||||
coord:Smoke(medsmoke)
|
||||
else
|
||||
-- smoke everything
|
||||
for _,_unit in pairs(visualset.Set) do
|
||||
local unit = _unit --Wrapper.Unit#UNIT
|
||||
if unit and unit:IsAlive() then
|
||||
local coord = unit:GetCoordinate()
|
||||
local threat = unit:GetThreatLevel()
|
||||
if coord then
|
||||
local color = lowsmoke
|
||||
if threat > 7 then
|
||||
color = highsmoke
|
||||
elseif threat > 2 then
|
||||
color = medsmoke
|
||||
end
|
||||
coord:Smoke(color)
|
||||
end
|
||||
end
|
||||
end
|
||||
coordinate:Smoke(color)
|
||||
end
|
||||
|
||||
if self.SmokeOwn[playername] then
|
||||
local cc = client:GetVec2()
|
||||
-- don't smoke mid-air
|
||||
@@ -1155,15 +1192,15 @@ function PLAYERRECCE:_FlareTargets(client,group,playername)
|
||||
-- smoke everything else
|
||||
for _,_unit in pairs(cameraset.Set) do
|
||||
local unit = _unit --Wrapper.Unit#UNIT
|
||||
if unit then
|
||||
if unit and unit:IsAlive() then
|
||||
local coord = unit:GetCoordinate()
|
||||
local threat = unit:GetThreatLevel()
|
||||
if coord then
|
||||
local color = lowsmoke
|
||||
if threat > 7 then
|
||||
color = medsmoke
|
||||
color = highsmoke
|
||||
elseif threat > 2 then
|
||||
color = lowsmoke
|
||||
color = medsmoke
|
||||
end
|
||||
coord:Flare(color)
|
||||
end
|
||||
@@ -1451,36 +1488,43 @@ end
|
||||
-- @param #string Gender (Optional) Defaults to "male"
|
||||
-- @param #string Culture (Optional) Defaults to "en-US"
|
||||
-- @param #number Port (Optional) Defaults to 5002
|
||||
-- @param #string Voice (Optional) Use a specifc voice with the @{Sound.SRS.SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||
-- @param #string Voice (Optional) Use a specifc voice with the @{Sound.SRS#SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||
-- Note that this must be installed on your windows system. Can also be Google voice types, if you are using Google TTS.
|
||||
-- @param #number Volume (Optional) Volume - between 0.0 (silent) and 1.0 (loudest)
|
||||
-- @param #string PathToGoogleKey (Optional) Path to your google key if you want to use google TTS
|
||||
-- @return #PLAYERRECCE self
|
||||
function PLAYERRECCE:SetSRS(Frequency,Modulation,PathToSRS,Gender,Culture,Port,Voice,Volume,PathToGoogleKey)
|
||||
self:T(self.lid.."SetSRS")
|
||||
self.PathToSRS = PathToSRS or "C:\\Program Files\\DCS-SimpleRadio-Standalone" --
|
||||
self.Gender = Gender or "male" --
|
||||
self.Culture = Culture or "en-US" --
|
||||
self.Port = Port or 5002 --
|
||||
self.Voice = Voice --
|
||||
self.PathToSRS = PathToSRS or MSRS.path or "C:\\Program Files\\DCS-SimpleRadio-Standalone" --
|
||||
self.Gender = Gender or MSRS.gender or "male" --
|
||||
self.Culture = Culture or MSRS.culture or "en-US" --
|
||||
self.Port = Port or MSRS.port or 5002 --
|
||||
self.Voice = Voice or MSRS.voice --
|
||||
self.PathToGoogleKey = PathToGoogleKey --
|
||||
self.Volume = Volume or 1.0 --
|
||||
self.Volume = Volume or 1.0 --
|
||||
self.UseSRS = true
|
||||
self.Frequency = Frequency or {127,251} --
|
||||
self.BCFrequency = self.Frequency
|
||||
self.Modulation = Modulation or {radio.modulation.FM,radio.modulation.AM} --
|
||||
self.BCModulation = self.Modulation
|
||||
-- set up SRS
|
||||
self.SRS=MSRS:New(self.PathToSRS,self.Frequency,self.Modulation,self.Volume)
|
||||
self.SRS=MSRS:New(self.PathToSRS,self.Frequency,self.Modulation)
|
||||
self.SRS:SetCoalition(self.Coalition)
|
||||
self.SRS:SetLabel(self.MenuName or self.Name)
|
||||
self.SRS:SetGender(self.Gender)
|
||||
self.SRS:SetCulture(self.Culture)
|
||||
self.SRS:SetPort(self.Port)
|
||||
self.SRS:SetVoice(self.Voice)
|
||||
self.SRS:SetVolume(self.Volume)
|
||||
if self.PathToGoogleKey then
|
||||
self.SRS:SetGoogle(self.PathToGoogleKey)
|
||||
self.SRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.PathToGoogleKey)
|
||||
self.SRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
-- Pre-configured Google?
|
||||
if (not PathToGoogleKey) and self.SRS:GetProvider() == MSRS.Provider.GOOGLE then
|
||||
self.PathToGoogleKey = MSRS.poptions.gcloud.credentials
|
||||
self.Voice = Voice or MSRS.poptions.gcloud.voice
|
||||
end
|
||||
self.SRS:SetVoice(self.Voice)
|
||||
self.SRSQueue = MSRSQUEUE:New(self.MenuName or self.Name)
|
||||
self.SRSQueue:SetTransmitOnlyWithPlayers(self.TransmitOnlyWithPlayers)
|
||||
return self
|
||||
@@ -1512,7 +1556,7 @@ end
|
||||
-- @param #PLAYERRECCE self
|
||||
-- @return #PLAYERRECCE self
|
||||
function PLAYERRECCE:EnableSmokeOwnPosition()
|
||||
self:T(self.lid.."ENableSmokeOwnPosition")
|
||||
self:T(self.lid.."EnableSmokeOwnPosition")
|
||||
self.smokeownposition = true
|
||||
return self
|
||||
end
|
||||
@@ -1526,6 +1570,24 @@ function PLAYERRECCE:DisableSmokeOwnPosition()
|
||||
return self
|
||||
end
|
||||
|
||||
--- [User] Enable smoking of average target positions, instead of all targets visible. Loses smoke per threatlevel -- each is med threat. Default is - smoke all positions.
|
||||
-- @param #PLAYERRECCE self
|
||||
-- @return #PLAYERRECCE self
|
||||
function PLAYERRECCE:EnableSmokeAverageTargetPosition()
|
||||
self:T(self.lid.."ENableSmokeOwnPosition")
|
||||
self.smokeaveragetargetpos = true
|
||||
return self
|
||||
end
|
||||
|
||||
--- [User] Disable smoking of average target positions, instead of all targets visible. Default is - smoke all positions.
|
||||
-- @param #PLAYERRECCE self
|
||||
-- @return #PLAYERRECCE
|
||||
function PLAYERRECCE:DisableSmokeAverageTargetPosition()
|
||||
self:T(self.lid.."DisableSmokeAverageTargetPosition")
|
||||
self.smokeaveragetargetpos = false
|
||||
return self
|
||||
end
|
||||
|
||||
--- [Internal] Get text for text-to-speech.
|
||||
-- Numbers are spaced out, e.g. "Heading 180" becomes "Heading 1 8 0 ".
|
||||
-- @param #PLAYERRECCE self
|
||||
@@ -1668,7 +1730,7 @@ function PLAYERRECCE:onafterRecceOnStation(From, Event, To, Client, Playername)
|
||||
local text2tts = string.format("All stations, FACA %s on station at %s!",callsign, coordtext)
|
||||
text2tts = self:_GetTextForSpeech(text2tts)
|
||||
if self.debug then
|
||||
self:I(text2.."\n"..text2tts)
|
||||
self:T(text2.."\n"..text2tts)
|
||||
end
|
||||
if self.UseSRS then
|
||||
local grp = Client:GetGroup()
|
||||
@@ -1707,7 +1769,7 @@ function PLAYERRECCE:onafterRecceOffStation(From, Event, To, Client, Playername)
|
||||
local texttts = string.format("All stations, FACA %s leaving station at %s, good bye!",callsign, coordtext)
|
||||
texttts = self:_GetTextForSpeech(texttts)
|
||||
if self.debug then
|
||||
self:I(text.."\n"..texttts)
|
||||
self:T(text.."\n"..texttts)
|
||||
end
|
||||
local text1 = "Going home!"
|
||||
if self.UseSRS then
|
||||
@@ -1983,7 +2045,7 @@ function PLAYERRECCE:onafterTargetLasing(From, Event, To, Client, Target, Laserc
|
||||
coordtext = coord:ToStringFromRPShort(self.ReferencePoint,self.RPName,client,Settings)
|
||||
end
|
||||
local coordtext = coord:ToStringA2G(client,Settings)
|
||||
local text = string.format("All stations, %s lasing %s\nat %s!\nCode %d, Duration %d seconds!",callsign, targettype, coordtext, Lasercode, Lasingtime)
|
||||
local text = string.format("All stations, %s lasing %s\nat %s!\nCode %d, Duration %d plus seconds!",callsign, targettype, coordtext, Lasercode, Lasingtime)
|
||||
MESSAGE:New(text,15,self.Name or "FACA"):ToClient(client)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20PlayerTask).
|
||||
-- Demo missions can be found on [GitHub](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops/PlayerTask).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -21,7 +21,7 @@
|
||||
-- ===
|
||||
-- @module Ops.PlayerTask
|
||||
-- @image OPS_PlayerTask.jpg
|
||||
-- @date Last Update Oct 2023
|
||||
-- @date Last Update Feb 2024
|
||||
|
||||
|
||||
do
|
||||
@@ -45,8 +45,8 @@ do
|
||||
-- @field Wrapper.Marker#MARKER TargetMarker
|
||||
-- @field #number SmokeColor
|
||||
-- @field #number FlareColor
|
||||
-- @field #table conditionSuccess = {},
|
||||
-- @field #table conditionFailure = {},
|
||||
-- @field #table conditionSuccess
|
||||
-- @field #table conditionFailure
|
||||
-- @field Ops.PlayerTask#PLAYERTASKCONTROLLER TaskController
|
||||
-- @field #number timestamp
|
||||
-- @field #number lastsmoketime
|
||||
@@ -98,7 +98,7 @@ PLAYERTASK = {
|
||||
|
||||
--- PLAYERTASK class version.
|
||||
-- @field #string version
|
||||
PLAYERTASK.version="0.1.22"
|
||||
PLAYERTASK.version="0.1.24"
|
||||
|
||||
--- Generic task condition.
|
||||
-- @type PLAYERTASK.Condition
|
||||
@@ -411,6 +411,15 @@ function PLAYERTASK:IsDone()
|
||||
return IsDone
|
||||
end
|
||||
|
||||
--- [User] Check if PLAYERTASK has clients assigned to it.
|
||||
-- @param #PLAYERTASK self
|
||||
-- @return #boolean hasclients
|
||||
function PLAYERTASK:HasClients()
|
||||
self:T(self.lid.."HasClients?")
|
||||
local hasclients = self:CountClients() > 0 and true or false
|
||||
return hasclients
|
||||
end
|
||||
|
||||
--- [User] Get client names assigned as table of #strings
|
||||
-- @param #PLAYERTASK self
|
||||
-- @return #table clients
|
||||
@@ -974,7 +983,7 @@ do
|
||||
-- @field #string locale
|
||||
-- @field #boolean precisionbombing
|
||||
-- @field Ops.FlightGroup#FLIGHTGROUP LasingDrone
|
||||
-- @field Core.MarkerOps_BASE#MARKEROPS_BASE MarkerOps
|
||||
-- @field Core.MarkerOps_Base#MARKEROPS_BASE MarkerOps
|
||||
-- @field #boolean taskinfomenu
|
||||
-- @field #boolean MarkerReadOnly
|
||||
-- @field #table FlashPlayer List of player who switched Flashing Direction Info on
|
||||
@@ -1028,7 +1037,7 @@ do
|
||||
-- ## 1 Overview
|
||||
--
|
||||
-- PLAYERTASKCONTROLLER is used to auto-create (optional) and control tasks for players. It can be set up as Air-to-Ground (A2G, main focus), Air-to-Ship (A2S) or Air-to-Air (A2A) controller.
|
||||
-- For the latter task type, also have a look at the @{Ops.Awacs#AWACS} class which allows for more complex scenarios.
|
||||
-- For the latter task type, also have a look at the @{Ops.AWACS#AWACS} class which allows for more complex scenarios.
|
||||
-- One task at a time can be joined by the player from the F10 menu. A task can be joined by multiple players. Once joined, task information is available via the F10 menu, the task location
|
||||
-- can be marked on the map and for A2G/S targets, the target can be marked with smoke and flares.
|
||||
--
|
||||
@@ -1552,7 +1561,7 @@ PLAYERTASKCONTROLLER.Messages = {
|
||||
|
||||
--- PLAYERTASK class version.
|
||||
-- @field #string version
|
||||
PLAYERTASKCONTROLLER.version="0.1.63"
|
||||
PLAYERTASKCONTROLLER.version="0.1.65"
|
||||
|
||||
--- Create and run a new TASKCONTROLLER instance.
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
@@ -1579,7 +1588,7 @@ function PLAYERTASKCONTROLLER:New(Name, Coalition, Type, ClientFilter)
|
||||
self.ClusterRadius = 0.5
|
||||
self.TargetRadius = 500
|
||||
|
||||
self.ClientFilter = ClientFilter or ""
|
||||
self.ClientFilter = ClientFilter --or ""
|
||||
|
||||
self.TargetQueue = FIFO:New() -- Utilities.FiFo#FIFO
|
||||
self.TaskQueue = FIFO:New() -- Utilities.FiFo#FIFO
|
||||
@@ -1965,6 +1974,9 @@ end
|
||||
-- @param Ops.FlightGroup#FLIGHTGROUP FlightGroup The FlightGroup (e.g. drone) to be used for lasing (one unit in one group only).
|
||||
-- Can optionally be handed as Ops.ArmyGroup#ARMYGROUP - **Note** might not find an LOS spot or get lost on the way. Cannot island-hop.
|
||||
-- @param #number LaserCode The lasercode to be used. Defaults to 1688.
|
||||
-- @param Core.Point#COORDINATE HoldingPoint (Optional) Point where the drone should initially circle. If not set, defaults to BullsEye of the coalition.
|
||||
-- @param #number Alt (Optional) Altitude in feet. Only applies if using a FLIGHTGROUP object! Defaults to 10000.
|
||||
-- @param #number Speed (Optional) Speed in knots. Only applies if using a FLIGHTGROUP object! Defaults to 120.
|
||||
-- @return #PLAYERTASKCONTROLLER self
|
||||
-- @usage
|
||||
-- -- Set up precision bombing, FlightGroup as lasing unit
|
||||
@@ -1979,7 +1991,7 @@ end
|
||||
-- ArmyGroup:Activate()
|
||||
-- taskmanager:EnablePrecisionBombing(ArmyGroup,1688)
|
||||
--
|
||||
function PLAYERTASKCONTROLLER:EnablePrecisionBombing(FlightGroup,LaserCode)
|
||||
function PLAYERTASKCONTROLLER:EnablePrecisionBombing(FlightGroup,LaserCode,HoldingPoint, Alt, Speed)
|
||||
self:T(self.lid.."EnablePrecisionBombing")
|
||||
if FlightGroup then
|
||||
if FlightGroup.ClassName and (FlightGroup.ClassName == "FLIGHTGROUP" or FlightGroup.ClassName == "ARMYGROUP")then
|
||||
@@ -1992,10 +2004,20 @@ function PLAYERTASKCONTROLLER:EnablePrecisionBombing(FlightGroup,LaserCode)
|
||||
self.LasingDrone:SetLaser(LaserCode)
|
||||
self.LaserCode = LaserCode or 1688
|
||||
self.LasingDroneTemplate = self.LasingDrone:_GetTemplate(true)
|
||||
self.LasingDroneAlt = Alt or 10000
|
||||
self.LasingDroneSpeed = Speed or 120
|
||||
-- let it orbit the BullsEye if FG
|
||||
if self.LasingDrone:IsFlightgroup() then
|
||||
self.LasingDroneIsFlightgroup = true
|
||||
local BullsCoordinate = COORDINATE:NewFromVec3( coalition.getMainRefPoint( self.Coalition ))
|
||||
local Orbit = AUFTRAG:NewORBIT_CIRCLE(BullsCoordinate,10000,120)
|
||||
if HoldingPoint then BullsCoordinate = HoldingPoint end
|
||||
local Orbit = AUFTRAG:NewORBIT_CIRCLE(BullsCoordinate,self.LasingDroneAlt,self.LasingDroneSpeed)
|
||||
self.LasingDrone:AddMission(Orbit)
|
||||
elseif self.LasingDrone:IsArmygroup() then
|
||||
self.LasingDroneIsArmygroup = true
|
||||
local BullsCoordinate = COORDINATE:NewFromVec3( coalition.getMainRefPoint( self.Coalition ))
|
||||
if HoldingPoint then BullsCoordinate = HoldingPoint end
|
||||
local Orbit = AUFTRAG:NewONGUARD(BullsCoordinate)
|
||||
self.LasingDrone:AddMission(Orbit)
|
||||
end
|
||||
else
|
||||
@@ -2534,10 +2556,16 @@ function PLAYERTASKCONTROLLER:_CheckPrecisionTasks()
|
||||
if self.LasingDrone then
|
||||
self.LasingDrone:_Respawn(1,nil,true)
|
||||
else
|
||||
-- TODO: Handle ArmyGroup
|
||||
local FG = FLIGHTGROUP:New(self.LasingDroneTemplate)
|
||||
FG:Activate()
|
||||
self:EnablePrecisionBombing(FG,self.LaserCode or 1688)
|
||||
-- DONE: Handle ArmyGroup
|
||||
if self.LasingDroneIsFlightgroup then
|
||||
local FG = FLIGHTGROUP:New(self.LasingDroneTemplate)
|
||||
FG:Activate()
|
||||
self:EnablePrecisionBombing(FG,self.LaserCode or 1688)
|
||||
else
|
||||
local FG = ARMYGROUP:New(self.LasingDroneTemplate)
|
||||
FG:Activate()
|
||||
self:EnablePrecisionBombing(FG,self.LaserCode or 1688)
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
@@ -2552,12 +2580,11 @@ function PLAYERTASKCONTROLLER:_CheckPrecisionTasks()
|
||||
self.LasingDrone.playertask.inreach = false
|
||||
self.LasingDrone.playertask.reachmessage = false
|
||||
-- move the drone to target
|
||||
if self.LasingDrone:IsFlightgroup() then
|
||||
local auftrag = AUFTRAG:NewORBIT_CIRCLE(task.Target:GetCoordinate(),10000,120)
|
||||
local currmission = self.LasingDrone:GetMissionCurrent()
|
||||
self.LasingDrone:AddMission(auftrag)
|
||||
currmission:__Cancel(-2)
|
||||
elseif self.LasingDrone:IsArmygroup() then
|
||||
if self.LasingDroneIsFlightgroup then
|
||||
self.LasingDrone:CancelAllMissions()
|
||||
local auftrag = AUFTRAG:NewORBIT_CIRCLE(task.Target:GetCoordinate(),self.LasingDroneAlt,self.LasingDroneSpeed)
|
||||
self.LasingDrone:AddMission(auftrag)
|
||||
elseif self.LasingDroneIsArmygroup then
|
||||
local tgtcoord = task.Target:GetCoordinate()
|
||||
local tgtzone = ZONE_RADIUS:New("ArmyGroup-"..math.random(1,10000),tgtcoord:GetVec2(),3000)
|
||||
local finalpos=nil -- Core.Point#COORDINATE
|
||||
@@ -2570,11 +2597,10 @@ function PLAYERTASKCONTROLLER:_CheckPrecisionTasks()
|
||||
end
|
||||
end
|
||||
if finalpos then
|
||||
self.LasingDrone:CancelAllMissions()
|
||||
-- yeah we got one
|
||||
local auftrag = AUFTRAG:NewARMOREDGUARD(finalpos,"Off road")
|
||||
local currmission = self.LasingDrone:GetMissionCurrent()
|
||||
self.LasingDrone:AddMission(auftrag)
|
||||
if currmission then currmission:__Cancel(-2) end
|
||||
else
|
||||
-- could not find LOS position!
|
||||
self:E("***Could not find LOS position to post ArmyGroup for lasing!")
|
||||
@@ -2606,6 +2632,7 @@ function PLAYERTASKCONTROLLER:_CheckPrecisionTasks()
|
||||
-- not done yet
|
||||
local dcoord = self.LasingDrone:GetCoordinate()
|
||||
local tcoord = task.Target:GetCoordinate()
|
||||
tcoord.y = tcoord.y + 2
|
||||
local dist = dcoord:Get2DDistance(tcoord)
|
||||
-- close enough?
|
||||
if dist < 3000 and not self.LasingDrone:IsLasing() then
|
||||
@@ -3155,7 +3182,7 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Task, Group, Client)
|
||||
local ttsname = self.gettext:GetEntry("TASKNAMETTS",self.locale)
|
||||
local taskname = string.format(tname,task.Type,task.PlayerTaskNr)
|
||||
local ttstaskname = string.format(ttsname,task.TTSType,task.PlayerTaskNr)
|
||||
local Coordinate = task.Target:GetCoordinate()
|
||||
local Coordinate = task.Target:GetCoordinate() or COORDINATE:New(0,0,0)
|
||||
local CoordText = ""
|
||||
local CoordTextLLDM = nil
|
||||
if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then
|
||||
@@ -3189,7 +3216,7 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Task, Group, Client)
|
||||
local islasing = self.LasingDrone:IsLasing() == true and yes or no
|
||||
local prectext = self.gettext:GetEntry("POINTERTARGETREPORT",self.locale)
|
||||
prectext = string.format(prectext,inreach,islasing)
|
||||
text = text .. prectext
|
||||
text = text .. prectext.." ("..self.LaserCode..")"
|
||||
end
|
||||
end
|
||||
-- Buddylasing
|
||||
@@ -3928,7 +3955,7 @@ function PLAYERTASKCONTROLLER:SetupIntel(RecceName)
|
||||
|
||||
local function NewCluster(Cluster)
|
||||
if not self.usecluster then return self end
|
||||
local cluster = Cluster -- Ops.Intelligence#INTEL.Cluster
|
||||
local cluster = Cluster -- Ops.Intel#INTEL.Cluster
|
||||
local type = cluster.ctype
|
||||
self:T({type,self.Type})
|
||||
if (type == INTEL.Ctype.AIRCRAFT and self.Type == PLAYERTASKCONTROLLER.Type.A2A) or (type == INTEL.Ctype.NAVAL and (self.Type == PLAYERTASKCONTROLLER.Type.A2S or self.Type == PLAYERTASKCONTROLLER.Type.A2GS)) then
|
||||
@@ -3936,7 +3963,7 @@ function PLAYERTASKCONTROLLER:SetupIntel(RecceName)
|
||||
local contacts = cluster.Contacts -- #table of GROUP
|
||||
local targetset = SET_GROUP:New()
|
||||
for _,_object in pairs(contacts) do
|
||||
local contact = _object -- Ops.Intelligence#INTEL.Contact
|
||||
local contact = _object -- Ops.Intel#INTEL.Contact
|
||||
self:T("Adding group: "..contact.groupname)
|
||||
targetset:AddGroup(contact.group,true)
|
||||
end
|
||||
@@ -3948,14 +3975,14 @@ function PLAYERTASKCONTROLLER:SetupIntel(RecceName)
|
||||
if type == INTEL.Ctype.GROUND then
|
||||
targetset = SET_GROUP:New()
|
||||
for _,_object in pairs(contacts) do
|
||||
local contact = _object -- Ops.Intelligence#INTEL.Contact
|
||||
local contact = _object -- Ops.Intel#INTEL.Contact
|
||||
self:T("Adding group: "..contact.groupname)
|
||||
targetset:AddGroup(contact.group,true)
|
||||
end
|
||||
elseif type == INTEL.Ctype.STRUCTURE then
|
||||
targetset = SET_STATIC:New()
|
||||
for _,_object in pairs(contacts) do
|
||||
local contact = _object -- Ops.Intelligence#INTEL.Contact
|
||||
local contact = _object -- Ops.Intel#INTEL.Contact
|
||||
self:T("Adding static: "..contact.groupname)
|
||||
targetset:AddStatic(contact.group)
|
||||
end
|
||||
@@ -3968,7 +3995,7 @@ function PLAYERTASKCONTROLLER:SetupIntel(RecceName)
|
||||
|
||||
local function NewContact(Contact)
|
||||
if self.usecluster then return self end
|
||||
local contact = Contact -- Ops.Intelligence#INTEL.Contact
|
||||
local contact = Contact -- Ops.Intel#INTEL.Contact
|
||||
local type = contact.ctype
|
||||
self:T({type,self.Type})
|
||||
if (type == INTEL.Ctype.AIRCRAFT and self.Type == PLAYERTASKCONTROLLER.Type.A2A) or (type == INTEL.Ctype.NAVAL and (self.Type == PLAYERTASKCONTROLLER.Type.A2S or self.Type == PLAYERTASKCONTROLLER.Type.A2GS)) then
|
||||
@@ -3993,7 +4020,7 @@ function PLAYERTASKCONTROLLER:SetupIntel(RecceName)
|
||||
return self
|
||||
end
|
||||
|
||||
--- [User] Set SRS TTS details - see @{Sound.SRS} for details
|
||||
--- [User] Set SRS TTS details - see @{Sound.SRS} for details.`SetSRS()` will try to use as many attributes configured with @{Sound.SRS#MSRS.LoadConfigFile}() as possible.
|
||||
-- @param #PLAYERTASKCONTROLLER self
|
||||
-- @param #number Frequency Frequency to be used. Can also be given as a table of multiple frequencies, e.g. 271 or {127,251}. There needs to be exactly the same number of modulations!
|
||||
-- @param #number Modulation Modulation to be used. Can also be given as a table of multiple modulations, e.g. radio.modulation.AM or {radio.modulation.FM,radio.modulation.AM}. There needs to be exactly the same number of frequencies!
|
||||
@@ -4001,20 +4028,22 @@ end
|
||||
-- @param #string Gender (Optional) Defaults to "male"
|
||||
-- @param #string Culture (Optional) Defaults to "en-US"
|
||||
-- @param #number Port (Optional) Defaults to 5002
|
||||
-- @param #string Voice (Optional) Use a specifc voice with the @{Sound.SRS.SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||
-- @param #string Voice (Optional) Use a specifc voice with the @{Sound.SRS#SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`.
|
||||
-- Note that this must be installed on your windows system. Can also be Google voice types, if you are using Google TTS.
|
||||
-- @param #number Volume (Optional) Volume - between 0.0 (silent) and 1.0 (loudest)
|
||||
-- @param #string PathToGoogleKey (Optional) Path to your google key if you want to use google TTS
|
||||
-- @param #string PathToGoogleKey (Optional) Path to your google key if you want to use google TTS; if you use a config file for MSRS, hand in nil here.
|
||||
-- @param #string AccessKey (Optional) Your Google API access key. This is necessary if DCS-gRPC is used as backend; if you use a config file for MSRS, hand in nil here.
|
||||
-- @param Core.Point#COORDINATE Coordinate Coordinate from which the controller radio is sending
|
||||
-- @return #PLAYERTASKCONTROLLER self
|
||||
function PLAYERTASKCONTROLLER:SetSRS(Frequency,Modulation,PathToSRS,Gender,Culture,Port,Voice,Volume,PathToGoogleKey,Coordinate)
|
||||
function PLAYERTASKCONTROLLER:SetSRS(Frequency,Modulation,PathToSRS,Gender,Culture,Port,Voice,Volume,PathToGoogleKey,AccessKey,Coordinate)
|
||||
self:T(self.lid.."SetSRS")
|
||||
self.PathToSRS = PathToSRS or "C:\\Program Files\\DCS-SimpleRadio-Standalone" --
|
||||
self.Gender = Gender or "male" --
|
||||
self.Culture = Culture or "en-US" --
|
||||
self.Port = Port or 5002 --
|
||||
self.Voice = Voice --
|
||||
self.PathToSRS = PathToSRS or MSRS.path or "C:\\Program Files\\DCS-SimpleRadio-Standalone" --
|
||||
self.Gender = Gender or MSRS.gender or "male" --
|
||||
self.Culture = Culture or MSRS.culture or "en-US" --
|
||||
self.Port = Port or MSRS.port or 5002 --
|
||||
self.Voice = Voice or MSRS.voice
|
||||
self.PathToGoogleKey = PathToGoogleKey --
|
||||
self.AccessKey = AccessKey
|
||||
self.Volume = Volume or 1.0 --
|
||||
self.UseSRS = true
|
||||
self.Frequency = Frequency or {127,251} --
|
||||
@@ -4022,19 +4051,28 @@ function PLAYERTASKCONTROLLER:SetSRS(Frequency,Modulation,PathToSRS,Gender,Cultu
|
||||
self.Modulation = Modulation or {radio.modulation.FM,radio.modulation.AM} --
|
||||
self.BCModulation = self.Modulation
|
||||
-- set up SRS
|
||||
self.SRS=MSRS:New(self.PathToSRS,self.Frequency,self.Modulation,self.Volume)
|
||||
self.SRS=MSRS:New(self.PathToSRS,self.Frequency,self.Modulation)
|
||||
self.SRS:SetCoalition(self.Coalition)
|
||||
self.SRS:SetLabel(self.MenuName or self.Name)
|
||||
self.SRS:SetGender(self.Gender)
|
||||
self.SRS:SetCulture(self.Culture)
|
||||
self.SRS:SetPort(self.Port)
|
||||
self.SRS:SetVoice(self.Voice)
|
||||
self.SRS:SetVolume(self.Volume)
|
||||
if self.PathToGoogleKey then
|
||||
self.SRS:SetGoogle(self.PathToGoogleKey)
|
||||
--self.SRS:SetGoogle(self.PathToGoogleKey)
|
||||
self.SRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey)
|
||||
self.SRS:SetProvider(MSRS.Provider.GOOGLE)
|
||||
end
|
||||
-- Pre-configured Google?
|
||||
if (not PathToGoogleKey) and self.SRS:GetProvider() == MSRS.Provider.GOOGLE then
|
||||
self.PathToGoogleKey = MSRS.poptions.gcloud.credentials
|
||||
self.Voice = Voice or MSRS.poptions.gcloud.voice
|
||||
self.AccessKey = AccessKey or MSRS.poptions.gcloud.key
|
||||
end
|
||||
if Coordinate then
|
||||
self.SRS:SetCoordinate(Coordinate)
|
||||
end
|
||||
self.SRS:SetVoice(self.Voice)
|
||||
self.SRSQueue = MSRSQUEUE:New(self.MenuName or self.Name)
|
||||
self.SRSQueue:SetTransmitOnlyWithPlayers(self.TransmitOnlyWithPlayers)
|
||||
return self
|
||||
|
||||
@@ -243,7 +243,7 @@ end
|
||||
|
||||
--- Set airwing.
|
||||
-- @param #SQUADRON self
|
||||
-- @param Ops.AirWing#AIRWING Airwing The airwing.
|
||||
-- @param Ops.Airwing#AIRWING Airwing The airwing.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetAirwing(Airwing)
|
||||
self.legion=Airwing
|
||||
@@ -252,7 +252,7 @@ end
|
||||
|
||||
--- Get airwing.
|
||||
-- @param #SQUADRON self
|
||||
-- @return Ops.AirWing#AIRWING The airwing.
|
||||
-- @return Ops.Airwing#AIRWING The airwing.
|
||||
function SQUADRON:GetAirwing(Airwing)
|
||||
return self.legion
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
-- @field #number prio Priority.
|
||||
-- @field #number importance Importance.
|
||||
-- @field Ops.Auftrag#AUFTRAG mission Mission attached to this target.
|
||||
-- @field Ops.Intelligence#INTEL.Contact contact Contact attached to this target.
|
||||
-- @field Ops.Intel#INTEL.Contact contact Contact attached to this target.
|
||||
-- @field #boolean isDestroyed If true, target objects were destroyed.
|
||||
-- @field #table resources Resource list.
|
||||
-- @field #table conditionStart Start condition functions.
|
||||
@@ -526,11 +526,11 @@ function TARGET:IsAlive()
|
||||
|
||||
for _,_target in pairs(self.targets) do
|
||||
local target=_target --Ops.Target#TARGET.Object
|
||||
if target.Status==TARGET.ObjectStatus.ALIVE then
|
||||
if target.Status~=TARGET.ObjectStatus.DEAD then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -1107,7 +1107,7 @@ function TARGET:GetTargetLife(Target)
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.SCENERY then
|
||||
|
||||
if Target.Object and Target.Object:IsAlive() then
|
||||
if Target.Object and Target.Object:IsAlive(25) then
|
||||
local life = Target.Object:GetLife()
|
||||
return life
|
||||
else
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Sound/Radio)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Authors: Hugues "Grey_Echo" Bousquet, funkyfranky
|
||||
--
|
||||
-- @module Sound.Radio
|
||||
|
||||
@@ -183,8 +183,10 @@ end
|
||||
-- @param #number Port SRS port. Default 5002.
|
||||
-- @return #RADIOQUEUE self The RADIOQUEUE object.
|
||||
function RADIOQUEUE:SetSRS(PathToSRS, Port)
|
||||
self.msrs=MSRS:New(PathToSRS, self.frequency/1000000, self.modulation)
|
||||
self.msrs:SetPort(Port)
|
||||
local path = PathToSRS or MSRS.path
|
||||
local port = Port or MSRS.port
|
||||
self.msrs=MSRS:New(path, self.frequency/1000000, self.modulation)
|
||||
self.msrs:SetPort(port)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -160,52 +160,63 @@ do -- Sound File
|
||||
-- @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 #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
|
||||
function SOUNDFILE:New(FileName, Path, Duration)
|
||||
|
||||
function SOUNDFILE:New(FileName, Path, Duration, UseSrs)
|
||||
|
||||
-- Inherit BASE.
|
||||
local self=BASE:Inherit(self, BASE:New()) -- #SOUNDFILE
|
||||
|
||||
-- Debug info:
|
||||
self:F( {FileName, Path, Duration, UseSrs} )
|
||||
|
||||
-- Set file name.
|
||||
self:SetFileName(FileName)
|
||||
|
||||
|
||||
-- Set if SRS should be used to play this file
|
||||
self:SetPlayWithSRS(UseSrs or false)
|
||||
|
||||
-- Set path.
|
||||
self:SetPath(Path)
|
||||
|
||||
|
||||
-- Set duration.
|
||||
self:SetDuration(Duration)
|
||||
|
||||
-- Debug info:
|
||||
self:T(string.format("New SOUNDFILE: file name=%s, path=%s", self.filename, self.path))
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set path, where the sound file is located.
|
||||
-- @param #SOUNDFILE self
|
||||
-- @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
|
||||
function SOUNDFILE:SetPath(Path)
|
||||
|
||||
self:F( {Path} )
|
||||
|
||||
-- Init path.
|
||||
self.path=Path or "l10n/DEFAULT/"
|
||||
|
||||
if not Path and self.useSRS then -- use path to mission temp dir
|
||||
self.path = os.getenv('TMP') .. "\\DCS\\Mission\\l10n\\DEFAULT"
|
||||
end
|
||||
|
||||
if not Path then
|
||||
if self.useSRS then -- use path to mission temp dir
|
||||
self.path = lfs.tempdir() .. "Mission\\l10n\\DEFAULT"
|
||||
else -- use internal path in miz file
|
||||
self.path="l10n/DEFAULT/"
|
||||
end
|
||||
else
|
||||
self.path = Path
|
||||
end
|
||||
|
||||
-- Remove (back)slashes.
|
||||
local nmax=1000 ; local n=1
|
||||
while (self.path:sub(-1)=="/" or self.path:sub(-1)==[[\]]) and n<=nmax do
|
||||
self.path=self.path:sub(1,#self.path-1)
|
||||
n=n+1
|
||||
end
|
||||
|
||||
|
||||
-- Append slash.
|
||||
self.path=self.path.."/"
|
||||
|
||||
|
||||
self:T("self.path=".. self.path)
|
||||
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
--- Get path of the directory, where the sound file is located.
|
||||
-- @param #SOUNDFILE self
|
||||
@@ -228,7 +239,7 @@ do -- Sound File
|
||||
--- Get the sound file name.
|
||||
-- @param #SOUNDFILE self
|
||||
-- @return #string Name of the soud file. This does *not* include its path.
|
||||
function SOUNDFILE:GetFileName()
|
||||
function SOUNDFILE:GetFileName()
|
||||
return self.filename
|
||||
end
|
||||
|
||||
@@ -264,14 +275,16 @@ do -- Sound File
|
||||
-- @param #boolean Switch If true or nil, use SRS. If false, use DCS transmission.
|
||||
-- @return #SOUNDFILE self
|
||||
function SOUNDFILE:SetPlayWithSRS(Switch)
|
||||
self:F( {Switch} )
|
||||
if Switch==true or Switch==nil then
|
||||
self.useSRS=true
|
||||
else
|
||||
self.useSRS=false
|
||||
end
|
||||
self:T("self.useSRS=".. tostring(self.useSRS))
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- Text-To-Speech
|
||||
|
||||
@@ -137,7 +137,7 @@ do -- UserSound
|
||||
return self
|
||||
end
|
||||
|
||||
--- Play the usersound to the given @{Wrapper.Unit}.
|
||||
--- Play the usersound to the given @{Wrapper.Unit}.
|
||||
-- @param #USERSOUND self
|
||||
-- @param Wrapper.Unit#UNIT Unit The @{Wrapper.Unit} to play the usersound to.
|
||||
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
|
||||
@@ -159,4 +159,24 @@ do -- UserSound
|
||||
return self
|
||||
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
|
||||
@@ -13,9 +13,9 @@
|
||||
-- ## Test Missions:
|
||||
--
|
||||
-- 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)
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Tasking system.
|
||||
|
||||
@@ -29,7 +29,6 @@ ENUMS = {}
|
||||
--- Suppress the error box
|
||||
env.setErrorMessageBoxEnabled( false )
|
||||
|
||||
|
||||
--- Rules of Engagement.
|
||||
-- @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.
|
||||
@@ -524,6 +523,7 @@ ENUMS.ReportingName =
|
||||
Hawkeye = "E-2D",
|
||||
Sentry = "E-3A",
|
||||
Stratotanker = "KC-135",
|
||||
Gasstation = "KC-135MPRS",
|
||||
Extender = "KC-10",
|
||||
Orion = "P-3C",
|
||||
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 ""
|
||||
|
||||
@@ -441,21 +441,45 @@ UTILS.BasicSerialize = function(s)
|
||||
end
|
||||
end
|
||||
|
||||
function UTILS.PrintTableToLog(table, indent)
|
||||
if not table then
|
||||
BASE:E("No table passed!")
|
||||
return
|
||||
--- Print a table to log in a nice format
|
||||
-- @param #table table The table to print
|
||||
-- @param #number indent Number of indents
|
||||
-- @param #boolean noprint Don't log but return text
|
||||
-- @return #string text Text created on the fly of the log output
|
||||
function UTILS.PrintTableToLog(table, indent, noprint)
|
||||
local text = "\n"
|
||||
if not table or type(table) ~= "table" then
|
||||
env.warning("No table passed!")
|
||||
return nil
|
||||
end
|
||||
if not indent then indent = 0 end
|
||||
for k, v in pairs(table) do
|
||||
if string.find(k," ") then k='"'..k..'"'end
|
||||
if type(v) == "table" then
|
||||
BASE:I(string.rep(" ", indent) .. tostring(k) .. " = {")
|
||||
UTILS.PrintTableToLog(v, indent + 1)
|
||||
BASE:I(string.rep(" ", indent) .. "}")
|
||||
if not noprint then
|
||||
env.info(string.rep(" ", indent) .. tostring(k) .. " = {")
|
||||
end
|
||||
text = text ..string.rep(" ", indent) .. tostring(k) .. " = {\n"
|
||||
text = text .. tostring(UTILS.PrintTableToLog(v, indent + 1)).."\n"
|
||||
if not noprint then
|
||||
env.info(string.rep(" ", indent) .. "},")
|
||||
end
|
||||
text = text .. string.rep(" ", indent) .. "},\n"
|
||||
elseif type(v) == "function" then
|
||||
else
|
||||
BASE:I(string.rep(" ", indent) .. tostring(k) .. " = " .. tostring(v))
|
||||
local value
|
||||
if tostring(v) == "true" or tostring(v) == "false" or tonumber(v) ~= nil then
|
||||
value=v
|
||||
else
|
||||
value = '"'..tostring(v)..'"'
|
||||
end
|
||||
if not noprint then
|
||||
env.info(string.rep(" ", indent) .. tostring(k) .. " = " .. tostring(value)..",\n")
|
||||
end
|
||||
text = text .. string.rep(" ", indent) .. tostring(k) .. " = " .. tostring(value)..",\n"
|
||||
end
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
--- Returns table in a easy readable string representation.
|
||||
@@ -809,6 +833,64 @@ UTILS.tostringLL = function( lat, lon, acc, DMS)
|
||||
end
|
||||
end
|
||||
|
||||
--[[acc:
|
||||
in DM: decimal point of minutes.
|
||||
In DMS: decimal point of seconds.
|
||||
position after the decimal of the least significant digit:
|
||||
So:
|
||||
42.32 - acc of 2.
|
||||
]]
|
||||
UTILS.tostringLLM2KData = function( lat, lon, acc)
|
||||
|
||||
local latHemi, lonHemi
|
||||
if lat > 0 then
|
||||
latHemi = 'N'
|
||||
else
|
||||
latHemi = 'S'
|
||||
end
|
||||
|
||||
if lon > 0 then
|
||||
lonHemi = 'E'
|
||||
else
|
||||
lonHemi = 'W'
|
||||
end
|
||||
|
||||
lat = math.abs(lat)
|
||||
lon = math.abs(lon)
|
||||
|
||||
local latDeg = math.floor(lat)
|
||||
local latMin = (lat - latDeg)*60
|
||||
|
||||
local lonDeg = math.floor(lon)
|
||||
local lonMin = (lon - lonDeg)*60
|
||||
|
||||
-- degrees, decimal minutes.
|
||||
latMin = UTILS.Round(latMin, acc)
|
||||
lonMin = UTILS.Round(lonMin, acc)
|
||||
|
||||
if latMin == 60 then
|
||||
latMin = 0
|
||||
latDeg = latDeg + 1
|
||||
end
|
||||
|
||||
if lonMin == 60 then
|
||||
lonMin = 0
|
||||
lonDeg = lonDeg + 1
|
||||
end
|
||||
|
||||
local minFrmtStr -- create the formatting string for the minutes place
|
||||
if acc <= 0 then -- no decimal place.
|
||||
minFrmtStr = '%02d'
|
||||
else
|
||||
local width = 3 + acc -- 01.310 - that's a width of 6, for example.
|
||||
minFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
|
||||
end
|
||||
|
||||
-- 024 23'N or 024 23.123'N
|
||||
return latHemi..string.format('%02d:', latDeg) .. string.format(minFrmtStr, latMin), lonHemi..string.format('%02d:', lonDeg) .. string.format(minFrmtStr, lonMin)
|
||||
|
||||
end
|
||||
|
||||
-- acc- the accuracy of each easting/northing. 0, 1, 2, 3, 4, or 5.
|
||||
UTILS.tostringMGRS = function(MGRS, acc) --R2.1
|
||||
|
||||
@@ -1048,9 +1130,9 @@ function UTILS.BeaufortScale(speed)
|
||||
return bn,bd
|
||||
end
|
||||
|
||||
--- Split string at seperators. C.f. [split-string-in-lua](http://stackoverflow.com/questions/1426954/split-string-in-lua).
|
||||
--- Split string at separators. C.f. [split-string-in-lua](http://stackoverflow.com/questions/1426954/split-string-in-lua).
|
||||
-- @param #string str Sting to split.
|
||||
-- @param #string sep Speparator for split.
|
||||
-- @param #string sep Separator for split.
|
||||
-- @return #table Split text.
|
||||
function UTILS.Split(str, sep)
|
||||
local result = {}
|
||||
@@ -1345,6 +1427,11 @@ function UTILS.VecSubstract(a, b)
|
||||
return {x=a.x-b.x, y=a.y-b.y, z=a.z-b.z}
|
||||
end
|
||||
|
||||
--- Substract is not a word, don't want to rename the original function because it's been around since forever
|
||||
function UTILS.VecSubtract(a, b)
|
||||
return UTILS.VecSubstract(a, b)
|
||||
end
|
||||
|
||||
--- Calculate the difference between two 2D vectors by substracting the x,y components from each other.
|
||||
-- @param DCS#Vec2 a Vector in 2D with x, y components.
|
||||
-- @param DCS#Vec2 b Vector in 2D with x, y components.
|
||||
@@ -1353,6 +1440,11 @@ function UTILS.Vec2Substract(a, b)
|
||||
return {x=a.x-b.x, y=a.y-b.y}
|
||||
end
|
||||
|
||||
--- Substract is not a word, don't want to rename the original function because it's been around since forever
|
||||
function UTILS.Vec2Subtract(a, b)
|
||||
return UTILS.Vec2Substract(a, b)
|
||||
end
|
||||
|
||||
--- Calculate the total vector of two 3D vectors by adding the x,y,z components of each other.
|
||||
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||
@@ -2120,17 +2212,17 @@ function UTILS.IsLoadingDoorOpen( unit_name )
|
||||
return true
|
||||
end
|
||||
|
||||
if string.find(type_name, "Bell-47") then -- bell aint got no doors so always ready to load injured soldiers
|
||||
if type_name == "Bell-47" then -- bell aint got no doors so always ready to load injured soldiers
|
||||
BASE:T(unit_name .. " door is open")
|
||||
return true
|
||||
end
|
||||
|
||||
if string.find(type_name, "UH-60L") and (unit:getDrawArgumentValue(401) == 1 or unit:getDrawArgumentValue(402) == 1) then
|
||||
|
||||
if type_name == "UH-60L" and (unit:getDrawArgumentValue(401) == 1 or unit:getDrawArgumentValue(402) == 1) then
|
||||
BASE:T(unit_name .. " cargo door is open")
|
||||
return true
|
||||
end
|
||||
|
||||
if string.find(type_name, "UH-60L" ) and (unit:getDrawArgumentValue(38) == 1 or unit:getDrawArgumentValue(400) == 1 ) then
|
||||
if type_name == "UH-60L" and (unit:getDrawArgumentValue(38) > 0 or unit:getDrawArgumentValue(400) == 1 ) then
|
||||
BASE:T(unit_name .. " front door(s) are open")
|
||||
return true
|
||||
end
|
||||
@@ -2145,6 +2237,11 @@ function UTILS.IsLoadingDoorOpen( unit_name )
|
||||
return true -- no doors on this one ;)
|
||||
end
|
||||
|
||||
if type_name == "MH-60R" and (unit:getDrawArgumentValue(403) > 0 or unit:getDrawArgumentValue(403) == -1) then
|
||||
BASE:T(unit_name .. " cargo door is open")
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
|
||||
end -- nil
|
||||
@@ -2245,20 +2342,37 @@ function UTILS.GenerateVHFrequencies()
|
||||
return FreeVHFFrequencies
|
||||
end
|
||||
|
||||
--- Function to generate valid UHF Frequencies in mHz (AM).
|
||||
--- Function to generate valid UHF Frequencies in mHz (AM). Can be between 220 and 399 mHz. 243 is auto-excluded.
|
||||
-- @param Start (Optional) Avoid frequencies between Start and End in mHz, e.g. 244
|
||||
-- @param End (Optional) Avoid frequencies between Start and End in mHz, e.g. 320
|
||||
-- @return #table UHF Frequencies
|
||||
function UTILS.GenerateUHFrequencies()
|
||||
function UTILS.GenerateUHFrequencies(Start,End)
|
||||
|
||||
local FreeUHFFrequencies = {}
|
||||
local _start = 220000000
|
||||
|
||||
while _start < 399000000 do
|
||||
if _start ~= 243000000 then
|
||||
table.insert(FreeUHFFrequencies, _start)
|
||||
|
||||
if not Start then
|
||||
while _start < 399000000 do
|
||||
if _start ~= 243000000 then
|
||||
table.insert(FreeUHFFrequencies, _start)
|
||||
end
|
||||
_start = _start + 500000
|
||||
end
|
||||
else
|
||||
local myend = End*1000000 or 399000000
|
||||
local mystart = Start*1000000 or 220000000
|
||||
|
||||
while _start < 399000000 do
|
||||
if _start ~= 243000000 and (_start < mystart or _start > myend) then
|
||||
print(_start)
|
||||
table.insert(FreeUHFFrequencies, _start)
|
||||
end
|
||||
_start = _start + 500000
|
||||
end
|
||||
|
||||
end
|
||||
_start = _start + 500000
|
||||
end
|
||||
|
||||
|
||||
|
||||
return FreeUHFFrequencies
|
||||
end
|
||||
|
||||
@@ -2391,7 +2505,7 @@ function UTILS.LoadFromFile(Path,Filename)
|
||||
-- Check if file exists.
|
||||
local exists=UTILS.CheckFileExists(Path,Filename)
|
||||
if not exists then
|
||||
BASE:E(string.format("ERROR: File %s does not exist!",filename))
|
||||
BASE:I(string.format("ERROR: File %s does not exist!",filename))
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -3101,3 +3215,631 @@ function UTILS.PlotRacetrack(Coordinate, Altitude, Speed, Heading, Leg, Coalitio
|
||||
circle_center_two_three:CircleToAll(UTILS.NMToMeters(turn_radius), coalition, color, alpha, nil, 0, lineType)--, ReadOnly, Text)
|
||||
|
||||
end
|
||||
|
||||
--- Get the current time in a "nice" format like 21:01:15
|
||||
-- @return #string Returns string with the current time
|
||||
function UTILS.TimeNow()
|
||||
return UTILS.SecondsToClock(timer.getAbsTime(), false, false)
|
||||
end
|
||||
|
||||
|
||||
--- Given 2 "nice" time string, returns the difference between the two in seconds
|
||||
-- @param #string start_time Time string like "07:15:22"
|
||||
-- @param #string end_time Time string like "08:11:27"
|
||||
-- @return #number Seconds between start_time and end_time
|
||||
function UTILS.TimeDifferenceInSeconds(start_time, end_time)
|
||||
return UTILS.ClockToSeconds(end_time) - UTILS.ClockToSeconds(start_time)
|
||||
end
|
||||
|
||||
--- Check if the current time is later than time_string.
|
||||
-- @param #string start_time Time string like "07:15:22"
|
||||
-- @return #boolean True if later, False if before
|
||||
function UTILS.TimeLaterThan(time_string)
|
||||
if timer.getAbsTime() > UTILS.ClockToSeconds(time_string) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- Check if the current time is before time_string.
|
||||
-- @param #string start_time Time string like "07:15:22"
|
||||
-- @return #boolean False if later, True if before
|
||||
function UTILS.TimeBefore(time_string)
|
||||
if timer.getAbsTime() < UTILS.ClockToSeconds(time_string) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
--- Combines two time strings to give you a new time. For example "15:16:32" and "02:06:24" would return "17:22:56"
|
||||
-- @param #string time_string_01 Time string like "07:15:22"
|
||||
-- @param #string time_string_02 Time string like "08:11:27"
|
||||
-- @return #string Result of the two time string combined
|
||||
function UTILS.CombineTimeStrings(time_string_01, time_string_02)
|
||||
local hours1, minutes1, seconds1 = time_string_01:match("(%d+):(%d+):(%d+)")
|
||||
local hours2, minutes2, seconds2 = time_string_02:match("(%d+):(%d+):(%d+)")
|
||||
local total_seconds = tonumber(seconds1) + tonumber(seconds2) + tonumber(minutes1) * 60 + tonumber(minutes2) * 60 + tonumber(hours1) * 3600 + tonumber(hours2) * 3600
|
||||
|
||||
total_seconds = total_seconds % (24 * 3600)
|
||||
if total_seconds < 0 then
|
||||
total_seconds = total_seconds + 24 * 3600
|
||||
end
|
||||
|
||||
local hours = math.floor(total_seconds / 3600)
|
||||
total_seconds = total_seconds - hours * 3600
|
||||
local minutes = math.floor(total_seconds / 60)
|
||||
local seconds = total_seconds % 60
|
||||
|
||||
return string.format("%02d:%02d:%02d", hours, minutes, seconds)
|
||||
end
|
||||
|
||||
|
||||
--- Subtracts two time string to give you a new time. For example "15:16:32" and "02:06:24" would return "13:10:08"
|
||||
-- @param #string time_string_01 Time string like "07:15:22"
|
||||
-- @param #string time_string_02 Time string like "08:11:27"
|
||||
-- @return #string Result of the two time string subtracted
|
||||
function UTILS.SubtractTimeStrings(time_string_01, time_string_02)
|
||||
local hours1, minutes1, seconds1 = time_string_01:match("(%d+):(%d+):(%d+)")
|
||||
local hours2, minutes2, seconds2 = time_string_02:match("(%d+):(%d+):(%d+)")
|
||||
local total_seconds = tonumber(seconds1) - tonumber(seconds2) + tonumber(minutes1) * 60 - tonumber(minutes2) * 60 + tonumber(hours1) * 3600 - tonumber(hours2) * 3600
|
||||
|
||||
total_seconds = total_seconds % (24 * 3600)
|
||||
if total_seconds < 0 then
|
||||
total_seconds = total_seconds + 24 * 3600
|
||||
end
|
||||
|
||||
local hours = math.floor(total_seconds / 3600)
|
||||
total_seconds = total_seconds - hours * 3600
|
||||
local minutes = math.floor(total_seconds / 60)
|
||||
local seconds = total_seconds % 60
|
||||
|
||||
return string.format("%02d:%02d:%02d", hours, minutes, seconds)
|
||||
end
|
||||
|
||||
--- Checks if the current time is in between start_time and end_time
|
||||
-- @param #string time_string_01 Time string like "07:15:22"
|
||||
-- @param #string time_string_02 Time string like "08:11:27"
|
||||
-- @return #bool True if it is, False if it's not
|
||||
function UTILS.TimeBetween(start_time, end_time)
|
||||
return UTILS.TimeLaterThan(start_time) and UTILS.TimeBefore(end_time)
|
||||
end
|
||||
|
||||
--- Easy to read one line to roll the dice on something. 1% is very unlikely to happen, 99% is very likely to happen
|
||||
-- @param #number chance (optional) Percentage chance you want something to happen. Defaults to a random number if not given
|
||||
-- @return #bool True if the dice roll was within the given percentage chance of happening
|
||||
function UTILS.PercentageChance(chance)
|
||||
chance = chance or math.random(0, 100)
|
||||
chance = UTILS.Clamp(chance, 0, 100)
|
||||
local percentage = math.random(0, 100)
|
||||
if percentage < chance then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- Easy to read one liner to clamp a value
|
||||
-- @param #number value Input value
|
||||
-- @param #number min Minimal value that should be respected
|
||||
-- @param #number max Maximal value that should be respected
|
||||
-- @return #number Clamped value
|
||||
function UTILS.Clamp(value, min, max)
|
||||
if value < min then value = min end
|
||||
if value > max then value = max end
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
--- Clamp an angle so that it's always between 0 and 360 while still being correct
|
||||
-- @param #number value Input value
|
||||
-- @return #number Clamped value
|
||||
function UTILS.ClampAngle(value)
|
||||
if value > 360 then return value - 360 end
|
||||
if value < 0 then return value + 360 end
|
||||
return value
|
||||
end
|
||||
|
||||
--- Remap an input to a new value in a given range. For example:
|
||||
--- UTILS.RemapValue(20, 10, 30, 0, 200) would return 100
|
||||
--- 20 is 50% between 10 and 30
|
||||
--- 50% between 0 and 200 is 100
|
||||
-- @param #number value Input value
|
||||
-- @param #number old_min Min value to remap from
|
||||
-- @param #number old_max Max value to remap from
|
||||
-- @param #number new_min Min value to remap to
|
||||
-- @param #number new_max Max value to remap to
|
||||
-- @return #number Remapped value
|
||||
function UTILS.RemapValue(value, old_min, old_max, new_min, new_max)
|
||||
new_min = new_min or 0
|
||||
new_max = new_max or 100
|
||||
|
||||
local old_range = old_max - old_min
|
||||
local new_range = new_max - new_min
|
||||
local percentage = (value - old_min) / old_range
|
||||
return (new_range * percentage) + new_min
|
||||
end
|
||||
|
||||
--- Given a triangle made out of 3 vector 2s, return a vec2 that is a random number in this triangle
|
||||
-- @param #Vec2 pt1 Min value to remap from
|
||||
-- @param #Vec2 pt2 Max value to remap from
|
||||
-- @param #Vec2 pt3 Max value to remap from
|
||||
-- @return #Vec2 Random point in triangle
|
||||
function UTILS.RandomPointInTriangle(pt1, pt2, pt3)
|
||||
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 * pt1.x + t * pt2.x + u * pt3.x,
|
||||
y = s * pt1.y + t * pt2.y + u * pt3.y}
|
||||
end
|
||||
|
||||
--- Checks if a given angle (heading) is between 2 other angles. Min and max have to be given in clockwise order For example:
|
||||
--- UTILS.AngleBetween(350, 270, 15) would return True
|
||||
--- UTILS.AngleBetween(22, 95, 20) would return False
|
||||
-- @param #number angle Min value to remap from
|
||||
-- @param #number min Max value to remap from
|
||||
-- @param #number max Max value to remap from
|
||||
-- @return #bool
|
||||
function UTILS.AngleBetween(angle, min, max)
|
||||
angle = (360 + (angle % 360)) % 360
|
||||
min = (360 + min % 360) % 360
|
||||
max = (360 + max % 360) % 360
|
||||
|
||||
if min < max then return min <= angle and angle <= max end
|
||||
return min <= angle or angle <= max
|
||||
end
|
||||
|
||||
--- Easy to read one liner to write a JSON file. Everything in @data should be serializable
|
||||
--- json.lua exists in the DCS install Scripts folder
|
||||
-- @param #table data table to write
|
||||
-- @param #string file_path File path
|
||||
function UTILS.WriteJSON(data, file_path)
|
||||
package.path = package.path .. ";.\\Scripts\\?.lua"
|
||||
local JSON = require("json")
|
||||
local pretty_json_text = JSON:encode_pretty(data)
|
||||
local write_file = io.open(file_path, "w")
|
||||
write_file:write(pretty_json_text)
|
||||
write_file:close()
|
||||
end
|
||||
|
||||
--- Easy to read one liner to read a JSON file.
|
||||
--- json.lua exists in the DCS install Scripts folder
|
||||
-- @param #string file_path File path
|
||||
-- @return #table
|
||||
function UTILS.ReadJSON(file_path)
|
||||
package.path = package.path .. ";.\\Scripts\\?.lua"
|
||||
local JSON = require("json")
|
||||
local read_file = io.open(file_path, "r")
|
||||
local contents = read_file:read( "*a" )
|
||||
io.close(read_file)
|
||||
return JSON:decode(contents)
|
||||
end
|
||||
|
||||
--- Get the properties names and values of properties set up on a Zone in the Mission Editor.
|
||||
--- This doesn't work for any zones created in MOOSE
|
||||
-- @param #string zone_name Name of the zone as set up in the Mission Editor
|
||||
-- @return #table with all the properties on a zone
|
||||
function UTILS.GetZoneProperties(zone_name)
|
||||
local return_table = {}
|
||||
for _, zone in pairs(env.mission.triggers.zones) do
|
||||
if zone["name"] == zone_name then
|
||||
if table.length(zone["properties"]) > 0 then
|
||||
for _, property in pairs(zone["properties"]) do
|
||||
return_table[property["key"]] = property["value"]
|
||||
end
|
||||
return return_table
|
||||
else
|
||||
BASE:I(string.format("%s doesn't have any properties", zone_name))
|
||||
return {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Rotates a point around another point with a given angle. Useful if you're loading in groups or
|
||||
--- statics but you want to rotate them all as a collection. You can get the center point of everything
|
||||
--- and then rotate all the positions of every object around this center point.
|
||||
-- @param #Vec2 point Point that you want to rotate
|
||||
-- @param #Vec2 pivot Pivot point of the rotation
|
||||
-- @param #number angle How many degrees the point should be rotated
|
||||
-- @return #Vec Rotated point
|
||||
function UTILS.RotatePointAroundPivot(point, pivot, angle)
|
||||
local radians = math.rad(angle)
|
||||
|
||||
local x = point.x - pivot.x
|
||||
local y = point.y - pivot.y
|
||||
|
||||
local rotated_x = x * math.cos(radians) - y * math.sin(radians)
|
||||
local rotatex_y = x * math.sin(radians) + y * math.cos(radians)
|
||||
|
||||
local original_x = rotated_x + pivot.x
|
||||
local original_y = rotatex_y + pivot.y
|
||||
|
||||
return { x = original_x, y = original_y }
|
||||
end
|
||||
|
||||
--- Makes a string semi-unique by attaching a random number between 0 and 1 million to it
|
||||
-- @param #string base String you want to unique-fy
|
||||
-- @return #string Unique string
|
||||
function UTILS.UniqueName(base)
|
||||
base = base or ""
|
||||
local ran = tostring(math.random(0, 1000000))
|
||||
|
||||
if base == "" then
|
||||
return ran
|
||||
end
|
||||
return base .. "_" .. ran
|
||||
end
|
||||
|
||||
--- Check if a string starts with something
|
||||
-- @param #string str String to check
|
||||
-- @param #string value
|
||||
-- @return #bool True if str starts with value
|
||||
function string.startswith(str, value)
|
||||
return string.sub(str,1,string.len(value)) == value
|
||||
end
|
||||
|
||||
|
||||
--- Check if a string ends with something
|
||||
-- @param #string str String to check
|
||||
-- @param #string value
|
||||
-- @return #bool True if str ends with value
|
||||
function string.endswith(str, value)
|
||||
return value == "" or str:sub(-#value) == value
|
||||
end
|
||||
|
||||
--- Splits a string on a separator. For example:
|
||||
--- string.split("hello_dcs_world", "-") would return {"hello", "dcs", "world"}
|
||||
-- @param #string input String to split
|
||||
-- @param #string separator What to split on
|
||||
-- @return #table individual strings
|
||||
function string.split(input, separator)
|
||||
local parts = {}
|
||||
for part in input:gmatch("[^" .. separator .. "]+") do
|
||||
table.insert(parts, part)
|
||||
end
|
||||
return parts
|
||||
end
|
||||
|
||||
|
||||
--- Checks if a string contains a substring. Easier to remember for Python people :)
|
||||
--- string.split("hello_dcs_world", "-") would return {"hello", "dcs", "world"}
|
||||
-- @param #string str
|
||||
-- @param #string value
|
||||
-- @return #bool True if str contains value
|
||||
function string.contains(str, value)
|
||||
return string.match(str, value)
|
||||
end
|
||||
|
||||
--- Given tbl is a indexed table ({"hello", "dcs", "world"}), checks if element exists in the table.
|
||||
--- The table can be made up out of complex tables or values as well
|
||||
-- @param #table tbl
|
||||
-- @param #string element
|
||||
-- @return #bool True if tbl contains element
|
||||
function table.contains(tbl, element)
|
||||
if element == nil or tbl == nil then return false end
|
||||
|
||||
local index = 1
|
||||
while tbl[index] do
|
||||
if tbl[index] == element then
|
||||
return true
|
||||
end
|
||||
index = index + 1
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- Checks if a table contains a specific key.
|
||||
-- @param #table tbl Table to check
|
||||
-- @param #string key Key to look for
|
||||
-- @return #bool True if tbl contains key
|
||||
function table.contains_key(tbl, key)
|
||||
if tbl[key] ~= nil then return true else return false end
|
||||
end
|
||||
|
||||
--- Inserts a unique element into a table.
|
||||
-- @param #table tbl Table to insert into
|
||||
-- @param #string element Element to insert
|
||||
function table.insert_unique(tbl, element)
|
||||
if element == nil or tbl == nil then return end
|
||||
|
||||
if not table.contains(tbl, element) then
|
||||
table.insert(tbl, element)
|
||||
end
|
||||
end
|
||||
|
||||
--- Removes an element from a table by its value.
|
||||
-- @param #table tbl Table to remove from
|
||||
-- @param #string element Element to remove
|
||||
function table.remove_by_value(tbl, element)
|
||||
local indices_to_remove = {}
|
||||
local index = 1
|
||||
for _, value in pairs(tbl) do
|
||||
if value == element then
|
||||
table.insert(indices_to_remove, index)
|
||||
end
|
||||
index = index + 1
|
||||
end
|
||||
|
||||
for _, idx in pairs(indices_to_remove) do
|
||||
table.remove(tbl, idx)
|
||||
end
|
||||
end
|
||||
|
||||
--- Removes an element from a table by its key.
|
||||
-- @param #table table Table to remove from
|
||||
-- @param #string key Key of the element to remove
|
||||
-- @return #string Removed element
|
||||
function table.remove_key(table, key)
|
||||
local element = table[key]
|
||||
table[key] = nil
|
||||
return element
|
||||
end
|
||||
|
||||
--- Finds the index of an element in a table.
|
||||
-- @param #table table Table to search
|
||||
-- @param #string element Element to find
|
||||
-- @return #int Index of the element, or nil if not found
|
||||
function table.index_of(table, element)
|
||||
for i, v in ipairs(table) do
|
||||
if v == element then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Counts the number of elements in a table.
|
||||
-- @param #table T Table to count
|
||||
-- @return #int Number of elements in the table
|
||||
function table.length(T)
|
||||
local count = 0
|
||||
for _ in pairs(T) do count = count + 1 end
|
||||
return count
|
||||
end
|
||||
|
||||
--- Slices a table between two indices, much like Python's my_list[2:-1]
|
||||
-- @param #table tbl Table to slice
|
||||
-- @param #int first Starting index
|
||||
-- @param #int last Ending index
|
||||
-- @return #table Sliced table
|
||||
function table.slice(tbl, first, last)
|
||||
local sliced = {}
|
||||
local start = first or 1
|
||||
local stop = last or table.length(tbl)
|
||||
local count = 1
|
||||
|
||||
for key, value in pairs(tbl) do
|
||||
if count >= start and count <= stop then
|
||||
sliced[key] = value
|
||||
end
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
return sliced
|
||||
end
|
||||
|
||||
--- Counts the number of occurrences of a value in a table.
|
||||
-- @param #table tbl Table to search
|
||||
-- @param #string value Value to count
|
||||
-- @return #int Number of occurrences of the value
|
||||
function table.count_value(tbl, value)
|
||||
local count = 0
|
||||
for _, item in pairs(tbl) do
|
||||
if item == value then count = count + 1 end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
--- Add 2 table together, t2 gets added to t1
|
||||
-- @param #table t1 First table
|
||||
-- @param #table t2 Second table
|
||||
-- @return #table Combined table
|
||||
function table.combine(t1, t2)
|
||||
if t1 == nil and t2 == nil then
|
||||
BASE:E("Both tables were empty!")
|
||||
end
|
||||
|
||||
if t1 == nil then return t2 end
|
||||
if t2 == nil then return t1 end
|
||||
for i=1,#t2 do
|
||||
t1[#t1+1] = t2[i]
|
||||
end
|
||||
return t1
|
||||
end
|
||||
|
||||
--- Merges two tables into one. If a key exists in both t1 and t2, the value of t1 with be overwritten by the value of t2
|
||||
-- @param #table t1 First table
|
||||
-- @param #table t2 Second table
|
||||
-- @return #table Merged table
|
||||
function table.merge(t1, t2)
|
||||
for k, v in pairs(t2) do
|
||||
if (type(v) == "table") and (type(t1[k] or false) == "table") then
|
||||
table.merge(t1[k], t2[k])
|
||||
else
|
||||
t1[k] = v
|
||||
end
|
||||
end
|
||||
return t1
|
||||
end
|
||||
|
||||
--- Adds an item to the end of a table.
|
||||
-- @param #table tbl Table to add to
|
||||
-- @param #string item Item to add
|
||||
function table.add(tbl, item)
|
||||
tbl[#tbl + 1] = item
|
||||
end
|
||||
|
||||
--- Shuffles the elements of a table.
|
||||
-- @param #table tbl Table to shuffle
|
||||
-- @return #table Shuffled table
|
||||
function table.shuffle(tbl)
|
||||
local new_table = {}
|
||||
for _, value in ipairs(tbl) do
|
||||
local pos = math.random(1, #new_table +1)
|
||||
table.insert(new_table, pos, value)
|
||||
end
|
||||
return new_table
|
||||
end
|
||||
|
||||
--- Finds a key-value pair in a table.
|
||||
-- @param #table tbl Table to search
|
||||
-- @param #string key Key to find
|
||||
-- @param #string value Value to find
|
||||
-- @return #table Table containing the key-value pair, or nil if not found
|
||||
function table.find_key_value_pair(tbl, key, value)
|
||||
for k, v in pairs(tbl) do
|
||||
if type(v) == "table" then
|
||||
local result = table.find_key_value_pair(v, key, value)
|
||||
if result ~= nil then
|
||||
return result
|
||||
end
|
||||
elseif k == key and v == value then
|
||||
return tbl
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Convert a decimal to octal
|
||||
-- @param #number Number the number to convert
|
||||
-- @return #number Octal
|
||||
function UTILS.DecimalToOctal(Number)
|
||||
if Number < 8 then return Number end
|
||||
local number = tonumber(Number)
|
||||
local octal = ""
|
||||
local n=1
|
||||
while number > 7 do
|
||||
local number1 = number%8
|
||||
octal = string.format("%d",number1)..octal
|
||||
local number2 = math.abs(number/8)
|
||||
if number2 < 8 then
|
||||
octal = string.format("%d",number2)..octal
|
||||
end
|
||||
number = number2
|
||||
n=n+1
|
||||
end
|
||||
return tonumber(octal)
|
||||
end
|
||||
|
||||
--- Convert an octal to decimal
|
||||
-- @param #number Number the number to convert
|
||||
-- @return #number Decimal
|
||||
function UTILS.OctalToDecimal(Number)
|
||||
return tonumber(Number,8)
|
||||
end
|
||||
|
||||
--- Function to save the position of a set of #OPSGROUP (ARMYGROUP) objects.
|
||||
-- @param Core.Set#SET_OPSGROUP Set of ops objects to save
|
||||
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
|
||||
-- @param #string Filename The name of the file.
|
||||
-- @param #boolean Structured Append the data with a list of typenames in the group plus their count.
|
||||
-- @return #boolean outcome True if saving is successful, else false.
|
||||
function UTILS.SaveSetOfOpsGroups(Set,Path,Filename,Structured)
|
||||
local filename = Filename or "SetOfGroups"
|
||||
local data = "--Save SET of groups: (name,legion,template,alttemplate,units,position.x,position.y,position.z,strucdata) "..Filename .."\n"
|
||||
local List = Set:GetSetObjects()
|
||||
for _,_group in pairs (List) do
|
||||
local group = _group:GetGroup() -- Wrapper.Group#GROUP
|
||||
if group and group:IsAlive() then
|
||||
local name = group:GetName()
|
||||
local template = string.gsub(name,"(.AID.%d+$","")
|
||||
if string.find(template,"#") then
|
||||
template = string.gsub(name,"#(%d+)$","")
|
||||
end
|
||||
local alttemplate = _group.templatename or "none"
|
||||
local legiono = _group.legion -- Ops.Legion#LEGION
|
||||
local legion = "none"
|
||||
if legiono and type(legiono) == "table" and legiono.ClassName then
|
||||
legion = legiono:GetName()
|
||||
local asset = legiono:GetAssetByName(name) -- Functional.Warehouse#WAREHOUSE.Assetitem
|
||||
alttemplate=asset.templatename
|
||||
end
|
||||
local units = group:CountAliveUnits()
|
||||
local position = group:GetVec3()
|
||||
if Structured then
|
||||
local structure = UTILS.GetCountPerTypeName(group)
|
||||
local strucdata = ""
|
||||
for typen,anzahl in pairs (structure) do
|
||||
strucdata = strucdata .. typen .. "=="..anzahl..";"
|
||||
end
|
||||
data = string.format("%s%s,%s,%s,%s,%d,%d,%d,%d,%s\n",data,name,legion,template,alttemplate,units,position.x,position.y,position.z,strucdata)
|
||||
else
|
||||
data = string.format("%s%s,%s,%s,%s,%d,%d,%d,%d\n",data,name,legion,template,alttemplate,units,position.x,position.y,position.z)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- save the data
|
||||
local outcome = UTILS.SaveToFile(Path,Filename,data)
|
||||
return outcome
|
||||
end
|
||||
|
||||
--- Load back a #OPSGROUP (ARMYGROUP) data from file for use with @{Ops.Brigade#BRIGADE.LoadBackAssetInPosition}()
|
||||
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
|
||||
-- @param #string Filename The name of the file.
|
||||
-- @return #table Returns a table of data entries: `{ groupname=groupname, size=size, coordinate=coordinate, template=template, structure=structure, legion=legion, alttemplate=alttemplate }`
|
||||
-- Returns nil when the file cannot be read.
|
||||
function UTILS.LoadSetOfOpsGroups(Path,Filename)
|
||||
|
||||
local filename = Filename or "SetOfGroups"
|
||||
local datatable = {}
|
||||
|
||||
if UTILS.CheckFileExists(Path,filename) then
|
||||
local outcome,loadeddata = UTILS.LoadFromFile(Path,Filename)
|
||||
-- remove header
|
||||
table.remove(loadeddata, 1)
|
||||
for _id,_entry in pairs (loadeddata) do
|
||||
local dataset = UTILS.Split(_entry,",")
|
||||
-- 1name,2legion,3template,4alttemplate,5units,6position.x,7position.y,8position.z,9strucdata
|
||||
local groupname = dataset[1]
|
||||
local legion = dataset[2]
|
||||
local template = dataset[3]
|
||||
local alttemplate = dataset[4]
|
||||
local size = tonumber(dataset[5])
|
||||
local posx = tonumber(dataset[6])
|
||||
local posy = tonumber(dataset[7])
|
||||
local posz = tonumber(dataset[8])
|
||||
local structure = dataset[9]
|
||||
local coordinate = COORDINATE:NewFromVec3({x=posx, y=posy, z=posz})
|
||||
if size > 0 then
|
||||
local data = { groupname=groupname, size=size, coordinate=coordinate, template=template, structure=structure, legion=legion, alttemplate=alttemplate }
|
||||
table.insert(datatable,data)
|
||||
end
|
||||
end
|
||||
else
|
||||
return nil
|
||||
end
|
||||
|
||||
return datatable
|
||||
end
|
||||
|
||||
--- Get the clock position from a relative heading
|
||||
-- @param #number refHdg The heading of the reference object (such as a Wrapper.UNIT) in 0-360
|
||||
-- @param #number tgtHdg The absolute heading from the reference object to the target object/point in 0-360
|
||||
-- @return #string text Text in clock heading such as "4 O'CLOCK"
|
||||
-- @usage Display the range and clock distance of a BTR in relation to REAPER 1-1's heading:
|
||||
--
|
||||
-- myUnit = UNIT:FindByName( "REAPER 1-1" )
|
||||
-- myTarget = GROUP:FindByName( "BTR-1" )
|
||||
--
|
||||
-- coordUnit = myUnit:GetCoordinate()
|
||||
-- coordTarget = myTarget:GetCoordinate()
|
||||
--
|
||||
-- hdgUnit = myUnit:GetHeading()
|
||||
-- hdgTarget = coordUnit:HeadingTo( coordTarget )
|
||||
-- distTarget = coordUnit:Get3DDistance( coordTarget )
|
||||
--
|
||||
-- clockString = UTILS.ClockHeadingString( hdgUnit, hdgTarget )
|
||||
--
|
||||
-- -- Will show this message to REAPER 1-1 in-game: Contact BTR at 3 o'clock for 1134m!
|
||||
-- MESSAGE:New("Contact BTR at " .. clockString .. " for " .. distTarget .. "m!):ToUnit( myUnit )
|
||||
function UTILS.ClockHeadingString(refHdg,tgtHdg)
|
||||
local relativeAngle = tgtHdg - refHdg
|
||||
if relativeAngle < 0 then
|
||||
relativeAngle = relativeAngle + 360
|
||||
end
|
||||
local clockPos = math.ceil((relativeAngle % 360) / 30)
|
||||
return clockPos.." o'clock"
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -123,18 +123,38 @@ end
|
||||
|
||||
--- Check if SCENERY Object is alive.
|
||||
--@param #SCENERY self
|
||||
--@param #number Threshold (Optional) If given, SCENERY counts as alive above this relative life in percent (1..100).
|
||||
--@return #number life
|
||||
function SCENERY:IsAlive()
|
||||
return self:GetLife() >= 1 and true or false
|
||||
function SCENERY:IsAlive(Threshold)
|
||||
if not Threshold then
|
||||
return self:GetLife() >= 1 and true or false
|
||||
else
|
||||
return self:GetRelativeLife() > Threshold and true or false
|
||||
end
|
||||
end
|
||||
|
||||
--- Check if SCENERY Object is dead.
|
||||
--@param #SCENERY self
|
||||
--@param #number Threshold (Optional) If given, SCENERY counts as dead below this relative life in percent (1..100).
|
||||
--@return #number life
|
||||
function SCENERY:IsDead()
|
||||
return self:GetLife() < 1 and true or false
|
||||
function SCENERY:IsDead(Threshold)
|
||||
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
|
||||
|
||||
--- Get the threat level of a SCENERY object. Always 0 as scenery does not pose a threat to anyone.
|
||||
--@param #SCENERY self
|
||||
--@return #number Threat level 0.
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
-- @image Wrapper_Static.JPG
|
||||
|
||||
|
||||
--- @type STATIC
|
||||
---
|
||||
-- @type STATIC
|
||||
-- @extends Wrapper.Positionable#POSITIONABLE
|
||||
|
||||
--- Wrapper class to handle Static objects.
|
||||
@@ -236,7 +237,7 @@ function STATIC:SpawnAt(Coordinate, Heading, Delay)
|
||||
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.
|
||||
-- @param #STATIC self
|
||||
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
||||
@@ -248,7 +249,7 @@ function STATIC:ReSpawn(CountryID, Delay)
|
||||
else
|
||||
|
||||
CountryID=CountryID or self:GetCountry()
|
||||
|
||||
|
||||
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, CountryID)
|
||||
|
||||
SpawnStatic:Spawn(nil, self.StaticName)
|
||||
@@ -270,8 +271,8 @@ function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
||||
|
||||
if Delay and Delay>0 then
|
||||
SCHEDULER:New(nil, self.ReSpawnAt, {self, Coordinate, Heading}, Delay)
|
||||
else
|
||||
|
||||
else
|
||||
|
||||
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, self:GetCountry())
|
||||
|
||||
SpawnStatic:SpawnFromCoordinate(Coordinate, Heading, self.StaticName)
|
||||
@@ -280,3 +281,52 @@ function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
||||
|
||||
return self
|
||||
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:
|
||||
--
|
||||
-- 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).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -33,93 +33,93 @@
|
||||
-- ===
|
||||
--
|
||||
-- # The STORAGE Concept
|
||||
--
|
||||
-- The STORAGE class offers an easy-to-use wrapper interface to all DCS API functions of DCS warehouses.
|
||||
--
|
||||
-- The STORAGE class offers an easy-to-use wrapper interface to all DCS API functions of DCS warehouses.
|
||||
-- We named the class STORAGE, because the name WAREHOUSE is already taken by another MOOSE class.
|
||||
--
|
||||
--
|
||||
-- This class allows you to add and remove items to a DCS warehouse, such as aircraft, liquids, weapons and other equipment.
|
||||
--
|
||||
--
|
||||
-- # Constructor
|
||||
--
|
||||
--
|
||||
-- A DCS warehouse is associated with an airbase. Therefore, a `STORAGE` instance is automatically created, once an airbase is registered and added to the MOOSE database.
|
||||
--
|
||||
-- You can get the `STORAGE` object from the
|
||||
--
|
||||
-- -- Create a STORAGE instance of the Batumi warehouse
|
||||
--
|
||||
-- You can get the `STORAGE` object from the
|
||||
--
|
||||
-- -- Create a STORAGE instance of the Batumi warehouse
|
||||
-- local storage=STORAGE:FindByName("Batumi")
|
||||
--
|
||||
--
|
||||
-- An other way to get the `STORAGE` object is to retrieve it from the AIRBASE function `AIRBASE:GetStorage()`
|
||||
--
|
||||
--
|
||||
-- -- Get storage instance of Batumi airbase
|
||||
-- local Batumi=AIRBASE:FindByName("Batumi")
|
||||
-- local storage=Batumi:GetStorage()
|
||||
--
|
||||
--
|
||||
-- # Aircraft, Weapons and Equipment
|
||||
--
|
||||
--
|
||||
-- ## Adding Items
|
||||
--
|
||||
--
|
||||
-- To add aircraft, weapons and/or othe equipment, you can use the @{#STORAGE.AddItem}() function
|
||||
--
|
||||
--
|
||||
-- storage:AddItem("A-10C", 3)
|
||||
-- storage:AddItem("weapons.missiles.AIM_120C", 10)
|
||||
--
|
||||
--
|
||||
-- This will add three A-10Cs and ten AIM-120C missiles to the warehouse inventory.
|
||||
--
|
||||
--
|
||||
-- ## Setting Items
|
||||
--
|
||||
--
|
||||
-- You can also explicitly set, how many items are in the inventory with the @{#STORAGE.SetItem}() function.
|
||||
--
|
||||
--
|
||||
-- ## Removing Items
|
||||
--
|
||||
--
|
||||
-- Items can be removed from the inventory with the @{#STORAGE.RemoveItem}() function.
|
||||
--
|
||||
--
|
||||
-- ## Getting Amount
|
||||
--
|
||||
--
|
||||
-- The number of items currently in the inventory can be obtained with the @{#STORAGE.GetItemAmount}() function
|
||||
--
|
||||
--
|
||||
-- local N=storage:GetItemAmount("A-10C")
|
||||
-- env.info(string.format("We currently have %d A-10Cs available", N))
|
||||
--
|
||||
--
|
||||
-- # Liquids
|
||||
--
|
||||
--
|
||||
-- Liquids can be added and removed by slightly different functions as described below. Currently there are four types of liquids
|
||||
--
|
||||
--
|
||||
-- * Jet fuel `STORAGE.Liquid.JETFUEL`
|
||||
-- * Aircraft gasoline `STORAGE.Liquid.GASOLINE`
|
||||
-- * MW 50 `STORAGE.Liquid.MW50`
|
||||
-- * Diesel `STORAGE.Liquid.DIESEL`
|
||||
--
|
||||
--
|
||||
-- ## Adding Liquids
|
||||
--
|
||||
--
|
||||
-- To add a certain type of liquid, you can use the @{#STORAGE.AddItem}(Type, Amount) function
|
||||
--
|
||||
--
|
||||
-- storage:AddLiquid(STORAGE.Liquid.JETFUEL, 10000)
|
||||
-- storage:AddLiquid(STORAGE.Liquid.DIESEL, 20000)
|
||||
--
|
||||
--
|
||||
-- This will add 10,000 kg of jet fuel and 20,000 kg of diesel to the inventory.
|
||||
--
|
||||
--
|
||||
-- ## Setting Liquids
|
||||
--
|
||||
--
|
||||
-- You can also explicitly set the amount of liquid with the @{#STORAGE.SetLiquid}(Type, Amount) function.
|
||||
--
|
||||
--
|
||||
-- ## Removing Liquids
|
||||
--
|
||||
--
|
||||
-- Liquids can be removed with @{#STORAGE.RemoveLiquid}(Type, Amount) function.
|
||||
--
|
||||
--
|
||||
-- ## Getting Amount
|
||||
--
|
||||
--
|
||||
-- The current amount of a certain liquid can be obtained with the @{#STORAGE.GetLiquidAmount}(Type) function
|
||||
--
|
||||
--
|
||||
-- local N=storage:GetLiquidAmount(STORAGE.Liquid.DIESEL)
|
||||
-- env.info(string.format("We currently have %d kg of Diesel available", N))
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
-- # Inventory
|
||||
--
|
||||
--
|
||||
-- The current inventory of the warehouse can be obtained with the @{#STORAGE.GetInventory}() function. This returns three tables with the aircraft, liquids and weapons:
|
||||
--
|
||||
--
|
||||
-- local aircraft, liquids, weapons=storage:GetInventory()
|
||||
--
|
||||
--
|
||||
-- UTILS.PrintTableToLog(aircraft)
|
||||
-- UTILS.PrintTableToLog(liquids)
|
||||
-- UTILS.PrintTableToLog(weapons)
|
||||
@@ -168,7 +168,7 @@ function STORAGE:New(AirbaseName)
|
||||
local self=BASE:Inherit(self, BASE:New()) -- #STORAGE
|
||||
|
||||
self.airbase=Airbase.getByName(AirbaseName)
|
||||
|
||||
|
||||
if Airbase.getWarehouse then
|
||||
self.warehouse=self.airbase:getWarehouse()
|
||||
end
|
||||
@@ -322,7 +322,7 @@ end
|
||||
function STORAGE:GetLiquidName(Type)
|
||||
|
||||
local name="Unknown"
|
||||
|
||||
|
||||
if Type==STORAGE.Liquid.JETFUEL then
|
||||
name = "Jet fuel"
|
||||
elseif Type==STORAGE.Liquid.GASOLINE then
|
||||
@@ -411,25 +411,25 @@ function STORAGE:IsUnlimited(Type)
|
||||
|
||||
-- Get current amount of type.
|
||||
local N=self:GetAmount(Type)
|
||||
|
||||
|
||||
local unlimited=false
|
||||
|
||||
|
||||
if N>0 then
|
||||
|
||||
|
||||
-- Remove one item.
|
||||
self:RemoveAmount(Type, 1)
|
||||
|
||||
|
||||
-- Get amount.
|
||||
local n=self:GetAmount(Type)
|
||||
|
||||
|
||||
-- If amount did not change, it is unlimited.
|
||||
unlimited=n==N
|
||||
|
||||
|
||||
-- Add item back.
|
||||
if not unlimited then
|
||||
self:AddAmount(Type, 1)
|
||||
end
|
||||
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Type=%s: unlimited=%s (N=%d n=%d)", tostring(Type), tostring(unlimited), N, n))
|
||||
end
|
||||
@@ -523,7 +523,7 @@ end
|
||||
function STORAGE:GetInventory(Item)
|
||||
|
||||
local inventory=self.warehouse:getInventory(Item)
|
||||
|
||||
|
||||
return inventory.aircraft, inventory.liquids, inventory.weapon
|
||||
end
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ end
|
||||
|
||||
--- Find the first(!) UNIT matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||
-- @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.
|
||||
-- @usage
|
||||
-- -- 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()`!
|
||||
-- @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
|
||||
-- @usage
|
||||
-- -- Find all group with a partial group name
|
||||
@@ -1244,7 +1244,9 @@ function UNIT:GetThreatLevel()
|
||||
|
||||
if Attributes["Fighters"] then ThreatLevel = 10
|
||||
elseif Attributes["Multirole fighters"] then ThreatLevel = 9
|
||||
elseif Attributes["Interceptors"] then ThreatLevel = 9
|
||||
elseif Attributes["Battleplanes"] then ThreatLevel = 8
|
||||
elseif Attributes["Battle airplanes"] then ThreatLevel = 8
|
||||
elseif Attributes["Attack helicopters"] then ThreatLevel = 7
|
||||
elseif Attributes["Strategic bombers"] then ThreatLevel = 6
|
||||
elseif Attributes["Bombers"] then ThreatLevel = 5
|
||||
@@ -1659,3 +1661,36 @@ function UNIT:GetSkill()
|
||||
local skill = _DATABASE.Templates.Units[name].Template.skill or "Random"
|
||||
return skill
|
||||
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
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -67,77 +69,77 @@
|
||||
-- ===
|
||||
--
|
||||
-- # The WEAPON Concept
|
||||
--
|
||||
--
|
||||
-- The WEAPON class offers an easy-to-use wrapper interface to all DCS API functions.
|
||||
--
|
||||
--
|
||||
-- Probably, the most striking highlight is that the position of the weapon can be tracked and its impact position can be determined, which is not
|
||||
-- possible with the native DCS scripting engine functions.
|
||||
--
|
||||
-- **Note** that this wrapper class is different from most others as weapon objects cannot be found with a DCS API function like `getByName()`.
|
||||
-- They can only be found in DCS events like the "Shot" event, where the weapon object is contained in the event data.
|
||||
--
|
||||
--
|
||||
-- # Tracking
|
||||
--
|
||||
--
|
||||
-- The status of the weapon can be tracked with the @{#WEAPON.StartTrack} function. This function will try to determin the position of the weapon in (normally) relatively
|
||||
-- small time steps. The time step can be set via the @{#WEAPON.SetTimeStepTrack} function and is by default set to 0.01 seconds.
|
||||
--
|
||||
--
|
||||
-- Once the position cannot be retrieved any more, the weapon has impacted (or was destroyed otherwise) and the last known position is safed as the impact point.
|
||||
-- The impact point can be accessed with the @{#WEAPON.GetImpactVec3} or @{#WEAPON.GetImpactCoordinate} functions.
|
||||
--
|
||||
--
|
||||
-- ## Impact Point Marking
|
||||
--
|
||||
--
|
||||
-- You can mark the impact point on the F10 map with @{#WEAPON.SetMarkImpact}.
|
||||
--
|
||||
--
|
||||
-- You can also trigger coloured smoke at the impact point via @{#WEAPON.SetSmokeImpact}.
|
||||
--
|
||||
--
|
||||
-- ## Callback functions
|
||||
--
|
||||
--
|
||||
-- It is possible to define functions that are called during the tracking of the weapon and upon impact, which help you to customize further actions.
|
||||
--
|
||||
--
|
||||
-- ### Callback on Impact
|
||||
--
|
||||
--
|
||||
-- The function called on impact can be set with @{#WEAPON.SetFuncImpact}
|
||||
--
|
||||
--
|
||||
-- ### Callback when Tracking
|
||||
--
|
||||
--
|
||||
-- The function called each time the weapon status is tracked can be set with @{#WEAPON.SetFuncTrack}
|
||||
--
|
||||
--
|
||||
-- # Target
|
||||
--
|
||||
-- If the weapon has a specific target, you can get it with the @{#WEAPON.GetTarget} function. Note that the object, which is returned can vary. Normally, it is a UNIT
|
||||
--
|
||||
-- If the weapon has a specific target, you can get it with the @{#WEAPON.GetTarget} function. Note that the object, which is returned can vary. Normally, it is a UNIT
|
||||
-- but it could also be a STATIC object.
|
||||
--
|
||||
--
|
||||
-- Also note that the weapon does not always have a target, it can loose a target and re-aquire it and the target might change to another unit.
|
||||
--
|
||||
--
|
||||
-- You can get the target name with the @{#WEAPON.GetTargetName} function.
|
||||
--
|
||||
--
|
||||
-- The distance to the target is returned by the @{#WEAPON.GetTargetDistance} function.
|
||||
--
|
||||
--
|
||||
-- # Category
|
||||
--
|
||||
--
|
||||
-- The category (bomb, rocket, missile, shell, torpedo) of the weapon can be retrieved with the @{#WEAPON.GetCategory} function.
|
||||
--
|
||||
-- You can check if the weapon is a
|
||||
--
|
||||
--
|
||||
-- You can check if the weapon is a
|
||||
--
|
||||
-- * bomb with @{#WEAPON.IsBomb}
|
||||
-- * rocket with @{#WEAPON.IsRocket}
|
||||
-- * missile with @{#WEAPON.IsMissile}
|
||||
-- * shell with @{#WEAPON.IsShell}
|
||||
-- * torpedo with @{#WEAPON.IsTorpedo}
|
||||
--
|
||||
--
|
||||
-- # Parameters
|
||||
--
|
||||
--
|
||||
-- You can get various parameters of the weapon, *e.g.*
|
||||
--
|
||||
--
|
||||
-- * position: @{#WEAPON.GetVec3}, @{#WEAPON.GetVec2 }, @{#WEAPON.GetCoordinate}
|
||||
-- * speed: @{#WEAPON.GetSpeed}
|
||||
-- * coalition: @{#WEAPON.GetCoalition}
|
||||
-- * country: @{#WEAPON.GetCountry}
|
||||
--
|
||||
--
|
||||
-- # Dependencies
|
||||
--
|
||||
--
|
||||
-- This class is used (at least) in the MOOSE classes:
|
||||
--
|
||||
--
|
||||
-- * RANGE (to determine the impact points of bombs and missiles)
|
||||
-- * ARTY (to destroy and replace shells with smoke or illumination)
|
||||
-- * FOX (to destroy the missile before it hits the target)
|
||||
@@ -179,60 +181,68 @@ function WEAPON:New(WeaponObject)
|
||||
|
||||
-- Inherit everything from FSM class.
|
||||
local self=BASE:Inherit(self, POSITIONABLE:New("Weapon")) -- #WEAPON
|
||||
|
||||
|
||||
-- Set DCS weapon object.
|
||||
self.weapon=WeaponObject
|
||||
|
||||
|
||||
-- Descriptors containing a lot of info.
|
||||
self.desc=WeaponObject:getDesc()
|
||||
|
||||
-- This gives the object category which is always Object.Category.WEAPON!
|
||||
--self.category=WeaponObject:getCategory()
|
||||
|
||||
|
||||
-- Weapon category: 0=SHELL, 1=MISSILE, 2=ROCKET, 3=BOMB (Weapon.Category.X)
|
||||
self.category = self.desc.category
|
||||
|
||||
if self:IsMissile() and self.desc.missileCategory then
|
||||
if self:IsMissile() and self.desc.missileCategory then
|
||||
self.categoryMissile=self.desc.missileCategory
|
||||
end
|
||||
|
||||
|
||||
-- Get type name.
|
||||
self.typeName=WeaponObject:getTypeName() or "Unknown Type"
|
||||
|
||||
|
||||
-- Get name of object. Usually a number like "1234567".
|
||||
self.name=WeaponObject:getName()
|
||||
|
||||
|
||||
-- Get coaliton of weapon.
|
||||
self.coalition=WeaponObject:getCoalition()
|
||||
|
||||
|
||||
-- Get country of weapon.
|
||||
self.country=WeaponObject:getCountry()
|
||||
|
||||
|
||||
-- Get DCS unit of the launcher.
|
||||
self.launcher=WeaponObject:getLauncher()
|
||||
|
||||
|
||||
-- Get launcher of weapon.
|
||||
self.launcherName="Unknown Launcher"
|
||||
if self.launcher then
|
||||
self.launcherName=self.launcher:getName()
|
||||
self.launcherUnit=UNIT:Find(self.launcher)
|
||||
end
|
||||
|
||||
|
||||
-- Init the coordinate of the weapon from that of the launcher.
|
||||
self.coordinate=COORDINATE:NewFromVec3(self.launcher:getPoint())
|
||||
|
||||
|
||||
-- Set log ID.
|
||||
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
|
||||
self:SetTimeStepTrack()
|
||||
self:SetDistanceInterceptPoint()
|
||||
|
||||
|
||||
-- Debug info.
|
||||
local text=string.format("Weapon v%s\nName=%s, TypeName=%s, Category=%s, Coalition=%d, Country=%d, Launcher=%s",
|
||||
local text=string.format("Weapon v%s\nName=%s, TypeName=%s, Category=%s, Coalition=%d, Country=%d, Launcher=%s",
|
||||
self.version, self.name, self.typeName, self.category, self.coalition, self.country, self.launcherName)
|
||||
self:T(self.lid..text)
|
||||
|
||||
|
||||
-- Descriptors.
|
||||
self:T2(self.desc)
|
||||
|
||||
@@ -302,13 +312,13 @@ function WEAPON:SetSmokeImpact(Switch, SmokeColor)
|
||||
else
|
||||
self.impactSmoke=true
|
||||
end
|
||||
|
||||
|
||||
self.impactSmokeColor=SmokeColor or SMOKECOLOR.Red
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set callback function when weapon is tracked and still alive. The first argument will be the WEAPON object.
|
||||
--- Set callback function when weapon is tracked and still alive. The first argument will be the WEAPON object.
|
||||
-- Note that this can be called many times per second. So be careful for performance reasons.
|
||||
-- @param #WEAPON self
|
||||
-- @param #function FuncTrack Function called during tracking.
|
||||
@@ -325,19 +335,19 @@ end
|
||||
-- @param #function FuncImpact Function called once the weapon impacted.
|
||||
-- @param ... Optional function arguments.
|
||||
-- @return #WEAPON self
|
||||
--
|
||||
--
|
||||
-- @usage
|
||||
-- -- Function called on impact.
|
||||
-- local function OnImpact(Weapon)
|
||||
-- Weapon:GetImpactCoordinate():MarkToAll("Impact Coordinate of weapon")
|
||||
-- end
|
||||
--
|
||||
--
|
||||
-- -- Set which function to call.
|
||||
-- myweapon:SetFuncImpact(OnImpact)
|
||||
--
|
||||
--
|
||||
-- -- Start tracking.
|
||||
-- myweapon:Track()
|
||||
--
|
||||
--
|
||||
function WEAPON:SetFuncImpact(FuncImpact, ...)
|
||||
self.impactFunc=FuncImpact
|
||||
self.impactArg=arg or {}
|
||||
@@ -358,37 +368,37 @@ end
|
||||
function WEAPON:GetTarget()
|
||||
|
||||
local target=nil --Wrapper.Object#OBJECT
|
||||
|
||||
|
||||
if self.weapon then
|
||||
|
||||
|
||||
-- Get the DCS target object, which can be a Unit, Weapon, Static, Scenery, Airbase.
|
||||
local object=self.weapon:getTarget()
|
||||
|
||||
|
||||
if object then
|
||||
|
||||
|
||||
-- Get object category.
|
||||
local category=Object.getCategory(object)
|
||||
|
||||
|
||||
--Target name
|
||||
local name=object:getName()
|
||||
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Got Target Object %s, category=%d", object:getName(), category))
|
||||
|
||||
self:T(self.lid..string.format("Got Target Object %s, category=%d", object:getName(), category))
|
||||
|
||||
if category==Object.Category.UNIT then
|
||||
|
||||
|
||||
target=UNIT:FindByName(name)
|
||||
|
||||
|
||||
elseif category==Object.Category.STATIC then
|
||||
|
||||
|
||||
target=STATIC:FindByName(name, false)
|
||||
|
||||
|
||||
elseif category==Object.Category.SCENERY then
|
||||
self:E(self.lid..string.format("ERROR: Scenery target not implemented yet!"))
|
||||
else
|
||||
self:E(self.lid..string.format("ERROR: Object category=%d is not implemented yet!", category))
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -403,25 +413,25 @@ function WEAPON:GetTargetDistance(ConversionFunction)
|
||||
|
||||
-- Get the target of the weapon.
|
||||
local target=self:GetTarget() --Wrapper.Unit#UNIT
|
||||
|
||||
|
||||
local distance=nil
|
||||
if target then
|
||||
|
||||
-- Current position of target.
|
||||
local tv3=target:GetVec3()
|
||||
|
||||
|
||||
-- Current position of weapon.
|
||||
local wv3=self:GetVec3()
|
||||
|
||||
|
||||
if tv3 and wv3 then
|
||||
distance=UTILS.VecDist3D(tv3, wv3)
|
||||
|
||||
|
||||
if ConversionFunction then
|
||||
distance=ConversionFunction(distance)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
return distance
|
||||
@@ -435,10 +445,10 @@ function WEAPON:GetTargetName()
|
||||
|
||||
-- Get the target of the weapon.
|
||||
local target=self:GetTarget() --Wrapper.Unit#UNIT
|
||||
|
||||
|
||||
local name="None"
|
||||
if target then
|
||||
name=target:GetName()
|
||||
name=target:GetName()
|
||||
end
|
||||
|
||||
return name
|
||||
@@ -466,13 +476,13 @@ function WEAPON:GetSpeed(ConversionFunction)
|
||||
if self.weapon then
|
||||
|
||||
local v=self:GetVelocityVec3()
|
||||
|
||||
|
||||
speed=UTILS.VecNorm(v)
|
||||
|
||||
|
||||
if ConversionFunction then
|
||||
speed=ConversionFunction(speed)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
return speed
|
||||
@@ -498,11 +508,11 @@ end
|
||||
function WEAPON:GetVec2()
|
||||
|
||||
local vec3=self:GetVec3()
|
||||
|
||||
|
||||
if vec3 then
|
||||
|
||||
|
||||
local vec2={x=vec3.x, y=vec3.z}
|
||||
|
||||
|
||||
return vec2
|
||||
end
|
||||
|
||||
@@ -511,28 +521,28 @@ end
|
||||
|
||||
--- Get type name.
|
||||
-- @param #WEAPON self
|
||||
-- @return #string The type name.
|
||||
-- @return #string The type name.
|
||||
function WEAPON:GetTypeName()
|
||||
return self.typeName
|
||||
end
|
||||
|
||||
--- Get coalition.
|
||||
-- @param #WEAPON self
|
||||
-- @return #number Coalition ID.
|
||||
-- @return #number Coalition ID.
|
||||
function WEAPON:GetCoalition()
|
||||
return self.coalition
|
||||
end
|
||||
|
||||
--- Get country.
|
||||
-- @param #WEAPON self
|
||||
-- @return #number Country ID.
|
||||
-- @return #number Country ID.
|
||||
function WEAPON:GetCountry()
|
||||
return self.country
|
||||
end
|
||||
|
||||
--- Get DCS object.
|
||||
-- @param #WEAPON self
|
||||
-- @return DCS#Weapon The weapon object.
|
||||
-- @return DCS#Weapon The weapon object.
|
||||
function WEAPON:GetDCSObject()
|
||||
-- This polymorphic function is used in Wrapper.Identifiable#IDENTIFIABLE
|
||||
return self.weapon
|
||||
@@ -552,6 +562,52 @@ function WEAPON:GetImpactCoordinate()
|
||||
return self.impactCoord
|
||||
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...
|
||||
-- @param #WEAPON self
|
||||
-- @return #boolean If `true`, weapon is in the air and `false` if not. Returns `nil` if weapon object itself is `nil`.
|
||||
@@ -619,23 +675,23 @@ end
|
||||
function WEAPON:Destroy(Delay)
|
||||
|
||||
if Delay and Delay>0 then
|
||||
self:ScheduleOnce(Delay, WEAPON.Destroy, self, 0)
|
||||
self:ScheduleOnce(Delay, WEAPON.Destroy, self, 0)
|
||||
else
|
||||
if self.weapon then
|
||||
self:T(self.lid.."Destroying Weapon NOW!")
|
||||
self:StopTrack()
|
||||
self.weapon:destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Start tracking the weapon until it impacts or is destroyed otherwise.
|
||||
-- The position of the weapon is monitored in small time steps. Once the position cannot be determined anymore, the monitoring is stopped and the last known position is
|
||||
-- the (approximate) impact point. Of course, the smaller the time step, the better the position can be determined. However, this can hit the performance as many
|
||||
-- The position of the weapon is monitored in small time steps. Once the position cannot be determined anymore, the monitoring is stopped and the last known position is
|
||||
-- the (approximate) impact point. Of course, the smaller the time step, the better the position can be determined. However, this can hit the performance as many
|
||||
-- calculations per second need to be carried out.
|
||||
-- @param #WEAPON self
|
||||
-- @param #WEAPON self
|
||||
-- @param #number Delay Delay in seconds before the tracking starts. Default 0.001 sec.
|
||||
-- @return #WEAPON self
|
||||
function WEAPON:StartTrack(Delay)
|
||||
@@ -644,8 +700,8 @@ function WEAPON:StartTrack(Delay)
|
||||
Delay=math.max(Delay or 0.001, 0.001)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Start tracking weapon in %.4f sec", Delay))
|
||||
|
||||
self:T(self.lid..string.format("Start tracking weapon in %.4f sec", Delay))
|
||||
|
||||
-- Weapon is not yet "alife" just yet. Start timer in 0.001 seconds.
|
||||
self.trackScheduleID=timer.scheduleFunction(WEAPON._TrackWeapon, self, timer.getTime() + Delay)
|
||||
|
||||
@@ -654,7 +710,7 @@ end
|
||||
|
||||
|
||||
--- Stop tracking the weapon by removing the scheduler function.
|
||||
-- @param #WEAPON self
|
||||
-- @param #WEAPON self
|
||||
-- @param #number Delay (Optional) Delay in seconds before the tracking is stopped.
|
||||
-- @return #WEAPON self
|
||||
function WEAPON:StopTrack(Delay)
|
||||
@@ -663,13 +719,13 @@ function WEAPON:StopTrack(Delay)
|
||||
-- Delayed call.
|
||||
self:ScheduleOnce(Delay, WEAPON.StopTrack, self, 0)
|
||||
else
|
||||
|
||||
|
||||
if self.trackScheduleID then
|
||||
|
||||
timer.removeFunction(self.trackScheduleID)
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
@@ -706,102 +762,108 @@ function WEAPON:_TrackWeapon(time)
|
||||
|
||||
-- Update last known position.
|
||||
self.pos3 = pos3
|
||||
|
||||
|
||||
-- Update last known vec3.
|
||||
self.vec3 = UTILS.DeepCopy(self.pos3.p)
|
||||
|
||||
|
||||
-- Update coordinate.
|
||||
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.
|
||||
self.tracking=true
|
||||
|
||||
|
||||
-- Callback function.
|
||||
if self.trackFunc then
|
||||
self.trackFunc(self, unpack(self.trackArg))
|
||||
end
|
||||
|
||||
|
||||
-- Verbose output.
|
||||
if self.verbose>=5 then
|
||||
|
||||
|
||||
-- Get vec2 of current position.
|
||||
local vec2={x=self.vec3.x, y=self.vec3.z}
|
||||
|
||||
|
||||
-- Land hight.
|
||||
local height=land.getHeight(vec2)
|
||||
|
||||
-- Current height above ground level.
|
||||
-- Current height above ground level.
|
||||
local agl=self.vec3.y-height
|
||||
|
||||
|
||||
-- Estimated IP (if any)
|
||||
local ip=self:_GetIP(self.distIP)
|
||||
|
||||
|
||||
-- Distance between positon and estimated impact.
|
||||
local d=0
|
||||
if ip then
|
||||
d=UTILS.VecDist3D(self.vec3, ip)
|
||||
end
|
||||
|
||||
|
||||
-- Output.
|
||||
self:I(self.lid..string.format("T=%.3f: Height=%.3f m AGL=%.3f m, dIP=%.3f", time, height, agl, d))
|
||||
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
|
||||
---------------------------
|
||||
-- Weapon does NOT exist --
|
||||
---------------------------
|
||||
|
||||
---------------------------
|
||||
|
||||
-- Get intercept point from position (p) and direction (x) in 50 meters.
|
||||
local ip = self:_GetIP(self.distIP)
|
||||
|
||||
|
||||
if self.verbose>=10 and ip then
|
||||
|
||||
|
||||
-- Output.
|
||||
self:I(self.lid.."Got intercept point!")
|
||||
|
||||
|
||||
-- Coordinate of the impact point.
|
||||
local coord=COORDINATE:NewFromVec3(ip)
|
||||
|
||||
|
||||
-- Mark coordinate.
|
||||
coord:MarkToAll("Intercept point")
|
||||
coord:SmokeBlue()
|
||||
|
||||
|
||||
-- Distance to last known pos.
|
||||
local d=UTILS.VecDist3D(ip, self.vec3)
|
||||
|
||||
|
||||
-- Output.
|
||||
self:I(self.lid..string.format("FF d(ip, vec3)=%.3f meters", d))
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Safe impact vec3.
|
||||
self.impactVec3=ip or self.vec3
|
||||
|
||||
|
||||
-- Safe impact coordinate.
|
||||
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.
|
||||
if self.impactMark then
|
||||
self.impactCoord:MarkToAll(string.format("Impact point of weapon %s\ntype=%s\nlauncher=%s", self.name, self.typeName, self.launcherName))
|
||||
end
|
||||
|
||||
|
||||
-- Smoke on impact point.
|
||||
if self.impactSmoke then
|
||||
self.impactCoord:Smoke(self.impactSmokeColor)
|
||||
end
|
||||
|
||||
|
||||
-- Call callback function.
|
||||
if self.impactFunc then
|
||||
self.impactFunc(self, unpack(self.impactArg or {}))
|
||||
end
|
||||
|
||||
|
||||
-- Stop tracking by returning nil below.
|
||||
self.tracking=false
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Return next time the function is called or nil to stop the scheduler.
|
||||
if self.tracking then
|
||||
if self.dtTrack and self.dtTrack>=0.00001 then
|
||||
@@ -823,12 +885,12 @@ function WEAPON:_GetIP(Distance)
|
||||
Distance=Distance or 50
|
||||
|
||||
local ip=nil --DCS#Vec3
|
||||
|
||||
|
||||
if Distance>0 and self.pos3 then
|
||||
|
||||
-- Get intercept point from position (p) and direction (x) in 20 meters.
|
||||
ip = land.getIP(self.pos3.p, self.pos3.x, Distance or 20) --DCS#Vec3
|
||||
|
||||
|
||||
end
|
||||
|
||||
return ip
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user