diff --git a/SQF/dayz_code/compile/keyboard.sqf b/SQF/dayz_code/compile/keyboard.sqf index b098af20f..794c76b3e 100644 --- a/SQF/dayz_code/compile/keyboard.sqf +++ b/SQF/dayz_code/compile/keyboard.sqf @@ -2,6 +2,8 @@ #include "\ca\editor\Data\Scripts\dikCodes.h" +private ["_dikCode","_shiftState","_ctrlState","_altState","_handled","_cancelBuild","_dze_f","_dze_q","_dze_z","_autoRun","_filterCheat","_openGroups","_muteSound","_statusUI","_rifle","_pistol","_melee","_surrender","_gear","_forcesave","_drop","_interrupt","_noise","_journal","_build_left","_build_right","_build_str8OnOff","_block","_addArray","_code"]; + _dikCode = _this select 1; _shiftState = _this select 2; _ctrlState = _this select 3; @@ -16,27 +18,29 @@ if (isNil "keyboard_keys") then { if (r_player_dead) then {_handled = true;}; // Disable ESC after death }; _dze_f = { - if (!_ctrlState && !_altState) then {DZE_F = true;}; + if (!_ctrlState && {!_altState}) then {DZE_F = true;}; }; _dze_q = { - if (!_ctrlState && !_altState) then {DZE_Q = true;}; - if (!_ctrlState && _altState) then {DZE_Q_alt = true;}; - if (_ctrlState && !_altState) then {DZE_Q_ctrl = true;}; + if (!_ctrlState && {!_altState}) then {DZE_Q = true;}; + if (!_ctrlState && {_altState}) then {DZE_Q_alt = true;}; + if (_ctrlState && {!_altState}) then {DZE_Q_ctrl = true;}; }; _dze_z = { - if (!_ctrlState && !_altState) then {DZE_Z = true;}; - if (!_ctrlState && _altState) then {DZE_Z_alt = true;}; - if (_ctrlState && !_altState) then {DZE_Z_ctrl = true;}; + if (!_ctrlState && {!_altState}) then {DZE_Z = true;}; + if (!_ctrlState && {_altState}) then {DZE_Z_alt = true;}; + if (_ctrlState && {!_altState}) then {DZE_Z_ctrl = true;}; }; _autoRun = { if (!dayz_autoRun) then { dayz_autoRun = true; dayz_autoRunThread = [] spawn { + private "_weapon"; + _weapon = currentWeapon player; while {dayz_autoRun} do { // SurfaceIsWater does not work for ponds // Check weapon to detect Arma action (dayz action is handled in dz_fn_switchWeapon) - if (player != vehicle player or (surfaceIsWater getPosASL player) or ((call fn_nearWaterHole) select 0) or (currentWeapon player != _weapon) or r_fracture_legs) exitWith { + if (player != vehicle player or {r_fracture_legs} or {surfaceIsWater getPosASL player} or {currentWeapon player != _weapon} or {(call fn_nearWaterHole) select 0}) exitWith { call dayz_autoRunOff; }; player playAction "FastF"; @@ -53,7 +57,7 @@ if (isNil "keyboard_keys") then { _handled = [displayNull,_dikCode,_shiftState] call dze_filterCheats; }; _openGroups = { - if (dayz_requireRadio && !("ItemRadio" in items player)) then { + if (dayz_requireRadio && {!("ItemRadio" in items player)}) then { localize "STR_EPOCH_NEED_RADIO" call dayz_rollingMessages; } else { if (isNull findDisplay 80000) then { @@ -106,7 +110,7 @@ if (isNil "keyboard_keys") then { _ammo_throwable set [ count _ammo_throwable, getText(configFile >> "cfgMagazines" >> _x >> "ammo") ]; _muzzles_throwable set [ count _muzzles_throwable, _muzz ]; _weapon_throwable set [ count _weapon_throwable, _weapon ]; - }; + }; } forEach getArray(configFile >> "cfgWeapons" >> _weapon >> _muzz >> "magazines"); } forEach _muzzles; } forEach ["Throw"]; @@ -114,7 +118,7 @@ if (isNil "keyboard_keys") then { _magCount = count _ammo_throwable; if (_magCount > 0) then { if (isNil "KB_CurrentThrowable") then { KB_CurrentThrowable = -1; }; - _currentAmmo = (weaponState player) select 3; + _currentAmmo = (weaponState player) select 3; _idx = _ammo_throwable find _currentAmmo; if (_idx >= 0) then { KB_CurrentThrowable = _idx; }; KB_CurrentThrowable = (KB_CurrentThrowable + 1) mod _magCount; @@ -129,26 +133,30 @@ if (isNil "keyboard_keys") then { _handled = true; }; _gear = { - if ((vehicle player != player) and !_shiftState and !_ctrlState and !_altState && !dialog) then { + if ((vehicle player != player) && {!_shiftState} && {!_ctrlState} && {!_altState} && {!dialog}) then { createGearDialog [player, "RscDisplayGear"]; _handled = true; - } - else { if ((vehicle player == player) and (speed vehicle player > 0)) then { - //[objNull, player, rSwitchMove,""] call RE; - _handled = true; - };}; + } else { + if ((vehicle player == player) && {speed vehicle player > 0}) then { + //[objNull, player, rSwitchMove,""] call RE; + _handled = true; + }; + }; }; _forcesave = { if (diag_tickTime - dayz_lastSave > 10) then { call player_forceSave; }; }; + /* _forcesave2 = { if ((!isNull (findDisplay 106)) OR dialog) then { - call player_forceSave; + call player_forceSave; }; }; + */ _drop = { + private "_doors"; if (r_drag_sqf) then { _doors = nearestObjects [player, DayZ_DropDrageeObjects, 3]; //Prevent dropping dragged player through objects if (count _doors > 0) then {_handled = true;}; @@ -167,14 +175,14 @@ if (isNil "keyboard_keys") then { _noise = { //Overriding default engine handling does not stop combination binds, need manual disableUserInput too _handled = [displayNull,_dikCode,_shiftState] call dze_filterCheats; - - if (diag_ticktime - dayz_lastCheckBit > 10 && !(_dikCode in channel_keys)) then { + + if (diag_ticktime - dayz_lastCheckBit > 10 && {!(_dikCode in channel_keys)}) then { dayz_lastCheckBit = diag_ticktime; [player,20,true,(getPosATL player)] call player_alertZombies; }; }; _journal = { - if (!dayz_isSwimming and !dialog) then { + if (!dayz_isSwimming && {!dialog}) then { [player,4,true,(getPosATL player)] call player_alertZombies; createDialog 'horde_journal_front_cover'; }; @@ -185,9 +193,11 @@ if (isNil "keyboard_keys") then { DZE_4 = true; // fence construction if (0 != count Dayz_constructionContext) then { + private ["_angleRef", "_dir","_new"]; + _angleRef = Dayz_constructionContext select 1; _dir = _angleRef - (getDir player) -5; - if (_dir > 180) then {_dir = _dir - 360}; + if (_dir > 180) then {_dir = _dir - 360}; if (_dir < -180) then {_dir = _dir + 360}; if ( _dir > -75) then { _new = floor((_angleRef - 5)/5)*5; @@ -201,9 +211,11 @@ if (isNil "keyboard_keys") then { _build_right = { DZE_6 = true; if (0 != count Dayz_constructionContext) then { + private ["_angleRef", "_dir","_new"]; + _angleRef = Dayz_constructionContext select 1; _dir = _angleRef - (getDir player) +5; - if (_dir > 180) then { _dir = _dir - 360; }; + if (_dir > 180) then { _dir = _dir - 360; }; if (_dir < -180) then { _dir = _dir + 360; }; if (_dir < 75) then { _new = ceil((_angleRef + 5)/5)*5; @@ -217,12 +229,12 @@ if (isNil "keyboard_keys") then { _build_str8OnOff = { r_interrupt = true; - + if (0 != count Dayz_constructionContext) then { Dayz_constructionContext set [ 5, !(Dayz_constructionContext select 5) ]; _handled = true; }; - + if (animationState player in ["bunnyhopunarmed","bunnyhoprifle"]) then { //Fixes invisible weapon switch glitch if double tapping vault with no weapon in hands _handled = true; @@ -230,6 +242,8 @@ if (isNil "keyboard_keys") then { if (player isKindOf "PZombie_VB") then { _handled = true; // do not allow player zombies to vault or jump } else { + private "_nearbyObjects"; + _nearbyObjects = nearestObjects [getPosATL player, dayz_disallowedVault, 8]; if (count _nearbyObjects > 0) then { if (diag_tickTime - dayz_lastCheckBit > 4) then { @@ -246,7 +260,7 @@ if (isNil "keyboard_keys") then { _block = { _handled = true; }; - + _addArray = { { if (_x <= 999999) then { @@ -324,7 +338,7 @@ if (isNil "keyboard_keys") then { [[ DIK_F9,DIK_F10,DIK_F11,DIK_F12, DIK_F8,DIK_F7,DIK_F6,DIK_F5, DIK_F2,DIK_9, - DIK_8,DIK_7,DIK_6,DIK_5,DIK_4], _block] call _addArray; + DIK_8,DIK_7,DIK_6,DIK_5,DIK_4,DIK_BACK], _block] call _addArray; if (dayz_groupSystem) then { [[DIK_F5], _openGroups] call _addArray; [[DIK_LWIN,DIK_RWIN], {dayz_groupNameTags = !dayz_groupNameTags;_handled = true;}] call _addArray;