forked from Tobias00723/DCS-Scripting-Library-Updated
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger.lua
More file actions
460 lines (390 loc) · 24.4 KB
/
trigger.lua
File metadata and controls
460 lines (390 loc) · 24.4 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
--[[
updated by Tobias00723
orignial author : unkown ;/
from the TGFB server
Discord : https://discord.gg/hEHd4A3czx
any questions? ^^
find me on the my discord server ^^
feel free to use these DCS prototypes
no mentions or anything needed :)
]]
---@meta
---@class vec3
---@field x number
---@field y number
---@field z number
---@class position3
---@field p vec3
---@field x vec3
---@field y vec3
---@field z vec3
---@class TriggerZone
---@field point vec3
---@field radius number
---The trigger singleton contains a number of functions that mimic actions and conditions found within the mission editor triggers. As a result these functions provide an easy way to interface with triggers setup within the mission editor. Additionally a few trigger functions act as a gateway between mission editor triggers and related scripting functions.
---https://wiki.hoggitworld.com/view/DCS_singleton_trigger
trigger = {}
---The trigger singleton contains a number of functions that mimic actions and conditions found within the mission editor triggers. As a result these functions provide an easy way to interface with triggers setup within the mission editor. Additionally a few trigger functions act as a gateway between mission editor triggers and related scripting functions.
---https://wiki.hoggitworld.com/view/DCS_singleton_trigger
trigger.action = {}
do
---Creates an explosion at a given point at the specified power.
---https://wiki.hoggitworld.com/view/DCS_func_explosion
---@param vec3 vec3
---@param power number
function trigger.action.explosion(vec3, power) end
---Creates colored smoke marker at a given point. Smoke uses trigger.smokeColor enum
---https://wiki.hoggitworld.com/view/DCS_func_smoke
---@param vec3 vec3
---@param smokeColor smokeColor trigger.smokeColor
function trigger.action.smoke(vec3, smokeColor) end
---Creates a large smoke effect on a vec3 point of a specified type and density.
---1 = small smoke and fire
---2 = medium smoke and fire
---3 = large smoke and fire
---4 = huge smoke and fire
---5 = small smoke
---6 = medium smoke
---7 = large smoke
---8 = huge smoke
---Density is any value from 0 to 1. For example 0.5. Name is a unique name given to the smoke mark to be used with removing it.
---https://wiki.hoggitworld.com/view/DCS_func_effectSmokeBig
---@param vec3 vec3
---@param smokePreset number
---@param density number
---@param name string|nil
function trigger.action.effectSmokeBig(vec3, smokePreset, density, name) end
---Stops a big smoke effect of the passed name. Used in conjunction with trigger.action.effectSmokeBig
---https://wiki.hoggitworld.com/view/DCS_func_effectSmokeStop
---@param name string
function trigger.action.effectSmokeStop(name) end
---Creates an illumination bomb at the specified point. y variable defines the altitude at which the bomb will appear at. The illumination bomb will burn for 300 seconds (5 minutes). Additionally the bomb will fall toward the ground, so a minimum altitude is required to get the full illumination time. The power is a value between 1 and 1000000.
---https://wiki.hoggitworld.com/view/DCS_func_illuminationBomb
---@param vec3 vec3
---@param power number
function trigger.action.illuminationBomb(vec3, power) end
---Creates a signal flare at the given point in the specified color. The flare will be launched in the direction of the azimuth variable.
---https://wiki.hoggitworld.com/view/DCS_func_signalFlare
---@param vec3 vec3
---@param flareColor flareColor
---@param azimuth number
function trigger.action.signalFlare(vec3, flareColor, azimuth) end
---Transmits an audio file to be broadcast over a specific frequency eneminating from the specified point.
---Modulation Values:
---https://wiki.hoggitworld.com/view/DCS_func_radioTransmission
---@param filename string
---@param point vec3
---@param modulation modulation
---@param loop boolean
---@param frequency number
---@param power number
---@param name string|nil
function trigger.action.radioTransmission(filename, point, modulation, loop, frequency, power, name) end
---Stops a radio transmission of the passed name. Transmission must be named in the trigger.action.radioTransmission it was sent from.
---https://wiki.hoggitworld.com/view/DCS_func_stopRadioTransmission
---@param name string
function trigger.action.stopRadioTransmission(name) end
---Sets the internal cargo for the specified unit at the specified mass. Overrides any previously set value. Can be used in conjunction with troop transport to simulate cargo being added to the aircraft. Can be used on any unit object, however it only will impact airplanes and helicopters. Mass is defined in kilograms.
---https://wiki.hoggitworld.com/view/DCS_func_setUnitInternalCargo
---@param unitName string
---@param mass number
function trigger.action.setUnitInternalCargo(unitName, mass) end
--- Plays a sound file to all players. The sound file must be placed inside of the miz file in order to be played.
---https://wiki.hoggitworld.com/view/DCS_func_outSound
---@param soundfile string
function trigger.action.outSound(soundfile) end
---Plays a sound file to all players on the specified coalition. The sound file must be placed inside of the miz file in order to be played.
---https://wiki.hoggitworld.com/view/DCS_func_outSoundForCoalition
---@param coalition side
---@param soundfile string
function trigger.action.outSoundForCoalition(coalition, soundfile) end
---Plays a sound file to all players on the specified country. The sound file must be placed inside of the miz file in order to be played.
---https://wiki.hoggitworld.com/view/DCS_func_outSoundForCountry
---@param country countryid
---@param soundfile string
function trigger.action.outSoundForCountry(country, soundfile) end
---Plays a sound file to all players in the specified group. Group is specified by their groupId. The sound file must be placed inside of the miz file in order to be played.
---https://wiki.hoggitworld.com/view/DCS_func_outSoundForGroup
---@param groupId number
---@param soundfile string
function trigger.action.outSoundForGroup(groupId, soundfile) end
---Displays the passed string of text for the specified time to all players. Boolean clearview defines whether or not to use the old message display format. The old message display overwrites existing messages and is good for displaying anything that must be updated at a high rate like lap times.
---https://wiki.hoggitworld.com/view/DCS_func_outText
---@param text string
---@param displayTime number
---@param clearview boolean|nil
function trigger.action.outText(text, displayTime, clearview) end
---Displays the passed string of text for the specified time to all players belonging to the specified coalition. Boolean clearview defines whether or not to use the old message display format. The old message display overwrites existing messages and is good for displaying anything that must be updated at a high rate like lap times.
---https://wiki.hoggitworld.com/view/DCS_func_outTextForCoalition
---@param coalition side
---@param text string
---@param displayTime number
---@param clearview boolean|nil
function trigger.action.outTextForCoalition(coalition, text, displayTime, clearview) end
---Displays the passed string of text for the specified time to all players belonging to the specified country. Boolean clearview defines whether or not to use the old message display format. The old message display overwrites existing messages and is good for displaying anything that must be updated at a high rate like lap times.
---https://wiki.hoggitworld.com/view/DCS_func_outTextForCountry
---@param country countryid
---@param text string
---@param displayTime number
---@param clearview boolean|nil
function trigger.action.outTextForCountry(country, text, displayTime, clearview) end
---Displays the passed string of text for the specified time to all players in the specified group. The group is defined by its groupId. Boolean clearview defines whether or not to use the old message display format. The old message display overwrites existing messages and is good for displaying anything that must be updated at a high rate like lap times.
---https://wiki.hoggitworld.com/view/DCS_func_outTextForGroup
---@param groupId number
---@param text string
---@param displayTime number
---@param clearview boolean|nil
function trigger.action.outTextForGroup(groupId, text, displayTime, clearview) end
---Adds a command to the "F10 Other" radio menu allowing players to call commands and set flags within the mission. Command is added for both teams. The string name is the text that will be displayed in the F10 Other menu and is also used in the function to remove the command from the menu.
---https://wiki.hoggitworld.com/view/DCS_func_addOtherCommand
---@param name string
---@param userFlagName string
---@param userFlagValue number
function trigger.action.addOtherCommand(name, userFlagName, userFlagValue) end
---Removes the command that matches the specified name input variable from the "F10 Other" radio menu.
---https://wiki.hoggitworld.com/view/DCS_func_removeOtherCommand
---@param name string
function trigger.action.removeOtherCommand(name) end
---Adds a command to the "F10 Other" radio menu allowing players to call commands and set flags within the mission. Command is added for all players belonging to the specified coalition. The string name is the text that will be displayed in the F10 Other menu and is also used in the function to remove the command from the menu.
---https://wiki.hoggitworld.com/view/DCS_func_addOtherCommandForCoalition
---@param coalition side
---@param name string
---@param userFlagName string
---@param userFlagValue number
function trigger.action.addOtherCommandForCoalition(coalition, name, userFlagName, userFlagValue) end
---Removes the command that matches the specified name input variable from the "F10 Other" radio menu if the command was added for coalition.
---https://wiki.hoggitworld.com/view/DCS_func_removeOtherCommandForCoalition
---@param coalitionId side
---@param name string
function trigger.action.removeOtherCommandForCoalition(coalitionId, name) end
---https://wiki.hoggitworld.com/view/DCS_func_addOtherCommandForGroup
---Adds a command to the "F10 Other" radio menu allowing players to call commands and set flags within the mission. Command is added for a specific group designated by its groupId. The string name is the text that will be displayed in the F10 Other menu and is also used in the function to remove the command from the menu.
---@param groupId number
---@param name string
---@param userFlagName string
---@param userFlagValue number
function trigger.action.addOtherCommandForGroup(groupId, name, userFlagName, userFlagValue) end
---Removes the command that matches the specified name input variable from the "F10 Other" radio menu if the command exists for the specified group.
---https://wiki.hoggitworld.com/view/DCS_func_removeOtherCommandForGroup
---@param groupId number
---@param name string
function trigger.action.removeOtherCommandForGroup(groupId, name) end
---Adds a mark point to all on the F10 map with attached text. 2.5 added the two new variables of readOnly and message. Read only if true will make it so users cannot remove the mark. Message is a message that is displayed when a mark is added. Set to for no message to be added.
---https://wiki.hoggitworld.com/view/DCS_func_markToAll
---@param id number
---@param text string
---@param vec3 vec3
---@param readOnly boolean|nil
---@param message string|nil
function trigger.action.markToAll(id, text, vec3, readOnly, message) end
---Adds a mark point to a coalition on the F10 map with attached text. 2.5 added the two new variables of readOnly and message. Read only if true will make it so users cannot remove the mark. Message is a message that is displayed when a mark is added. Set to for no message to be added.
---https://wiki.hoggitworld.com/view/DCS_func_markToCoalition
---@param id number
---@param text string
---@param vec3 vec3
---@param coalitionId side
---@param readOnly boolean|nil
---@param message string|nil
function trigger.action.markToCoalition(id, text, vec3, coalitionId, readOnly, message) end
---Adds a mark point to a group on the F10 map with attached text. 2.5 added the two new variables of readOnly and message. Read only if true will make it so users cannot remove the mark. Message is a message that is displayed when a mark is added. Set to for no message to be added.
---https://wiki.hoggitworld.com/view/DCS_func_markToGroup
---@param id number
---@param text string
---@param vec3 vec3
---@param groupId number
---@param readOnly boolean|nil
---@param message string|nil
function trigger.action.markToGroup(id, text, vec3, groupId, readOnly, message) end
---Removes a mark panel from the f10 map
---https://wiki.hoggitworld.com/view/DCS_func_removeMark
---@param id number
function trigger.action.removeMark(id) end
---Creates the defined shape on the F10 map. Uses the same definitions as the specific functions to create different shapes with the only difference being the first parameter is used to define the shape. This function does have an additional type of shape of "freeform" which allows you to create an 3+ vertices shape in any format you wish. Shape Ids:
---https://wiki.hoggitworld.com/view/DCS_func_markupToAll
---@param shapeId number
---@param coalition side
---@param id number
---@param points vec3
---@param color table|any
---@param fillColor table|any
---@param lineType number|any
---@param readOnly boolean|nil|any
---@param message string|nil|any
---@param ... any
function trigger.action.markupToAll(shapeId, coalition, id, points , color, fillColor, lineType, readOnly, message, ...) end
---Creates a line on the F10 map from one point to another. Coalition Ids to be used.
---https://wiki.hoggitworld.com/view/DCS_func_lineToAll
---@param coalition side
---@param id number
---@param startPoint vec3
---@param endPoint vec3
---@param color table
---@param lineType number
---@param readOnly boolean|nil
---@param message string|nil
function trigger.action.lineToAll(coalition, id, startPoint, endPoint, color, lineType, readOnly, message) end
---Creates a circle on the map with a given radius, color, fill color, and outline. Coalition Ids to be used.
---https://wiki.hoggitworld.com/view/DCS_func_circleToAll
---@param coalition side
---@param id number
---@param center vec3
---@param radius number
---@param color table
---@param fillColor table
---@param lineType number
---@param readOnly boolean|nil
---@param message string|nil
function trigger.action.circleToAll(coalition, id, center, radius, color, fillColor, lineType, readOnly, message) end
---Creates a rectangle on the map from the startpoint in one corner to the endPoint in the opposite corner. Coalition Ids to be used.
---https://wiki.hoggitworld.com/view/DCS_func_rectToAll
---@param coalition side
---@param id number
---@param startPoint vec3
---@param EndPoint vec3
---@param color table
---@param fillColor table
---@param lineType number
---@param readOnly boolean|nil
---@param message string|nil
function trigger.action.rectToAll(coalition, id, startPoint, EndPoint, color, fillColor, lineType, readOnly, message) end
---Creates a shape defined by the 4 points on the F10 map.
---https://wiki.hoggitworld.com/view/DCS_func_quadToAll Coalition Ids to be used.
---@param coalition side
---@param id number
---@param point1 vec3
---@param point2 vec3
---@param point3 vec3
---@param point4 vec3
---@param color table
---@param fillColor table
---@param lineType number
---@param readOnly boolean|nil
---@param message string|nil
function trigger.action.quadToAll(coalition, id, point1, point2, point3, point4, color, fillColor, lineType, readOnly, message) end
---Creates a text imposed on the map at a given point. Text scales with the map. Coalition Ids to be used.
---https://wiki.hoggitworld.com/view/DCS_func_textToAll
---@param coalition side
---@param id number
---@param point vec3
---@param color table
---@param fillColor table
---@param fontSize number
---@param readOnly boolean
---@param text string
function trigger.action.textToAll(coalition, id, point, color, fillColor, fontSize, readOnly, text) end
---Creates an arrow from the startPoint to the endPoint on the F10 map. The arrow will be "pointing at" the startPoint. There is no control over other dimensions of the arrow. Coalition Ids to be used.
---https://wiki.hoggitworld.com/view/DCS_func_arrowToAll
---@param coalition side
---@param id number
---@param startPoint vec3
---@param endPoint vec3
---@param color table
---@param fillColor table
---@param lineType number
---@param readOnly boolean|nil
---@param message string|nil
function trigger.action.arrowToAll(coalition, id, startPoint, endPoint, color, fillColor, lineType, readOnly, message) end
---Updates the radius of the specified mark to be the new value. If the id of the passed mark is not a circle then nothing will happen.
---https://wiki.hoggitworld.com/view/DCS_func_setMarkupRadius
---@param id number
---@param radius number
function trigger.action.setMarkupRadius(id, radius) end
---Updates the text value of the passed mark to the passed text value. If the id of the passed mark does not have any text then nothing will happen.
---https://wiki.hoggitworld.com/view/DCS_func_setMarkupText
---@param id number
---@param text string
function trigger.action.setMarkupText(id, text) end
---Updates the font size of the specified mark to be the new value. If the id of the passed mark does not have text then nothing will happen.
---https://wiki.hoggitworld.com/view/DCS_func_setMarkupFontSize
---@param id number
---@param fontSize number
function trigger.action.setMarkupFontSize(id, fontSize) end
---Updates the color of the specified mark to be the new value. Color format is {r, g, b, alpha} with values ranging from 0 to 1.
---https://wiki.hoggitworld.com/view/DCS_func_setMarkupColor
---@param id number
---@param color table
function trigger.action.setMarkupColor(id, color) end
---Updates the colorfill of the specified mark to be the new value. Color format is {r, g, b, alpha} with values ranging from 0 to 1.
---https://wiki.hoggitworld.com/view/DCS_func_setMarkupColorFill
---@param id number
---@param colorFill table
function trigger.action.setMarkupColorFill(id, colorFill) end
---Updates the type line of the specified mark to be the new value.
---https://wiki.hoggitworld.com/view/DCS_func_setMarkupTypeLine
---@param id number
---@param TypeLine number
function trigger.action.setMarkupTypeLine(id, TypeLine) end
---Updates the position of a mark that was defined at the last point given to create it. Can be used to "move" an existing mark from one place to the next without deleting it and creating a new one.
---https://wiki.hoggitworld.com/view/DCS_func_setMarkupPositionEnd
---@param id number
---@param vec3 vec3
function trigger.action.setMarkupPositionEnd(id, vec3) end
---Updates the position of a mark that was defined at the first point given to create it. Can be used to "move" an existing mark from one place to the next without deleting it and creating a new one.
---https://wiki.hoggitworld.com/view/DCS_func_setMarkupPositionStart
---@param id number
---@param vec3 vec3
function trigger.action.setMarkupPositionStart(id, vec3) end
---Sets the task of the specified index to be the one and only active task.
---https://wiki.hoggitworld.com/view/DCS_func_setAITask
---@param taskIndex number
---@param Group Group
function trigger.action.setAITask(Group, taskIndex) end
---Pushes the task of the specified index to the front of the tasking queue.
---https://wiki.hoggitworld.com/view/DCS_func_pushAITask
---@param taskIndex number
---@param Group Group
function trigger.action.pushAITask(Group, taskIndex) end
---Activates the specified group if it is setup for "late activation." Calls the Group.activate function.
---https://wiki.hoggitworld.com/view/DCS_func_activateGroup
---@param Group Group
function trigger.action.activateGroup(Group) end
---Deactivates the specified group. Calls the Group.destroy function.
---https://wiki.hoggitworld.com/view/DCS_func_deactivateGroup
---@param Group Group
function trigger.action.deactivateGroup(Group) end
---Turns the specified groups AI on. Calls the Group.getController(setOnOff(true)) function. Only works with ground and ship groups.
---https://wiki.hoggitworld.com/view/DCS_func_setGroupAIOn
---@param Group Group
function trigger.action.setGroupAIOn(Group) end
---Turns the specified groups AI off. Calls the Group.getController(setOnOff(false)) function. Only works with ground and ship groups.
---https://wiki.hoggitworld.com/view/DCS_func_setGroupAIOff
---@param Group Group
function trigger.action.setGroupAIOff(Group) end
---Orders the specified group to stop moving. Calls Group.getController(setCommand()) function and sets the stopRoute command to true. Only works with ground groups.
---https://wiki.hoggitworld.com/view/DCS_func_groupStopMoving
---@param Group Group
function trigger.action.groupStopMoving(Group) end
---Orders the specified group to resume moving. Calls Group.getController(setCommand()) function and sets the stopRoute command to false. Only works with ground groups.
---https://wiki.hoggitworld.com/view/DCS_func_groupContinueMoving
---@param Group Group
function trigger.action.groupContinueMoving(Group) end
---Creates a smoke plume behind a specified aircraft. When passed 0 for smoke type the plume will be disabled. When triggering the on the same unit with a different color the plume will simply change color. Optional value for altitude can be set. This value is in meters and defines the altitude at which the aircraft must be for the smoke to dispense. If the aircraft goes below that altitude the smoke will stop. As long as the smoke is enabled the toggling on/off by changing altitude is automated.
---https://wiki.hoggitworld.com/view/DCS_func_ctfColorTag
---@Example The following creates a blue smoke plume on an aircraft named "IWishEDWouldDocumentFeaturesMore" that will be enabled as long as the aircraft is above 1000 meters.
---trigger.action.ctfColorTag('IWishEDWouldDocumentFeaturesMore', 5, 1000)
---@param unitName string
---@param smokeColor number
---@param altitude number
function trigger.action.ctfColorTag(unitName, smokeColor, altitude) end
---Sets a user flag to the specified value.
---https://wiki.hoggitworld.com/view/DCS_func_setUserFlag
---@param flagNumFlagName string
---@param userFlagValue boolean|number
function trigger.action.setUserFlag(flagNumFlagName, userFlagValue) end
end
---The trigger singleton contains a number of functions that mimic actions and conditions found within the mission editor triggers. As a result these functions provide an easy way to interface with triggers setup within the mission editor. Additionally a few trigger functions act as a gateway between mission editor triggers and related scripting functions.
---https://wiki.hoggitworld.com/view/DCS_singleton_trigger
trigger.misc = {}
do
---Returns the value of a user flag.
---https://wiki.hoggitworld.com/view/DCS_func_getUserFlag
---@return number
---@param flagNumFlagName string
function trigger.misc.getUserFlag(flagNumFlagName) end
---Returns a trigger zone table of a given name
---https://wiki.hoggitworld.com/view/DCS_func_getZone
---@return TriggerZone class
---@param zoneName string
function trigger.misc.getZone(zoneName) end
end
return trigger