Advertisement
Guest User

Untitled

a guest
Sep 24th, 2014
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.33 KB | None | 0 0
  1. /*
  2. * Pos_fnc2.sqf
  3. * Pos_mark_fnc2 = compile preprocessFile "Pos_mark_fnc2.sqf";
  4. * Dimon UA Find position SCRIPT.
  5. * пример:
  6. [_veh, getpos player, 3, [100, 100], [10, 10], 0.1, false, [4, 20, 40], [[],0], 1500, _cnt] call Pos_mark_fnc2;
  7. *   _minDistance = _this select 2;              // минимально допустимая дистанция до ближайшего объекта.
  8.     если значение 0 то:
  9.     _minDistance = sizeOf typeOf vehicle;
  10.     _gradientRadius = sizeOf typeOf vehicle * _gradientRadius;
  11.     _xdistance = sizeOf typeOf vehicle * _xdistance;
  12. * _onroad:
  13.   0 - дороги не должно быть
  14.   1 - все равно
  15.   2 - только на дороге
  16.   3 - дороги не должно быть, радиус от дороги для размещения
  17.   4 - дорога должна быть или допустимый радиус от дороги.
  18.   5 - дороги не должно быть и мин радиус от дороги где не должно быть, радиус от дороги где можно разместить
  19. */
  20.  
  21. #define cn !(isOnRoad _isFlat)
  22. #define ucn (isOnRoad _isFlat)
  23. #define tn (count (_isFlat nearRoads _xr) == 0)
  24. #define utn (count (_isFlat nearRoads _xr) > 0)
  25. #define uctn (count (_isFlat nearRoads _xrm) > 0)
  26. #define mn (count (nearestObjects [ _isFlat , _neartype, _xdistance]) == 0)
  27. #define sn sizeOf typeOf _type
  28.  
  29.  
  30. private["_type","_count","_marker","_radius","_minDistance","_minradius","_maxradius","_minGradient","_maxGradient","_gradientRadius","_onShore","_onroad",
  31.         "_xr","_xc","_xrm","_posfind","_neartype","_xdistance","_damage","_typecount","_unittype","_xradius","_xGradient", "_xcountx","_cnt","_isFlat","_poss","_veh"];
  32.  
  33. _type = _this select 0;        // обьект
  34. _marker = _this select 1;      // центр радиуса размещения обьекта
  35. _minDistance = _this select 2;              // минимально допустимая дистанция до ближайшего объекта. 0 - по дефолту
  36. _minradius = ((_this select 3) select 0);   // минимальный радиус поиска площадки вокруг обьекта
  37. _maxradius = ((_this select 3) select 1);   // максимальный радиус поиска площадки вокруг обьекта
  38. _minGradient=((_this select 4) select 0);   // минимальное значение максимального допустимого наклона (разница высот) площадки
  39. _maxGradient=((_this select 4) select 1);   // максимальное значение максимального допустимого наклона (разница высот) площадки
  40. _gradientRadius = _this select 5;           // радиус окружности, в пределах которой учитывается _minGradient
  41. _onShore=_this select 6;                    // true если необходима вода в радиусе 25 метров
  42. _onroad=((_this select 7) select 0);   
  43. _xr=((_this select 7) select 1);        // 1 радиус в котором ищется наличие дороги.
  44. _xrm=((_this select 7) select 2);       // 2 радиус в котором ищется наличие дороги.
  45. _neartype=((_this select 8) select 0);      // массив обьектов возле которых при заданной дистанции от обьекта нельзя ставить обьект.
  46. _xdistance=((_this select 8) select 1);     // дистанция до обьектов возле которых нельзя ставить нужный нам обьект(ы).
  47. _xc = _this select 9;
  48. _cnt = _this select 10;
  49.  
  50. _xradius = (_maxradius - _minradius) / _xc;
  51. _xGradient = (_maxGradient - _minGradient) / _xc;
  52. _xcountx = 0;
  53. _isFlat = [];
  54. _p = position _type;
  55. while {_xcountx < _xc} do
  56. {
  57.     _veh=createVehicle ["Sign_sphere100cm_EP1", _p, [], _minradius, "CAN_COLLIDE"];
  58.     if (_minDistance == 0) then
  59.     {
  60.         _minDistance = sn;
  61.         _gradientRadius = sn * _gradientRadius;
  62.         _xdistance = sn * _xdistance;
  63.     };     
  64.     _isFlat = (position _veh) isFlatEmpty [_minDistance , _minradius, _minGradient, _gradientRadius, 0, _onShore, _veh];
  65.     if (count _isFlat > 0) then
  66.     {
  67.         sleep 0.01;
  68.         if ((_onroad == 1) && (mn)) then  
  69.         {
  70.             _poss = _isFlat;
  71.             _veh setPos _poss;
  72.             call compile format ["
  73.             _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
  74.             _m%1 setMarkerShape ""ICON"";
  75.             _m%1 setMarkerType ""DOT"";
  76.             _m%1 setmarkercolor ""colorred"";
  77.             ",_cnt];
  78.             _type setPos getPos _veh;
  79.             deletevehicle _veh;
  80.             _type setVectorUp (surfaceNormal (position _veh));
  81.             _xcountx = _xcountx + _xc;
  82.         } else {
  83.             deletevehicle _veh;
  84.         };
  85.         if ( (_onroad == 0) && cn && tn && mn) then  
  86.         {
  87.             _poss = _isFlat;
  88.             _veh setPos _poss;
  89.             call compile format ["
  90.             _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
  91.             _m%1 setMarkerShape ""ICON"";
  92.             _m%1 setMarkerType ""DOT"";
  93.             _m%1 setmarkercolor ""colorred"";
  94.             ",_cnt];
  95.             _type setPos getPos _veh;
  96.             deletevehicle _veh;
  97.             _type setVectorUp (surfaceNormal (position _type));
  98.             _xcountx = _xcountx + _xc;
  99.         } else {
  100.             deletevehicle _veh;
  101.         };
  102.         if ( (_onroad == 2) && ucn && mn) then  
  103.         {
  104.             _poss = _isFlat;
  105.             _veh setPos _poss;
  106.             call compile format ["
  107.             _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
  108.             _m%1 setMarkerShape ""ICON"";
  109.             _m%1 setMarkerType ""DOT"";
  110.             _m%1 setmarkercolor ""colorred"";
  111.             ",_cnt];
  112.             _type setPos getPos _veh;
  113.             deletevehicle _veh;
  114.             _type setVectorUp (surfaceNormal (position _type));
  115.             _xcountx = _xcountx + _xc;
  116.         } else {
  117.             deletevehicle _veh;
  118.         };
  119.         if ( (_onroad == 3) && cn && utn && mn) then  
  120.         {
  121.             _poss = _isFlat;
  122.             _veh setPos _poss;
  123.             call compile format ["
  124.             _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
  125.             _m%1 setMarkerShape ""ICON"";
  126.             _m%1 setMarkerType ""DOT"";
  127.             _m%1 setmarkercolor ""colorred"";
  128.             ",_cnt];
  129.             _type setPos getPos _veh;
  130.             deletevehicle _veh;
  131.             _type setVectorUp (surfaceNormal (position _type));
  132.             _xcountx = _xcountx + _xc;
  133.         } else {
  134.             deletevehicle _veh;
  135.         };
  136.         if ( (_onroad == 4) && (ucn || utn) && mn) then  
  137.         {
  138.             _poss = _isFlat;
  139.             _veh setPos _poss;
  140.             call compile format ["
  141.             _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
  142.             _m%1 setMarkerShape ""ICON"";
  143.             _m%1 setMarkerType ""DOT"";
  144.             _m%1 setmarkercolor ""colorred"";
  145.             ",_cnt];
  146.             _type setPos getPos _veh;
  147.             deletevehicle _veh;
  148.             _type setVectorUp (surfaceNormal (position _type));
  149.             _xcountx = _xcountx + _xc;
  150.         } else {
  151.             deletevehicle _veh;
  152.         };
  153.         if ( (_onroad == 5) && cn && tn && uctn && mn) then  
  154.         {
  155.             _poss = _isFlat;
  156.             _veh setPos _poss;
  157.             call compile format ["
  158.             _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
  159.             _m%1 setMarkerShape ""ICON"";
  160.             _m%1 setMarkerType ""DOT"";
  161.             _m%1 setmarkercolor ""colorred"";
  162.             ",_cnt];
  163.             _type setPos getPos _veh;
  164.             deletevehicle _veh;
  165.             _type setVectorUp (surfaceNormal (position _type));
  166.             _xcountx = _xcountx + _xc;
  167.         } else {
  168.             deletevehicle _veh;
  169.         };
  170.         if (_onroad > 5)  then  
  171.         {
  172.             deletevehicle _veh;
  173.         };                     
  174.     } else {
  175.         deletevehicle _veh;
  176.     };
  177.     _xcountx = _xcountx + 1;
  178.     _minradius = _minradius + _xradius;
  179.     _minGradient = _minGradient + _xGradient;
  180. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement