From 3a7f034e25a91a406d74ab77124614b4e6fa927d Mon Sep 17 00:00:00 2001 From: Dystopian Date: Tue, 17 May 2022 07:59:12 +0400 Subject: [PATCH] Vehicles - Add cruise control/speed limiter to boats (#8905) * Add cruise control to boats * fix other use of `Controll` Co-authored-by: PabstMirror --- addons/vehicles/XEH_postInit.sqf | 41 ++++++++++--------- .../vehicles/functions/fnc_speedLimiter.sqf | 4 +- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/vehicles/XEH_postInit.sqf b/addons/vehicles/XEH_postInit.sqf index 20bd452d1d..8b1866c8ee 100644 --- a/addons/vehicles/XEH_postInit.sqf +++ b/addons/vehicles/XEH_postInit.sqf @@ -7,23 +7,25 @@ GVAR(isSpeedLimiter) = false; ["ACE3 Vehicles", QGVAR(speedLimiter), localize LSTRING(SpeedLimiter), { private _connectedUAV = getConnectedUAV ACE_player; - private _uavControll = UAVControl _connectedUAV; - if ((_uavControll select 1) == "DRIVER") then { + private _uavControl = UAVControl _connectedUAV; + if ((_uavControl select 1) == "DRIVER") then { if !(_connectedUAV isKindOf "UGV_01_base_F") exitWith {false}; GVAR(isUAV) = true; - [_uavControll select 0, _connectedUAV] call FUNC(speedLimiter); + [_uavControl select 0, _connectedUAV] call FUNC(speedLimiter); true } else { // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if !(ACE_player == driver vehicle ACE_player && - {vehicle ACE_player isKindOf 'Car' || - {vehicle ACE_player isKindOf 'Tank'}}) exitWith {false}; + private _vehicle = vehicle ACE_player; + if ( + ACE_player != driver _vehicle + || {-1 == ["Car", "Tank", "Ship"] findIf {_vehicle isKindOf _x}} + ) exitWith {false}; - GVAR(isUAV) = false; + GVAR(isUAV) = false; // Statement - [ACE_player, vehicle ACE_player] call FUNC(speedLimiter); + [ACE_player, _vehicle] call FUNC(speedLimiter); true }; }, @@ -32,27 +34,28 @@ GVAR(isSpeedLimiter) = false; ["ACE3 Vehicles", QGVAR(cruiseControl), localize LSTRING(CruiseControl), { private _connectedUAV = getConnectedUAV ACE_player; - private _uavControll = UAVControl _connectedUAV; - if ((_uavControll select 1) == "DRIVER") then { + private _uavControl = UAVControl _connectedUAV; + if ((_uavControl select 1) == "DRIVER") then { if !(_connectedUAV isKindOf "UGV_01_base_F") exitWith {false}; GVAR(isUAV) = true; - [_uavControll select 0, _connectedUAV, true] call FUNC(speedLimiter); + [_uavControl select 0, _connectedUAV, true] call FUNC(speedLimiter); true } else { // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if !(ACE_player == driver vehicle ACE_player && - {vehicle ACE_player isKindOf 'Car' || - {vehicle ACE_player isKindOf 'Tank'} || - {vehicle ACE_player isKindOf 'Plane'}}) exitWith {false}; + private _vehicle = vehicle ACE_player; + if ( + ACE_player != driver _vehicle + || {-1 == ["Car", "Tank", "Ship", "Plane"] findIf {_vehicle isKindOf _x}} + ) exitWith {false}; - GVAR(isUAV) = false; + GVAR(isUAV) = false; // Statement - if (vehicle ACE_player isKindOf 'Plane') then { - [ACE_player, vehicle ACE_player] call FUNC(autoThrottle); + if (_vehicle isKindOf "Plane") then { + [ACE_player, _vehicle] call FUNC(autoThrottle); } else { - [ACE_player, vehicle ACE_player, true] call FUNC(speedLimiter); + [ACE_player, _vehicle, true] call FUNC(speedLimiter); }; true }; diff --git a/addons/vehicles/functions/fnc_speedLimiter.sqf b/addons/vehicles/functions/fnc_speedLimiter.sqf index 312352457c..5be170697a 100644 --- a/addons/vehicles/functions/fnc_speedLimiter.sqf +++ b/addons/vehicles/functions/fnc_speedLimiter.sqf @@ -67,8 +67,8 @@ GVAR(speedLimitInit) = true; _args params ["_driver", "_vehicle"]; if (GVAR(isUAV)) then { - private _uavControll = UAVControl _vehicle; - if ((_uavControll select 0) != _driver || _uavControll select 1 != "DRIVER") then { + private _uavControl = UAVControl _vehicle; + if ((_uavControl select 0) != _driver || _uavControl select 1 != "DRIVER") then { GVAR(isSpeedLimiter) = false; TRACE_1("UAV driver changed, disabling speedlimit",_vehicle); _vehicle setCruiseControl [0, false];