From a3a91d4f45b22fd487ecbc954ad979be5d03efdd Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:38:09 +0300 Subject: init --- Common/Functions/Common_PlaceNear.sqf | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Common/Functions/Common_PlaceNear.sqf (limited to 'Common/Functions/Common_PlaceNear.sqf') diff --git a/Common/Functions/Common_PlaceNear.sqf b/Common/Functions/Common_PlaceNear.sqf new file mode 100644 index 0000000..99f9b75 --- /dev/null +++ b/Common/Functions/Common_PlaceNear.sqf @@ -0,0 +1,34 @@ +Private["_destination","_direction","_faceAway","_maxRadius","_minRadius","_object","_placeSafe","_position","_radius","_randomDirection","_safeRadius"]; + +_object = _this Select 0; +_position = _this Select 1; +_minRadius = _this Select 2; +_maxRadius = _this Select 3; + +_faceAway = true; +if (Count _this > 4) then {_faceAway = _this Select 4}; + +_randomDirection = true; +if (Count _this > 5) then {_randomDirection = _this Select 5}; + +_placeSafe = false; +if (Count _this > 6) then {_placeSafe = _this Select 6}; + +_direction = Random 360; +_radius = (Random (_maxRadius - _minRadius)) + _minRadius; + +if (_placeSafe) then { + _safeRadius = (_maxRadius - _minRadius) / 2; + if (_safeRadius < 5) then {_safeRadius = 5}; + _destination = [(_position Select 0)+((sin _direction)*_radius),(_position Select 1)+((cos _direction)*_radius),(_position Select 2)+0.5]; + [_object,_destination,_safeRadius] Call PlaceSafe; +} else { + _object SetPos [(_position Select 0)+((sin _direction)*_radius),(_position Select 1)+((cos _direction)*_radius),(_position Select 2)+0.5]; +}; + +if (_randomDirection) then {_object SetDir Random 360}; + +if (_faceAway) then { + _destination = GetPos _object; + _object SetDir -((((_destination Select 1) - (_position Select 1)) atan2 ((_destination Select 0) - (_position Select 0))) - 90); +}; \ No newline at end of file -- cgit v1.3.1