Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.31 KB | None | 0 0
  1. /*
  2. a: reyhard
  3. adds ability to move around flying c130 cargo bay
  4. kind of attachToWithMovment but using attachTo command
  5. */
  6.  
  7. _v = _this select 0;
  8. _p = call lala_c17_fnc_rhs_findPlayer;
  9.  
  10. _p action ["eject",_v];
  11. USAF_c130J_attached = true;
  12.  
  13. _pos = [0,14,-1.21];
  14. _posOld = _pos;
  15. _p attachTo [_v,_pos];
  16.  
  17. _vc = [0,0,0];
  18. _h1 = [0,0,0];
  19. _h2 = [0,0,0];
  20. _h3 = [0,0,0];
  21.  
  22. _dir = getdir _p;
  23.  
  24. hint format["to get back to seat press %1",actionKeysNames "LockTarget"];
  25. _p forceWalk false;
  26. while {USAF_c130J_attached} do
  27. {
  28.  
  29.     if(inputAction "LockTarget" > 0)then
  30.     {
  31.         detach _p;
  32.         USAF_c130J_attached = false;
  33.         _p setVelocity [0,0,0];
  34.         _p moveInCargo _v;
  35.     };
  36.     if(inputAction "moveForward" > 0)then
  37.     {
  38.         _pos = _pos vectorAdd (([(vectorDir _p),getDirVisual _v] call BIS_fnc_rotateVector2D) vectorMultiply 0.05);
  39.     };
  40.     if(inputAction "moveBack" > 0)then
  41.     {
  42.         _pos = _pos vectorAdd (([(vectorDir _p),getDirVisual _v] call BIS_fnc_rotateVector2D) vectorMultiply -(0.05));
  43.     };
  44.     if(inputAction "turnLeft" > 0)then
  45.     {
  46.         _vc = [vectorDirVisual _p,(getDirVisual _v)-90] call BIS_fnc_rotateVector2D;
  47.         _pos = _pos vectorAdd (_vc vectorMultiply -0.05);
  48.     };
  49.     if(inputAction "turnRight" > 0)then
  50.     {
  51.         _vc = [vectorDirVisual _p,(getDirVisual _v)+90] call BIS_fnc_rotateVector2D;
  52.         _pos = _pos vectorAdd ( _vc vectorMultiply -(0.05) );
  53.     };
  54.     if(not(_pos isEqualTo _posOld))then
  55.     {
  56.         _pos set [2,-1.21];
  57.  
  58.         if( (getPosASL _v select 2) > (getPosATL _v select 2) )then{
  59.             _h1=ATLToASL(_v modelToWorldVisual [(_pos select 0 )*1.2,(_pos select 1)*1.2,(_pos select 2)+0.2]);
  60.             _h2=ATLToASL(_v modelToWorldVisual (_posOld vectorAdd [0,0,0.2]));
  61.         }else{
  62.             _h1=(_v modelToWorldVisual [(_pos select 0)*1.2,(_pos select 1)*1.2,(_pos select 2)+0.2]);
  63.             _h2=(_v modelToWorldVisual (_posOld vectorAdd [0,0,0.2]));
  64.         };
  65.         if(not(lineIntersects [_h1,_h2]))then{_p attachTo [_v, _pos]; _posOld = _pos}else{_pos = _posOld};
  66.         if((getpos _p select 2) > 1)then{
  67.             _p allowDamage false;
  68.             detach _p;
  69.             _p setVelocity [0,0,0];
  70.             USAF_c130J_attached = false;
  71.             sleep 1;
  72.             _p allowDamage true;
  73.         };
  74.     };
  75.     if (inputAction "AimRight" > 0) then {_dir = _dir+(2*(inputAction "AimRight")); _p setdir _dir;};
  76.     if (inputAction "AimLeft" > 0) then     {_dir = _dir-(2*(inputAction "AimLeft")); _p setdir _dir;};
  77.     sleep 0.01;
  78. };
  79. _p forceWalk false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement