From 2e7f56ee39d9946610a1f941893f42bcccdb874e Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 21 Nov 2023 21:18:19 +0100 Subject: [PATCH] Dragging - Fix captives (#9660) Fixes and cleanup --- addons/dragging/XEH_postInit.sqf | 66 +++++++++---------- .../dragging/functions/fnc_setCarryable.sqf | 2 +- .../dragging/functions/fnc_setDraggable.sqf | 3 +- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 32b7d72faa..815437e62d 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -4,16 +4,6 @@ if (isServer) then { // Release object on disconnection. Function is identical to killed addMissionEventHandler ["HandleDisconnect", LINKFUNC(handleKilled)]; - - // Handle surrending and handcuffing - ["ace_captiveStatusChanged", { - params ["_unit", "_state"]; - - // If surrended or handcuffed, drop dragged/carried object - if (_state) then { - _unit call FUNC(handleKilled); - }; - }] call CBA_fnc_addEventHandler; }; if (!hasInterface) exitWith {}; @@ -38,12 +28,45 @@ if (isNil QGVAR(maxWeightCarryRun)) then { ["vehicle", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call CBA_fnc_addPlayerEventHandler; ["weapon", LINKFUNC(handlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler; +// When changing cameras, drop carried and dragged objects +["featureCamera", { + params ["_unit", "_camera"]; + + // Unit can either drag or carry, functions themselves handle which ones are executed + switch (_camera) do { + // Default camera + case "": { + _unit call FUNC(resumeDrag); + _unit call FUNC(resumeCarry); + }; + // Arsenals make the unit change animations, which makes the unit drop dragged/carried objects regardless + case "arsenal"; + case "ace_arsenal": { + _unit call FUNC(handleKilled); + }; + default { + _unit call FUNC(pauseDrag); + _unit call FUNC(pauseCarry); + }; + }; +}] call CBA_fnc_addPlayerEventHandler; + // Handle waking up dragged unit and falling unconscious while dragging ["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler; // Display event handler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler; +// Handle surrendering and handcuffing +["ace_captiveStatusChanged", { + params ["_unit", "_state"]; + + // If surrended or handcuffed, drop dragged/carried object + if (_state && {local _unit}) then { + _unit call FUNC(handleKilled); + }; +}] call CBA_fnc_addEventHandler; + [QGVAR(carryingContainerClosed), { params ["_container", "_owner"]; TRACE_2("carryingContainerClosed EH",_container,_owner); @@ -81,27 +104,4 @@ if (isNil QGVAR(maxWeightCarryRun)) then { }; }] call CBA_fnc_addEventHandler; -// When changing cameras, drop carried and dragged objects -["featureCamera", { - params ["_unit", "_camera"]; - - // Unit can either drag or carry, functions themselves handle which ones are executed - switch (_camera) do { - // Default camera - case "": { - _unit call FUNC(resumeDrag); - _unit call FUNC(resumeCarry); - }; - // Arsenals make the unit change animations, which makes the unit drop dragged/carried objects regardless - case "arsenal"; - case "ace_arsenal": { - _unit call FUNC(handleKilled); - }; - default { - _unit call FUNC(pauseDrag); - _unit call FUNC(pauseCarry); - }; - }; -}] call CBA_fnc_addPlayerEventHandler; - #include "initKeybinds.sqf" diff --git a/addons/dragging/functions/fnc_setCarryable.sqf b/addons/dragging/functions/fnc_setCarryable.sqf index 0348bd0483..174bdbf972 100644 --- a/addons/dragging/functions/fnc_setCarryable.sqf +++ b/addons/dragging/functions/fnc_setCarryable.sqf @@ -54,7 +54,7 @@ GVAR(initializedClasses_carry) = _initializedClasses; [QGVAR(carryingContainerClosed), [_object, _owner], _owner] call CBA_fnc_targetEvent; }, false] call CBA_fnc_addClassEventHandler; -private _icon = [QUOTE(PATHTOF(UI\icons\box_carry.paa)), QUOTE(PATHTOF(UI\icons\person_carry.paa))] select (_object isKindOf "Man"); +private _icon = [QPATHTOF(UI\icons\box_carry.paa), QPATHTOF(UI\icons\person_carry.paa)] select (_object isKindOf "CAManBase"); private _carryAction = [QGVAR(carry), LLSTRING(Carry), _icon, {[_player, _target] call FUNC(startCarry)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction); private _dropAction = [QGVAR(drop_carry), LLSTRING(Drop), "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction); diff --git a/addons/dragging/functions/fnc_setDraggable.sqf b/addons/dragging/functions/fnc_setDraggable.sqf index d2adba1a61..a00e3005e9 100644 --- a/addons/dragging/functions/fnc_setDraggable.sqf +++ b/addons/dragging/functions/fnc_setDraggable.sqf @@ -54,8 +54,7 @@ GVAR(initializedClasses) = _initializedClasses; [QGVAR(draggingContainerClosed), [_object, _owner], _owner] call CBA_fnc_targetEvent; }, false] call CBA_fnc_addClassEventHandler; - -private _icon = [QUOTE(PATHTOF(UI\icons\box_drag.paa)), QUOTE(PATHTOF(UI\icons\person_drag.paa))] select (_object isKindOf "Man"); +private _icon = [QPATHTOF(UI\icons\box_drag.paa), QPATHTOF(UI\icons\person_drag.paa)] select (_object isKindOf "CAManBase"); private _dragAction = [QGVAR(drag), LLSTRING(Drag), _icon, {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}] call EFUNC(interact_menu,createAction); private _dropAction = [QGVAR(drop), LLSTRING(Drop), "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}] call EFUNC(interact_menu,createAction);