Jump to content
flyingsaucerinvasion

Finding TOTALLY empty position

Recommended Posts

Need help coming up with a solution to this problem.

 

The requirements are:

 

1) Returned Position must be relatively flat.  (i.e., not at a great slope, and not at the apex of a ridge or mountain).

 

2) Returned Position should be as close to the target Position as possible.  (No returning positions hundreds of meters away when ones much closer would also meet the criteria).

 

Most importantly:

 

3) Returned Position must be totally and completely devoid of anything that could possibly cause a collision issue.  This includes, map objects, editor objects, moving objects (men and vehicles), as well as structures (buildings, ammo boxes, etc....) spawned in during the mission.

 

4) Position must be large enough to fit vehicles of any specific type.

 

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

 

I've got partial solutions to this problem that work most of, but not all of the time.  And they fail all of the above requirements some of the time.

 

Share this post


Link to post
Share on other sites

Explore the map and find all the suitable positions.

 

Place a marker at each position.

 

Link the markers to the vehicle.

 

Every time the mission starts, he will start on one of the markers selected at random.

Share this post


Link to post
Share on other sites

This can be used in debug console. Its working and tested.

just point to an object. Its position is the search start position.

Player gets teleported to the position which fullfills the requirements:

// diameter of the flat, empty area you are searching for
private _posMaxWidth = 50;

// position to start at
private _center = getPos cursorObject; // [ 3727.84, 13759.1, 0.496591 ];

// radius of the area you are searching at
private _abortDist = 1000;

// gradient (bumpiness [0.0 ... 1.0] ) of the area you are searching for
private _maxGrad = 0.1;

private _dblPosMaxWidth = 2 * _posMaxWidth;

private _objDist = _posMaxWidth * 0.5;
private _maxDist = _objDist;

private _minDist = 0;

private _invalidPos = [ 0, 0, 0 ];
private _pos = _invalidPos;

private _waterMode = 0;
private _shoreMode = 0;

private _blacklistPos = [];
private _defaultPos = [ _invalidPos, _invalidPos ];


// Start of the search in the immediate vicinity of the starting point and expansion of the search area as long as no suitable area has been found.
while { (_pos isEqualTo _invalidPos) and (_maxDist < _abortDist) } do
{
 _pos = [ _center, _minDist, _maxDist, _objDist, _waterMode, _maxGrad, _shoreMode, _blacklistPos, _defaultPos ] call BIS_fnc_findSafePos;

 _maxDist = _maxDist + _posMaxWidth;
  
 //Exclude already searched areas from a new search.
 _minDist = if ( _maxDist > _dblPosMaxWidth ) then { _maxDist - _dblPosMaxWidth } else { 0 }; 
};

// check the result
if ( _pos isEqualTo _invalidPos ) then
{
	hint format [ "No suitable area found within a radius of %1m.", _abortDist ];
} else
{
	hint format [ "Position %1 meets all requirements.", _pos ];

	player setPos _pos;
};

 

  • Like 3

Share this post


Link to post
Share on other sites
10 hours ago, sarogahtyp said:

 

Unless I'm mistaken, BIS_fnc_findSafePos doesn't check for moving objects, such as men, or vehicles.  It's very important that vehicles don't spawn on top of men or other vehicles.  Sometimes it seems to also miss structures that have been spawned in during the mission, example: a warfare bunker or the hbarriers surrounding it.

 

 

 

It also seems to be my experience that BIS_fnc_findSafePos can return a position at the apex of a hill or mountain, because the apex is technically a low gradient, even though the area immediately around it is not.  This is not suitable in cases where you are looking to find a place to put a structure, because the structure's perimeter foundation may end up hovering above the ground.  Please correct me if I'm wrong about this.

Share this post


Link to post
Share on other sites

You can easily check the found area against moving vehicles and men and discard the solution within the while loop.

 

Your other cases ... yeah man work on it and u ll solve it. There is a way for nearly everything if u spend enough time on it.

Share this post


Link to post
Share on other sites
4 hours ago, flyingsaucerinvasion said:

This is not suitable in cases where you are looking to find a place to put a structure, because the structure's perimeter foundation may end up hovering above the ground.

Check the objects corner bounds at the safe position, to see if they are above ground?

Spoiler

//find safe pos as previously shown

//Spawn object at corner of map in the air
_objectToPlace = createVehicle[ "SomeObject", [0,0,1000], [], 0, "CAN_COLLIDE" ];
_objectToPlace simulationEnabled false;

//Get its geometery corners
2 boundingBoxReal _objectToPlace params[ "_mins", "_maxs" ];
_mins params[ "_minX", "_minY" ];
_maxs params[ "_maxX", "_maxY" ];

//Make sure all four corners are not above the ground
_canBePlaced = [
	_safePos vectorAdd[ _minX, _minY, 0 ],
	_safePos vectorAdd[ _minX, _maxY, 0 ], 
	_safePos vectorAdd[ _maxX, _minY, 0 ], 
	_safePos vectorAdd[ _maxX, _maxY, 0 ]
] findIf { getPosATL _x select 2 > 0 } == -1;

//Place object at safe position	
if ( _canBePlaced ) then {
	_objectToPlace setPosATL _safePos;
	_objectToPlace simulationEnabled true;
};

 

It may need to be finessed for some structures that have negative( _minZ ). You know for those buildings with a large base to prevent such things as this( floating above ground ). Anyway, should give you something to play with.

  • Like 2

Share this post


Link to post
Share on other sites

When you start testing your position finding system, this spot on Tanoa is very good for testing. Returns as a nice position in most "safe pos" systems, but for spawning objects and compositions it is quite treacherous

 

Zn2TqrU.jpeg

 

use "nearEntities" command to check for nearby moving entities, such as people and vehicles.

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

×