Jump to content

Function to randomly select a route


Bushmanni

Recommended Posts

I happened to have a problem of randomizing routes of groups and figured a very simple and easy to use way to do it and decided to share it as I'd like to see this more on other peoples missions too.

 

Basically there's only one function that you give the name of the group, names of the groups with routes in a table and optionally a number of the new route. Example: You have a group "test" with some waypoints. You add "run script" command to the last wp 'selectRoute("test", {"opt1", "opt2", "opt3"});'. "opt1", "opt2" and "opt3" are the groupnames of the units with alternate routes and each of the alternate route groups have their #1 wp close to the last wp of the group "test". The function will pick one of the routes of the provided groups and start from wp #1. The function uses mist.getGroupRoute so it preserves all the information that it can grab except whats in the first waypoint.

 

I haven't yet tested if enroute tasks are preserved from previous route or if you need to reassign them at the first wp of the new route. I have attached example mission which should demonstrate how to use this.

selectRoute example.miz

route.lua


Edited by Bushmanni
Updated route.lua
  • Like 1

DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community

--------------------------------------------------

SF Squadron

Link to comment
Share on other sites

My only issue with get route anything is the issue AI have with bridges. My random routes - when I use them- are generally established through random spawning of groups with the same makeup and same destination with different route- but I think all of us would love a function that reliably mixed it up without having to do that.

 

Keep in mind there are also issues with random zone spawn and group to random zone / teleport etc... In that the servers can see but the clients can't. This causes issues when- what it looks like- an AI unit on the server is killed or affected and the clients don't have that unit... Causes a crash. (My assessment of it)

 

So if you have problems with your function I'm just saying it might not be your function that isn't working.

"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

There was a bug that made the newly assigned route lose it's tasks, ie. you couldn't daisy chain routes. I fixed the problem and updated the lua file in first post.

 

Using the function in following way will make the route unit-independent, ie. you can send whatever group through the route and it will randomly pick a new route at the end of it. This makes it possible to send multiple groups to the same route network. You can also build routes that link back to other routes in the network and when you send groups to one of the routes it will keep randomly driving around the network indefinitely.

local thisGroup = ...
groupname = thisGroup:getName();
selectRoute(groupname, {"opt1", "opt2", "opt3"});

DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community

--------------------------------------------------

SF Squadron

Link to comment
Share on other sites

  • Recently Browsing   0 members

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