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

@ -18,7 +18,7 @@ GVAR(isSpeedLimiter) = false;
if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
if !(ACE_player == driver vehicle ACE_player && if !(ACE_player == driver vehicle ACE_player &&
{vehicle ACE_player isKindOf 'Car' || {vehicle ACE_player isKindOf 'Car' ||
{vehicle ACE_player isKindOf 'Tank'}}) exitWith {false}; {vehicle ACE_player isKindOf 'Tank'}}) exitWith {false};
GVAR(isUAV) = false; GVAR(isUAV) = false;
@ -30,3 +30,19 @@ GVAR(isSpeedLimiter) = false;
}, },
{false}, {false},
[211, [false, false, false]], false] call CBA_fnc_addKeybind; //DELETE Key [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"; playSound "ACE_Sound_Click";
GVAR(isSpeedLimiter) = true; GVAR(isSpeedLimiter) = true;
private _maxSpeed = speed _vehicle max 5; GVAR(speedLimit) = speed _vehicle max 5;
[{ [{
params ["_args", "_idPFH"]; params ["_args", "_idPFH"];
_args params ["_driver", "_vehicle", "_maxSpeed"]; _args params ["_driver", "_vehicle"];
if (GVAR(isUAV)) then { if (GVAR(isUAV)) then {
private _uavControll = UAVControl _vehicle; private _uavControll = UAVControl _vehicle;
@ -51,8 +51,8 @@ private _maxSpeed = speed _vehicle max 5;
private _speed = speed _vehicle; private _speed = speed _vehicle;
if (_speed > _maxSpeed) then { if (_speed > GVAR(speedLimit)) then {
_vehicle setVelocity ((velocity _vehicle) vectorMultiply ((_maxSpeed / _speed) - 0.00001)); // fix 1.42-hotfix PhysX libraries applying force in previous direction when turning _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" #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 FUEL_FACTOR 0.165 // fuel capacity = range in km * FUEL_FACTOR
#define STARTUP_DELAY 1.3 #define STARTUP_DELAY 1.3

View File

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