Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Pos_fnc2.sqf
- * Pos_mark_fnc2 = compile preprocessFile "Pos_mark_fnc2.sqf";
- * Dimon UA Find position SCRIPT.
- * пример:
- [_veh, getpos player, 3, [100, 100], [10, 10], 0.1, false, [4, 20, 40], [[],0], 1500, _cnt] call Pos_mark_fnc2;
- * _minDistance = _this select 2; // минимально допустимая дистанция до ближайшего объекта.
- если значение 0 то:
- _minDistance = sizeOf typeOf vehicle;
- _gradientRadius = sizeOf typeOf vehicle * _gradientRadius;
- _xdistance = sizeOf typeOf vehicle * _xdistance;
- * _onroad:
- 0 - дороги не должно быть
- 1 - все равно
- 2 - только на дороге
- 3 - дороги не должно быть, радиус от дороги для размещения
- 4 - дорога должна быть или допустимый радиус от дороги.
- 5 - дороги не должно быть и мин радиус от дороги где не должно быть, радиус от дороги где можно разместить
- */
- #define cn !(isOnRoad _isFlat)
- #define ucn (isOnRoad _isFlat)
- #define tn (count (_isFlat nearRoads _xr) == 0)
- #define utn (count (_isFlat nearRoads _xr) > 0)
- #define uctn (count (_isFlat nearRoads _xrm) > 0)
- #define mn (count (nearestObjects [ _isFlat , _neartype, _xdistance]) == 0)
- #define sn sizeOf typeOf _type
- private["_type","_count","_marker","_radius","_minDistance","_minradius","_maxradius","_minGradient","_maxGradient","_gradientRadius","_onShore","_onroad",
- "_xr","_xc","_xrm","_posfind","_neartype","_xdistance","_damage","_typecount","_unittype","_xradius","_xGradient", "_xcountx","_cnt","_isFlat","_poss","_veh"];
- _type = _this select 0; // обьект
- _marker = _this select 1; // центр радиуса размещения обьекта
- _minDistance = _this select 2; // минимально допустимая дистанция до ближайшего объекта. 0 - по дефолту
- _minradius = ((_this select 3) select 0); // минимальный радиус поиска площадки вокруг обьекта
- _maxradius = ((_this select 3) select 1); // максимальный радиус поиска площадки вокруг обьекта
- _minGradient=((_this select 4) select 0); // минимальное значение максимального допустимого наклона (разница высот) площадки
- _maxGradient=((_this select 4) select 1); // максимальное значение максимального допустимого наклона (разница высот) площадки
- _gradientRadius = _this select 5; // радиус окружности, в пределах которой учитывается _minGradient
- _onShore=_this select 6; // true если необходима вода в радиусе 25 метров
- _onroad=((_this select 7) select 0);
- _xr=((_this select 7) select 1); // 1 радиус в котором ищется наличие дороги.
- _xrm=((_this select 7) select 2); // 2 радиус в котором ищется наличие дороги.
- _neartype=((_this select 8) select 0); // массив обьектов возле которых при заданной дистанции от обьекта нельзя ставить обьект.
- _xdistance=((_this select 8) select 1); // дистанция до обьектов возле которых нельзя ставить нужный нам обьект(ы).
- _xc = _this select 9;
- _cnt = _this select 10;
- _xradius = (_maxradius - _minradius) / _xc;
- _xGradient = (_maxGradient - _minGradient) / _xc;
- _xcountx = 0;
- _isFlat = [];
- _p = position _type;
- while {_xcountx < _xc} do
- {
- _veh=createVehicle ["Sign_sphere100cm_EP1", _p, [], _minradius, "CAN_COLLIDE"];
- if (_minDistance == 0) then
- {
- _minDistance = sn;
- _gradientRadius = sn * _gradientRadius;
- _xdistance = sn * _xdistance;
- };
- _isFlat = (position _veh) isFlatEmpty [_minDistance , _minradius, _minGradient, _gradientRadius, 0, _onShore, _veh];
- if (count _isFlat > 0) then
- {
- sleep 0.01;
- if ((_onroad == 1) && (mn)) then
- {
- _poss = _isFlat;
- _veh setPos _poss;
- call compile format ["
- _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
- _m%1 setMarkerShape ""ICON"";
- _m%1 setMarkerType ""DOT"";
- _m%1 setmarkercolor ""colorred"";
- ",_cnt];
- _type setPos getPos _veh;
- deletevehicle _veh;
- _type setVectorUp (surfaceNormal (position _veh));
- _xcountx = _xcountx + _xc;
- } else {
- deletevehicle _veh;
- };
- if ( (_onroad == 0) && cn && tn && mn) then
- {
- _poss = _isFlat;
- _veh setPos _poss;
- call compile format ["
- _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
- _m%1 setMarkerShape ""ICON"";
- _m%1 setMarkerType ""DOT"";
- _m%1 setmarkercolor ""colorred"";
- ",_cnt];
- _type setPos getPos _veh;
- deletevehicle _veh;
- _type setVectorUp (surfaceNormal (position _type));
- _xcountx = _xcountx + _xc;
- } else {
- deletevehicle _veh;
- };
- if ( (_onroad == 2) && ucn && mn) then
- {
- _poss = _isFlat;
- _veh setPos _poss;
- call compile format ["
- _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
- _m%1 setMarkerShape ""ICON"";
- _m%1 setMarkerType ""DOT"";
- _m%1 setmarkercolor ""colorred"";
- ",_cnt];
- _type setPos getPos _veh;
- deletevehicle _veh;
- _type setVectorUp (surfaceNormal (position _type));
- _xcountx = _xcountx + _xc;
- } else {
- deletevehicle _veh;
- };
- if ( (_onroad == 3) && cn && utn && mn) then
- {
- _poss = _isFlat;
- _veh setPos _poss;
- call compile format ["
- _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
- _m%1 setMarkerShape ""ICON"";
- _m%1 setMarkerType ""DOT"";
- _m%1 setmarkercolor ""colorred"";
- ",_cnt];
- _type setPos getPos _veh;
- deletevehicle _veh;
- _type setVectorUp (surfaceNormal (position _type));
- _xcountx = _xcountx + _xc;
- } else {
- deletevehicle _veh;
- };
- if ( (_onroad == 4) && (ucn || utn) && mn) then
- {
- _poss = _isFlat;
- _veh setPos _poss;
- call compile format ["
- _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
- _m%1 setMarkerShape ""ICON"";
- _m%1 setMarkerType ""DOT"";
- _m%1 setmarkercolor ""colorred"";
- ",_cnt];
- _type setPos getPos _veh;
- deletevehicle _veh;
- _type setVectorUp (surfaceNormal (position _type));
- _xcountx = _xcountx + _xc;
- } else {
- deletevehicle _veh;
- };
- if ( (_onroad == 5) && cn && tn && uctn && mn) then
- {
- _poss = _isFlat;
- _veh setPos _poss;
- call compile format ["
- _m%1 = createMarker[""mySpot%1"",[_poss select 0,_poss select 1]];
- _m%1 setMarkerShape ""ICON"";
- _m%1 setMarkerType ""DOT"";
- _m%1 setmarkercolor ""colorred"";
- ",_cnt];
- _type setPos getPos _veh;
- deletevehicle _veh;
- _type setVectorUp (surfaceNormal (position _type));
- _xcountx = _xcountx + _xc;
- } else {
- deletevehicle _veh;
- };
- if (_onroad > 5) then
- {
- deletevehicle _veh;
- };
- } else {
- deletevehicle _veh;
- };
- _xcountx = _xcountx + 1;
- _minradius = _minradius + _xradius;
- _minGradient = _minGradient + _xGradient;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement