Jump to content

Random Airtraffic Script (with MIST2.0)


Recommended Posts

This is my attempt to script random AI airtraffic at airfields.

 

This script generates AI airplanes and helicopters of all available type (except P51,F190, F-117) at 3 airfields. The aircraft startup, takeoff and fly to a random point inside a zone and return to one of the 3 airfields randomly, which are to be defined in the ME and in the script.

 

After landing and shutting down, the aircraft despawn. Also after an traffic accident on the taxi or runway, the aircraft will be removed. Every aircraft will have its own weapon loadout and skin. Fighter and bomber will fly as two-ship formation, helicopter, recon, transport will fly solo.

 

For warning the player of AI activity around, the aircraft will trigger messages to the coalition it belongs to, reflecting the phase of the procedure the craft is in. As example an RFF IL78M spawned on Kutiasi:

 

"Kutaisi, RFF5897, IL-78M, taxiing to active runway!" [unit spawned on Apron]

"Kutaisi, RFF5897, departing active runway and leaving control zone!" [(2nd of Flight) Unit started takeoff roll]

"Kutaisi, RFF5897, airborne" [ (2nd of Flight) Unit is 15m above ground]

"Kutaisi, RFF5897, is bearing: 308 for 3 nautical miles at altitude 1800, leaving control zone." [(2nd of Flight) Unit leaves triggerzone you have to set in the ME around airfield]

"Tbilisi-West, RFF5897, is N42,125 - E 042,045 at altitude 20000, checking in." [(1st of Flight)Unit enters triggerzone "trafficzone"]

"Kobuleti, RFF5897, is bearing: 102 for 3 nautical miles at altitude 2000, for landing." [(1st of Flight) Unit enters triggerzone you have to set in the ME around airfield]

"Kobuleti, RFF5897, on final!" [(1st of Flight) Unit is lower than 500m above ground]

"Kobuleti, RFF5897, touchdown!" [(2nd of Flight) Unit is lower than 15m above ground]

"Kobuleti, RFF5897, runway vacated!" [(2nd of Flight) Unit is not moving anymore and taken out of game]

 

The nations are set to Russia, Georgia, USA, UK, Germany, France and Netherlands, so if you want deconflict according to your coalition setup, you have to edit the script in line 26-28:

 

randomAirplane = math.random(1,18) -- random for airplanettype; Russian AC 10-18 , for russion only set (10,18), or otherwise for other nations
randomHeli = math.random(1,18) --Russian AC 13-18, for russion only set (13,18), or otherwise for other nations
randomFighter = math.random(1,36) --Russian AC 18-36, for russion only set (18,36), or otherwise for other nations

In line 10 the spawnintervall can be set:

 

intervall = math.random(300,900) --(x,y) minimum x seconds, max. y seconds

You have define 4 zones in the ME in order to implement the script. Zones "airfield1" to "airfield3" (the name must be exact this) mus lie over the 3 airfields on which the traffic shall be generated. According to this zones you have to write the name of the corresponding airfield into the script in the lines 12-14. Zone 4 must be named "trafficzone". This is the zone which defines the random waypoint to which the aircraft will fly after takeoff. The radius defines the spread.

 

Triggerzones to be set in the ME:

Zone 1. "Name-of-airfield-AF1-as-in-script line 12" <- defines one of the airfields

Zone 2. "Name-of-airfield-AF2-as-in-script line 13", <- defines one of the airfields

Zone 3. "Name-of-airfield-AF3-as-in-script line 14" <- defines one of the airfields

Zone 4."trafficzone" <- defines the waypoint spread between takeoff and landing in zone 1-3.

 

Note this is version 6 and requires MIST2.0 or newer

 

Any feedback, ideas, bug hints etc welcome! Note that I am no programmer, so this script is not really efficient I guess, but it worked.

 

PS:

1. Updated to v4, fixed some issues with other scripts, when random AI planes was destroyed.

 

2. Updated to v5, some issue with despawning is hopefully fixed

 

3. Updated r6, fixing issues with removal of landed flights in combination with other scripts.

 

