ZeroG 23 Posted October 16, 2016 Hello @all! I have an array of markers which I like to check against in a 10 sec while loop instead of using too many 0.5 sec triggers on the map. I'd like to check all markers in that very array against all units on my side for distance between each other and add all "positive markers" into an array. My attempts have led me to the code that can be seen below. With that script however, only the markers get stored that are close to one of my units, not the entire side. I assume I have to do sth about the double forEach-loop ?! or does anyone have an even better idea how to achieve what I'm looking for? Help is much appreciated! _Friendly = []; {if ((side _x) == WEST) then {_Friendly pushBack _x}} forEach allUnits; _CloseMarkers = []; {if ( ({_x} forEach _Friendly) distance (getmarkerpos _x) < 2000) then {_CloseMarkers pushBack _x} } forEach ZONEMARKERS; Share this post Link to post Share on other sites
theend3r 83 Posted October 16, 2016 ( ({_x} forEach _Friendly) distance (getmarkerpos _x) < 2000) seems rather strange and is probably the reason for your problems. Something like { if (call compile ["{_x distance2D (getmarkerpos %1) < 2000} count _friendly > 0", _x]) then {_CloseMarkers pushBack _x} } count ZONEMARKERS; should work but is very messy. I bet there are better solutions. Edit: Do you want to pushBack markers that include at least 1 blufor or only a marker that has all blufor units inside? If the latter, then just change the >0 to == number_of_blufor_units. Share this post Link to post Share on other sites
ZeroG 23 Posted October 16, 2016 Seems I figured out a workaround with BIS_fnc_nearestPosition, not 100% what I wanted but also suiting my purpose: //LOCATION CHECK LOOP FOR EACH UNIT OF A SPECIFIC SIDE MYLOCATIONS = [[x1,y1,z1],[x2,y2,z2],...]; //Can be markers/objects as well. If so, then getmarkerpos/getpos _NearestLocation has to be used at the distance check line below. CLOSELOCATIONS = []; while {true} do { _NearestLocation = []; { if ((side _x) == west) then { _NearestLocation = [MYLOCATIONS , _x] call BIS_fnc_nearestPosition; if (_x distance NearestLocation < 1250) then { CLOSELOCATIONS pushBack _NearestLocation ; //fill array with new item MYLOCATIONS = MYLOCATIONS - [_NearestLocation]; //remove item from original array if repeated script execution is unwanted }; } } forEach allUnits; sleep 20; //adapt as needed }; Share this post Link to post Share on other sites