From 633e7ec234780be1dce7d8c9842f2d8e0b58d9f9 Mon Sep 17 00:00:00 2001 From: Fratee Date: Sun, 9 Jun 2024 23:39:10 +0200 Subject: [PATCH] add camera slewing via HMD --- XEH_preInit.sqf | 13 ++++++++++++- functions/MPaddaction.sqf | 11 +++++++---- functions/hmdSlew.sqf | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 functions/hmdSlew.sqf diff --git a/XEH_preInit.sqf b/XEH_preInit.sqf index b5adf24..b7ee42c 100644 --- a/XEH_preInit.sqf +++ b/XEH_preInit.sqf @@ -109,4 +109,15 @@ nil, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer { } // function that will be executed once on mission start and every time the setting is changed. -] call CBA_Settings_fnc_init; \ No newline at end of file +] call CBA_Settings_fnc_init; + +[ + "Fat_Lurch_HmdSlew", // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting. + "CHECKBOX", // setting type. CHECKBOX, EDITBOX, SLIDER, LIST or COLOR + "Allow Slew via HMD", // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + "Turret Enhanced", // Pretty name of the category where the setting can be found. Can be stringtable entry. + TRUE, // data for this setting: [min, max, default, number of shown trailing decimals] + nil, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + { + } // function that will be executed once on mission start and every time the setting is changed. +] call CBA_Settings_fnc_init; diff --git a/functions/MPaddaction.sqf b/functions/MPaddaction.sqf index b1f058e..e394ad5 100644 --- a/functions/MPaddaction.sqf +++ b/functions/MPaddaction.sqf @@ -8,9 +8,11 @@ _pri = -1000; #include "\a3\editor_f\Data\Scripts\dikCodes.h" +// Add keybinds ["Turret Enhanced","add_blk_marker", "Mark Target (Blk)",{_this call fatlurch_fnc_addMarkerBlk}, "", [DIK_1, [true, false, false]]] call CBA_fnc_addKeybind; ["Turret Enhanced","add_blu_marker", "Mark Target (Blu)",{_this call fatlurch_fnc_addMarkerBlu}, "", [DIK_2, [true, false, false]]] call CBA_fnc_addKeybind; ["Turret Enhanced","add_red_marker", "Mark Target (Red)",{_this call fatlurch_fnc_addMarkerRed}, "", [DIK_3, [true, false, false]]] call CBA_fnc_addKeybind; +["Turret Enhanced","hmd_slew", "HMD Slew",{_this call fatlurch_fnc_hmdSlew}, "", [DIK_Y, [true, true, false]]] call CBA_fnc_addKeybind; // Default keybinding (Ctrl + Shift + Y) _unit addAction ["Mark Target (Blk)", "_this call fatlurch_fnc_addMarkerBlk",nil, _pri,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(Fat_Lurch_Markers))"]; _unit addAction ["Mark Target (Blu)", "_this call fatlurch_fnc_addMarkerBlu",nil, _pri - 1,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(Fat_Lurch_Markers))"]; @@ -19,11 +21,12 @@ _unit addAction ["Mark Target (Red)", "_this call fatlurc _unit addAction ["Change Altitude", "_this call fatlurch_fnc_changeAltitude",nil, _pri - 3,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR) && (_target isKindOf 'uav'))"]; //2020_08_24 _unit addAction ["Change Loiter", "_this call fatlurch_fnc_changeLoiter",nil, _pri - 4,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR) && (_target isKindOf 'uav') && (waypointType [group _target, currentWaypoint group _target] == 'LOITER'))"]; //2020_08_24 _unit addAction ["Map Slew", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target, _caller] call fatlurch_fnc_mapSlew;},nil, _pri - 5,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(Fat_Lurch_MapSlew))"]; -_unit addAction ["Slew to Grid", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target, _caller] call fatlurch_fnc_inputGrid;},nil, _pri - 6, false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(Fat_Lurch_Grid))"]; -_unit addAction ["Measure Distance", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target] call fatlurch_fnc_measDistance;},nil, _pri - 7,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(Fat_Lurch_Measure))"]; +_unit addAction ["HMD Slew", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target] call fatlurch_fnc_hmdSlew;},nil, _pri - 6,false, true, "","(!([_this, _target] call fatlurch_fnc_isViewISR)&&(hasPilotCamera vehicle _this)&&(Fat_Lurch_HmdSlew))"]; +_unit addAction ["Slew to Grid", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target, _caller] call fatlurch_fnc_inputGrid;},nil, _pri - 7, false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(Fat_Lurch_Grid))"]; +_unit addAction ["Measure Distance", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target] call fatlurch_fnc_measDistance;},nil, _pri - 8,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(Fat_Lurch_Measure))"]; //Placeholder for Measure -_unit addAction ["Weapon Status", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target] call fatlurch_fnc_weaponReport;},nil, _pri - 9,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(_target isKindOf 'uav'))"]; -_unit addAction ["Reset VMS", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target] call fatlurch_fnc_resetUAV;},nil, _pri - 10,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(_target isKindOf 'uav'))"]; +_unit addAction ["Weapon Status", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target] call fatlurch_fnc_weaponReport;},nil, _pri - 10,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(_target isKindOf 'uav'))"]; +_unit addAction ["Reset VMS", {params ["_target", "_caller", "_actionId", "_arguments"]; [_target] call fatlurch_fnc_resetUAV;},nil, _pri - 11,false, true, "","(([_this, _target] call fatlurch_fnc_isViewISR)&&(_target isKindOf 'uav'))"]; diff --git a/functions/hmdSlew.sqf b/functions/hmdSlew.sqf new file mode 100644 index 0000000..c45d050 --- /dev/null +++ b/functions/hmdSlew.sqf @@ -0,0 +1,17 @@ +// slew the camera to the HMD LOS + +if (Fat_Lurch_HmdSlew) then +{ + 0 spawn { + _HMDLos = screenToWorld [0.5,0.5]; + turretPath = player call CBA_fnc_turretPath; + _veh = vehicle player; + _tmpPos = "Land_PenBlack_F" createVehicle _HMDLos; + systemChat format["Turret Slewed to %1", mapgridposition _tmpPos]; + sleep 0.1; + _veh lockCameraTo [visiblePositionASL _tmpPos, turretPath]; + _veh setPilotCameraTarget (visiblePositionASL _tmpPos); + sleep 0.1; + deleteVehicle _tmpPos; + } +} \ No newline at end of file