Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
_isSafePos = false;
_minDist = 250;
_building = objNull;
_itterations = 0;
_maxItterations = 5;
while {!_isSafePos && _itterations < _maxItterations} do {
_players = allPlayers - entities "HeadlessClient_F";
_alivePlayers = [];
_playerPositions = [];
{
if (alive _x) then {
_alivePlayers = _alivePlayers + [_x];
_playerPositions = _playerPositions + [getPos _x];
};
} forEach _players;
_centerPos = selectRandom _playerPositions;
_safePos = [_centerPos, _minDist, 5000, 1, 0, 1, 0, _playerPositions, [_centerPos, _centerPos]] call BIS_fnc_findSafePos;
_buildings = nearestObjects [_safePos, ["house"], _minDist];
_building = _buildings select 0;
_buildingPos = getPos _building;
_minDistanceToAllPlayers = true;
{
if((_buildingPos distance _x) < _minDist) {
_minDistanceToAllPlayers = false;
}
} forEach _alivePlayers;
_isSafePos = _minDistanceToAllPlayers;
_itterations = _itterations + 1;
};
_building
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment