fn_findNearestBase.sqf 706 B

123456789101112131415161718192021222324252627282930313233
  1. private ["_this", "_pos", "_blacklist", "_min", "_base", "_dist"];
  2. _pos = [_this,0,[0,0,0],[[],objNull],[2,3]] call BIS_fnc_param;
  3. _blacklist = [_this,1,[],[[]]] call BIS_fnc_param;
  4. _side = [_this,2,"",[WEST]] call BIS_fnc_param;
  5. if (typeName _pos == "OBJECT") then { _pos = getPos _pos; };
  6. _min = 1e9;
  7. _base = "";
  8. {
  9. _dist = ((markerPos _x) distance _pos);
  10. if (_dist < _min && !(_x in _blacklist)) then
  11. {
  12. if (typeName _side != "STRING") then
  13. {
  14. if (_side == WEST && _x in basesOwned) then
  15. {
  16. _min = _dist;
  17. _base = _x;
  18. }
  19. else if (!(_x in basesOwned)) then
  20. {
  21. _min = _dist;
  22. _base = _x;
  23. };
  24. } else {
  25. _min = _dist;
  26. _base = _x;
  27. };
  28. };
  29. } forEach allBases;
  30. _base