-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapMarkerCommands.lua
More file actions
2089 lines (2038 loc) · 92.2 KB
/
Copy pathMapMarkerCommands.lua
File metadata and controls
2089 lines (2038 loc) · 92.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
EXTERNAL_LUA = (lfs.Writedir().."\\Missions\\OzDM-MMC\\")
assert(loadfile(EXTERNAL_LUA .. "MISSION_TASK_TEMPLATES.lua"))()
JSON = assert(loadfile(EXTERNAL_LUA .. "json.lua"))()
--[[
Name : MapMarkerCommands.lua
Author : OzDeaDMeaT
Date : 27/09/2023
Version : 0.2p]]
ScriptVer = '0.2p'
--[[
This script is designed as a quick way to add the ability to order tankers, AWACS and Drones around the airspace quickly and easily with little to no LUA experience.
Current Functionality:
- Customizable Command Prefix (Do not use a `-` or a `:` )
- CoOrd Command (!coord) : Prints the MGRS and Lat Long for a point on the map. All coord commands will display altitude in both meters and ft.
-- Example> !coord:all : (Returns all CoOrd types)
-- Example> !coord:grid : (Returns MGRS Grid)
-- Example> !coord:mgrs : (Returns MGRS)
-- Example> !coord:LL : (Returns both types of LL)
-- Example> !coord:DM : (Returns LLDM)
-- Example> !coord:DMS : (Returns LLDMS)
- Smoke Command (!smoke) : Drops smoke at the marker location
-- Example> !smoke:red
-- Example> !smoke:white
-- Example> !smoke:blue
-- Example> !smoke:orange
-- Example> !smoke:green
- Flare Command (!flare) : Drops a flare at the marker location
-- Example> !flare:red
-- Example> !flare:white
-- Example> !flare:green
-- Example> !flare:orange
- Illum Command (!illum) : Drops a illum flare at the marker location
-- Example> !illum:5000
- Clean Command (!clean) : Removes wrecks (units) and craters from an area around the marker location (Argument value is the radius in meters)
-- Example> !clean:1000 : Cleans a location with an area of 1000m radius
- ISR Command (!isr) : Draws an orbit box and orders the Drone to orbit at a marker location
-- Example> !isr:Pontiac11 [press "ENTER" after the aircraft name to go to next line]
-a20000 -s250 -rt 180-5 [This example will select Pontiac11 and order them to move to the new location and change altitude to 20000ft and 250knts with a race track orbit to the south with a leg length of 5km]
-- Example> !isr:Chevy11 [press "ENTER" after the aircraft name to go to next line]
-a15000 -s130 [This example will select Chevy11 and order them to move to the new location and change altitude to 15000ft and 130knts with a circular orbit]
-- Example> !isr:Uzi11 [This example will select Uzi11 and order them to move to the new location and use a circular orbit, altitude and speed settings
-- Example> !isr:Colt11 [press "ENTER" after the aircraft name to go to next line]
-a15000 -s130 -dm [This example will select Colt11 and order them to change altitude and speed settings without moving to a new location
- TANKER Command (!tanker) : Same options as isr
- AWACS Command (!awacs) : Same options as isr
- Mark Command (!mark) : Marks an object on the F10 map. (Scenery Objects, not trees or bushes etc. Only buildings, lights etc)
-- Example> !mark
- Explode Command (!smite) : Causes an explosion at the marker location
-- Example> !smite:250
]]
Terrain = require('terrain') --REQUIRED FOR function:MarkTerrainObject
-------------------SCRIPT SETTINGS HERE
OzDM = {
COMMAND_PREFIX = '!' , -- Command Prefix, all commands must have this symbol at the start to be registered as command requests
MarkID = 666666 , -- For Terrain Marking
DEBUG = true , -- SET to false to reduce logging
SHOW_ORBIT = true , -- Will mark approximate orbit with a map marker
SHOW_ORBIT_NAME = true , -- Will not display if SHOW_ORBIT is not enabled. Will mark orbit marker with the callsign of the commanded unit
ENABLE_COORD = true , -- Enables the COORD command
ENABLE_SMOKE = true , -- Enables the smoke command
ENABLE_FLARE = true , -- Enables the flare command
ENABLE_ILLUM = true , -- Enables the illum command
ENABLE_CLEAN = true , -- Enables the clean command
ENABLE_ISR = true , -- Enables the ISR command
ENABLE_AWACS = true , -- Enables the AWACS command
ENABLE_TANKER = true , -- Enables the TANKER command
ENABLE_MARK = true , -- Enables the MARK command
ENABLE_EXPLOSION= true , -- Enables the explosion command
ILLUM_LIMIT = 1000000 , -- Maximum brightness level of an illumination flare
EXPLOSION_LIMIT = 9000 , -- Maximum value for explosions command, and value higher will default to this number
CLEAN_LIMIT = 5000 , -- Maximum value for clean command, and value higher will default to this number
DEFAULT_SMOKE = "white" , -- Default colour of smoke if no colour is requested
DEFAULT_FLARE = "white" , -- Default colour of flare if no colour is requested
DEFAULT_ISR = false , -- Default UAV if no ISR asset is given (SET TO FALSE if you don't want an ISR Default) NOTE: Any incorrect spelling of unit will mean this Default unit will be retasked. Recommend using this setting only when you have a single UAV unit in mission
EH = {} -- Table place holder for all Event Handlers
}
-------------------AIR SUPPORT TABLE
Air_Support_Table = {}
ISR_SETTINGS = { --All entries are knots and ft
minspeed = 75,
maxspeed = 240,
minalt = 5000,
maxalt = 14000
}
TNK_SETTINGS = { --All entries are knots and ft
minspeed = 210,
maxspeed = 400,
minalt = 15000,
maxalt = 24000
}
AWC_SETTINGS = { --All entries are knots and ft
minspeed = 210,
maxspeed = 400,
minalt = 25000,
maxalt = 30000
}
-------------------
Uzi11 = {
id = 200000,
NameID = 210000,
FontSize = 25,
LaserCode = 1666,
FreqMode = 0, --AM == 0, FM == 1
Freq = 333.5,
TACAN = {
CALLSIGN = "",
MODECHANNEL = nil,
CHANNEL = nil,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 3048, -- 3048m (Approx:10,000ft)
speed = 75, -- 75mps (Approx:145kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2 (ALWAYS CURRENT AIRCRAFT LOCATION)
x = 0,
y = 0
},
WP02 = { --vec2 (ORBIT START)
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Chevy11 = {
id = 220000,
NameID = 230000,
FontSize = 25,
LaserCode = 1555,
FreqMode = 0, --AM == 0, FM == 1
Freq = 369,
TACAN = {
CALLSIGN = "",
MODECHANNEL = nil,
CHANNEL = nil,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 3048, -- 3048m (Approx:10,000ft)
speed = 75, -- 75mps (Approx:145kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Pontiac11 = {
id = 240000,
NameID = 250000,
FontSize = 25,
LaserCode = 1788,
FreqMode = 0, --AM == 0, FM == 1
Freq = 333.5,
TACAN = {
CALLSIGN = "",
MODECHANNEL = nil,
CHANNEL = nil,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 3048, -- 3048m (Approx:10,000ft)
speed = 75, -- 75mps (Approx:145kt)
speed_transit = 130, -- 130mps (Approx:245kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Colt11 = {
id = 260000,
NameID = 270000,
FontSize = 25,
LaserCode = 1588,
FreqMode = 0, --AM == 0, FM == 1
Freq = 305.5,
TACAN = {
CALLSIGN = "",
MODECHANNEL = nil,
CHANNEL = nil,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 3048, -- 3048m (Approx:10,000ft)
speed = 75, -- 75mps (Approx:145kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Colt21 = {
id = 280000,
NameID = 290000,
FontSize = 25,
LaserCode = 1438,
FreqMode = 0, --AM == 0, FM == 1
Freq = 303.65,
TACAN = {
CALLSIGN = "",
MODECHANNEL = nil,
CHANNEL = nil,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 3048, -- 3048m (Approx:10,000ft)
speed = 75, -- 75mps (Approx:145kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Texaco11 = {
id = 300000,
NameID = 310000,
FontSize = 25,
LaserCode = nil,
FreqMode = 0, --AM == 0, FM == 1
Freq = 325,
TACAN = {
CALLSIGN = "TEX",
MODECHANNEL = "X",
CHANNEL = 65,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 6705.6, -- 3048m (Approx:20,000ft)
speed = 165, -- 165mps (Approx:320kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Texaco21 = {
id = 320000,
NameID = 330000,
FontSize = 25,
LaserCode = nil,
FreqMode = 0, --AM == 0, FM == 1
Freq = 326,
TACAN = {
CALLSIGN = "TEX",
MODECHANNEL = "X",
CHANNEL = 66,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 6705.6, -- 3048m (Approx:20,000ft)
speed = 165, -- 165mps (Approx:320kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Arco11 = {
id = 340000,
NameID = 350000,
FontSize = 25,
LaserCode = nil,
FreqMode = 0, --AM == 0, FM == 1
Freq = 327,
TACAN = {
CALLSIGN = "ARC",
MODECHANNEL = "X",
CHANNEL = 75,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 5486.4, -- 3048m (Approx:20,000ft)
speed = 165, -- 165mps (Approx:320kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Shell11 = {
id = 350000,
NameID = 360000,
FontSize = 25,
LaserCode = nil,
FreqMode = 0, --AM == 0, FM == 1
Freq = 328,
TACAN = {
CALLSIGN = "SHL",
MODECHANNEL = "X",
CHANNEL = 70,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 6096, -- 6096m (Approx:20,000ft)
speed = 165, -- 165mps (Approx:320kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
Darkstar11 = {
id = 370000,
NameID = 380000,
FontSize = 25,
LaserCode = nil,
FreqMode = 0, --AM == 0, FM == 1
Freq = 345.5,
TACAN = {
CALLSIGN = "DKS",
MODECHANNEL = "X",
CHANNEL = 72,
AA = false,
},
FUEL = 525, --2,440 MQ-9 : 525L MQ-1
Invisible = true,
Immortal = true,
Ready4Tasking = false,
LineColourArray = {0.1, 0.1, 0.1, 1}, -- Line {r, g, b, a}
FillColourArray = {0.1, 0.1, 0.1, 0.15}, -- Fill {r, g, b, a}
LineType = 5, -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
LastOrder = {
alt = 8382, -- 3048m (Approx:20,000ft)
speed = 165, -- 165mps (Approx:320kt)
RT = false,
RT_Bearing = 0,
RT_Distance = 0,
WP01 = { --vec2
x = 0,
y = 0
},
WP02 = { --vec2
x = 0,
y = 0
},
WP03 = { --vec2 (RT ORBIT WP)
x = 0,
y = 0
}
}
}
-------------------
Air_Support_Table.Uzi11 = Uzi11
Air_Support_Table.Chevy11 = Chevy11
Air_Support_Table.Pontiac11 = Pontiac11
Air_Support_Table.Colt11 = Colt11
Air_Support_Table.Colt21 = Colt21
Air_Support_Table.Texaco11 = Texaco11
Air_Support_Table.Texaco21 = Texaco21
Air_Support_Table.Arco11 = Arco11
Air_Support_Table.Shell11 = Shell11
Air_Support_Table.Darkstar11 = Darkstar11
--Functions-------------------------------------------------------------------------------------------------------------------------
--Feet to Meters Converter
function Ft2m(value) -- Feet to Meters
return value / 3.2808
end
-------------------
--Meters to Feet Converter
function M2ft(value) -- Feet to Meters
return value / 0.3048000097536
end
-------------------
--Nautical Miles to Meters Converter
function Nm2m(value) -- Nautical Miles to Meters
return value * 1852
end
-------------------
--Meters to Nautical Miles Converter
function M2nm(value) -- Nautical Miles to Meters
return value * 0.00053995682073434123939
end
-------------------
--Knots to Meters Per Second Converter
function Kt2mps(value) -- Knots to Meters / Second
return value * 0.514444
end
-------------------
--Meters Per Second to Knots Converter
function Mps2kt(value)
return value * 1.94384
end
-------------------
function StringSplit(str, sep)
local result = {}
local regex = ("([^%s]+)"):format(sep)
for each in string.gmatch(str,regex) do
table.insert(result, each)
end
return result
end
-------------------
function IsInteger(n)
return n==math.floor(n)
end
-------------------
function StringPad(str, len, char)
if char == nil then char = ' ' end
return str .. string.rep(char, len - #str)
end
-------------------
function math.round(num, numDecimalPlaces)--[[
Borrowed from http://lua-users.org/wiki/SimpleRound]]
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
-------------------
function TACANToFrequency(TACANChannel, TACANMode)
if type(TACANChannel) ~= "number" then
return nil -- error in arguments
end
if TACANMode ~= "X" and TACANMode ~= "Y" then
return nil -- error in arguments
end
-- This code is largely based on ED's code, in DCS World\Scripts\World\Radio\BeaconTypes.lua, line 137.
-- I have no idea what it does but it seems to work
local A = 1151 -- 'X', channel >= 64
local B = 64 -- channel >= 64
if TACANChannel < 64 then
B = 1
end
if TACANMode == 'Y' then
A = 1025
if TACANChannel < 64 then
A = 1088
end
else -- 'X'
if TACANChannel < 64 then
A = 962
end
end
return (A + TACANChannel - B) * 1000000
end
-------------------
function IsUnit(UnitName)--[[
This function returns true or false if a unit exists or not
Author : OzDeaDMeaT
Creation Date: 5-AUG-2023
Usage : IsUnit(string)
Return : bool]]
local RTN = false
if(type(UnitName) == 'string') then
local UnitVAR = Unit.getByName(UnitName)
if(type(UnitVAR) == 'table') then
if(UnitVAR:isActive()) then
RTN = true
else
if(OzDM.DEBUG == true) then env.info("!!!ERROR!!! IsUnit : UnitName is NOT active in the simulation") end
end
else
if(OzDM.DEBUG == true) then env.info("!!!ERROR!!! IsUnit : UnitName is NOT a table value, it is a " .. type(UnitVAR) .. " variable") end
end
else
if(OzDM.DEBUG == true) then env.info("!!!ERROR!!! IsUnit : UnitName was passed to function and was NOT a string value") end
end
return RTN
end
-------------------
function IsGroup(AircraftGroupName)--[[
This function returns true or false if a group exists or not
Author : OzDeaDMeaT
Creation Date: 5-AUG-2023
Usage : IsGroup(string)
Return : bool]]
local RTN = false
if(type(AircraftGroupName) == 'string') then
local GroupVar = Group.getByName(AircraftGroupName)
if(type(GroupVar) == 'table') then
RTN = true
end
else
if(OzDM.DEBUG == true) then env.info("!!!ERROR!!! IsGroup : AircraftGroupName was passed to function and was not a string value") end
end
return RTN
end
-------------------
function GetCallsignID(UnitName)--[[
This function returns the Callsign ID numberfor the specific aircraft callsign
Author : OzDeaDMeaT
Creation Date: 6-AUG-2023
Usage : GetCallsignID(string)
Example : GetCallsignID("Uzi11")
Return : number]]
local Proceed = false
if(IsUnit(UnitName) == true) then
Proceed = true
end
if (Proceed == true) then
local CallsignString = Unit.getByName(UnitName):getCallsign()
local CALLSIGN = {
Enfield = 1,
Springfield = 2,
Uzi = 3,
Colt = 4,
Dodge = 5,
Ford = 6,
Chevy = 7,
Pontiac = 8,
Hawg = 9,
Boar = 10,
Pig = 11,
Tusk = 12,
Overlord = 1,
Magic = 2,
Wizard = 3,
Focus = 4,
Darkstar = 5,
Texaco = 1,
Arco = 2,
Shell = 3,
Axeman = 1,
Darknight = 2,
Warrior = 3,
Pointer = 4,
Eyeball = 5,
Moonbeam = 6,
Whiplash = 7,
Finger = 8,
Pinpoint = 9,
Ferret = 10,
Shaba = 11,
Playboy = 12,
Hammer = 13,
Jaguar = 14,
Deathstar = 15,
Anvil = 16,
Firefly = 17,
Mantis = 18,
Badger = 19,
London = 1,
Dallas = 2,
Paris = 3,
Moscow = 4,
Berlin = 5,
Rome = 6,
Madrid = 7,
Warsaw = 8,
Dublin = 9,
Perth = 10,
Viper = 9,
Venom = 10,
Lobo = 11,
Cowboy = 12,
Python = 13,
Rattler = 14,
Panther = 15,
Wolf = 16,
Weasel = 17,
Wild = 18,
Ninja = 19,
Jedi = 20,
Hornet = 9,
Squid = 10,
Ragin = 11,
Roman = 12,
Sting = 13,
Jury = 14,
Jokey = 15,
Ram = 16,
Hawk = 17,
Devil = 18,
Check = 19,
Snake = 20,
Dude = 9,
Thud = 10,
Gunny = 11,
Trek = 12,
Sniper = 13,
Sled = 14,
Best = 15,
Jazz = 16,
Rage = 17,
Tahoe = 18,
Bone = 9,
Dark = 10,
Vader = 11,
Buff = 9,
Dump = 10,
Kenworth = 11,
Heavy = 9,
Trash = 10,
Cargo = 11,
Ascot = 12,
}
local regex = string.match(CallsignString,'%a+')
CallsignCheck = CALLSIGN[regex]
if(type(CallsignCheck) == 'number') then
return CallsignCheck
end
end
end
-------------------
function File_exists(path)
-- Return true if file exists and is readable.
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
-------------------
function Readall(filename)
-- Read an entire file.
-- Use "a" in Lua 5.3; "*a" in Lua 5.1 and 5.2
local fh = assert(io.open(filename, "rb"))
local contents = assert(fh:read(_VERSION <= "Lua 5.2" and "*a" or "a"))
fh:close()
return contents
end
-------------------
function Write(filename, contents)
-- Write a string to a file.
local fh = assert(io.open(filename, "wb"))
fh:write(contents)
fh:flush()
fh:close()
end
-------------------
if(File_exists(EXTERNAL_LUA .. "MAP_OBJECT_TABLE.json")) then
MOT = JSON:decode(Readall(EXTERNAL_LUA .. "MAP_OBJECT_TABLE.json"))
else
MOT = {}
end
-------------------
function CheckLaserCode(LaserCode)--[[
This function checks if a LaserCode that is supplied as a number is a valid laser code.
Author : OzDeaDMeaT
Creation Date: 6-AUG-2023
Usage : CheckLaserCode(number)
Example : CheckLaserCode(1788)
Return : true or false]]
local RTN = false
local minLaserCode = 1111
local maxLaserCode = 2688
local StringCheck = nil
local LaserCodeSTR = tostring(LaserCode)
if(type(LaserCode) == 'number') then
if(LaserCode >= minLaserCode and LaserCode <=2688) then
StringCheck = string.match(LaserCodeSTR,'[1-2][1-8][1-8][1-8]')
if(type(StringCheck) ~= 'nil') then
RTN = true
if(OzDM.DEBUG == true) then env.info("CheckLaserCode : " .. StringCheck .. " is a valid Laser Code") end
else
if(OzDM.DEBUG == true) then env.info("CheckLaserCode : " .. LaserCodeSTR .. " is NOT valid Laser Code") end
end
else
if(OzDM.DEBUG == true) then env.info("CheckLaserCode : " .. LaserCodeSTR .. " is NOT valid Laser Code") end
end
else
if(OzDM.DEBUG == true) then env.info("CheckLaserCode : The lasercode was not supplied as a number") end
end
return RTN
end
-------------------
function SetUnitTACAN(UnitName , callsign , modeChannel , channel , AA )--[[
This function sets a units returns true or false if a group exists or not
Author : OzDeaDMeaT
Creation Date: 29-JUL-2023
Usage : SetUnitBEACON(string, number, number)
Example : SetUnitBEACON("Arco11","ARC", "Y", 64 , false) Use False for AA as it seems buggy
Return : nothing]]
--lifted from MOOSE and ED
local RunCommand = false --If All checks are correct, proceed to run the command
local sys
local BEACON = {}
BEACON.System={
TACAN = 3,
TACAN_TANKER_X = 4,
TACAN_TANKER_Y = 5,
TACAN_AA_MODE_X = 13,
TACAN_AA_MODE_Y = 14
}
BEACON.Type={
TACAN = 4
}
if(IsUnit(UnitName) == true) then
if(OzDM.DEBUG == true) then env.info("SetUnitTACAN : " .. UnitName .. " exists!") end
if(type(callsign) == 'string' and type(modeChannel) == 'string' and type(channel) == 'number' and type(AA) == 'boolean') then
RunCommand = true
else
if(OzDM.DEBUG == true and type(callsign) ~= 'string') then env.info("SetUnitTACAN : callsign variable not a string, currently variable is a " .. type(callsign)) end
if(OzDM.DEBUG == true and type(modeChannel) ~= 'string') then env.info("SetUnitTACAN : modeChannel variable not a string, currently variable is a " .. type(modeChannel)) end
if(OzDM.DEBUG == true and type(channel) ~= 'number') then env.info("SetUnitTACAN : freq variable not a number, currently variable is a " .. type(channel)) end
if(OzDM.DEBUG == true and type(AA) ~= 'boolean') then env.info("SetUnitTACAN : AA variable not a bool, currently variable is a " .. type(AA)) end
end
else
if(OzDM.DEBUG == true) then env.info("!!!ERROR!!! SetUnitTACAN : UnitName was passed to function and was not a valid value") end
end
if(RunCommand == true) then
if(OzDM.DEBUG == true) then env.info("SetUnitTACAN : All Argument Variables checked and OK, proceeding to run command") end
if AA then
sys = 5 --NOTE: 5 is how you cat the correct tanker behaviour! --BEACON.System.TACAN_TANKER
-- Check if "Y" mode is selected for aircraft.
if modeChannel:lower()=="x" then
--self:E({"WARNING: The POSITIONABLE you want to attach the AA Tacan Beacon is an aircraft: Mode should Y!", self.Positionable})
sys = BEACON.System.TACAN_AA_MODE_X
else
sys = BEACON.System.TACAN_AA_MODE_Y
end
else
if modeChannel:lower()=="x" then
--self:E({"WARNING: The POSITIONABLE you want to attach the AA Tacan Beacon is an aircraft: Mode should Y!", self.Positionable})
sys = BEACON.System.TACAN_TANKER_X
else
sys = BEACON.System.TACAN_TANKER_Y
end
end
local UnitVAR = Unit.getByName(UnitName)
local Cntrl = UnitVAR:getController()
local BEACONON = ACTIVATE_TACAN(BEACON.Type.TACAN, AA, callsign, modeChannel, channel, sys, UnitVAR:getID(), TACANToFrequency(channel, modeChannel))
Cntrl:setCommand(BEACONON)
end
end
-------------------
function SetUnitRadioFrequency(UnitName, Frequency, Modulation)--[[
This function sets a units returns true or false if a group exists or not
Author : OzDeaDMeaT
Creation Date: 29-JUL-2023
Usage : SetUnitRadioFrequency(string, number, number)
Example : SetUnitRadioFrequency("Uzi11", 305, 0) Modulation = 0 for AM, 1 for FM
SetUnitRadioFrequency("Arco11", 315, 0)
Return : nothing]]
local RunCommand = false --If All checks are correct, proceed to run the command
--local Mod = Modulation
if(IsUnit(UnitName) == true) then
if(type(Frequency) == 'number') then
RunCommand = true
if(type(Modulation) == 'number') then
if(Modulation < 0 or Modulation > 1) then --DEFAULTING TO AM if incorrect number set (Modulation = 0 for AM, 1 for FM)
Modulation = 0
end
else
Modulation = 0 --use AM as Default
if(OzDM.DEBUG == true) then env.info("SetUnitRadioFrequency : Modulation Default 'AM' being used as no value was passed") end
end
else
if(OzDM.DEBUG == true) then env.info("!!!ERROR!!! SetUnitRadioFrequency : Frequency was passed to function and was not a number value") end
end
else
if(OzDM.DEBUG == true) then env.info("!!!ERROR!!! SetUnitRadioFrequency : UnitName was passed to function and was not a valid value") end
end
if(RunCommand == true) then
if(OzDM.DEBUG == true) then env.info("SetUnitRadioFrequency : All Argument Variables checked and OK, proceeding to run command") end
local UnitVAR = Unit.getByName(UnitName)
local SF = PrepUnitFrequencyChange(UnitVAR:getID(), Frequency, Modulation)
local Cntrl = UnitVAR:getController()
Cntrl:setCommand(SF)
--local FrequencyHz = Frequency * 1000000
--SF.params.unitId = UnitVAR:getID()
--SF.params.frequency = FrequencyHz
--SF.params.modulation = Modulation
end
end
---------------
function MapObjectTable(MapObject) --!mot
-- Author : OzDeaDMeaT
-- Creation Date: 20-SEP-2023
-- Usage : MapObjectTable(EventData) --Designed to be used with Map Marker Remove EventHandler
-- Returns : Will drop building information from map object to a file
local MOT_NewEntry = #MOT + 1
MOT[MOT_NewEntry] = MapObject
local converted = JSON:encode_pretty(MOT)
Write(EXTERNAL_LUA .. "MAP_OBJECT_TABLE.json", converted)
end
---------------
function MarkTerrainObject(EventData,MOT) --MOT is bool on whether map item is recorded to MAP_OBJECT_TABLE.json
--Author : OzDeaDMeaT
--Creation Date: 2-AUG-2023
--Usage : MarkTerrainObject(vec3)
--Returns : nothing
--Marks objects on the F10 map in the Mission Scripting Environment
local vec3 = EventData.pos
env.info("Marking position: {x = " .. vec3.x .. " , y = " .. vec3.y .. " , z = " .. vec3.z)
local objects = Terrain.getObjectsAtMapPoint(vec3.x, vec3.z)
if(type(objects) ~= "nil") then
local a_object = objects[1]
local radius = a_object.radius
local sinRot = math.sin(-a_object.rotation)
local cosRot = math.cos(-a_object.rotation)
local dx = a_object.sizeOBB[1] / 2
local dy = a_object.sizeOBB[2] / 2
local PolyPoints = {
[1] = {x = -dx*cosRot-(-dy*sinRot), y= 0, z = -dx*sinRot+(-dy*cosRot)},
[2] = {x = dx*cosRot-(-dy*sinRot), y= 0, z = dx*sinRot+(-dy*cosRot)},
[3] = {x = dx*cosRot-(dy*sinRot), y= 0, z = dx*sinRot+(dy*cosRot)},
[4] = {x = -dx*cosRot-(dy*sinRot), y= 0, z = -dx*sinRot+(dy*cosRot)}
}
local GlobalPoints = {
[1] = {x = (a_object.center[1] + PolyPoints[1].x), y = 0, z = (a_object.center[2] + PolyPoints[1].z)},
[2] = {x = (a_object.center[1] + PolyPoints[2].x), y = 0, z = (a_object.center[2] + PolyPoints[2].z)},
[3] = {x = (a_object.center[1] + PolyPoints[3].x), y = 0, z = (a_object.center[2] + PolyPoints[3].z)},
[4] = {x = (a_object.center[1] + PolyPoints[4].x), y = 0, z = (a_object.center[2] + PolyPoints[4].z)}
}
local LineColourArray = {0, 0, 0, 1} -- Line {r, g, b, a}
local FillColourArray = {0.75, 0.1, 0.1, 0.25} -- Fill {r, g, b, a}
local LineType = 1 -- 0 No Line 1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
OzDM.MarkID = OzDM.MarkID + 1
trigger.action.markupToAll(7, -1 , OzDM.MarkID , GlobalPoints[1] , GlobalPoints[2] , GlobalPoints[3] , GlobalPoints[4] , LineColourArray , FillColourArray , LineType , true, tostring(a_object.model))
if(MOT) then
a_object.GlobalPoints = GlobalPoints
MapObjectTable(a_object)
end
else
trigger.action.outText(
"No object found under marker!",
3,
false)
end
end
-------------------
function GetFreeMarkerID(StartHere)--[[
Author : OzDeaDMeaT
Creation Date: 2-AUG-2023
Usage : GetFreeMarkerID()
Returns : number [Will return a that has not been allocated in the MarkerPanels table]]
if(type(StartHere) == nil) then StartHere = 2000000 end
local MarkerCheck = -1
StartHere = StartHere + 1
local AllMarkers = world.getMarkPanels()
if(#AllMarkers == 0) then MarkerCheck = StartHere end
for k,v in ipairs(AllMarkers) do