Jump to content
socs

Randomized Plane Paths

Recommended Posts

Im currently creating a battle royale and wondering how exactly I would go about creating random plane starting paths/routes... Any and all help is much appreciated! Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

You could use BIS_fnc_ambientFlyBy on a loop with a bunch of predefined start/finish positions that you randomly select from. I've got something that randomly picks positions a certain distance away from a central point, and uses those as start/finish positions but I'm not at home so i can't say for sure how i did it. 

  • Like 1

Share this post


Link to post
Share on other sites

We're kind of reinventing the wheel here, but...

 

I assume there will be a visible circular marker on the map that resizes during gameplay to show the play area. Let's call this marker "center". Now that it exists and has a name, you can move it around and resize it as needed using setMarkerPos and setMarkerSize.

 

When you want to spawn a supply drop plane, try something like this:

//get position of marker
_center = getMarkerPos "center";

//get radius of marker
_radius = (getMarkerSize "center") select 0;

//arbitrary distance outside marker to prevent "pop-in" of plane when spawned
_dist = (_radius + 2000);

//random start and end positions
_r1 = round (random 359);
_rand = round (random 90) - 45;
_r2 = (_r1 - 180) + _rand;

_pos1 = _center getPos [_dist, _r1];
_pos2 = _center getPos [_dist, _r2];

So, _pos1 is a random position somewhere 2000 meters outside the circle, while _pos2 is a position +/-45 degrees from its antipode. A line segment connecting the two will cross a fair portion of the circle without necessarily crossing the center point, introducing some unpredictability. Now you just need to spawn your plane at _pos1 and give it a waypoint at _pos2. You can delete your plane when it completes that waypoint or whatever. Also, you might want to setDir your plane on spawn so that it is pointing the right way:

_dir = _plane getDir _pos2;
_plane setDir _dir;

Dynamic systems like this are fun to work with, and once you get it figured out you can do a lot with them.

  • Like 1

Share this post


Link to post
Share on other sites

It's not perfect by any means, and in fact must be fixed for when the circle gets smaller than a few thousand meters in radius, else the plane could end up outside the circle entirely. Redo!

  • Like 1

Share this post


Link to post
Share on other sites

Alrighty.

 

//get marker info
_center = getMarkerPos "center";
_radius = (getMarkerSize "center") select 0;

//get random entry/exit points on perimeter of circle
_r1 = round (random 359);
_rand = round (random 90) - 45;
_r2 = (_r1 - 180) + _rand;
_pos1a = _center getPos [_radius, _r1];
_pos1b = _center getPos [_radius, _r2];

//get start/end points outside circle
_dir1 = _pos1a getDir _pos1b;
_dir2 = _dir1 - 180;
_pos2a = _pos1a getPos [2000, _dir2];  //change "2000" to whatever value works for you
_pos2b = _pos1b getPos [2000, _dir1];  //same

//get random drop point inside circle with 10% radius buffer to prevent drop too close to perimeter
_dropRange = _pos1a distance2D _pos1b;
_buffer = _radius/10;
_dropRange = _dropRange - _buffer; 
_distDrop = round (random _dropRange);
_posDrop = _pos1a getPos [_distDrop, _dir1];

 

As with all code I share here, it's a hamfisted approach, but it works:

hx1Ha3U.png

 

_pos2a is the start (spawn) point, _pos2b is the end (despawn) point, and _dropPos is the drop position. _pos1a and _pos1b (the markers on the circle perimeter) are only used in determining the other positions.

You could use isFlatEmpty or BIS_fnc_findSafePos to check if the drop position is over water, and then make the script iterate until it isn't, but that still won't guarantee that the drop won't float with the wind out over water anyway. There is probably a way to force the drop to ignore wind, but I've never looked into such a thing. I'm going to sleep now. Have fun!

  • Like 2

Share this post


Link to post
Share on other sites

@Harzach @beno_83au Thank you both for the help... I've been gone for a couple day so i apologize for the late reply...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×