mrSkortch / MissionScriptingTools

Mission Scripting Tools for Digital Combat Simulator
GNU General Public License v3.0
190 stars 42 forks source link

Aircraft groups "go dumb" after respawnInZone() or teleportInZone() #56

Closed ColdFrontWI closed 3 years ago

ColdFrontWI commented 3 years ago

I am trying to randomize the spawn location of aircraft groups. I can make them spawn at a random location or move them to a random location after spawning (using respawnInZone() or teleportInZone(), respectively), but after this they "go dumb." They slowly descend to ~200' agl and eventually crash into the ground if there's a terrain rise. They don't follow flight plan, and don't engage.

The same groups work fine if I spawn them at their ME-specified starting point with respawnGroup(). Is there any fix or workaround for this?

Thanks!

mrSkortch commented 3 years ago

The respawn/clone/teleportInZone functions aren't really meant to be used with aircraft since it doesn't reassign or modify their route in anyway. Its relatively inconsequential to the route if they just started randomly in an area and then flew to exactly the same point. But push comes to shove you can use the same function that all of those functions use to do most of the work. You just have to populate some of the values that respawnInZone would have populated.

https://wiki.hoggitworld.com/view/MIST_teleportToPoint

Something like this should do the trick.

local rndPoint = mist.getRandomPointInZone('zoneName', radius)
mist.teleportToPoint({action = 'respawn', point = rndPoint, groupName = 'groupName',  route = mist.getGroupRoute('groupName', true) })