Jump to content
Sign in to follow this  
1para{god-father}

Random Town Pos but x distance away from Marker

Recommended Posts

I am selecting a random Town but I need it to not be near to my marker i.e "Respawn_west" so approx 1200 away

How can i do that ?

	_towns = nearestLocations [getPosATL player, ["NameVillage","NameCity","NameCityCapital","StrongPoint"], 15000];
	_pos = position (_towns select (floor (random (count _towns))));

Share this post


Link to post
Share on other sites
_towns = nearestLocations [getPosATL player, ["NameVillage","NameCity","NameCityCapital","StrongPoint"], 15000];

_myTown = someTown;
_minDistanceFrom = 1200;
_filtered = [];

{
  if (_x distance _myTown > _minDistanceFrom) {
     _filtered set [count _filtered, _x];
  };
} forEach _towns;

_randomFarAwayTown = _filtered select (floor (random (count _filtered)));

//_randomFarAwayTown

Edited by neokika
Corrected mistake!

Share this post


Link to post
Share on other sites

Thanks

If i want to use a marker would I have to use getmarkerpos ?

_myTown =getmarkerpos "respawn_west";

or an object

_myTown = objectName

Share this post


Link to post
Share on other sites

Getting an error but cannot work out why ?

Error in expression <_x distance _myTown > _minDistanceFrom) {
_filtered set [count _filtered, _x];
}>
 Error position: <{
_filtered set [count _filtered, _x];
}>
 Error Missing ;

Share this post


Link to post
Share on other sites

_towns = nearestLocations [getPosATL player, ["NameVillage","NameCity","NameCityCapital","StrongPoint"], 15000];

_myTown = mhq_safe;  ///  object at start position
_minDistanceFrom = 1200;
_filtered = [];

{
  if (_x distance _myTown > _minDistanceFrom) {
     _filtered set [count _filtered, _x];
  };
} forEach _towns;

_pos= position _filtered select (floor (random (count _filtered)));

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
Sign in to follow this  

×