Skip to content

Instantly share code, notes, and snippets.

@Gummibeer
Created February 23, 2017 10:46
Show Gist options
  • Save Gummibeer/16bf61f698a8ca5c08717c5c6a038f91 to your computer and use it in GitHub Desktop.
Save Gummibeer/16bf61f698a8ca5c08717c5c6a038f91 to your computer and use it in GitHub Desktop.
_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