diff options
| author | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:53:22 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:53:22 +0300 |
| commit | c055d44dcdb87e8db49fb23e632fc086aa44cce6 (patch) | |
| tree | 7ac98d865915930bebc86b36b512a859c31538e5 /Common/Functions/Common_PlaceNear.sqf | |
| download | a2wf_zargabad-c055d44dcdb87e8db49fb23e632fc086aa44cce6.tar.gz a2wf_zargabad-c055d44dcdb87e8db49fb23e632fc086aa44cce6.tar.bz2 a2wf_zargabad-c055d44dcdb87e8db49fb23e632fc086aa44cce6.zip | |
init
Diffstat (limited to '')
| -rw-r--r-- | Common/Functions/Common_PlaceNear.sqf | 34 |
1 files changed, 34 insertions, 0 deletions
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 |
