Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.47 KB | None | 0 0
  1. /*
  2.     Author: Lala14
  3.  
  4.     Description:
  5.     attaches an object and moves it towards a point *SPAWN THIS*
  6.  
  7.     Parameter(s):
  8.     0: OBJECT   - Attach this vehicle
  9.     1: OBJECT   - The Vehicle that the object is being attached to
  10.     2: ARRAY    - Where the object starts (model space)
  11.     3: ARRAY    - Move object to here (model space)
  12.     4: NUMBER   - Step take (optional) default 1
  13.     5: NUMBER   - Sleep time (optional) default 0.1
  14.     6: NUMBER   - DIRECTION (optional) default 0
  15.     7: ARRAY    - SetVectorDirAndUp (optional) default [[0,0,0],[0,0,0]]
  16.     8: BOOL     - DEBUG (optional) default false
  17.  
  18.     Returns:
  19.     NIL
  20. */
  21. /*null = _this spawn
  22. {*/
  23.     _obj = _this select 0;
  24.     _attachTo = _this select 1;
  25.     _attachToInit = _this select 2;
  26.     _moveToPart = _this select 3;
  27.     _step = [_this,4,1] call bis_fnc_param;
  28.     _sleep = [_this,5,0.1] call bis_fnc_param;
  29.     _dir = [_this,6,0] call bis_fnc_param;
  30.     _vectordirandup = [_this,7,[[0,0,0],[0,0,0]]] call bis_fnc_param;
  31.     _debug = [_this,8,false] call bis_fnc_param;
  32.  
  33.     _steps = 1;
  34.  
  35.     _attachToInitx = _attachToInit select 0;
  36.     _attachToInity = _attachToInit select 1;
  37.     _attachToInitz = _attachToInit select 2;
  38.  
  39.     _moveToPartx = _moveToPart select 0;
  40.     _moveToParty = _moveToPart select 1;
  41.     _moveToPartz = _moveToPart select 2;
  42.  
  43.     _x = _moveToPartx - _attachToInitx;
  44.     _y = _moveToParty - _attachToInity;
  45.     _z = _moveToPartz - _attachToInitz;
  46.  
  47.     if (_debug) then {systemChat format ["x:%1 y:%2 z:%3",_x,_y,_z];};
  48.  
  49.     switch (true) do {
  50.         case (((abs _x) > (abs _y)) && ((abs _x) > (abs _z))): { _steps = round ((abs _x) / _step); };
  51.         case (((abs _y) > (abs _z)) && ((abs _y) > (abs _x))): { _steps = round ((abs _y) / _step); };
  52.         case (((abs _z) > (abs _y)) && ((abs _z) > (abs _x))): { _steps = round ((abs _z) / _step); };
  53.     };
  54.  
  55.     if (_debug) then {systemChat format ["steps: %1",_steps];};
  56.     _obj attachTo [_attachTo,_attachToInit];
  57.     if (_dir != 0) then {[[_obj,_dir],"setDir"] spawn bis_fnc_MP};
  58.     if !(_vectordirandup isEqualTo [[0,0,0],[0,0,0]]) then {_obj setVectorDirAndUp _vectordirandup};
  59.  
  60.     for "_i" from 0 to _steps do {
  61.         _pos = [(((_x / _steps) * _i) + _attachToInitx), (((_y / _steps) * _i) + _attachToInity), (((_z / _steps) * _i) + _attachToInitz)];
  62.         if (_debug) then {systemChat str _pos;};
  63.         _obj AttachTo [_attachTo, _pos];
  64.         sleep _sleep;
  65.     };
  66.  
  67.     if (_dir != 0) then {[[_obj,_dir],"setDir"] spawn bis_fnc_MP};
  68.     if !(_vectordirandup isEqualTo [[0,0,0],[0,0,0]]) then {_obj setVectorDirAndUp _vectordirandup};
  69. //};
  70.  
  71. true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement