Jump to content
fn_Quiksilver

Finding a safe spawn position in wooded area

Recommended Posts

Hi guys,

 

Trying to design a function to find a safe spawning position for units/vehicles, which doesn't see trees/vegetation as obstructions. For instance most spawn systems use isFlatEmpty, but isFlatEmpty sees terrain objects like trees as obstructions.

 

Trying to create an object/unit spawning system for Tanoa, which doesnt mind spawning stuff in wooded areas.

 

Will post workings and solution here, as I think it will have some utility for a lot of scenario designers.

 

https://community.bistudio.com/wiki/nearestTerrainObjects

https://community.bistudio.com/wiki/selectBestPlaces

https://community.bistudio.com/wiki/isFlatEmpty

Share this post


Link to post
Share on other sites

Sorry for the bit off topic but... are you able to edit with Tanoa??? If so, how to?

Share this post


Link to post
Share on other sites

Sorry barb, I think he means to say he is preparing for Tanoa's green spawning hell.

Looking forward to see what you come up with @mdcclxxvi.

Share this post


Link to post
Share on other sites

oh!

 

well, I'm very used to findEmptyPosition and BIS_fnc_findSafePos, but I think those don't ignore trees.

 

A possible solution could be, if findEmpyPosition returns [], then select a random position and literally hideObject the nearby trees, like "we didnt had enough space and we had to chop down this trees to buy this tank"

Share this post


Link to post
Share on other sites

It has to be selectBestPlaces
 

_position = position player; 
_radius = 1500; 
_options = "+trees +forest*10 -meadow"; 
_result = selectBestPlaces [_position, _radius, _options, (_radius / 10) min 500, 100]; 
_pos = _result select 0 select 0;  
player setPos _pos;
  • Like 1

Share this post


Link to post
Share on other sites

Pretty much what KK said,

if you look at the wiki entry and go through ruebes thread you can set it up to find a great variety of possible locations.

This is probably the best command to get some variation regarding random locations.

 

Cheers

Share this post


Link to post
Share on other sites

 

It has to be selectBestPlaces

 

_position = position player; 
_radius = 1500; 
_options = "+trees +forest*10 -meadow"; 
_result = selectBestPlaces [_position, _radius, _options, (_radius / 10) min 500, 100]; 
_pos = _result select 0 select 0;  
player setPos _pos;

 

unfortunately we need more than this to determine the position is safe to spawn groups and compositions. for instance testing terrain gradient and ensuring no rocks/cliffs/etc nearby. I dont necessarily want to find a position in vegetation, just want a function like 'BIS_fnc_findSafePos' which will disregard trees and not see them as obstructions.

 

At the moment I am thinking to use isFlatEmpty but to set the nearby objects param to -1, and instead use some nearestterrainobjects or nearobjects check to ensure no non-tree obstructions at the checked position.

Share this post


Link to post
Share on other sites

isflatempty is the most simple and effective way. The recognition of trees and large rocks is a good thing and is the only clear position command that can identify those objects. Setting the first param to say 5 will find a nice clear spot of 5 meter radius. Just keep in mind and build alternative construct in the case that isflatempty returns nothing because it could not find an area with your requirements such as changing start position, lessening first parameter or use less effective/different clear position command. I use it alot since arma 2 for things like finding areas for compositions or spawning a suicide bomber.

Share this post


Link to post
Share on other sites

well I'm currently using

_spawnpos = nil;
while {true} do {
scopeName "SpawnPosGen";
_randir = floor(random 360);
_randis = _mindis + floor(random _radius);
_spawnpos = [(_markpos select 0) + ((sin _randir) * _randis), (_markpos select 1) + ((cos _randir) * _randis), 0.1];
_houses = nearestObjects [_spawnpos, ["house","wall"], 50];
_vehicles = nearestObjects [_spawnpos, ["LandVehicle", "Land_BagBunker_01_Large_green_F", "Land_TTowerBig_2_F"], 20];
_isFlat = _spawnpos isFlatEmpty [10, -1, 0.5, 10, 0, false, HaloFlag ]; 
_danger = false;
{ if (floor(_spawnpos distance getPos _x) < 20) then { _danger=true; }; } forEach _houses;
{ if (floor(_spawnpos distance getPos _x) < 10) then { _danger=true; }; } forEach _vehicles;
if (surfaceIsWater _spawnpos) then { _danger=true; };
if (count _isFlat < 1 ) then { _danger=true; };
if (!_danger) then { breakOut "SpawnPosGen" };
};

To find a fairly flat location.. on the map in an area however since APEX release and moving to the new map .. this is not working as there are really big hills.. 

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

×