Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addMissionEventHandler["EachFrame", {
- private _vehicle = vehicle player;
- private _prevVelocity = _vehicle getVariable ["LIB_prevVelocity", [0,0,0]];
- private _velocityVehicle = velocityModelSpace _vehicle;
- private _3Dspeed = vectorMagnitude _velocityVehicle;
- private _maxAccelerations = [1,3,1];
- private _overG = false;
- private _velocityDiff = _velocityVehicle vectorDiff _prevVelocity;
- _vehicle setVariable ["LIB_AntiFlipSystemDisabled", true];
- _vehicle allowdamage true;
- player allowdamage true;
- {
- private _i = _forEachIndex;
- if ((abs _x) > (_maxAccelerations select _i)) then {
- _overG = true;
- };
- } forEach _velocityDiff;
- private _time = _vehicle getVariable ["LIB_prevVelocity_timestamp", diag_tickTime];
- if ((!_overG && {(floor (diag_tickTime * 10)% 2) isEqualTo 0}) || (diag_tickTime - _time > 0.25)) then {
- _vehicle setVariable ["LIB_prevVelocity", _velocityVehicle];
- _vehicle setVariable ["LIB_prevVelocity_timestamp", diag_tickTime];
- };
- if (_overG && _3DSpeed != 0) then {
- private _corrected = _velocityVehicle vectorMultiply (2.5/_3Dspeed);
- _vehicle setVelocityModelSpace _corrected;
- };
- private _vectorUpVehicle = vectorup _vehicle;
- private _prevVectorUp = _vehicle getVariable ["LIB_prevVectorUp", _vectorUpVehicle];
- private _maxUpDelta = [0.3,0.3,0.3];
- private _overVUP = false;
- private _VUPDiff = _vectorUpVehicle vectorDiff _prevVectorUp;
- private _correctionVUP = _prevVectorUp;
- {
- private _i = _forEachIndex;
- if ((abs _x) > (_maxUpDelta select _i)) then {
- _correctionVUP set [_i,(_maxUpDelta select _i)];
- _overVUP = true;
- systemChat str [_x, _maxUpDelta select _i];
- };
- } forEach _VUPDiff;
- private _time = _vehicle getVariable ["LIB_prevVectorUp_timestamp", diag_tickTime];
- if (!_overVUP && {(diag_tickTime - _time) > 0.25} || {(floor (diag_tickTime * 10)% 2) isEqualTo 0}) then {
- _vehicle setVariable ["LIB_prevVectorUp", _prevVectorUp];
- _vehicle setVariable ["LIB_prevVectorUp_timestamp", diag_tickTime];
- };
- if (_overVUP) then {
- private _correctedVUP = vectorNormalized (_prevVectorUp vectoradd _correctionVUP);
- _vehicle setVectorUp _correctedVUP;
- };
- private _posAGLS = getPos _vehicle;
- private _posATL = getPosATL _vehicle;
- private _heightVehicle = (abs ((_posAGLS select 2) - (_posATL select 2))) min (_posAGLS select 2);
- private _flying = false;
- private _flipping = false;
- _vehicle allowdamage false;
- player allowdamage false;
- if (_heightVehicle > 3 && ((_velocityVehicle select 2) > 1)) then {
- _vehicle setVelocityModelSpace (_velocityVehicle vectorDiff [0,0,(abs ((_velocityVehicle select 2)*0.05))]);
- _flying = true;
- } else {
- if ((_velocityVehicle select 2) > 5) then {
- _vehicle setVelocityModelSpace (_velocityVehicle vectorDiff [0,0,1]);
- _flying = true;
- } else {
- if (((_vectorUpVehicle select 2) < 0.3) || ((abs ((_vehicle call BIS_fnc_getPitchBank) select 1)) > 75)) then {
- _vehicle setVectorUp (_vectorUpVehicle vectorAdd [0,0,0.1]);
- _flipping = true;
- };
- };
- };
- if (_overG || _overVUP || _flying || _flipping) then {
- hintSilent format ["Antiflip Script Activated:\nOverspeed: %1\nOverrotation: %2\n Flipping: %3\nFlying: %4", _overG, _overVUP, _flipping, _flying];
- };
- _vehicle allowdamage true;
- player allowdamage true;
- }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement