KungFu Posted March 7, 2018 Posted March 7, 2018 Ok, so I've been struggling with MOOSE on this and wondering if someone can give me a bit of help here. So what I want to do is spawn a group of vehicles randomly in one or more zones and then route them to another random point in another zone. Here is what I have: GroundOrgZones = { ZONE:New("Zone 1"), ZONE:New("Zone 2") } SpawnRandomCCCPConvoy = SPAWN:New( "CCCP Convoy 2" ) :InitLimit( 10, 10 ) :InitRandomizeRoute( 1, 1, 200 ) :InitRandomizeZones( GroundOrgZones ) :SpawnScheduled( 5, .5 ) GroundUnits = GROUP:FindByName( "CCCP Convoy 2" ) GroundUnits:TaskRouteToZone( "Sochi Zone",Randomize,50,"Vee") The units spawn ok, but don't move. I've tried soooo many different methods based on the videos and can't get any of it to work. Some methods in the videos and sample missions seem to be outdated (or at least not in intellisense) What I get in DCS log with this: 21609: attempt to call method 'GetVec2' (a nil value) If I can just get something like this going I'll be 90% done with an almost entirely dynamic mission that my buddies have been asking for in DCS for years. :) Win 11 Professional, I9-14700K, 64GB DDR5, 4090, 2x 980 PRO PCIe 4.0 NVMe , 2x VKB Gunfighter mk III, MCG Ultimate, SCG, Orion 2 Throttle, Thrustmaster TPR pedals, Pimax Crystal
funkyfranky Posted March 7, 2018 Posted March 7, 2018 Try this: SpawnRandomCCCPConvoy = SPAWN:New( "CCCP Convoy 2" ) :InitLimit( 10, 10 ) :InitRandomizeRoute( 1, 1, 200 ) :InitRandomizeZones( GroundOrgZones ) :OnSpawnGroup( function( SpawnGroup ) SpawnGroup:TaskRouteToZone( ZONE:New("Sochi Zone"), true, 50, "Vee") end) :SpawnScheduled( 5, .5 ) To explain: 1.) TaskRouteToZone needs a MOOSE zone as first parameter not just the name of the zone. 2.) You need a callback function :OnSpawnGroup(). Just giving the TaskRouteToZone right after the spawn command will not work, since it is only executed once and the spawned groups might not be alive yet. Sorry, it's from the top of my head. Hope it works or guides you in the right direction :) A warrior's mission is to foster the success of others. i9-12900K | RTX 4090 | 128 GB Ram 3200 MHz DDR-4 | Quest 3 RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss
KungFu Posted March 7, 2018 Author Posted March 7, 2018 That worked perfectly, much appreciated. I even was able to change the formation to "On Road" and they spawn randomly and make their way to the closest road .... excellent. Now time to get more creative :) edit: The forum is changing my text for some reason Win 11 Professional, I9-14700K, 64GB DDR5, 4090, 2x 980 PRO PCIe 4.0 NVMe , 2x VKB Gunfighter mk III, MCG Ultimate, SCG, Orion 2 Throttle, Thrustmaster TPR pedals, Pimax Crystal
skunk160 Posted March 8, 2018 Posted March 8, 2018 That worked perfectly, much appreciated. I even was able to change the formation to "On Road" and they spawn randomly and make their way to the closest road .... excellent. Now time to get more creative :) edit: The forum is changing my text for some reason lemme know if you want to share this mission once your happy with it :music_whistling: skunk160 | Win10 PRO 64bit | i7-4770K 3.50 GHz | 32GB DDR3/1866MHz | GIGABYTE GeForce GTX 1080 x2 | Oculus Rift S | Virpil MongoosT-50CM2 | Virpil F-14B grip | Virpil 200m Curved Extension | PointCTRL | Delta Sim TM Slew | Sim Bandit AHCP | MFG Crosswind Pedals | //FOX2 Switch Boxes | RECARO SPG Seat | AuraSound AST-2B-4 Pro Bass Transducer x2 //FOXTWO Multi-Role Combat Pit Build http://forums.eagle.ru/showthread.php?t=134745
KungFu Posted March 11, 2018 Author Posted March 11, 2018 lemme know if you want to share this mission once your happy with it :music_whistling: That is the plan, but the lua/moose struggle is real... :megalol: Win 11 Professional, I9-14700K, 64GB DDR5, 4090, 2x 980 PRO PCIe 4.0 NVMe , 2x VKB Gunfighter mk III, MCG Ultimate, SCG, Orion 2 Throttle, Thrustmaster TPR pedals, Pimax Crystal
fargo007 Posted March 11, 2018 Posted March 11, 2018 Maybe to move you a step further, you could randomize the zone chosen like this: z1 = ZONE:New("zone 1") z2 = ZONE:New("zone 2") z3 = ZONE:New("zone 3") ... zonetable = { z1, z2, z3 } randomzone = zonetable[math.random(1,#zonetable)] --lua table index starts from 1, not zero ... SpawnGroup:TaskRouteToZone( randomzone, true, 50, "Vee") ... Have fun. Don't suck. Kill bad guys. https://discord.gg/blacksharkden/
KungFu Posted March 11, 2018 Author Posted March 11, 2018 (edited) Actually I put that feature in just today. What I need a bit of help on is I want the units to travel to the zone on road (Because off road travel in DCS is kinda hokey without waypoints). Then I would like the units to decide randomly on whether to move off road to a random formation/point in the zone and wait, or patrol the zone in a random formation. And I'm not sure if that is possible or how to do it exactly. So there is in OnSpawnGroup....but how to control the group after the taskroutetozone is complete? I also would like to setup zones as capture zones, but it seems like ZONE_CAPTURE_COALITION is not being recognized as an object in 2.2.6 when I do: ZoneCaptureCoalition = ZONE_CAPTURE_COALITION:New( ZONE:New( "Soloniki Zone" ), coalition.side.RED ) So not sure what the problem is there. GroundFrontLineZonesWest = { ZONE:New("Hadzhiko Zone"), ZONE:New("Ashe Zone"), ZONE:New("Lazarevskoe Zone"), ZONE:New("Soloniki Zone") } FrontLineZones = { ZONE:New("Hadzhiko Zone"), ZONE:New("Ashe Zone"), ZONE:New("Lazarevskoe Zone"), ZONE:New("Shahe Zone"), ZONE:New("Sochi Zone"), ZONE:New("Soloniki Zone"), ZONE:New("Chemitokvadze Zone"), ZONE:New("Dagomys Zone") } Formation = { "Off Road", "On Road", "Line Abreast", "Cone", "Vee", "Diamond", "Echelon Left", "Echelon Right"} GroundUnitsFrontLineWest = SPAWN:New( "CCCP Convoy 2" ) :InitLimit( 40, 100 ) :InitRandomizeRoute( 1, 1, 200 ) :InitRandomizeZones( GroundFrontLineZonesWest ) :OnSpawnGroup ( function (SpawnGroup) ChosenZone = FrontLineZones[ math.random(1, 8) ] SpawnGroup:TaskRouteToZone( ChosenZone, true, 50, "On Road") end) :SpawnScheduled( 5, .5 ) Edited March 11, 2018 by KungFu Win 11 Professional, I9-14700K, 64GB DDR5, 4090, 2x 980 PRO PCIe 4.0 NVMe , 2x VKB Gunfighter mk III, MCG Ultimate, SCG, Orion 2 Throttle, Thrustmaster TPR pedals, Pimax Crystal
fargo007 Posted March 11, 2018 Posted March 11, 2018 (edited) Just spitballin here, Another way would be to define them in the ME, and only instantiate based on the random choice itself. Put the badguy template names (created with late actv. in the ME with all the different trappings) in a table, then select one randomly from the table and instantiate & spawn it. You don't even have to use SpawnScheduled if you do it this way because you could loop it and control it that way. Unless you need a guarantee there are only X alive at a time. Or create a function that spawns a group with the argument to the function being the randomly chosen template name. Edited March 11, 2018 by fargo007 Have fun. Don't suck. Kill bad guys. https://discord.gg/blacksharkden/
Recommended Posts