Skip to content

Commit

Permalink
Speed limit scroll (#6384)
Browse files Browse the repository at this point in the history
Vehicles - Set speed limited with mouse scroll wheel
  • Loading branch information
tbeswick96 authored and PabstMirror committed Jul 5, 2018
1 parent 49f2a1b commit 805e177
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
18 changes: 17 additions & 1 deletion addons/vehicles/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GVAR(isSpeedLimiter) = false;
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 'Car' ||
{vehicle ACE_player isKindOf 'Tank'}}) exitWith {false};

GVAR(isUAV) = false;
Expand All @@ -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
10 changes: 5 additions & 5 deletions addons/vehicles/functions/fnc_speedLimiter.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
3 changes: 3 additions & 0 deletions addons/vehicles/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions addons/vehicles/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>

0 comments on commit 805e177

Please sign in to comment.