Vehicles - Add cruise control/speed limiter to boats (#8905)

* Add cruise control to boats

* fix other use of `Controll`

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Dystopian 2022-05-17 07:59:12 +04:00 committed by GitHub
parent c66304daf9
commit 3a7f034e25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 21 deletions

View File

@ -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;
// 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;
// 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
};

View File

@ -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];