SNAFU Posted June 17, 2013 Share Posted June 17, 2013 (edited) 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 planesMIST3_2_RandAirtraffic_r5.luarandomairtraffic_scripttest.mizMIST3_2_RandAirtraffic_r6.lua Edited October 16, 2014 by SNAFU [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Midnight Posted June 22, 2013 Share Posted June 22, 2013 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! Link to comment Share on other sites More sharing options...
SNAFU Posted June 24, 2013 Author Share Posted June 24, 2013 (edited) 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 June 24, 2013 by SNAFU 1 [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
luza Posted June 24, 2013 Share Posted June 24, 2013 awesome script. Yet to try it, but cool stuff non the less! :) [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
SNAFU Posted June 24, 2013 Author Share Posted June 24, 2013 (edited) @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 June 24, 2013 by SNAFU [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
daribouca Posted June 24, 2013 Share Posted June 24, 2013 (edited) 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 ... Edited June 24, 2013 by daribouca finally understood Link to comment Share on other sites More sharing options...
ENO Posted June 25, 2013 Share Posted June 25, 2013 I haven't tested it yet but this is EXACTLY what I've been looking to do to in my missions to add just a little something extra. Rep just on principle! "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
SNAFU Posted June 25, 2013 Author Share Posted June 25, 2013 EDIT: ok, I think I got it, looks like mist.scheduleFunction and timer.scheduleFunction are not quite exactly the same ... 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 More sharing options...
daribouca Posted June 25, 2013 Share Posted June 25, 2013 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 More sharing options...
Grimes Posted June 25, 2013 Share Posted June 25, 2013 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: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
gunterlund21 Posted June 26, 2013 Share Posted June 26, 2013 can you post a mission? I was in Art of the Kill D#@ it!!!! Link to comment Share on other sites More sharing options...
WildBillKelsoe Posted June 26, 2013 Share Posted June 26, 2013 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 More sharing options...
SNAFU Posted June 26, 2013 Author Share Posted June 26, 2013 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 More sharing options...
Midnight Posted June 26, 2013 Share Posted June 26, 2013 @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. Link to comment Share on other sites More sharing options...
SNAFU Posted June 26, 2013 Author Share Posted June 26, 2013 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 More sharing options...
SNAFU Posted August 2, 2013 Author Share Posted August 2, 2013 Because I was asked several times for an example mission I now had the chance to attach an example below. Disregard: I cannot attache the same file twice, but you can find the file here: http://forums.eagle.ru/showthread.php?t=110915 [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
SNAFU Posted October 25, 2013 Author Share Posted October 25, 2013 Updated to v4 in first post, fixed some issues with other scripts, when random AI planes was destroyed. 1 [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Midnight Posted October 25, 2013 Share Posted October 25, 2013 Thanks mate! Link to comment Share on other sites More sharing options...
Davis0079 Posted January 30, 2014 Share Posted January 30, 2014 trial traffic.miz 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 It only takes two things to fly, Airspeed and Money. Link to comment Share on other sites More sharing options...
Highwayman-Ed Posted January 30, 2014 Share Posted January 30, 2014 Excellent idea! Intel i9-9900KF @5.2GHz MSI Z390 Gaming Pro Carbon 32GB G.Skill Trident Z DDR3200 RAM MSI RTX 2080 Ti Gaming X Trio 40" Panasonic TH-40DX600U @ 4K Pimax Vision 8K Plus / Oculus Rift CV1 / HTC Vive Gametrix JetSeat with SimShaker Windows 10 64 Bit Home Edition [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Silver_Dragon Posted January 30, 2014 Share Posted January 30, 2014 need a good ATC and improving some type of SID / STAR :) Link to comment Share on other sites More sharing options...
Davis0079 Posted January 31, 2014 Share Posted January 31, 2014 [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 More sharing options...
diveplane Posted January 31, 2014 Share Posted January 31, 2014 this one working then? https://www.youtube.com/user/diveplane11 DCS Audio Modding. Link to comment Share on other sites More sharing options...
rassy7 Posted January 31, 2014 Share Posted January 31, 2014 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. 1 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 More sharing options...
Highwayman-Ed Posted January 31, 2014 Share Posted January 31, 2014 Yep, this is a great idea. Excellent job. Intel i9-9900KF @5.2GHz MSI Z390 Gaming Pro Carbon 32GB G.Skill Trident Z DDR3200 RAM MSI RTX 2080 Ti Gaming X Trio 40" Panasonic TH-40DX600U @ 4K Pimax Vision 8K Plus / Oculus Rift CV1 / HTC Vive Gametrix JetSeat with SimShaker Windows 10 64 Bit Home Edition [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Recommended Posts