4. Update currently no tested version at hand, will upload one asap

 

5. Uploaded MIST3_2_RandAirtraffic_r5.lua and example *.miz file (miz file including a script simulating autonomous GCI / CAP AI in final testing)

 

6. Added radio transmissions (text message to coalition the aircraft belongs to) and reworked clean up part of script, to remove idle or damaged planes

MIST3_2_RandAirtraffic_r5.lua

randomairtraffic_scripttest.miz

MIST3_2_RandAirtraffic_r6.lua


Edited by SNAFU

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • Replies 170
  • Created
  • Last Reply

Top Posters In This Topic

Hi SNAFU, I tried this script but cannot get it to work, think I missed something with the assigning of airfield:

 

intervall = math.random(300,900)     --random repeater intervall between (A and B) in seconds
Nameprefix = "A-"                 --Unit and Group name should not be used in ME by other units, this prefix can be altered if used by other scripts
AF1 = 'Tbilisi-Lochini'                     --Exact name of airfield with the zone "airfield1"
AF2 = 'Beslan'                     --Exact name of airfield with the zone "airfield2"
AF3 = 'Kutaisi'                    --Exact name of airfield with the zone "airfield3"

 

Nice work on this man!

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to comment
Share on other sites

Hi Midnight,

 

Following questions come into my mind:

 

Did you also placed triggerzones with the corresponding zone names 'airfield1' (over Tbilisi-Lochini), 'airfield2' (over Beslan) and 'airfield3' over Kutaisi?

 

Additionally it requires a Waypoint to be generated by placing a trigger zone calles 'airlanehub1'.

 

Prior to loading the script, Mist2.0 needs to be intialized.

 

Did you get an error message?

 

Did you check the airfield names? If you click on the airfield in ME, a field appears with the ressource manager window, from which you can also copy and paste the airfield name.

 

Do you have other scripts in the mission? If so, do they also use varaibles as "groupcounter"? (This can be a variable also used in other scripts, so you might need to rename the "groupcounter" to "_groupcounter" or something by using the Notepad++ replace function (ctrl+h))


Edited by SNAFU
  • Like 1

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

@Midnight:

 

Another thought I had, is Tbilisi-Lochini should be AF Id 29, might also be just called "Lochini".

If you uncomment the line

 

--trigger.action.outText(string.format(AF1ID).."-" ..string.format(AF2ID).."-" ..string.format(AF3ID),10)

By deleting the "--" in the beginning the aifield IDs should be displayed, when the script is loaded. If there is something wrong with this, you should find out this way.

 

This should be the airdrome IDs:

 

0 Airdrome_0

1 Khersones

2 Saki

3 Simpheropol

4 Razdolnoe

5 Dzhankoy

6 Kirovskoe

7 Kerch

8 Belbek

9 Krasnogvardeyskoye

10 Octyabrskoe

11 Gvardeyskoe

12 Anapa

13 Krasnodar

14 Novorossiysk

15 Krymsk

16 Maykop

17 Gelendzhik

18 Sochi

19 Krasnodar_P

20 Sukhumi

21 Gudauta

22 Batumi

23 Tskhakaya

24 Kobuleti

25 Kutaisi

26 MinVody

27 Nalchik

28 Mozdok

29 Lochini

30 TbilisiMilitary

31 Vaziani

32 Beslan


Edited by SNAFU

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

This is a great idea ! Thanks a lot for sharing :beer:

 

I can not test it ATM, but I read it, and I have a question for you: are the three times functions supposed to be run only once ?

 

As far as I know, scheduled function that wanna re-schedule themselves have to have the signature "function(args, time)", and must return as follow: "return time + DELAY", with delay being what you want between two calls.

 

I'm trying to understand how you did it, but I gave it my best without success, and as I said I have no possibility to test it until next week.

 

Is there another way to schedule functions with Mist besides the one described above ? Or am I totally and hopelessly off ? :P

 

EDIT: ok, I think I got it, looks like mist.scheduleFunction and timer.scheduleFunction are not quite exactly the same ... doh.gif


