Kydoimos 916 Posted July 19, 2014 Hi all - looking for a godsend to help here! Basically, I wish to disable the movement keys - as part of a workaround for the gunner on the offroad issuing driving commands. Not sure if there's a way to detect whcih keys have been mapped to player's movement or not? Failing that, to be able to block the most common movement keys (W,A,S,Z) and (UP, DOWN, LEFT, RIGHT arrow keys) would be helpful! I want to stay away from that nasty disableUserInput command too! Any suggestions / codes / scripts would be highly appreciated! Thanks guys! Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 19, 2014 You can get different key mappings with actionKeys. And yound might be able to rework this snippet I use for cutscenes. It detects space bar hits to skip the cutscene, ignores movements but keeps view control enabled at the same time. disableSerialization; IP_Cutscene_Skip = false; _ehSkip = ([] call BIS_fnc_displayMission) displayAddEventHandler [ "KeyDown", " if (_this select 1 == 57) then { if (IP_Cutscene_Skip) exitWith {}; playSound ['click',true]; IP_Cutscene_Skip = true; }; if !((_this select 1) in (actionKeys 'PersonView' + [1])) then {true}; " ]; uiNamespace setVariable ["IP_Cutscene_ehSkip", _ehSkip]; And to remove it: ([] call BIS_fnc_displayMission) displayRemoveEventHandler ['KeyDown', (uiNamespace getVariable "IP_Cutscene_ehSkip")]; uiNamespace setVariable ["IP_Cutscene_ehSkip", nil]; IP_Cutscene_Skip = nil; 1 Share this post Link to post Share on other sites
Kydoimos 916 Posted July 19, 2014 Nice one! I'll play around with that! It's a little over my head but I'm sure I'll work it out! I think a variation of that could probably be used to kill player movement buttons. I can take out the playSound, and the cutscene skip parts, maybe it should work! Thanks, IndeedPete - very helpful, as always! ---------- Post added at 11:58 ---------- Previous post was at 11:43 ---------- if (_this select 1 == 57)I had little look at the actionKeys and can see the keys are referred too with some sort of code. So, I assume, '57' is the space bar key? And there's a 'Keydown' eventHandler that triggers the code that skips the cutscene. Out of interest, how / where did you get the '57' from? Also, how would I go about disabling the key in the 'Keydown' eventhandler? It's really interesting stuff - thanks for the pointer! Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 19, 2014 (edited) Yes, 57 identifies the space bar key. Here's a list of identified keys but I'm not sure if it's up to date. The actual code to skip the cutscene is somewhere else, I just use the global var "IP_Cutscene_Skip" as flag. It's checked after every sentence of a cutscene. The full script just for the sake of context is this one (it's part of my conv system): if (count _this < 2) exitWith {false}; private ["_speakers", "_sentences", "_whichChat", "_isCutscene", "_count", "_ehSkip"]; _speakers = [_this, 0, [], [[]]] call BIS_fnc_param; _sentences = [_this, 1, [], [[]]] call BIS_fnc_param; _whichChat = [_this, 2, "SIDE", [""]] call BIS_fnc_param; _isCutscene = [_this, 3, false, [true]] call BIS_fnc_param; _count = count _speakers; if (_isCutscene) then { disableSerialization; IP_Cutscene_Skip = false; _ehSkip = ([] call BIS_fnc_displayMission) displayAddEventHandler [ "KeyDown", " if (_this select 1 == 57) then { if (IP_Cutscene_Skip) exitWith {}; playSound ['click',true]; IP_Cutscene_Skip = true; }; if !((_this select 1) in (actionKeys 'PersonView' + [1])) then {true}; " ]; uiNamespace setVariable ["IP_Cutscene_ehSkip", _ehSkip]; [0] call BIS_fnc_cinemaBorder; }; for "_i" from 0 to ((count _sentences) - 1) do { _speaker = _speakers select (_i mod _count); _sentence = _sentences select _i; [_speaker, _sentence, _whichChat] call IP_fnc_simpleSentence; [color="#FF0000"][b]if ((!isNil "IP_Cutscene_Skip") && {IP_Cutscene_Skip}) exitWith {};[/b][/color] }; if (_isCutscene) then { [1] call BIS_fnc_cinemaBorder; ([] call BIS_fnc_displayMission) displayRemoveEventHandler ['KeyDown', (uiNamespace getVariable "IP_Cutscene_ehSkip")]; uiNamespace setVariable ["IP_Cutscene_ehSkip", nil]; IP_Cutscene_Skip = nil; }; I simulate simple face-to-face or group-conversations with that one. It's the contrary to my dialog-based multiple choice system. I guess for your purposes you can scratch the part with "if (_this select 1 == 57) then {...". You should focus on the last line: if !((_this select 1) in (actionKeys 'PersonView' + [1])) then {true}; Where (_this select 1) is the pressed key and (actionKeys "PersonView") an array of whitelisted keys which should be processed by the game whereas any other key may be ignored. It basically means that the player is still able to look around during a cutsceneand hit Escape, but he can't shoot or walk or anything else. You could adapt that to a blacklist functionality by removing the ! operator (untested): if ((_this select 1) in (actionKeys 'PersonView')) then {true}; This should ignore all keys mapped to the category "PersonView". Edited July 19, 2014 by IndeedPete Share this post Link to post Share on other sites
f2k sel 164 Posted July 19, 2014 if (isNull player) exitwith {}; KEY_fnc_keyDown = { _ctrl = _this select 0; _dikCode = _this select 1; _shift = _this select 2; _ctrlKey = _this select 3; _alt = _this select 4; Bkeys=[]; {Bkeys = Bkeys + [(actionKeys _x) select 0]} foreach [ "moveBack","moveDown","moveFastForward","moveForward","moveLeft","moveRight","moveSlowForward","turbo","turnLeft","turnRight", "commandBack","commandFast","commandForward","commandLeft","commandRight","commandSlow", "CarFastForward","CarBack","CarForward","CarLeft","CarMovement","CarRight","CarSlowForward","CarWheelLeft","CarWheelRight" ]; if (_dikCode in Bkeys) then { hint "Disabled input"; true }; }; waitUntil {!isNull findDisplay 46}; (findDisplay 46) displayAddEventHandler ["keyDown","_this call KEY_fnc_keyDown"]; That blocks most of the movement keys, but as yet I can't seem to block the arrow keys without using numbers, there must be an action key for it. There is one major issue the vehicle won't move unless ordered to move by the player so it seems pointless Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 19, 2014 Yes, that seems true. Maybe it works if the player gets put into the gunner position once the AI is already on the road? Or maybe use unitCapture right away if there's no need for dynamic movement. Share this post Link to post Share on other sites
f2k sel 164 Posted July 19, 2014 They only move until they reach the next waypoint then they wait for your orders. Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 19, 2014 Well, one could try a rather clunky approach by doing cutout-remove player from vehicle-wait a few seconds-move player back into vehicle-cutin on every waypoint... Share this post Link to post Share on other sites
f2k sel 164 Posted July 19, 2014 You would have to re add the waypoints or be removed before the current waypoint completes. It would be nearly as hard as getting BIS to fix it, they still haven't fixed the reversing issue. Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 19, 2014 Reversing issue? Only really annoying issue with WPs I had was that if a vehicle gets disabled but the crew survives their current WP seems to be completed immediately. If it was their last WP they simply stop at their current position. Share this post Link to post Share on other sites
f2k sel 164 Posted July 19, 2014 I did a little test and removing the player from the vehicle for 0.3 secs does actually work, it's not pretty though. in the waypoints act player setpos [0,0,100]; null=[] spawn {sleep 0.3;player moveingunner tankname} If you give the order for AI driver to reverse it either does it very slowly (seems to be fighting forward movement) or just stops and spins tracks, at worst it carries on going forwards. http://feedback.arma3.com/view.php?id=16717 Share this post Link to post Share on other sites
Kydoimos 916 Posted July 19, 2014 Thanks guys! Yes - the waypoint issue is still a problem (fortunately, for me, there's only 1 waypoint needed!). To be honest now, I'm thinking about using the UnitPlay function, locking first person view with the cinema border (thus hiding the non-existent wheel movement) and recording the audio for the vehicle movement separately! It's a rather long-winded process for such a simple idea - but hey, there we go. If that fails, I'm going to have to try blocking the movement keys. Thanks F2K Sel, IndeedPete - I might have to add some easter eggs into the campaign relating to you both! :cool: Share this post Link to post Share on other sites