diff --git a/SQF/dayz_code/compile/fnc_brakeFix.sqf b/SQF/dayz_code/compile/fnc_brakeFix.sqf new file mode 100644 index 000000000..97b350000 --- /dev/null +++ b/SQF/dayz_code/compile/fnc_brakeFix.sqf @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Improve braking power of motorcycles and bicycles. +// +/////////////////////////////////////////////////////////////////////////////////////////////////// + +local _bike = _this select 0; +local _speed = speed _bike; +local _slow = 0.4; // increase/decrease this value to adjust braking power. Must be > 0. Default: 0.4 + +while {player != (vehicle player)} do { + if (DZE_isBraking && {_speed > 0}) then { + local _vel = velocity _bike; + local _dir = getDir _bike; + + _bike setVelocity [ + (_vel select 0) - (sin _dir * _slow), + (_vel select 1) - (cos _dir * _slow), + (_vel select 2) + ]; + + DZE_isBraking = false; + }; + uiSleep 0.01; + _speed = speed _bike; +}; +DZE_isOnBike = false; diff --git a/SQF/dayz_code/compile/keyboard.sqf b/SQF/dayz_code/compile/keyboard.sqf index 9cfa02764..2c408d746 100644 --- a/SQF/dayz_code/compile/keyboard.sqf +++ b/SQF/dayz_code/compile/keyboard.sqf @@ -290,6 +290,11 @@ if (isNil "keyboard_keys") then { } forEach (_this select 0); }; + local _brake = { + if (DZE_isOnBike) then {DZE_isBraking = true}; + call _interrupt; + }; + keyboard_keys = []; channel_keys = []; voice_keys = []; @@ -331,7 +336,7 @@ if (isNil "keyboard_keys") then { [actionKeys "MoveLeft", _interrupt] call _addArray; // Delete Key [actionKeys "MoveRight", _interrupt] call _addArray; // End Key [actionKeys "MoveForward", _interrupt] call _addArray; // W / Up Arrow Keys - [actionKeys "MoveBack", _interrupt] call _addArray; // S / Down Arrow Keys + [actionKeys "MoveBack", _brake] call _addArray; // S / Down Arrow Keys [actionKeys "TurnLeft", _interrupt] call _addArray; // A / Left Arrow Keys [actionKeys "TurnRight", _interrupt] call _addArray; // D / Right Arrow Keys /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index dcda08a07..072fa9fbd 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -197,6 +197,7 @@ if (!isDedicated) then { fnc_remoteMessage = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_remoteMessage.sqf"; fnc_freeBackpackSlots = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_freeBackpackSlots.sqf"; fnc_apsiState = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\apsiState.sqf"; // Toggle APSI on and off + fnc_brakeFix = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fnc_brakeFix.sqf"; // fix for motorcycle & bicycle brakes if (DZE_EVR) then {call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\client_evr.sqf";}; if (DZE_Remote_Vehicle) then { @@ -256,6 +257,7 @@ if (!isDedicated) then { }; fnc_setWeather = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\weather\setWeather.sqf"; fnc_groundFog = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\weather\groundFog.sqf"; + fnc_issheltered = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_isSheltered.sqf"; // Compiles of all trading related functions call compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\AdvancedTrading\compiles.sqf"; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 09c987c86..a775cea79 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -510,4 +510,6 @@ if (!isDedicated) then { DZE_sheltered = 0.0; // used in determining how much a player is sheltered from the environment DZE_roofOverhead = false; DZE_allTrees = dayz_trees + ["b_craet1.p3d"]; // include shrubs that the player can hide in + DZE_isOnBike = false; + DZE_isBraking = false; }; diff --git a/SQF/dayz_code/system/player_spawn_2.sqf b/SQF/dayz_code/system/player_spawn_2.sqf index e94496961..ece15a47a 100644 --- a/SQF/dayz_code/system/player_spawn_2.sqf +++ b/SQF/dayz_code/system/player_spawn_2.sqf @@ -309,8 +309,11 @@ while {1 == 1} do { //sleep 1; }; - //Crowbar ammo fix - //"MeleeCrowbar" call dayz_meleeMagazineCheck; + // Brake Fix for Motorcycles and Bicycles + if (!DZE_isOnBike && {_refObj isKindOf "Motorcycle" && {driver _refObj == player}}) then { // player just mounted a motorcycle or bicycle + DZE_isOnBike = true; + [_refObj] spawn fnc_brakeFix; + }; /* _stop = diag_tickTime;