mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-21 23:50:48 +03:00
Improve filterCheats and VON block
Filter cheats is now added to the main options menus that needed it.
It is not needed on the map (display 12) because KeyDown for display 46
also fires when it is open. So filterCheats was firing twice (once on
each display) in that case.
KeyDown does not fire on display 63 at all
regardless of whether PTT or VON is held down, toggled or chat open.
Keydown does fire on 55, but only after the mic icon is locked on, so it
is of limited use. MouseButtonDown does not fire on 55 or 63. So it is
useless to add to those displays. You can confirm this with:
(findDisplay 63) displayAddEventHandler ["KeyDown","systemchat
'fired';"];
Filter cheats is now only checked on display 46 when a
voice, channel, or cheat key is pressed instead of on every key press.
This still works 100% of the time for blocking cheat input. For
performance reasons it's probably not worth checking all the conditions
in filterCheats with every key press on display46 just for the VON
block. Doing so covers some edge combination bind cases better, so it
may be worth considering again if no better alternative is found. For
now this solution is good enough to cover the majority of cases without
slowing down the keyhandler during normal usage.
The VON message now
tells you exactly which channel block you triggered instead of listing
all of them.
Fixed issue mentioned in 52c9c7c with VON getting stuck on when using a
double tap keybind.
Tested:
1. Talk in side with regular/combo/mouse bind
2. Change channels
while mic is locked on with regular/combo/mouse bind
3. Change channels
with Up/Down arrows while chat is open.
4. Trying all cases in steps 1-3
with a dialog open.
It is possible to bypass the VON block with some different control
settings and combinations of the above, but for default controls and
common usage it works the majority of the time.
This commit is contained in:
@@ -43,6 +43,10 @@ if (isNil "keyboard_keys") then {
|
||||
};
|
||||
_handled = true;
|
||||
};
|
||||
_filterCheat = {
|
||||
//Overriding default engine handling does not stop cheat input, need manual disableUserInput too
|
||||
_handled = [displayNull,_dikCode,_shiftState] call dze_filterCheats;
|
||||
};
|
||||
_openGroups = {
|
||||
if (dayz_requireRadio && !("ItemRadio" in items player)) then {
|
||||
localize "STR_EPOCH_NEED_RADIO" call dayz_rollingMessages;
|
||||
@@ -144,7 +148,10 @@ if (isNil "keyboard_keys") then {
|
||||
};
|
||||
// TODO: left/right, when gear open: onKeyDown = "[_this,'onKeyDown',0,107,0,107] execVM '\z\addons\dayz_code\system\handleGear.sqf'";
|
||||
_noise = {
|
||||
if (diag_ticktime - dayz_lastCheckBit > 10) then {
|
||||
//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 {
|
||||
dayz_lastCheckBit = diag_ticktime;
|
||||
[player,20,true,(getPosATL player)] call player_alertZombies;
|
||||
};
|
||||
@@ -245,6 +252,10 @@ if (isNil "keyboard_keys") then {
|
||||
};
|
||||
|
||||
keyboard_keys = [];
|
||||
channel_keys = [];
|
||||
voice_keys = [];
|
||||
{voice_keys = voice_keys + (actionKeys _x)} count voice_actions;
|
||||
{channel_keys = channel_keys + (actionKeys _x)} count ["NextChannel","PrevChannel"];
|
||||
keyboard_keys resize 256;
|
||||
[[DIK_ESCAPE], _cancelBuild] call _addArray;
|
||||
[[DIK_INSERT], {DZE_Q_alt = true;}] call _addArray;
|
||||
@@ -255,6 +266,7 @@ if (isNil "keyboard_keys") then {
|
||||
[[DIK_Q], {DZE_4 = true;}] call _addArray;
|
||||
[[DIK_E], {DZE_6 = true;}] call _addArray;
|
||||
[[DIK_0], _autoRun] call _addArray;
|
||||
[[DIK_NUMPADMINUS], _filterCheat] call _addArray;
|
||||
[[DIK_SPACE], {DZE_5 = true;}] call _addArray;
|
||||
[actionKeys "User6", {DZE_F = true;}] call _addArray;
|
||||
[actionKeys "User7", {DZE_Q_ctrl = true;}] call _addArray;
|
||||
@@ -280,9 +292,16 @@ if (isNil "keyboard_keys") then {
|
||||
[actionKeys "MoveBack", _interrupt] call _addArray;
|
||||
[actionKeys "TurnLeft", _interrupt] call _addArray;
|
||||
[actionKeys "TurnRight", _interrupt] call _addArray;
|
||||
[actionKeys "PushToTalk", _noise] call _addArray;
|
||||
[actionKeys "PushToTalk", _noise] call _addArray;
|
||||
[actionKeys "PushToTalkAll", _noise] call _addArray;
|
||||
[actionKeys "PushToTalkCommand", _noise] call _addArray;
|
||||
[actionKeys "PushToTalkDirect", _noise] call _addArray;
|
||||
[actionKeys "PushToTalkGroup", _noise] call _addArray;
|
||||
[actionKeys "PushToTalkSide", _noise] call _addArray;
|
||||
[actionKeys "PushToTalkVehicle", _noise] call _addArray;
|
||||
[actionKeys "VoiceOverNet", _noise] call _addArray;
|
||||
[actionKeys "PushToTalkDirect", _noise] call _addArray;
|
||||
[actionKeys "NextChannel", _noise] call _addArray;
|
||||
[actionKeys "PrevChannel", _noise] call _addArray;
|
||||
[actionKeys "Chat", _noise] call _addArray;
|
||||
[actionKeys "User20", _journal] call _addArray;
|
||||
[actionKeys "Diary", _journal] call _addArray;
|
||||
@@ -310,12 +329,10 @@ if (isNil "keyboard_keys") then {
|
||||
if (!isNil "bis_fnc_halo_keydown_eh") then {bis_fnc_halo_keydown_eh = (finddisplay 46) displayaddeventhandler ["keydown","_this call bis_fnc_halo_keydown;"];}; // halo in progress
|
||||
};
|
||||
|
||||
_CheatHandled = _this call DZE_FilterCheats;
|
||||
|
||||
if (r_player_unconsciousInputDisabled) exitWith {true};
|
||||
_code = keyboard_keys select _dikCode;
|
||||
if (!isNil "_code") then {
|
||||
call _code;
|
||||
};
|
||||
|
||||
(_handled || _CheatHandled);
|
||||
_handled
|
||||
50
SQF/dayz_code/compile/player_filterCheats.sqf
Normal file
50
SQF/dayz_code/compile/player_filterCheats.sqf
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Overriding default engine handling does not stop cheat input.
|
||||
It also does not stop VON when combination binds like Ctrl+Z are used, because keyDown registers each key press individually.
|
||||
We need to manually disable user input.
|
||||
*/
|
||||
#include "\ca\editor\Data\Scripts\dikCodes.h"
|
||||
_dik = _this select 1;
|
||||
_shift = _this select 2;
|
||||
|
||||
_handled = false;
|
||||
_channel = ctrlText (findDisplay 63 displayCtrl 101);
|
||||
_micIcon = ctrlShown (findDisplay 55 displayCtrl 101);
|
||||
_inputAction1 = {inputAction _x > 0} count voice_actions; //Includes mouse buttons and combination binds, but does not work when a dialog is open
|
||||
_inputAction2 = {inputAction _x > 0} count ["NextChannel","PrevChannel"];
|
||||
/*
|
||||
_channel = previous channel when changing channels.
|
||||
We can not predict which one that will be, because description.ext settings vary.
|
||||
So block all changing of channels while mic is locked on for now.
|
||||
*/
|
||||
_channelChange = _micIcon && ((!isNull findDisplay 24 && _dik in [DIK_DOWN,DIK_UP]) or (_dik in channel_keys) or (_inputAction2 > 0));
|
||||
_blockVoice = _channelChange or ((_dik in voice_keys or (_inputAction1 > 0)) && (_channel in DZE_DisabledChannels));
|
||||
|
||||
if ((_dik == DIK_NUMPADMINUS && _shift) or _blockVoice) then {
|
||||
if (!_blockVoice) then {call player_forceSave;}; //Perform before disableUserInput to prevent reenable
|
||||
disableUserInput true;disableUserInput true;
|
||||
if (_blockVoice) then {findDisplay 55 closeDisplay 2;};
|
||||
|
||||
[_blockVoice,_channel,_channelChange] spawn {
|
||||
_blockVoice = _this select 0;
|
||||
_channel = _this select 1;
|
||||
_channelChange = _this select 2;
|
||||
_testTime = diag_tickTime;
|
||||
CheatsDisabled = _testTime;
|
||||
switch true do {
|
||||
case _channelChange: {[localize "STR_EPOCH_NO_CHANNEL_SWITCH",1] call dayz_rollingMessages;};
|
||||
case _blockVoice: {[format[localize "STR_EPOCH_NO_VOICE",_channel],1] call dayz_rollingMessages;};
|
||||
default {[localize "STR_EPOCH_NO_CHEATS",1] call dayz_rollingMessages;};
|
||||
};
|
||||
uiSleep 5;
|
||||
if (!r_player_unconsciousInputDisabled && CheatsDisabled == _testTime) then {
|
||||
//Enable input, disable and reenable to prevent the last key press being input after re-enable
|
||||
disableUserInput false;disableUserInput true;disableUserInput false;disableUserInput false;
|
||||
};
|
||||
};
|
||||
_handled = true;
|
||||
};
|
||||
|
||||
//diag_log format["FilterCheats - Display:%7 DIK:%1 Channel:%2 ChannelChange:%3 BlockVoice:%4 Handled:%5 MicIcon:%6 InputAction1:%8 InputAction2:%9",_dik,_channel,_channelChange,_blockVoice,_handled,_micIcon,(_this select 0),_inputAction1,_inputAction2];
|
||||
|
||||
_handled
|
||||
@@ -3,11 +3,6 @@ private ["_holdBreath","_turboKey"];
|
||||
//Sleep required for actionKeys to update after controls dialog closes
|
||||
uiSleep 1;
|
||||
|
||||
dayz_voiceControls = [];
|
||||
DayZ_channelChangeKeys = [];
|
||||
{dayz_voiceControls = dayz_voiceControls + (actionKeys _x)} count ["voiceOverNet","PushToTalk","PushToTalkAll","PushToTalkCommand","PushToTalkDirect","PushToTalkGroup","PushToTalkSide","PushToTalkVehicle"];
|
||||
{DayZ_channelChangeKeys = DayZ_channelChangeKeys + (actionKeys _x)} count ["NextChannel","PrevChannel"];
|
||||
|
||||
//Refresh keyboard_keys after controls change
|
||||
if (_this) then {
|
||||
keyboard_keys = nil;
|
||||
|
||||
Reference in New Issue
Block a user