Dragging - Fix captives (#9660)

Fixes and cleanup
This commit is contained in:
johnb432 2023-11-21 21:18:19 +01:00 committed by GitHub
parent 3904240153
commit 2e7f56ee39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 36 deletions

View File

@ -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"

View File

@ -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);

View File

@ -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);