Jump to content
BlackbirdSD

Rectangular unit placement radius

Recommended Posts

For me the most useful thing for making my missions is to have the ability to place units randomly within a rectangle instead of just a circle.  Is there a way to lay down a trigger, shaped how I want then have a unit randomly start within that trigger shape?

Share this post


Link to post
Share on other sites

Yes.

As you know, most of the commands/functions for placing/spawning/moving something in an area, refers to the radius. For example, Bis_fnc_findSafePos   findEmpyPosition    but also selectBestPlaces , waypoints completion radius...

With a rectangle, no more radius question. You can compare x,y coordinates... but that means a North oriented rectangle.

 

So, what I do, is to manage a randomized position inside a usual circled area (larger than rectangle), with a looped condition exiting  for this position inside the rectangle.

 

something like:

private _pos = [0,0,0];

While {! (_pos inArea _myRectangle)} do { _pos = _centerOfArea getPos [_circleRadius * sqrt random 1, random 360]; _pos};

 

 

Share this post


Link to post
Share on other sites
17 hours ago, BlackbirdSD said:

Is there a way to lay down a trigger, shaped how I want then have a unit randomly start within that trigger shape?

BIS_fnc_randomPosTrigger

Unit init...

if ( isServer ) then {
	this setPos ( [ myTrigger ] call BIS_fnc_randomPosTrigger );
};

Where myTrigger is the name given to your trigger

 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Larrow said:

BIS_fnc_randomPosTrigger

Unit init...


if ( isServer ) then {
	this setPos ( [ myTrigger ] call BIS_fnc_randomPosTrigger );
};

Where myTrigger is the name given to your trigger

 

Perfect thanks.  I hope if they make an Arma 4 they will just include a placement rectangle to make it easier.  

Share this post


Link to post
Share on other sites

Yes, BIS_fnc_randomPosTrigger is not too bad, and definitely better than whitelisting in  BIS_fnc_randomPos.

 

Now, for performance, may I suggest you to compare:

[ myTrigger ] call BIS_fnc_randomPosTrigger;

 

and

private _pos = [0,0,0];
_circleRadius = 1.42 * ((triggerArea myTrigger #0) max (triggerArea myTrigger #1));
While {! (_pos inArea myTrigger)} do { _pos = myTrigger getPos [_circleRadius * sqrt random 1, random 360]; _pos};

 

 

Share this post


Link to post
Share on other sites
5 hours ago, pierremgi said:

Yes, BIS_fnc_randomPosTrigger is not too bad, and definitely better than whitelisting in  BIS_fnc_randomPos.

 

Now, for performance, may I suggest you to compare:

[ myTrigger ] call BIS_fnc_randomPosTrigger;

 

and

private _pos = [0,0,0];
_circleRadius = 1.42 * ((triggerArea myTrigger #0) max (triggerArea myTrigger #1));
While {! (_pos inArea myTrigger)} do { _pos = myTrigger getPos [_circleRadius * sqrt random 1, random 360]; _pos};

 

 

What do you mean by test for performance?  See which one works better?

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

×