From e12d1702f0a0756a55780f9faa8eb4f2d924afbd Mon Sep 17 00:00:00 2001 From: Eero af Heurlin Date: Sun, 13 Jun 2021 16:21:01 +0300 Subject: [PATCH] Use @mija s lzselect code, probably fixes #4 --- helotraining_mp.Altis/selectLZ.sqf | 51 +++++++----------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/helotraining_mp.Altis/selectLZ.sqf b/helotraining_mp.Altis/selectLZ.sqf index 8fa8216..fdf5beb 100644 --- a/helotraining_mp.Altis/selectLZ.sqf +++ b/helotraining_mp.Altis/selectLZ.sqf @@ -1,45 +1,16 @@ -//diag_log format["selectLZ called, _this: %1", _this]; -private _excludeList = _this select 0; -private _returnValue = false; +params [["_excludeList", []]]; private _candidates = lzList; -if (!(_excludeList isEqualTo false)) then -{ - _candidates = _candidates - _excludeList; -}; -private _taskLocations = []; -{ - [_taskLocations, ([_x] call BIS_fnc_taskDestination)] call BIS_fnc_arrayPush; -} forEach ([west] call getSideActiveTasks); -scopeName "main"; -private _i = 0; -while {true} do -{ - scopeName "selectloop"; - private _usable = true; - private _candidate = _candidates call BIS_fnc_SelectRandom; - { - scopeName "checkloop"; - private _dist = _candidate distance _x; - if (_dist < LZMinDistace) then - { - _usable = false; - breakOut "checkloop"; - }; - } forEach _taskLocations; - if (_usable) then - { - _returnValue = _candidate; - breakOut "selectloop"; - }; - _i = _i + 1; - if (_i > LZCOUNT) then - { - _returnValue = false; - breakOut "selectloop"; - } +if (_excludeList isEqualType []) then +{ + _candidates = _candidates - _excludeList; }; -//diag_log format["selectLZ returning: %1", _returnValue]; -_returnValue \ No newline at end of file +private _taskLocations = [west] call getSideActiveTasks apply { [_x] call BIS_fnc_taskDestination }; + +for "_i" from 0 to LZCOUNT do { + private _candidate = selectRandom _candidates; + if (_taskLocations findIf { _x distance _candidate < LZMinDistace } == -1 && { allPlayers findIf { _x distance _candidate > LZMaxDistace } == -1 }) exitWith { _candidate }; + false +} \ No newline at end of file