Edited by daribouca
finally understood
Link to comment
Share on other sites

 

EDIT: ok, I think I got it, looks like mist.scheduleFunction and timer.scheduleFunction are not quite exactly the same ... doh.gif

 

Yes, the functions are repeated with the mist.scheduleFunction and "intervall" sets the time-intervall it is repeated.

 

The single functions are scheduled with an offset, because the mist.goRoute function needs existing units to work and therefore I have to spawn the units, before I can give them a route. I am also looking for a way to randomise the spawn intervall more than just once in the beginning, but havent´t figured out a working path so far. 300 seconds minimum might be a little too low intervall and mission might get crowded too fast. Than the intervall must be set to lower a frequenzy.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Yes, the functions are repeated with the mist.scheduleFunction and "intervall" sets the time-intervall it is repeated.

 

The single functions are scheduled with an offset, because the mist.goRoute function needs existing units to work and therefore I have to spawn the units, before I can give them a route. I am also looking for a way to randomise the spawn intervall more than just once in the beginning, but havent´t figured out a working path so far. 300 seconds minimum might be a little too low intervall and mission might get crowded too fast. Than the intervall must be set to lower a frequenzy.

 

If you want to randomize the delay each time, you could go the timer.scheduleFunction way.

 

The function has to have the signature "function(args, time)", and it also has to return as "return time + delay", where "delay" is the time in seconds until next execution. Is this not what you want to randomize ? :beer:

Link to comment
Share on other sites

mist.scheduleFunction is practically the same as timer.scheduleFunction, however it runs a bit differently. Basically we call timer.scheduleFunction to repeatedly run the function that monitors and runs all of the mist.scheduleFunctions. Because it uses our own code we can add a little more capability to it, for instance the repeating interval and stop time variables. Both work and can be used together without issue.

 

If you wanted to do a randomized time delay for the function, you will need to reschedule it randomly each time.

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

how do I use this script? Can you post a tutorial? I am completely new to this.

AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS

 

Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.

Link to comment
Share on other sites

If you want to randomize the delay each time, you could go the timer.scheduleFunction way.

 

The function has to have the signature "function(args, time)", and it also has to return as "return time + delay", where "delay" is the time in seconds until next execution. Is this not what you want to randomize ?

 

Basically yes, but due to the fact that the functions need to be called in a certain order (spawn - give route - check if idle) I had troubles with randomizing the interval value. I need to generate a new random value after every cycle, looks easy, but I have to stop the cycle in between, because I got difficulties changing the value, while the function is active. So all the intervalls got mixed up. If I have some time I can look further into this, but so far it is not so important methinks.

mist.scheduleFunction is practically the same as timer.scheduleFunction, however it runs a bit differently. Basically we call timer.scheduleFunction to repeatedly run the function that monitors and runs all of the mist.scheduleFunctions. Because it uses our own code we can add a little more capability to it, for instance the repeating interval and stop time variables. Both work and can be used together without issue.

 

If you wanted to do a randomized time delay for the function, you will need to reschedule it randomly each time.

Yes, I have to call the functions on a different way, but as this is just scenery enhancement...

can you post a mission?

Will do, but not today, as I am not home.

how do I use this script? Can you post a tutorial? I am completely new to this.

1. Download Speed&Grimes MIST 2.0 script collection

2. Open your mission in the mission editor

3. Open the trigger page

4. Below you find a row with which you initialize the MIST 2.0 file

5. Choose airfield nr 1 you want to have traffic on, place a trigger zone with the name "airfield1" over the airfield. Write the name of the airfield, in the script in line 12

6. Choose airfield nr 2 you want to have traffic on, place a trigger zone with the name "airfield2" over the airfield. Write the name of the airfield, in the script in line 13

7. Choose airfield nr 3 you want to have traffic on, place a trigger zone with the name "airfield3" over the airfield. Write the name of the airfield, in the script in line 14

8. Place a triggerzone called "airlanehub1" somewhere on the map. The radius of the zone defines the spread of points the planes will fly to after take off. (They take off fly to a random point in the zone and land at a random airfield (1-3))

