From 959507bfc7fb20e498e81d37215100f47ec7233c Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Tue, 1 Mar 2016 22:34:36 -0500 Subject: [PATCH] Add autorun hotkey Tested while autorunning: - getting knocked out - breaking legs - running into water - getting into and out of vehicles - climbing a ladder - dying - antiTP enabled - running up steep hills - as player zombie Everything works as expected. This does allow you to run up and down pretty steep hills, but if you try to scale something too steep you will break your legs as expected. --- CHANGE LOG 1.0.6.txt | 1 + SQF/dayz_code/compile/fn_unconscious.sqf | 1 + SQF/dayz_code/compile/keyboard.sqf | 19 ++++++++++++++++++- SQF/dayz_code/compile/player_death.sqf | 1 + SQF/dayz_code/init/compiles.sqf | 6 ++++++ SQF/dayz_code/init/variables.sqf | 1 + 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGE LOG 1.0.6.txt b/CHANGE LOG 1.0.6.txt index b4ea3135d..4165599b3 100644 --- a/CHANGE LOG 1.0.6.txt +++ b/CHANGE LOG 1.0.6.txt @@ -9,6 +9,7 @@ [NEW] Auto login when a player joins the server, default 10 seconds, requires description.ext update in the mission (disable in description.ext by setting defValueParam1 = 31;) @icomrade [NEW] Upgraded (_DZE1,2,3,4) ArmoredSUV and Kamaz classes are now available. #1518 #1538 @McKeighan [NEW] Optional news/rules feed on player login from DayZ Mod, set dayz_enableRules in init.sqf #1673 @ebaydayz +[NEW] Autorun hotkey (0 = Toggle auto run) @ebaydayz [NEW] Weapon switch hotkeys (1 = primary, 2 = pistol, 3 = melee) from DayZ Mod #1673 @ebaydayz [NEW] Added waves effect during stormy weather #974 @FramedYannick @ebaydayz [NEW] Optional variable to restrict wearable clothes. Add DZE_RestrictSkins to init.sqf #1560 @BetterDeadThanZed @ebaydayz diff --git a/SQF/dayz_code/compile/fn_unconscious.sqf b/SQF/dayz_code/compile/fn_unconscious.sqf index 2eae7725b..bdec73ea1 100644 --- a/SQF/dayz_code/compile/fn_unconscious.sqf +++ b/SQF/dayz_code/compile/fn_unconscious.sqf @@ -19,6 +19,7 @@ if ((!r_player_handler1) && (r_handlerCount == 0)) then { 0 fadeSound 0.05; disableUserInput true; _disableHdlr = [] spawn { uiSleep 2; disableUserInput true; r_player_unconsciousInputDisabled = true; }; + autoRunActive = 0; while {r_player_unconscious} do { _ctrl1 ctrlSetPosition [(_ctrl1Pos select 0),(_ctrl1Pos select 1),(_ctrl1Pos select 2),((0.136829 * safezoneH) * (1 -(r_player_timeout / _totalTimeout)))]; _ctrl1 ctrlCommit 1; diff --git a/SQF/dayz_code/compile/keyboard.sqf b/SQF/dayz_code/compile/keyboard.sqf index 79697d1a7..5ccb46880 100644 --- a/SQF/dayz_code/compile/keyboard.sqf +++ b/SQF/dayz_code/compile/keyboard.sqf @@ -32,6 +32,21 @@ if (isNil "keyboard_keys") then { if (!_ctrlState && _altState) then {DZE_Z_alt = true;}; if (_ctrlState && !_altState) then {DZE_Z_ctrl = true;}; }; + _autoRun = { + if (autoRunActive == 0) then { + autoRunActive = 1; + autoRunThread = [] spawn { + while {autoRunActive == 1} do { + if ((player != vehicle player) or (surfaceIsWater (getPosASL player)) or r_fracture_legs) exitWith {call autoRunOff;}; + player playAction "FastF"; + uiSleep 0.5; + }; + }; + } else { + call autoRunOff; + }; + _handled = true; + }; _rifle = { ["rifle"] spawn player_switchWeapon; _handled = true; @@ -162,6 +177,7 @@ if (isNil "keyboard_keys") then { _interrupt = { r_interrupt = true; if (DZE_Surrender) then {call dze_surrender_off}; + if (autoRunActive == 1) then {call autoRunOff;}; }; // TODO: left/right, when gear open: onKeyDown = "[_this,'onKeyDown',0,107,0,107] execVM '\z\addons\dayz_code\system\handleGear.sqf'"; _noise = { @@ -272,6 +288,7 @@ if (isNil "keyboard_keys") then { [[DIK_NEXT], _dze_z] call _addArray; [[DIK_Q], {DZE_4 = true;}] call _addArray; [[DIK_E], {DZE_6 = true;}] call _addArray; + [[DIK_0], _autoRun] call _addArray; [[DIK_SPACE], {DZE_5 = true;}] call _addArray; [actionKeys "User6", {DZE_F = true;}] call _addArray; [actionKeys "User7", {DZE_Q_ctrl = true;}] call _addArray; @@ -314,7 +331,7 @@ if (isNil "keyboard_keys") then { [actionKeys "ForceCommandingMode", {DZE_5 = true;_handled = true;}] call _addArray; [[ DIK_F9,DIK_F10,DIK_F11,DIK_F12, DIK_F8,DIK_F7,DIK_F6,DIK_F5,DIK_F4, - DIK_F3,DIK_F2,DIK_F1,DIK_0,DIK_9, + DIK_F3,DIK_F2,DIK_F1,DIK_9, DIK_8,DIK_7,DIK_6,DIK_5,DIK_4], _block] call _addArray; (findDisplay 46) displayRemoveAllEventHandlers "KeyUp"; diff --git a/SQF/dayz_code/compile/player_death.sqf b/SQF/dayz_code/compile/player_death.sqf index a960009d3..6006b5222 100644 --- a/SQF/dayz_code/compile/player_death.sqf +++ b/SQF/dayz_code/compile/player_death.sqf @@ -41,6 +41,7 @@ player setVariable ["medForceUpdate",true,true]; player setVariable ["startcombattimer", 0]; r_player_unconscious = false; r_player_cardiac = false; +autoRunActive = 0; _array = _this; if (count _array > 0) then { diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 1bd1383b0..09696f677 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -379,6 +379,12 @@ if (!isDedicated) then { player setVariable ["DZE_Surrendered", false, true]; DZE_Surrender = false; }; + + autoRunOff = { + autoRunActive = 0; + terminate autoRunThread; + player playActionNow "Stop"; + }; gear_ui_init = { private["_control","_parent","_menu","_dspl","_grpPos"]; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 613643bbd..e2a0fcfb6 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -835,4 +835,5 @@ if(!isDedicated) then { DZE_SaveTime = 30; Dayz_constructionContext = []; + autoRunActive = 0; };