Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicles - Utilize setCruiseControl for speed limiter #8273

Merged
merged 5 commits into from
Oct 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions addons/vehicles/functions/fnc_speedLimiter.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ params ["_driver", "_vehicle"];
if (GVAR(isSpeedLimiter)) exitWith {
[localize LSTRING(Off)] call EFUNC(common,displayTextStructured);
playSound "ACE_Sound_Click";
_vehicle setCruiseControl [0, false];
GVAR(isSpeedLimiter) = false;
};

AndreasBrostrom marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -38,21 +39,25 @@ GVAR(speedLimit) = speed _vehicle max 5;
private _uavControll = UAVControl _vehicle;
if ((_uavControll select 0) != _driver || _uavControll select 1 != "DRIVER") then {
GVAR(isSpeedLimiter) = false;
_vehicle setCruiseControl [0, false];
};
} else {
if (_driver != driver _vehicle) then {
GVAR(isSpeedLimiter) = false;
_vehicle setCruiseControl [0, false];
};
};

if (!GVAR(isSpeedLimiter)) exitWith {
_vehicle setCruiseControl [0, false];
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

_vehicle setCruiseControl [GVAR(speedLimit), false];
veteran29 marked this conversation as resolved.
Show resolved Hide resolved
AndreasBrostrom marked this conversation as resolved.
Show resolved Hide resolved

private _speed = speed _vehicle;
AndreasBrostrom marked this conversation as resolved.
Show resolved Hide resolved

if (_speed > GVAR(speedLimit)) then {
if (_speed > GVAR(speedLimit)+2) then {
_vehicle setVelocity ((velocity _vehicle) vectorMultiply ((GVAR(speedLimit) / _speed) - 0.00001)); // fix 1.42-hotfix PhysX libraries applying force in previous direction when turning
};
AndreasBrostrom marked this conversation as resolved.
Show resolved Hide resolved

}, 0, [_driver, _vehicle]] call CBA_fnc_addPerFrameHandler;