Speed limit scroll (#6384)

Vehicles - Set speed limited with mouse scroll wheel
This commit is contained in:
Tim Beswick 2018-07-05 17:32:40 +01:00 committed by PabstMirror
parent 5495bd5a1f
commit 80e648938a
4 changed files with 34 additions and 6 deletions

View File

@ -30,3 +30,19 @@ GVAR(isSpeedLimiter) = false;
},
{false},
[211, [false, false, false]], false] call CBA_fnc_addKeybind; //DELETE Key
["ACE3 Vehicles", QGVAR(scrollUp), localize LSTRING(IncreaseSpeedLimit), {
if (GVAR(isSpeedLimiter)) then {
GVAR(speedLimit) = round (GVAR(speedLimit) + 1) max 5;
[["%1: %2", LSTRING(SpeedLimit), GVAR(speedLimit)]] call EFUNC(common,displayTextStructured);
true
};
}, {false}, [MOUSE_SCROLL_UP, [false, true, false]], false] call CBA_fnc_addKeybind; // Ctrl + Mouse Wheel Scroll Up
["ACE3 Vehicles", QGVAR(scrollDown), localize LSTRING(DecreaseSpeedLimit), {
if (GVAR(isSpeedLimiter)) then {
GVAR(speedLimit) = round (GVAR(speedLimit) - 1) max 5;
[["%1: %2", LSTRING(SpeedLimit), GVAR(speedLimit)]] call EFUNC(common,displayTextStructured);
true
};
}, {false}, [MOUSE_SCROLL_DOWN, [false, true, false]], false] call CBA_fnc_addKeybind; // Ctrl + Mouse Wheel Scroll Down

View File

@ -28,11 +28,11 @@ if (GVAR(isSpeedLimiter)) exitWith {
playSound "ACE_Sound_Click";
GVAR(isSpeedLimiter) = true;
private _maxSpeed = speed _vehicle max 5;
GVAR(speedLimit) = speed _vehicle max 5;
[{
params ["_args", "_idPFH"];
_args params ["_driver", "_vehicle", "_maxSpeed"];
_args params ["_driver", "_vehicle"];
if (GVAR(isUAV)) then {
private _uavControll = UAVControl _vehicle;
@ -51,8 +51,8 @@ private _maxSpeed = speed _vehicle max 5;
private _speed = speed _vehicle;
if (_speed > _maxSpeed) then {
_vehicle setVelocity ((velocity _vehicle) vectorMultiply ((_maxSpeed / _speed) - 0.00001)); // fix 1.42-hotfix PhysX libraries applying force in previous direction when turning
if (_speed > GVAR(speedLimit)) then {
_vehicle setVelocity ((velocity _vehicle) vectorMultiply ((GVAR(speedLimit) / _speed) - 0.00001)); // fix 1.42-hotfix PhysX libraries applying force in previous direction when turning
};
} , 0, [_driver, _vehicle, _maxSpeed]] call CBA_fnc_addPerFrameHandler;
}, 0, [_driver, _vehicle]] call CBA_fnc_addPerFrameHandler;

View File

@ -16,5 +16,8 @@
#include "\z\ace\addons\main\script_macros.hpp"
#define MOUSE_SCROLL_UP 0xF8
#define MOUSE_SCROLL_DOWN 0xF9
#define FUEL_FACTOR 0.165 // fuel capacity = range in km * FUEL_FACTOR
#define STARTUP_DELAY 1.3

View File

@ -33,6 +33,9 @@
<Chinesesimp>停用速度限制</Chinesesimp>
<Chinese>停用速度限制</Chinese>
</Key>
<Key ID="STR_ACE_Vehicles_SpeedLimit">
<English>Speed Limit</English>
</Key>
<Key ID="STR_ACE_Vehicles_SpeedLimiter">
<English>Speed Limiter</English>
<German>Begrenzer</German>
@ -49,5 +52,11 @@
<Chinesesimp>速度限制器</Chinesesimp>
<Chinese>速度限制器</Chinese>
</Key>
<Key ID="STR_ACE_Vehicles_IncreaseSpeedLimit">
<English>Increase Speed Limit</English>
</Key>
<Key ID="STR_ACE_Vehicles_DecreaseSpeedLimit">
<English>Decrease Speed Limit</English>
</Key>
</Package>
</Project>