9. Create a "Once->Time more than 1 seconds -> Do script file (load the script)" Trigger

10. Start the mission

You can edit the script randomization in a way, that you only spawn planes of certain nations or types in lines 26-28. "math.random(x,y)" means it chooses a random value in the range of [x,y], so if you edit x and y you can define the range aircrafttypes and therefore nations, because every type is only available for one nation, except a few like Uh-1, Mi-8, Yak-40 and the like.

In line 10 you can edit the spawnintervall, if you feel the map gets too crowded, or you want to have more traffic.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

@Midnight:

 

Another thought I had, is Tbilisi-Lochini should be AF Id 29, might also be just called "Lochini".

If you uncomment the line

 

--trigger.action.outText(string.format(AF1ID).."-" ..string.format(AF2ID).."-" ..string.format(AF3ID),10)

By deleting the "--" in the beginning the aifield IDs should be displayed, when the script is loaded. If there is something wrong with this, you should find out this way.

 

This should be the airdrome IDs:

 

0 Airdrome_0

1Khersones

2 Saki

3Simpheropol

4 Razdolnoe

5 Dzhankoy

6 Kirovskoe

7 Kerch

8 Belbek

9 Krasnogvardeyskoye

10 Octyabrskoe

11 Gvardeyskoe

12 Anapa

13 Krasnodar

14 Novorossiysk

15 Krymsk

16 Maykop

17 Gelendzhik

18 Sochi

19 Krasnodar_P

20 Sukhumi

21 Gudauta

22 Batumi

23 Tskhakaya

24 Kobuleti

25 Kutaisi

26 MinVody

27 Nalchik

28 Mozdok

29 Lochini

30 TbilisiMilitary

31 Vaziani

32 Beslan

 

 

Hi SNAFU

 

Sorry I only reply now, been in the Kalahari desert for a couple of days(no internet)

 

Will give it a go tonight, thanks.

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to comment
Share on other sites

Huh, I guess winter is the best time of the year for that trip?

Only travelled the Karoo once, think it was '97, never made it up that far north, so it`s still on my todo list... ;)

 

Let me know, if it works.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 3 months later...

need a good ATC and improving some type of SID / STAR :)

More news to the front

My Rig: Intel I-5 750 2.67Ghz / Packard Bell FMP55 / 16 GB DDR3 RAM / GTX-1080 8 GB RAM / HD 1Tb/2Tb / Warthog / 2 MDF / TFPR

DCS: Roadmap (unofficial): https://forums.eagle.ru/showthread.php?t=116893

DCS: List of Vacant models: https://forums.eagle.ru/showthread.php?p=4076891#post4076891

Silver_Dragon Youtube

Link to comment
Share on other sites

[ATTACH]93705[/ATTACH]

 

 

 

I cant get this to work...I'm trying to use mist3.2....heres a . miz of my try...i change the spawn to 30,60 to be able to run trail/error

 

bump....someone plz help me get this working......must i use mist2.0???........

It only takes two things to fly, Airspeed and Money.

Link to comment
Share on other sites

Can't believe this hasn't been played up more. What an excellent idea. ED should really release an option for something like this is every mission, similar to the traffic sliders in FSX. Not ALL missions are combat-oriented and I'd love to have some traffic while I practice techniques around the airdrome. So as diveplane asked, I too, am wondering if this is now good to go.

The State Military (MAG 13)

 

[sIGPIC][/sIGPIC]



 

SHEEP WE-01

AV-8B BuNo 164553

VMA-214

Col J. “Poe” Rasmussen

http://www.statelyfe.com

 

Specs: Gigabyte Z390 Pro Wifi; i9-9900K; EVGA 2080 Ti Black; 32GB Corsair Vengeance LPX DDR4; Samsung 970 EVO Series M.2 SSD; WIN10; ASUS VG248QE; CV-1 and Index



Modules: A-10C; AV8B; CA; FC3; F-5; F-14; F-18; F-86; HAWK; L-39; P-51; UH1H; NTTR; Normandy; Persian Gulf

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...