From 3b10396d3bd016daeae5268c89d22d9f114def59 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 27 Aug 2024 06:36:07 +0200 Subject: [PATCH] Dragging - Fix dragging breaking via keybind (#10261) Fixed dragging breaking via keybind --- addons/dragging/functions/fnc_carryObject.sqf | 3 --- addons/dragging/functions/fnc_dragObject.sqf | 3 --- addons/dragging/functions/fnc_startCarryLocal.sqf | 2 +- addons/dragging/functions/fnc_startCarryPFH.sqf | 5 ++--- addons/dragging/functions/fnc_startDragLocal.sqf | 3 +++ addons/dragging/functions/fnc_startDragPFH.sqf | 6 ++---- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/addons/dragging/functions/fnc_carryObject.sqf b/addons/dragging/functions/fnc_carryObject.sqf index 579e6a0ac3..7b2b4faa6b 100644 --- a/addons/dragging/functions/fnc_carryObject.sqf +++ b/addons/dragging/functions/fnc_carryObject.sqf @@ -48,9 +48,6 @@ if (_target isKindOf "CAManBase") then { [QEGVAR(common,setDir), [_target, _direction], _target] call CBA_fnc_targetEvent; -_unit setVariable [QGVAR(isCarrying), true, true]; -_unit setVariable [QGVAR(carriedObject), _target, true]; - // Add drop action _unit setVariable [QGVAR(releaseActionID), [ _unit, "DefaultAction", diff --git a/addons/dragging/functions/fnc_dragObject.sqf b/addons/dragging/functions/fnc_dragObject.sqf index 87272491da..e7bf706f9f 100644 --- a/addons/dragging/functions/fnc_dragObject.sqf +++ b/addons/dragging/functions/fnc_dragObject.sqf @@ -49,9 +49,6 @@ if (_target isKindOf "CAManBase") then { [_target, "AinjPpneMrunSnonWnonDb_still", 0] call EFUNC(common,doAnimation); }; -_unit setVariable [QGVAR(isDragging), true, true]; -_unit setVariable [QGVAR(draggedObject), _target, true]; - // Add drop action GVAR(unit) = _unit; diff --git a/addons/dragging/functions/fnc_startCarryLocal.sqf b/addons/dragging/functions/fnc_startCarryLocal.sqf index 743a56e1f4..0f679f2d49 100644 --- a/addons/dragging/functions/fnc_startCarryLocal.sqf +++ b/addons/dragging/functions/fnc_startCarryLocal.sqf @@ -82,7 +82,7 @@ if (_target isKindOf "CAManBase") then { // Prevents dragging and carrying at the same time _unit setVariable [QGVAR(isCarrying), true, true]; -// Required for aborting animation +// Required for aborting (animation & keybind) _unit setVariable [QGVAR(carriedObject), _target, true]; [LINKFUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/dragging/functions/fnc_startCarryPFH.sqf b/addons/dragging/functions/fnc_startCarryPFH.sqf index f928ef942a..aefe6d76fc 100644 --- a/addons/dragging/functions/fnc_startCarryPFH.sqf +++ b/addons/dragging/functions/fnc_startCarryPFH.sqf @@ -53,10 +53,9 @@ if (_target isKindOf "CAManBase") then { // Timeout: Drop target. CBA_missionTime, because anim length is linked to ingame time if (CBA_missionTime > _timeOut) exitWith { TRACE_4("timeout",_unit,_target,_timeOut,CBA_missionTime); - _idPFH call CBA_fnc_removePerFrameHandler; + [_unit, _target] call FUNC(dropObject_carry); - private _carriedObject = _unit getVariable [QGVAR(carriedObject), objNull]; - [_unit, _carriedObject] call FUNC(dropObject_carry); + _idPFH call CBA_fnc_removePerFrameHandler; }; // Wait for the unit to stand up diff --git a/addons/dragging/functions/fnc_startDragLocal.sqf b/addons/dragging/functions/fnc_startDragLocal.sqf index de41d712a4..20d5e007db 100644 --- a/addons/dragging/functions/fnc_startDragLocal.sqf +++ b/addons/dragging/functions/fnc_startDragLocal.sqf @@ -99,6 +99,9 @@ if (_target isKindOf "CAManBase") then { // Prevents dragging and carrying at the same time _unit setVariable [QGVAR(isDragging), true, true]; +// Required for aborting (keybind) +_unit setVariable [QGVAR(draggedObject), _target, true]; + [LINKFUNC(startDragPFH), 0.2, [_unit, _target, CBA_missionTime + 5]] call CBA_fnc_addPerFrameHandler; // Disable collisions by setting the physx mass to almost zero diff --git a/addons/dragging/functions/fnc_startDragPFH.sqf b/addons/dragging/functions/fnc_startDragPFH.sqf index daf887c362..e1cf75b38e 100644 --- a/addons/dragging/functions/fnc_startDragPFH.sqf +++ b/addons/dragging/functions/fnc_startDragPFH.sqf @@ -43,11 +43,9 @@ if (!alive _target || {_unit distance _target > 10}) exitWith { // Timeout: Drop target. CBA_missionTime, because anim length is linked to ingame time if (CBA_missionTime > _timeOut) exitWith { TRACE_4("timeout",_unit,_target,_timeOut,CBA_missionTime); - _idPFH call CBA_fnc_removePerFrameHandler; + [_unit, _target] call FUNC(dropObject); - // Drop if in timeout - private _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull]; - [_unit, _draggedObject] call FUNC(dropObject); + _idPFH call CBA_fnc_removePerFrameHandler; }; // Unit is ready to start dragging