Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 3.35 KB | None | 0 0
  1.  
  2. addMissionEventHandler["EachFrame", {
  3.  
  4.   private _vehicle = vehicle player;
  5.   private _prevVelocity = _vehicle getVariable ["LIB_prevVelocity", [0,0,0]];
  6.   private _velocityVehicle = velocityModelSpace _vehicle;
  7.   private _3Dspeed = vectorMagnitude _velocityVehicle;
  8.   private _maxAccelerations = [1,3,1];
  9.   private _overG = false;
  10.   private _velocityDiff = _velocityVehicle vectorDiff _prevVelocity;
  11.  
  12.   _vehicle setVariable ["LIB_AntiFlipSystemDisabled", true];
  13.   _vehicle allowdamage true;
  14.   player allowdamage true;
  15.  
  16.   {
  17.     private _i = _forEachIndex;
  18.     if ((abs _x) > (_maxAccelerations select _i)) then {
  19.             _overG = true;
  20.         };
  21.   } forEach _velocityDiff;
  22.   private _time = _vehicle getVariable ["LIB_prevVelocity_timestamp", diag_tickTime];
  23.   if ((!_overG && {(floor (diag_tickTime * 10)% 2) isEqualTo 0}) || (diag_tickTime - _time > 0.25)) then {
  24.     _vehicle setVariable ["LIB_prevVelocity", _velocityVehicle];
  25.     _vehicle setVariable ["LIB_prevVelocity_timestamp", diag_tickTime];
  26.   };
  27.   if (_overG && _3DSpeed != 0) then {
  28.     private _corrected = _velocityVehicle vectorMultiply (2.5/_3Dspeed);
  29.     _vehicle setVelocityModelSpace _corrected;
  30.   };
  31.  
  32.  
  33. private _vectorUpVehicle = vectorup _vehicle;
  34. private _prevVectorUp = _vehicle getVariable ["LIB_prevVectorUp", _vectorUpVehicle];
  35. private _maxUpDelta = [0.3,0.3,0.3];
  36. private _overVUP = false;
  37. private _VUPDiff = _vectorUpVehicle vectorDiff _prevVectorUp;
  38. private _correctionVUP = _prevVectorUp;
  39.  
  40.  
  41. {
  42.   private _i = _forEachIndex;
  43.   if ((abs _x) > (_maxUpDelta select _i)) then {
  44.     _correctionVUP set [_i,(_maxUpDelta select _i)];
  45.     _overVUP = true;
  46.     systemChat str [_x, _maxUpDelta select _i];
  47.   };
  48. } forEach _VUPDiff;
  49.  
  50. private _time = _vehicle getVariable ["LIB_prevVectorUp_timestamp", diag_tickTime];
  51. if (!_overVUP && {(diag_tickTime - _time) > 0.25} || {(floor (diag_tickTime * 10)% 2) isEqualTo 0}) then {
  52.   _vehicle setVariable ["LIB_prevVectorUp", _prevVectorUp];
  53.   _vehicle setVariable ["LIB_prevVectorUp_timestamp", diag_tickTime];
  54. };
  55. if (_overVUP) then {
  56.   private _correctedVUP = vectorNormalized (_prevVectorUp vectoradd _correctionVUP);
  57.   _vehicle setVectorUp _correctedVUP;
  58. };
  59.  
  60.  
  61.  
  62.   private _posAGLS = getPos _vehicle;
  63.   private _posATL = getPosATL _vehicle;
  64.   private _heightVehicle = (abs ((_posAGLS select 2) - (_posATL select 2))) min (_posAGLS select 2);
  65.   private _flying = false;
  66.   private _flipping = false;
  67.   _vehicle allowdamage false;
  68.   player allowdamage false;
  69.   if (_heightVehicle > 3 && ((_velocityVehicle select 2) > 1)) then {
  70.      _vehicle setVelocityModelSpace (_velocityVehicle vectorDiff [0,0,(abs ((_velocityVehicle select 2)*0.05))]);
  71.      _flying = true;
  72.   } else {
  73.     if ((_velocityVehicle select 2) > 5) then {
  74.       _vehicle setVelocityModelSpace (_velocityVehicle vectorDiff [0,0,1]);
  75.       _flying = true;
  76.     } else {
  77.       if (((_vectorUpVehicle select 2) < 0.3) || ((abs ((_vehicle call BIS_fnc_getPitchBank) select 1)) > 75)) then {
  78.         _vehicle setVectorUp (_vectorUpVehicle vectorAdd [0,0,0.1]);
  79.         _flipping = true;
  80.       };
  81.     };
  82.   };
  83.  
  84.  
  85.     if (_overG || _overVUP || _flying || _flipping) then {
  86.          hintSilent format ["Antiflip Script Activated:\nOverspeed: %1\nOverrotation: %2\n Flipping: %3\nFlying: %4", _overG, _overVUP, _flipping, _flying];
  87.     };
  88.   _vehicle allowdamage true;
  89.   player allowdamage true;
  90. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement