Advertisement
Guest User

ffa_fnc_arrays_dist

a guest
Mar 17th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.96 KB | None | 0 0
  1.     private ["_arx", "_rad", "_cnt", "_debug", "_ref", "_pef", "_sef", "_def", "_ref1", "_pef1", "_sef1", "_def1", "_ref2", "_pef2", "_sef2",
  2.     "_def2", "_ref3", "_pef3", "_sef3", "_def3", "_ref4", "_pef4", "_sef4", "_def4", "_ref5", "_pef5", "_sef5", "_def5", "_ref6", "_pef6",
  3.     "_sef6", "_def6", "_newPos", "_otherPos", "_m"];
  4.     _arx = _this select 0; //массив
  5.     _rad = _this select 1; //радиус субмассива
  6.     _cnt = _this select 2; // минимальное кол -во в субмассиве
  7.     _debug = true;
  8.     _ref=[];
  9.     _pef=[];
  10.     _sef=[];
  11.     _def =[];
  12.     _ref1=[];
  13.     _pef1=[];
  14.     _sef1=[];
  15.     _def1 =[];
  16.     _ref2=[];
  17.     _pef2=[];
  18.     _sef2=[];
  19.     _def2 =[];
  20.     _ref3=[];
  21.     _pef3=[];
  22.     _sef3=[];
  23.     _def3 =[];
  24.     _ref4=[];
  25.     _pef4=[];
  26.     _sef4=[];
  27.     _def4 =[];
  28.     _ref5=[];
  29.     _pef5=[];
  30.     _sef5=[];
  31.     _def5 =[];
  32.     _ref6=[];
  33.     _pef6=[];
  34.     _sef6=[];
  35.     _def6 =[];
  36.    
  37.    
  38.     if ((count _arx) > 0) then
  39.     {
  40.         {
  41.             call
  42.             {
  43.                 if (((_arx select 0) distance _x) < _rad ) exitwith  
  44.                 {
  45.                     _newPos = _x;
  46.                     _ref set [count _ref,_newPos];
  47.                 };
  48.                 if (((_arx select (count _arx - 1)) distance _x) < _rad ) exitwith
  49.                 {
  50.                     _newPos = _x;
  51.                     _pef set [count _pef,_newPos];
  52.                 };
  53.                 if (((_arx select (floor((count _arx)*0.5))) distance _x) < _rad ) exitwith
  54.                 {
  55.                     _newPos = _x;
  56.                     _sef set [count _sef,_newPos];
  57.                 };
  58.                 _otherPos = _x;
  59.                 _def set [count _def,_otherPos];
  60.             };
  61.         } foreach _arx;
  62.     };
  63.     if ((count _def) > 0) then
  64.     {
  65.         {
  66.             call
  67.             {
  68.                 if (((_def select 0) distance _x) < _rad ) exitwith  
  69.                 {
  70.                     _newPos = _x;
  71.                     _ref1 set [count _ref1,_newPos];
  72.                 };
  73.                 if (((_def select (count _def - 1)) distance _x) < _rad ) exitwith
  74.                 {
  75.                     _newPos = _x;
  76.                     _pef1 set [count _pef1,_newPos];
  77.                 };
  78.                 if (((_def select (floor((count _def)*0.5))) distance _x) < _rad ) exitwith
  79.                 {
  80.                     _newPos = _x;
  81.                     _sef1 set [count _sef1,_newPos];
  82.                 };
  83.                 _otherPos = _x;
  84.                 _def1 set [count _def1,_otherPos];
  85.             };
  86.         } foreach _def;
  87.     };
  88.     if ((count _def1) > 0) then
  89.     {
  90.         {
  91.             call
  92.             {
  93.                 if (((_def1 select 0) distance _x) < _rad ) exitwith  
  94.                 {
  95.                     _newPos = _x;
  96.                     _ref2 set [count _ref2,_newPos];
  97.                 };
  98.                 if (((_def1 select (count _def1 - 1)) distance _x) < _rad ) exitwith
  99.                 {
  100.                     _newPos = _x;
  101.                     _pef2 set [count _pef2,_newPos];
  102.                 };
  103.                 if (((_def1 select (floor((count _def1)*0.5))) distance _x) < _rad ) exitwith
  104.                 {
  105.                     _newPos = _x;
  106.                     _sef2 set [count _sef2,_newPos];
  107.                 };
  108.                 _otherPos = _x;
  109.                 _def2 set [count _def2,_otherPos];
  110.             };
  111.         } foreach _def1;
  112.     };
  113.     if ((count _def2) > 0) then
  114.     {
  115.         {
  116.             call
  117.             {
  118.                 if (((_def2 select 0) distance _x) < _rad ) exitwith  
  119.                 {
  120.                     _newPos = _x;
  121.                     _ref3 set [count _ref3,_newPos];
  122.                 };
  123.                 if (((_def2 select (count _def2 - 1)) distance _x) < _rad ) exitwith
  124.                 {
  125.                     _newPos = _x;
  126.                     _pef3 set [count _pef3,_newPos];
  127.                 };
  128.                 if (((_def2 select (floor((count _def2)*0.5))) distance _x) < _rad ) exitwith
  129.                 {
  130.                     _newPos = _x;
  131.                     _sef3 set [count _sef3,_newPos];
  132.                 };
  133.                 _otherPos = _x;
  134.                 _def3 set [count _def3,_otherPos];
  135.             };
  136.         } foreach _def2;
  137.     };                             
  138.     if ((count _def3) > 0) then
  139.     {
  140.         {
  141.             call
  142.             {
  143.                 if (((_def3 select 0) distance _x) < _rad ) exitwith  
  144.                 {
  145.                     _newPos = _x;
  146.                     _ref4 set [count _ref4,_newPos];
  147.                 };
  148.                 if (((_def3 select (count _def3 - 1)) distance _x) < _rad ) exitwith
  149.                 {
  150.                     _newPos = _x;
  151.                     _pef4 set [count _pef4,_newPos];
  152.                 };
  153.                 if (((_def3 select (floor((count _def3)*0.5))) distance _x) < _rad ) exitwith
  154.                 {
  155.                     _newPos = _x;
  156.                     _sef4 set [count _sef4,_newPos];
  157.                 };
  158.                 _otherPos = _x;
  159.                 _def4 set [count _def4,_otherPos];
  160.             };
  161.         } foreach _def3;
  162.     }; 
  163.     if ((count _def4) > 0) then
  164.     {
  165.         {
  166.             call
  167.             {
  168.                 if (((_def4 select 0) distance _x) < _rad ) exitwith  
  169.                 {
  170.                     _newPos = _x;
  171.                     _ref5 set [count _ref5,_newPos];
  172.                 };
  173.                 if (((_def4 select (count _def4 - 1)) distance _x) < _rad ) exitwith
  174.                 {
  175.                     _newPos = _x;
  176.                     _pef5 set [count _pef5,_newPos];
  177.                 };
  178.                 if (((_def4 select (floor((count _def4)*0.5))) distance _x) < _rad ) exitwith
  179.                 {
  180.                     _newPos = _x;
  181.                     _sef5 set [count _sef5,_newPos];
  182.                 };
  183.                 _otherPos = _x;
  184.                 _def5 set [count _def5,_otherPos];
  185.             };
  186.         } foreach _def4;
  187.     };
  188.     if ((count _def5) > 0) then
  189.     {
  190.         {
  191.             call
  192.             {
  193.                 if (((_def5 select 0) distance _x) < _rad ) exitwith  
  194.                 {
  195.                     _newPos = _x;
  196.                     _ref6 set [count _ref6,_newPos];
  197.                 };
  198.                 if (((_def5 select (count _def5 - 1)) distance _x) < _rad ) exitwith
  199.                 {
  200.                     _newPos = _x;
  201.                     _pef6 set [count _pef6,_newPos];
  202.                 };
  203.                 if (((_def5 select (floor((count _def5)*0.5))) distance _x) < _rad ) exitwith
  204.                 {
  205.                     _newPos = _x;
  206.                     _sef6 set [count _sef6,_newPos];
  207.                 };
  208.                 _otherPos = _x;
  209.                 _def6 set [count _def6,_otherPos];
  210.             };
  211.         } foreach _def5;
  212.     };                                                                                     
  213.  
  214.     _arx resize 0;
  215.     if ((count _ref)>=_cnt) then { _arx set [count _arx, _ref];};
  216.     if ((count _pef)>=_cnt) then { _arx set [count _arx, _pef];};
  217.     if ((count _sef)>=_cnt) then { _arx set [count _arx, _sef];};
  218.     if ((count _ref1)>=_cnt) then { _arx set [count _arx, _ref1];};
  219.     if ((count _pef1)>=_cnt) then { _arx set [count _arx, _pef1];};
  220.     if ((count _sef1)>=_cnt) then { _arx set [count _arx, _sef1];};
  221.     if ((count _ref2)>=_cnt) then { _arx set [count _arx, _ref2];};
  222.     if ((count _pef2)>=_cnt) then { _arx set [count _arx, _pef2];};
  223.     if ((count _sef2)>=_cnt) then { _arx set [count _arx, _sef2];};
  224.     if ((count _ref3)>=_cnt) then { _arx set [count _arx, _ref3];};
  225.     if ((count _pef3)>=_cnt) then { _arx set [count _arx, _pef3];};
  226.     if ((count _sef3)>=_cnt) then { _arx set [count _arx, _sef3];};
  227.     if ((count _ref4)>=_cnt) then { _arx set [count _arx, _ref4];};
  228.     if ((count _pef4)>=_cnt) then { _arx set [count _arx, _pef4];};
  229.     if ((count _sef4)>=_cnt) then { _arx set [count _arx, _sef4];};
  230.     if ((count _ref5)>=_cnt) then { _arx set [count _arx, _ref5];};
  231.     if ((count _pef5)>=_cnt) then { _arx set [count _arx, _pef5];};
  232.     if ((count _sef5)>=_cnt) then { _arx set [count _arx, _sef5];};
  233.     if ((count _ref6)>=_cnt) then { _arx set [count _arx, _ref6];};
  234.     if ((count _pef6)>=_cnt) then { _arx set [count _arx, _pef6];};
  235.     if ((count _sef6)>=_cnt) then { _arx set [count _arx, _sef6];};
  236.  
  237.     if _debug then {
  238.         _color = [];
  239.         _color =["ColorBlack","ColorRed","ColorGreen",
  240.         "ColorBlue",
  241.         "ColorYellow",
  242.         "ColorGreenAlpha",
  243.         "ColorOrange",
  244.         "ColorWhite",
  245.         "ColorPink",
  246.         "ColorBrown",
  247.         "ColorRedAlpha",
  248.         "ColorKhaki"];
  249.         _markercolor = "ColorBlack";
  250.         {
  251.             _index=str _forEachIndex;
  252.             if ((count _arx) <= 12) then
  253.             {
  254.                 _markercolor = _color select _forEachIndex;
  255.             }else{
  256.                 _markercolor = _color select (floor random (count _color));
  257.             };
  258.             {
  259.                 _m = createMarker["marker5" + _index + (str _forEachIndex), [ _x select 0,_x select 1]];
  260.                 _m setMarkerShape "ICON";
  261.                 _m setMarkerType "DOT";
  262.                 _m setmarkercolor _markercolor;
  263.             } foreach _x;
  264.         } foreach _arx;
  265.     };  
  266.     _arx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement