Naj-Treg Posted October 3, 2020 Posted October 3, 2020 Hi All. Can someone help me setting up a little script for MOOSE to spawn a random group out of some templates? I want to setup a training mission where a random group (selected out of some template groups) gets spawned with the groups waypoints and mission. Even better if the random group spawns in a random zone and after spawning proceeds to his first waypoint and flies the route it has been given. I achieved to spawn a group out of a template in a random zone. It spawns random units. But it always flies the same set route. I just can not find the right script to spawn a randomized group with it route. This is bugging me for 2 weeks now:joystick: Any help would be much appreciated Kind regards Naj-Treg
Habu_69 Posted October 3, 2020 Posted October 3, 2020 About as simple as it gets using a table of templates. Can also use a Moose set instead of table. AAA1 = SPAWN:New( "AAA 36 1" ) AAA2 = SPAWN:New( "AAA 36 2" ) AAA3 = SPAWN:New( "AAA 36 3" ) AAA4 = SPAWN:New( "AAA 36 4" ) Rand36 = math.random( 1, 4 ) TBL36 = { AAA1, AAA2, AAA3, AAA4 } AAA_1 = table.remove( TBL36, Rand36 ) AAA_1:Spawn()
fargo007 Posted October 3, 2020 Posted October 3, 2020 Or the :InitRandomizeTemplates(templatetable) method. Have fun. Don't suck. Kill bad guys. https://discord.gg/blacksharkden/
HC_Official Posted October 3, 2020 Posted October 3, 2020 sadly in lua, random ........... can be very not random at times I tend to use math.random() math.random() math.random() on a line before I ask for any random numbers No more pre-orders Click here for tutorials for using Virpil Hardware and Software Click here for Virpil Flight equipment dimensions and pictures. .
Naj-Treg Posted October 3, 2020 Author Posted October 3, 2020 About as simple as it gets using a table of templates. Can also use a Moose set instead of table. AAA1 = SPAWN:New( "AAA 36 1" ) AAA2 = SPAWN:New( "AAA 36 2" ) AAA3 = SPAWN:New( "AAA 36 3" ) AAA4 = SPAWN:New( "AAA 36 4" ) Rand36 = math.random( 1, 4 ) TBL36 = { AAA1, AAA2, AAA3, AAA4 } AAA_1 = table.remove( TBL36, Rand36 ) AAA_1:Spawn() Thank you! I got this working :thumbup::thumbup: I do have some questions tho....where does th "36" as in "AAA 36 1" stands for? I assume it's for the table... But do you need to name the group also like that? my script looks likes this as this are the names i use: SPAWN_PLANE_1 = SPAWN:New( "SPAWN_PLANE_1" ) SPAWN_PLANE_2 = SPAWN:New( "SPAWN_PLANE_2" ) SPAWN_PLANE_3 = SPAWN:New( "SPAWN_PLANE_3" ) SPAWN_PLANE_4 = SPAWN:New( "SPAWN_PLANE_4" ) Rand36 = math.random( 1, 4 ) TBL36 = { SPAWN_PLANE_1, SPAWN_PLANE_2, SPAWN_PLANE_3, SPAWN_PLANE_4, } SPAWN_PLANE_1 = table.remove( TBL36, Rand36 ) SPAWN_PLANE_1:Spawn() This works for me.... Only i can not get it to spawn in random zones with the line :InitRandomizeZones(SpawnZoneTable) Where do i put this line or set it up to spawn planes in random zones? Naj-Treg
Naj-Treg Posted October 3, 2020 Author Posted October 3, 2020 Or the :InitRandomizeTemplates(templatetable) method. I use this line in an other test script. I gives me the random templates of the group but not the routes i give it.
Naj-Treg Posted October 3, 2020 Author Posted October 3, 2020 sadly in lua, random ........... can be very not random at times I tend to use math.random() math.random() math.random() on a line before I ask for any random numbers Can you give me a sample how to set it up in my script shown above? Sorry for all these questions.. Am very basic at the scripting side...trying to understand it more and get deeper in i it. It is hard to understand how DCS reads and execute the script. But it gives you so much more options wich makes missions so much more fun.
Habu_69 Posted October 3, 2020 Posted October 3, 2020 AAA 36 1 is simply the name of the "template" group in the ME. Recommend you check out the Moose User Guide from Moose Info channel of the Moose Discord as a very handy primer for scripting in general, and Moose in particular.
Naj-Treg Posted October 3, 2020 Author Posted October 3, 2020 AAA 36 1 is simply the name of the "template" group in the ME. Recommend you check out the Moose User Guide from Moose Info channel of the Moose Discord as a very handy primer for scripting in general, and Moose in particular. I use it alot Also I look a lot in the sample missions. But somethimes i find it hard to understand what they say in the manual. But tnx everyone for helping me out! I am a step further in the right way. Now i need to tweak it to get what i want. Naj-Treg
Recommended Posts