Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragging - Fix captives #9660

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions addons/dragging/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand All @@ -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);
Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion addons/dragging/functions/fnc_setCarryable.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions addons/dragging/functions/fnc_setDraggable.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down