Created
September 12, 2015 09:26
-
-
Save headswe/483a44e4e604cfb76a67 to your computer and use it in GitHub Desktop.
Cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_getCluster = { | |
private ["_clusters","_checkedMen","_distanceMaX","_cluster","_unit"]; | |
_clusters = []; | |
_checkedMen = []; | |
_distanceMaX = 35; | |
{ | |
if(!(_x in _checkedMen)) then | |
{ | |
_cluster = [_x]; | |
_unit = _x; | |
_checkedMen pushBack _x; | |
{ | |
if(_x distance2d _unit < _distanceMaX && _x != _unit) then | |
{ | |
_cluster pushBack _x; | |
_checkedMen pushBack _x; | |
}; | |
} foreach units group player; | |
_clusters pushback _cluster; | |
}; | |
} foreach units group player; | |
_clusters | |
}; | |
_clusters = [] call _getCluster; | |
{ | |
_clusters set [_foreachindex,[count _x,_x]]; | |
} _clusters; | |
_clusters sort true; | |
_cluster = (_clusters select 0) select 1; | |
_pos = [0,0,0]; | |
{ | |
_pos vectoradd (getpos _x); | |
} foreach _cluster; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment