Naj-Treg Posted September 23, 2020 Share Posted September 23, 2020 Hello all. I am trying to setup a mission where I setup some different groups with different tasks. I want one of the groups spawn randomly in a zone that is also rondomly selected. After spawning the group proceeds its mission and waypoints For now i have a script that spawns 1 airplane group in a random zone and proceed it's mission. But i can not get MOOSE to random select a plane template and then spawn it in a random zone. -- this is the working script i use now -- local Iterations = 10 local Iteration = 1 AirplaneZones = { "AirplaneZone1", "AirplaneZone2", "AirplaneZone3", "AirplaneZone4", "AirplaneZone5", "AirplaneZone6","AirplaneZone7", "AirplaneZone8", "AirplaneZone9","AirplaneZone10", "AirplaneZone11", "AirplaneZone" } HeightLimit = 6000 SpawnAirplanes = SPAWN:New("Airplane"):InitLimit( 20, 4 ) --- Spawns these groups slowly. SCHEDULER:New( nil, function( Interation, Iterations ) do -- Spawn Airplanes local ZoneName = AirplaneZones[ math.random( 1, 11 ) ] local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() ) SpawnAirplanes:SpawnFromVec2( SpawnVec3:GetVec2() ) SpawnAirplanes:SpawnFromVec2( SpawnVec3:GetVec2(), 200, 500 ) end end, {}, 0, 15, 0.5 ) ---------------------------------------- Any help would be much appreciated. Kind regards Naj-Treg Link to comment Share on other sites More sharing options...
fargo007 Posted September 23, 2020 Share Posted September 23, 2020 To add to your spawn: :InitRandomizeTemplate(templatetable) :InitRandomizeZones(zonetable) :SpawnScheduled(n,n) ----- See the moose SPAWN class documentation for the particulars, but this is what you need I think. A scheduler isn't necessary at all here. Have fun. Don't suck. Kill bad guys. https://discord.gg/blacksharkden/ Link to comment Share on other sites More sharing options...
Naj-Treg Posted September 23, 2020 Author Share Posted September 23, 2020 (edited) To add to your spawn: :InitRandomizeTemplate(templatetable) :InitRandomizeZones(zonetable) :SpawnScheduled(n,n) ----- See the moose SPAWN class documentation for the particulars, but this is what you need I think. A scheduler isn't necessary at all here. Tnx for the reply! I tried that too... but that stopped the whole spawning...even with 1 plane group. And now even my working script does not work anymore...:doh: Scripting can be so much fun:music_whistling::lol: I often make use of the sample missions and then do some reversed engineering. This script comes from one of the sample missions and had the scheduler in the script, I take it out and see what it does. I am at the beginning stage of scripting and have alot to learn, but i like it. Tnx for the advice. Gonna try some more.:thumbup: Naj-Treg Edited September 23, 2020 by Naj-Treg Link to comment Share on other sites More sharing options...
Naj-Treg Posted September 24, 2020 Author Share Posted September 24, 2020 Got it working. Now expanding from this. :thumbup: Naj-Treg Link to comment Share on other sites More sharing options...
gavagai Posted September 24, 2020 Share Posted September 24, 2020 Mind showing the fix, please? P-51D | Fw 190D-9 | Bf 109K-4 | Spitfire Mk IX | P-47D | WW2 assets pack | F-86 | Mig-15 | Mig-21 | Mirage 2000C | A-10C II | F-5E | F-16 | F/A-18 | Ka-50 | Combined Arms | FC3 | Nevada | Normandy | Straight of Hormuz | Syria Link to comment Share on other sites More sharing options...
Naj-Treg Posted September 24, 2020 Author Share Posted September 24, 2020 Mind showing the fix, please? Well... it was not just a fix... I adjusted the mission units and the script. For what it now does..... It spawns a random number of planes in the spawnzones. These planes follow the route set by template (SPAWN_PLANE_1) and will be randomized plane types set to the templates (AXIS_RAND_TEMPLATE_1, AXIS_RAND_TEMPLATE_, etc) Il put in here the mission and the lua file.Test.mizScript test.lua Link to comment Share on other sites More sharing options...
Naj-Treg Posted September 24, 2020 Author Share Posted September 24, 2020 For now i would like to add more routes who will be rondom selected and will random select the unit type..... But that i still have to figure out.. Naj-Treg Link to comment Share on other sites More sharing options...
gavagai Posted September 24, 2020 Share Posted September 24, 2020 Thanks, always interesting to see what others have done. P-51D | Fw 190D-9 | Bf 109K-4 | Spitfire Mk IX | P-47D | WW2 assets pack | F-86 | Mig-15 | Mig-21 | Mirage 2000C | A-10C II | F-5E | F-16 | F/A-18 | Ka-50 | Combined Arms | FC3 | Nevada | Normandy | Straight of Hormuz | Syria Link to comment Share on other sites More sharing options...
Recommended Posts