FlightControl-Master / MOOSE

Mission Object Oriented Scripting Environment (MOOSE) for lua mission scripting design in DCS World
http://flightcontrol-master.github.io/MOOSE/
GNU General Public License v3.0
290 stars 94 forks source link

Spawn all unit randomly inside a zone #2069

Closed MrAlien753 closed 8 months ago

MrAlien753 commented 8 months ago

Spawn all unit randomly inside a zone, instead of only the first unit in zone and the other within a radius (potentially outside the zone, and in some cases in the middle of a runway)

Applevangelist commented 8 months ago

Thanks for that! Now, before we go off trying n*20 to find a coordinate in a zone, can we ensure the zone is big enough? Else this could get costly.

MrAlien753 commented 8 months ago

Good remark indeed. We have two option to solve this issue:

  1. if radius is bigger that bounding box then reduce radius. But this results in units to be always close together when we have a very thin but elongated zone in the horizontal or vertical direction and this will not help if the zone on at an angle (ie. 45 degrees)
  2. Alternate between trying random point within radius and random point in zone.

We can also reduce the number or tries. At the end the unit will be inside the zone anyway. It might not be within a radius but this is typically less important. (except for SAM systems maybe).

FYI, I do see quite some inefficiencies inside the code. Maybe we should try to solve those as well. Not sure about Lua but in most languages it is better to use:

Actually what is the best way to measure performance of your mission?