From db39416cb67d9b5b08d321e325959024a625ce33 Mon Sep 17 00:00:00 2001 From: Bailey Danyluk Date: Fri, 30 Aug 2024 00:25:43 -0600 Subject: [PATCH] mclos updates --- addons/missileguidance/XEH_postInit.sqf | 34 ++++++++----------- .../functions/fnc_MCLOS_onFired.sqf | 1 + .../functions/fnc_mclosButtonPressed.sqf | 17 +++++++--- .../functions/fnc_seekerType_MCLOS.sqf | 3 +- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/addons/missileguidance/XEH_postInit.sqf b/addons/missileguidance/XEH_postInit.sqf index d3563814c7..692f6edaac 100644 --- a/addons/missileguidance/XEH_postInit.sqf +++ b/addons/missileguidance/XEH_postInit.sqf @@ -1,44 +1,40 @@ #include "script_component.hpp" +#include "\a3\ui_f\hpp\defineDIKCodes.inc" [QGVAR(handoff), LINKFUNC(handleHandoff)] call CBA_fnc_addEventHandler; ["ACE3 Weapons", QGVAR(cycleFireMode), LLSTRING(CycleFireMode), { - [] call FUNC(cycleAttackProfileKeyDown); - false + [] call FUNC(cycleAttackProfileKeyDown) }, { }, -[15, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key +[DIK_TAB, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key // Each MCLOS argument is the vector which acceleration will be applied ["ACE3 Weapons", QGVAR(mclosUp), LLSTRING(mclosUp), { - [[0, 0, 1], ACE_player] call FUNC(mclosButtonPressed); - false + [[0, 0, 1], ACE_player] call FUNC(mclosButtonPressed) }, { - [[0, 0, -1], ACE_player] call FUNC(mclosButtonPressed); + [[0, 0, -1], ACE_player] call FUNC(mclosButtonPressed) }, -[0x48, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 8 +[DIK_NUMPAD8, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 8 ["ACE3 Weapons", QGVAR(mclosDown), LLSTRING(mclosDown), { - [[0, 0, -1], ACE_player] call FUNC(mclosButtonPressed); - false + [[0, 0, -1], ACE_player] call FUNC(mclosButtonPressed) }, { - [[0, 0, 1], ACE_player] call FUNC(mclosButtonPressed); + [[0, 0, 1], ACE_player] call FUNC(mclosButtonPressed) }, -[0x50, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 2 +[DIK_NUMPAD2, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 2 ["ACE3 Weapons", QGVAR(mclosLeft), LLSTRING(mclosLeft), { - [[1, 0, 0], ACE_player] call FUNC(mclosButtonPressed); - false + [[1, 0, 0], ACE_player] call FUNC(mclosButtonPressed) }, { - [[-1, 0, 0], ACE_player] call FUNC(mclosButtonPressed); + [[-1, 0, 0], ACE_player] call FUNC(mclosButtonPressed) }, -[0x4D, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 6 +[DIK_NUMPAD6, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 6 ["ACE3 Weapons", QGVAR(mclosRight), LLSTRING(mclosRight), { - [[-1, 0, 0], ACE_player] call FUNC(mclosButtonPressed); - false + [[-1, 0, 0], ACE_player] call FUNC(mclosButtonPressed) }, { - [[1, 0, 0], ACE_player] call FUNC(mclosButtonPressed); + [[1, 0, 0], ACE_player] call FUNC(mclosButtonPressed) }, -[0x4B, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 4 +[DIK_NUMPAD4, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // Numpad 4 diff --git a/addons/missileguidance/functions/fnc_MCLOS_onFired.sqf b/addons/missileguidance/functions/fnc_MCLOS_onFired.sqf index e5f9bace0e..f4cdb2d3c6 100644 --- a/addons/missileguidance/functions/fnc_MCLOS_onFired.sqf +++ b/addons/missileguidance/functions/fnc_MCLOS_onFired.sqf @@ -18,3 +18,4 @@ params ["_firedEH", "", "", "", "_stateParams"]; _firedEH params ["_shooter","_weapon","","","","","_projectile"]; _stateParams params ["", "_seekerStateParams"]; +_projectile setVariable [QGVAR(source), vehicle _shooter]; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_mclosButtonPressed.sqf b/addons/missileguidance/functions/fnc_mclosButtonPressed.sqf index 542a4acbbe..c3f1e81955 100644 --- a/addons/missileguidance/functions/fnc_mclosButtonPressed.sqf +++ b/addons/missileguidance/functions/fnc_mclosButtonPressed.sqf @@ -8,7 +8,7 @@ * 1: Unit * * Return Value: - * None + * If the button is pressed with an MCLOS context * * Example: * [[0, 0, 1], player] call ace_missileguidance_fnc_mclosButtonPressed @@ -20,10 +20,17 @@ private _projectiles = _player getVariable [QGVAR(MCLOS_Projectiles), []]; _projectiles = _projectiles select { !isNull _x }; _player setVariable [QGVAR(MCLOS_Projectiles), _projectiles]; -if (getNumber ((configOf vehicle _player) >> QGVAR(hasMCLOSControl) == 1) then { +private _inMclosControlled = false; + +private _shooter = vehicle _player; +if (getNumber ((configOf _shooter) >> QGVAR(hasMCLOSControl) == 1) then { playSound "ACE_Sound_Click"; + + private _currentDirection = _shooter getVariable [QGVAR(MCLOS_direction), [0, 0, 0]]; + // Send direction across network for non-local projectiles + // This is the case in a wanted development for a proper Malyutka implementation + _shooter setVariable [QGVAR(MCLOS_direction), _currentDirection vectorAdd _accelerationDirection, true]; + _inMclosControlled = true; }; -private _currentDirection = _player getVariable [QGVAR(MCLOS_direction), [0, 0, 0]]; -_player setVariable [QGVAR(MCLOS_direction), _currentDirection vectorAdd _accelerationDirection]; - +_inMclosControlled diff --git a/addons/missileguidance/functions/fnc_seekerType_MCLOS.sqf b/addons/missileguidance/functions/fnc_seekerType_MCLOS.sqf index 86d792a964..d5640bded5 100644 --- a/addons/missileguidance/functions/fnc_seekerType_MCLOS.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_MCLOS.sqf @@ -21,8 +21,9 @@ _firedEH params ["","","","","","","_projectile","_gunner"]; _flightParams params ["_pitchRate", "_yawRate"]; private _projectilePos = getPosASLVisual _projectile; +private _source = _projectile getVariable [QGVAR(source), _projectile]; -private _accelerationDirection = _projectile vectorModelToWorldVisual (_gunner getVariable [QGVAR(MCLOS_direction), [0, 0, 0]]); +private _accelerationDirection = _projectile vectorModelToWorldVisual (_source getVariable [QGVAR(MCLOS_direction), [0, 0, 0]]); private _returnPos = _projectilePos vectorAdd (_accelerationDirection vectorMultiply (_pitchRate max _yawRate)); _targetData set [0, _projectilePos vectorFromTo _returnPos];