From b00977eda04b38d01bc0024f8ec6845fddd8c11b Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 4 Oct 2020 22:39:52 +0200 Subject: [PATCH 01/39] Create clones for corpse carrying/dragging --- addons/dragging/CfgVehicles.hpp | 3 +++ addons/dragging/XEH_PREP.hpp | 2 ++ addons/dragging/XEH_postInit.sqf | 8 ++++++ addons/dragging/functions/fnc_canCarry.sqf | 2 +- addons/dragging/functions/fnc_canDrag.sqf | 2 +- addons/dragging/functions/fnc_carryObject.sqf | 3 +++ addons/dragging/functions/fnc_createClone.sqf | 26 +++++++++++++++++++ addons/dragging/functions/fnc_dropClone.sqf | 26 +++++++++++++++++++ addons/dragging/functions/fnc_dropObject.sqf | 5 ++++ .../functions/fnc_dropObject_carry.sqf | 5 ++++ addons/dragging/functions/fnc_startCarry.sqf | 4 +++ addons/dragging/functions/fnc_startDrag.sqf | 5 ++++ 12 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 addons/dragging/functions/fnc_createClone.sqf create mode 100644 addons/dragging/functions/fnc_dropClone.sqf diff --git a/addons/dragging/CfgVehicles.hpp b/addons/dragging/CfgVehicles.hpp index 4c43dd814ea..d83fca3389c 100644 --- a/addons/dragging/CfgVehicles.hpp +++ b/addons/dragging/CfgVehicles.hpp @@ -2,6 +2,9 @@ class CBA_Extended_EventHandlers; class CfgVehicles { + class C_man_1; + class GVAR(clone): C_man_1 {}; + // Static weapons class LandVehicle; class StaticWeapon: LandVehicle { diff --git a/addons/dragging/XEH_PREP.hpp b/addons/dragging/XEH_PREP.hpp index b04c15e7ec3..f9fbd4529c7 100644 --- a/addons/dragging/XEH_PREP.hpp +++ b/addons/dragging/XEH_PREP.hpp @@ -5,8 +5,10 @@ PREP(canDrop); PREP(canDrop_carry); PREP(carryObject); PREP(carryObjectPFH); +PREP(createClone); PREP(dragObject); PREP(dragObjectPFH); +PREP(dropClone); PREP(dropObject); PREP(dropObject_carry); PREP(getWeight); diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index dd782eddb2f..7828d441b60 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -27,6 +27,14 @@ if (isNil "ACE_maxWeightCarry") then { // handle waking up dragged unit and falling unconscious while dragging ["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler; +// handle local effect commands for clones +[QGVAR(cloneCreated), { + params ["_unit", "_clone"]; + + _clone setFace face _unit; + _clone setMimic "unconscious"; +}] call CBA_fnc_addEventHandler; + // display event handler ["MouseZChanged", {_this select 1 call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler; diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index b5edbd800c5..1bb10f93773 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -27,4 +27,4 @@ if ((_unit getHitPointDamage "HitLegs") >= 0.5) exitWith {false}; // a static weapon has to be empty for dragging (ignore UAV AI) if (((typeOf _target) isKindOf "StaticWeapon") && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false}; -alive _target && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} +(alive _target || {_target isKindOf "CAManBase"}) && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious", "deadstate"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index dbae83521b3..b43f5e71c78 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -23,4 +23,4 @@ if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exi // a static weapon has to be empty for dragging (ignore UAV AI) if ((typeOf _target) isKindOf "StaticWeapon" && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false}; -alive _target && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} +(alive _target || {_target isKindOf "CAManBase"}) && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious", "deadstate"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} diff --git a/addons/dragging/functions/fnc_carryObject.sqf b/addons/dragging/functions/fnc_carryObject.sqf index e3f8c2b61ec..121b673cf99 100644 --- a/addons/dragging/functions/fnc_carryObject.sqf +++ b/addons/dragging/functions/fnc_carryObject.sqf @@ -26,6 +26,9 @@ private _direction = _target getVariable [QGVAR(carryDirection), 0]; // handle objects vs persons if (_target isKindOf "CAManBase") then { + if (!alive _target) then { + _target = [_target] call FUNC(createClone); + }; [_unit, "AcinPercMstpSnonWnonDnon", 2, true] call EFUNC(common,doAnimation); [_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2, true] call EFUNC(common,doAnimation); diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf new file mode 100644 index 00000000000..bf38fa42e1d --- /dev/null +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Creates a draggable / carryable clone of a dead unit. + * + * Arguments: + * 0: Dead unit + * + * Return Value: + * Cloned unit. + * + * Example: + * [player] call ace_dragging_fnc_createClone; + * + * Public: No + */ +params ["_unit"]; + +private _clone = QGVAR(clone) createVehicle [0, 0, 0]; +_clone setUnitLoadout getUnitLoadout _unit; +_clone setVariable [QGVAR(original), _unit]; +_unit hideObjectGlobal true; + +[QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent; + +_clone diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf new file mode 100644 index 00000000000..5438a512907 --- /dev/null +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Drops a draggable / carryable clone of a dead unit. + * + * Arguments: + * 0: Clone + * + * Return Value: + * Original unit. + * + * Example: + * [player] call ace_dragging_fnc_createClone; + * + * Public: No + */ +params ["_clone"]; + +private _unit = _clone getVariable [QGVAR(original), objNull]; +_unit setPosASL getPosASL _clone; +_unit hideObjectGlobal false; + +detach _clone; +deleteVehicle _clone; + +_unit diff --git a/addons/dragging/functions/fnc_dropObject.sqf b/addons/dragging/functions/fnc_dropObject.sqf index 4ecc876afd9..18ec97fe481 100644 --- a/addons/dragging/functions/fnc_dropObject.sqf +++ b/addons/dragging/functions/fnc_dropObject.sqf @@ -24,6 +24,11 @@ TRACE_2("params",_unit,_target); private _inBuilding = [_unit] call FUNC(isObjectOnObject); +// drop cloned dead units +if (_target isKindOf QGVAR(clone)) then { + _target = [_target] call FUNC(dropClone); +}; + if !(_unit getVariable ["ACE_isUnconscious", false]) then { // play release animation [_unit, "released"] call EFUNC(common,doGesture); diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index 5235b7e66df..66880cd0ddd 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -24,6 +24,11 @@ TRACE_1("params",_this); private _inBuilding = [_unit] call FUNC(isObjectOnObject); +// drop cloned dead units +if (_target isKindOf QGVAR(clone)) then { + _target = [_target] call FUNC(dropClone); +}; + // prevent collision damage [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; [QEGVAR(common,fixCollision), _target, _target] call CBA_fnc_targetEvent; diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index a52afd1c27e..b184a1e7bb9 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -32,6 +32,10 @@ private _timer = CBA_missionTime + 5; // handle objects vs persons if (_target isKindOf "CAManBase") then { + // create clone for dead units + if (!alive _target) then { + _target = [_target] call FUNC(createClone); + }; // add a primary weapon if the unit has none. if (primaryWeapon _unit isEqualto "") then { diff --git a/addons/dragging/functions/fnc_startDrag.sqf b/addons/dragging/functions/fnc_startDrag.sqf index 7a4c8908d33..c09d921a837 100644 --- a/addons/dragging/functions/fnc_startDrag.sqf +++ b/addons/dragging/functions/fnc_startDrag.sqf @@ -28,6 +28,11 @@ if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && { [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); }; +// create clone for dead units +if (!alive _target) then { + _target = [_target] call FUNC(createClone); +}; + // add a primary weapon if the unit has none. // @todo prevent opening inventory when equipped with a fake weapon if (primaryWeapon _unit isEqualto "") then { From 905e8cae82939c30bb0e28503b23edf5e6188196 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 5 Oct 2020 10:35:44 +0200 Subject: [PATCH 02/39] Fix doccomment for dropClone Co-authored-by: Dystopian --- addons/dragging/functions/fnc_dropClone.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 5438a512907..97cdebf334d 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -10,7 +10,7 @@ * Original unit. * * Example: - * [player] call ace_dragging_fnc_createClone; + * [player] call ace_dragging_fnc_dropClone; * * Public: No */ From 3fa5b6958c8a36efab5f08344c26f18db3bc285f Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 5 Oct 2020 10:36:49 +0200 Subject: [PATCH 03/39] Remove duplicate clone Co-authored-by: Dystopian --- addons/dragging/functions/fnc_carryObject.sqf | 3 --- 1 file changed, 3 deletions(-) diff --git a/addons/dragging/functions/fnc_carryObject.sqf b/addons/dragging/functions/fnc_carryObject.sqf index 121b673cf99..e3f8c2b61ec 100644 --- a/addons/dragging/functions/fnc_carryObject.sqf +++ b/addons/dragging/functions/fnc_carryObject.sqf @@ -26,9 +26,6 @@ private _direction = _target getVariable [QGVAR(carryDirection), 0]; // handle objects vs persons if (_target isKindOf "CAManBase") then { - if (!alive _target) then { - _target = [_target] call FUNC(createClone); - }; [_unit, "AcinPercMstpSnonWnonDnon", 2, true] call EFUNC(common,doAnimation); [_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2, true] call EFUNC(common,doAnimation); From 28e0491d3e6ef43e36cf42d3f8b8be7ec2acf6fb Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 11 Oct 2020 20:37:59 +0200 Subject: [PATCH 04/39] Add comment with reasoning for detach before delete --- addons/dragging/functions/fnc_dropClone.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 97cdebf334d..83817babb26 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -20,6 +20,7 @@ private _unit = _clone getVariable [QGVAR(original), objNull]; _unit setPosASL getPosASL _clone; _unit hideObjectGlobal false; +// Detach first to prevent objNull in attachedObjects detach _clone; deleteVehicle _clone; From efd71c617965e2b668cfed36faf997720a6fc72f Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 11 Oct 2020 20:42:34 +0200 Subject: [PATCH 05/39] Bury corpse to prevent desecration --- addons/dragging/functions/fnc_createClone.sqf | 2 +- addons/dragging/functions/fnc_dropClone.sqf | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index bf38fa42e1d..c42b17e5868 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -19,7 +19,7 @@ params ["_unit"]; private _clone = QGVAR(clone) createVehicle [0, 0, 0]; _clone setUnitLoadout getUnitLoadout _unit; _clone setVariable [QGVAR(original), _unit]; -_unit hideObjectGlobal true; +_unit setPosATL [0, 0, -10]; [QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 83817babb26..d0eeb71d2c7 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -18,7 +18,6 @@ params ["_clone"]; private _unit = _clone getVariable [QGVAR(original), objNull]; _unit setPosASL getPosASL _clone; -_unit hideObjectGlobal false; // Detach first to prevent objNull in attachedObjects detach _clone; From 2d30be436c68ad491bf665a18e35b908bea9dced Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 11 Oct 2020 20:44:35 +0200 Subject: [PATCH 06/39] Prevent screams of agony from dragged corpse --- addons/dragging/functions/fnc_createClone.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index c42b17e5868..eca1c2025de 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -18,6 +18,7 @@ params ["_unit"]; private _clone = QGVAR(clone) createVehicle [0, 0, 0]; _clone setUnitLoadout getUnitLoadout _unit; +_clone allowDamage false; _clone setVariable [QGVAR(original), _unit]; _unit setPosATL [0, 0, -10]; From fb065d1098ebcb4d7fdba929273dde16de87f676 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Thu, 20 Jul 2023 19:42:35 +0200 Subject: [PATCH 07/39] Continue corpse carry --- addons/common/XEH_postInit.sqf | 5 +++ addons/dragging/functions/fnc_canCarry.sqf | 7 ++-- addons/dragging/functions/fnc_canDrag.sqf | 7 ++-- addons/dragging/functions/fnc_createClone.sqf | 28 ++++++++++---- addons/dragging/functions/fnc_dropClone.sqf | 37 +++++++++++++++---- addons/dragging/functions/fnc_dropObject.sqf | 9 +++-- .../functions/fnc_dropObject_carry.sqf | 10 +++-- addons/dragging/functions/fnc_startCarry.sqf | 4 +- addons/dragging/functions/fnc_startDrag.sqf | 4 +- 9 files changed, 78 insertions(+), 33 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 00d1a4406b6..8e55a44595b 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -120,6 +120,11 @@ _object setMass _mass; }] call CBA_fnc_addEventHandler; +[QGVAR(awake), { + params ["_object", "_awake"]; + _object awake _awake; +}] call CBA_fnc_addEventHandler; + //Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit //This variable is used for isPlayer checks if (isServer) then { diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index 2e93a6f62ce..570f7877272 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -18,7 +18,7 @@ params ["_unit", "_target"]; -if !(alive _target && {_target getVariable [QGVAR(canCarry), false]} && {isNull objectParent _target}) exitWith {false}; +if !((alive _target || {_target isKindOf "CAManBase"}) && {_target getVariable [QGVAR(canCarry), false]} && {isNull objectParent _target}) exitWith {false}; if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; @@ -33,8 +33,9 @@ if (_target isKindOf "StaticWeapon") exitWith { // Units need to be unconscious or limping if (_target isKindOf "CAManBase") exitWith { - lifeState _target == "INCAPACITATED" || - {_target getHitPointDamage "HitLegs" >= 0.5} + lifeState _target isEqualTo "INCAPACITATED" + || {_target getHitPointDamage "HitLegs" >= 0.5} || + {(animationState _target) in ["", "unconscious", "deadstate"]} }; // Check max items for WeaponHolders diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index 1478abacf5c..7ec7999d367 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -18,7 +18,7 @@ params ["_unit", "_target"]; -if !(alive _target && {_target getVariable [QGVAR(canDrag), false]} && {isNull objectParent _target}) exitWith {false}; +if !((alive _target || {_target isKindOf "CAManBase"}) && {_target getVariable [QGVAR(canDrag), false]} && {isNull objectParent _target}) exitWith {false}; if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false}; @@ -29,8 +29,9 @@ if (_target isKindOf "StaticWeapon") exitWith { // Units need to be unconscious or limping if (_target isKindOf "CAManBase") exitWith { - lifeState _target == "INCAPACITATED" || - {_target getHitPointDamage "HitLegs" >= 0.5} + lifeState _target isEqualTo "INCAPACITATED" + || {_target getHitPointDamage "HitLegs" >= 0.5} || + {(animationState _target) in ["", "unconscious", "deadstate"]} }; // Check max items for WeaponHolders diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index eca1c2025de..20406c725b1 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -1,27 +1,41 @@ #include "script_component.hpp" /* - * Author: BaerMitUmlaut + * Author: BaerMitUmlaut, johnb43 * Creates a draggable / carryable clone of a dead unit. * * Arguments: * 0: Dead unit * * Return Value: - * Cloned unit. + * Cloned unit * * Example: * [player] call ace_dragging_fnc_createClone; * * Public: No */ -params ["_unit"]; +params ["_target"]; private _clone = QGVAR(clone) createVehicle [0, 0, 0]; -_clone setUnitLoadout getUnitLoadout _unit; + +// Clone loadout +_clone setUnitLoadout getUnitLoadout _target; +[_clone, _target call BIS_fnc_getUnitInsignia] call BIS_fnc_setUnitInsignia; + +// Disable all damage _clone allowDamage false; -_clone setVariable [QGVAR(original), _unit]; -_unit setPosATL [0, 0, -10]; +_clone setVariable [QGVAR(original), _target, true]; + +// Turn on PhysX so that unit is not desync when moving with 'setPos' commands +[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + +// Move unit below terrain in order to hide it +_target setPosATL [0, 0, -10]; + +// Turn off PhysX +[QEGVAR(common,awake), [_target, false]] call CBA_fnc_globalEvent; -[QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent; +// Sets the facial expression +[[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; _clone diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index d0eeb71d2c7..e8c2fe43a33 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -1,26 +1,47 @@ #include "script_component.hpp" /* - * Author: BaerMitUmlaut + * Author: BaerMitUmlaut, johnb43 * Drops a draggable / carryable clone of a dead unit. * * Arguments: - * 0: Clone + * 0: Unit dragging / carrying + * 1: Clone + * 2: If unit is in building * * Return Value: - * Original unit. + * Original unit * * Example: - * [player] call ace_dragging_fnc_dropClone; + * [player, cursorObject, false] call ace_dragging_fnc_dropClone; * * Public: No */ -params ["_clone"]; +params ["_unit", "_clone", "_inBuilding"]; -private _unit = _clone getVariable [QGVAR(original), objNull]; -_unit setPosASL getPosASL _clone; +private _target = _clone getVariable [QGVAR(original), objNull]; + +if (isNull _target) exitWith {objNull}; + +// Turn on PhysX so that unit is not desync when moving +[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + +private _posASL = getPosASL _clone; + +if (_inBuilding) then { + _posASL = _posASL vectorAdd [0, 0, 0.05]; +}; + +// Set the unit's direction +[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; + +// Bring unit back to clone's position +_target setPosASL _posASL; + +// Turn off PhysX +[QEGVAR(common,awake), [_target, false]] call CBA_fnc_globalEvent; // Detach first to prevent objNull in attachedObjects detach _clone; deleteVehicle _clone; -_unit +_target diff --git a/addons/dragging/functions/fnc_dropObject.sqf b/addons/dragging/functions/fnc_dropObject.sqf index 895717d1fa6..b4e2932964c 100644 --- a/addons/dragging/functions/fnc_dropObject.sqf +++ b/addons/dragging/functions/fnc_dropObject.sqf @@ -28,10 +28,11 @@ if !(GVAR(dragAndFire)) then { }; private _inBuilding = [_unit] call FUNC(isObjectOnObject); +private _isClone = _target isKindOf QGVAR(clone); -// drop cloned dead units -if (_target isKindOf QGVAR(clone)) then { - _target = [_target] call FUNC(dropClone); +// Drop cloned dead units +if (_isClone) then { + _target = [_unit, _target, _inBuilding] call FUNC(dropClone); }; if !(_unit getVariable ["ACE_isUnconscious", false]) then { @@ -59,7 +60,7 @@ _unit removeWeapon "ACE_FakePrimaryWeapon"; [_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set); // prevent object from flipping inside buildings -if (_inBuilding) then { +if (_inBuilding && {!_isClone}) then { _target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]); TRACE_2("setPos",getPosASL _unit,getPosASL _target); }; diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index 1c2dd69cdcc..f3b91422d6c 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -23,10 +23,11 @@ TRACE_1("params",_this); [_unit, "DefaultAction", _unit getVariable [QGVAR(ReleaseActionID), -1]] call EFUNC(common,removeActionEventHandler); private _inBuilding = [_unit] call FUNC(isObjectOnObject); +private _isClone = _target isKindOf QGVAR(clone); -// drop cloned dead units -if (_target isKindOf QGVAR(clone)) then { - _target = [_target] call FUNC(dropClone); +// Drop cloned dead units +if (_isClone) then { + _target = [_unit, _target, _inBuilding] call FUNC(dropClone); }; // prevent collision damage @@ -65,8 +66,9 @@ if (_previousWeaponIndex != -1) then { [_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set); // prevent object from flipping inside buildings -if (_inBuilding) then { +if (_inBuilding && {!_isClone}) then { _target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]); + TRACE_2("setPos",getPosASL _unit,getPosASL _target); }; _unit setVariable [QGVAR(isCarrying), false, true]; diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index 194175799e6..5e39a05fe34 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -33,9 +33,9 @@ private _timer = CBA_missionTime + 5; // handle objects vs persons if (_target isKindOf "CAManBase") then { - // create clone for dead units + // Create clone for dead units if (!alive _target) then { - _target = [_target] call FUNC(createClone); + _target = _target call FUNC(createClone); }; // add a primary weapon if the unit has none. diff --git a/addons/dragging/functions/fnc_startDrag.sqf b/addons/dragging/functions/fnc_startDrag.sqf index ebcf75a2114..3bdbc80538e 100644 --- a/addons/dragging/functions/fnc_startDrag.sqf +++ b/addons/dragging/functions/fnc_startDrag.sqf @@ -28,9 +28,9 @@ if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && { [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); }; -// create clone for dead units +// Create clone for dead units if (!alive _target) then { - _target = [_target] call FUNC(createClone); + _target = _target call FUNC(createClone); }; // Add a primary weapon if the unit has none From cbc7748eef29e19ed284b665ed2830f714343751 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Thu, 20 Jul 2023 19:44:49 +0200 Subject: [PATCH 08/39] Update XEH_postInit.sqf --- addons/dragging/XEH_postInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 9e487fd6a5b..d0aee9ef43d 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -30,7 +30,7 @@ if (isNil QGVAR(maxWeightCarryRun)) then { // handle waking up dragged unit and falling unconscious while dragging ["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler; -// handle local effect commands for clones +// Handle local effect commands for clones [QGVAR(cloneCreated), { params ["_unit", "_clone"]; From b32ad48f825edb2f8938b825502679e6ace78a10 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 21 Jul 2023 19:24:25 +0200 Subject: [PATCH 09/39] Potential fix for duplicating --- addons/dragging/XEH_postInit.sqf | 5 ++ addons/dragging/functions/fnc_createClone.sqf | 39 ++++++++++++--- addons/dragging/functions/fnc_dropClone.sqf | 48 +++++++++++++------ 3 files changed, 71 insertions(+), 21 deletions(-) diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index d0aee9ef43d..19ac9322545 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -19,6 +19,11 @@ if (isNil QGVAR(maxWeightCarryRun)) then { GVAR(maxWeightCarryRun) = 50; }; +// Extended EH doesn't fire for dead units, so add interactions manually +{ + _x call FUNC(initPerson); +} forEach allDeadMen; + ["isNotDragging", {!((_this select 0) getVariable [QGVAR(isDragging), false])}] call EFUNC(common,addCanInteractWithCondition); ["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition); diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 20406c725b1..5cf4b443dde 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -16,24 +16,49 @@ */ params ["_target"]; -private _clone = QGVAR(clone) createVehicle [0, 0, 0]; +// Get current position of unit, -10 m below surface +private _posATL = getPosATL _target; +_posATL set [2, -10]; + +private _clone = createVehicle [QGVAR(clone), _posATL]; // Clone loadout -_clone setUnitLoadout getUnitLoadout _target; +[_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; [_clone, _target call BIS_fnc_getUnitInsignia] call BIS_fnc_setUnitInsignia; +// Hide unit until it can be moved below terrain +private _isObjectHidden = isObjectHidden _target; + +if (_isObjectHidden) then { + [QEGVAR(common,hideObjectGlobal), [_target, true]] call CBA_fnc_serverEvent; +}; + +private _simulationEnabled = simulationEnabled _target; + +if (_simulationEnabled) then { + [QEGVAR(common,enableSimulationGlobal), [_target, false]] call CBA_fnc_serverEvent; +}; + +private _isInRemainsCollector = isInRemainsCollector _target; + +// Make sure corpse isn't deleted by engine's garbage collector +if (_isInRemainsCollector) then { + removeFromRemainsCollector [_target]; +}; + // Disable all damage _clone allowDamage false; -_clone setVariable [QGVAR(original), _target, true]; +_clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden, _simulationEnabled], true]; // Turn on PhysX so that unit is not desync when moving with 'setPos' commands [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; -// Move unit below terrain in order to hide it -_target setPosATL [0, 0, -10]; +[{ + params ["_target", "_posATL"]; -// Turn off PhysX -[QEGVAR(common,awake), [_target, false]] call CBA_fnc_globalEvent; + // Move unit below terrain in order to hide it + _target setPosATL _posATL; +}, [_target, _posATL], 0.1] call CBA_fnc_waitAndExecute; // Sets the facial expression [[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index e8c2fe43a33..0efa2c90e76 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -18,27 +18,47 @@ */ params ["_unit", "_clone", "_inBuilding"]; -private _target = _clone getVariable [QGVAR(original), objNull]; +(_clone getVariable [QGVAR(original), []]) params [["_target", objNull], ["_isInRemainsCollector", true], ["_isObjectHidden", false], ["_simulationEnabled", true]]; -if (isNull _target) exitWith {objNull}; +// Check if unit was deleted +if (!isNull _target) then { + // Turn on PhysX so that unit is not desync when moving + [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; -// Turn on PhysX so that unit is not desync when moving -[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + private _posASL = getPosASL _clone; -private _posASL = getPosASL _clone; + if (_inBuilding) then { + _posASL = _posASL vectorAdd [0, 0, 0.05]; + }; -if (_inBuilding) then { - _posASL = _posASL vectorAdd [0, 0, 0.05]; -}; + // Set the unit's direction + [QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; + + [{ + params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled", "_posASL"]; + + // Bring unit back to clone's position + _target setPosASL _posASL; -// Set the unit's direction -[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; + [{ + params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled"]; -// Bring unit back to clone's position -_target setPosASL _posASL; + if (_isObjectHidden) then { + [QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent; + }; -// Turn off PhysX -[QEGVAR(common,awake), [_target, false]] call CBA_fnc_globalEvent; + if (_simulationEnabled) then { + [QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent; + }; + + deleteVehicle _clone; + }, _this, 0.1] call CBA_fnc_waitAndExecute; + }, [_target, _clone, _isObjectHidden, _simulationEnabled, _posASL], 0.1] call CBA_fnc_waitAndExecute; + + if (_isInRemainsCollector) then { + addToRemainsCollector [_target]; + }; +}; // Detach first to prevent objNull in attachedObjects detach _clone; From 897ca7a17b3bb14fac59f95f97afc573d2d5e024 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 3 Oct 2023 08:38:49 +0200 Subject: [PATCH 10/39] Update fnc_handleAnimChanged.sqf --- addons/dragging/functions/fnc_handleAnimChanged.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_handleAnimChanged.sqf b/addons/dragging/functions/fnc_handleAnimChanged.sqf index 4820a467ff6..dd58545a53f 100644 --- a/addons/dragging/functions/fnc_handleAnimChanged.sqf +++ b/addons/dragging/functions/fnc_handleAnimChanged.sqf @@ -5,7 +5,7 @@ * * Arguments: * 0: Unit - * 1: Animaion + * 1: Animation * * Return Value: * None From 1ccd2b4643cc67f8f1da642a1eb9e7c6bd2527d3 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 3 Oct 2023 08:46:27 +0200 Subject: [PATCH 11/39] New script_component --- addons/dragging/functions/fnc_createClone.sqf | 2 +- addons/dragging/functions/fnc_dropClone.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 5cf4b443dde..e2c9e8c8503 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -1,4 +1,4 @@ -#include "script_component.hpp" +#include "..\script_component.hpp" /* * Author: BaerMitUmlaut, johnb43 * Creates a draggable / carryable clone of a dead unit. diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 0efa2c90e76..4832740e0f4 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -1,4 +1,4 @@ -#include "script_component.hpp" +#include "..\script_component.hpp" /* * Author: BaerMitUmlaut, johnb43 * Drops a draggable / carryable clone of a dead unit. From 29881bc9a14b912543395a82a7281084162acb6a Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:23:06 +0200 Subject: [PATCH 12/39] Update fnc_createClone.sqf --- addons/dragging/functions/fnc_createClone.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index e2c9e8c8503..3d454aea9c3 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -24,7 +24,6 @@ private _clone = createVehicle [QGVAR(clone), _posATL]; // Clone loadout [_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; -[_clone, _target call BIS_fnc_getUnitInsignia] call BIS_fnc_setUnitInsignia; // Hide unit until it can be moved below terrain private _isObjectHidden = isObjectHidden _target; From 4a5f056d713918da7998ea838ea90730f23ac7e4 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 7 Jan 2024 16:29:01 +0100 Subject: [PATCH 13/39] Fixed/improved checks --- addons/dragging/functions/fnc_canCarry.sqf | 9 ++++----- addons/dragging/functions/fnc_canDrag.sqf | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index 1d0168d119d..6d45d2df713 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -28,15 +28,14 @@ if ((_unit getHitPointDamage "HitLegs") >= 0.5) exitWith {false}; // Static weapons need to be empty for carrying (ignore UAV AI) if (_target isKindOf "StaticWeapon") exitWith { - (crew _target) findIf {getText (configOf _x >> "simulation") != "UAVPilot"} == -1 + (crew _target) findIf {!unitIsUAV _x} == -1 }; // Units need to be unconscious or limping; Units also need to not be in ragdoll, as that causes desync issues if (_target isKindOf "CAManBase") exitWith { - isAwake _target && // not ragdolled - {lifeState _target == "INCAPACITATED" || - {_target getHitPointDamage "HitLegs" >= 0.5} || - {(animationState _target) in ["", "unconscious", "deadstate"]}} + (isAwake _target != alive _target) && // not ragdolled + {!(lifeState _target in ["HEALTHY", "INJURED"]) || + {_target getHitPointDamage "HitLegs" >= 0.5}} }; // Check max items for WeaponHolders diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index f67a3d6f866..ad1f0d40b49 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -24,15 +24,14 @@ if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exi // Static weapons need to be empty for dragging (ignore UAV AI) if (_target isKindOf "StaticWeapon") exitWith { - (crew _target) findIf {getText (configOf _x >> "simulation") != "UAVPilot"} == -1 + (crew _target) findIf {!unitIsUAV _x} == -1 }; // Units need to be unconscious or limping; Units also need to not be in ragdoll, as that causes desync issues if (_target isKindOf "CAManBase") exitWith { - isAwake _target && // not ragdolled - {lifeState _target == "INCAPACITATED" || - {_target getHitPointDamage "HitLegs" >= 0.5} || - {(animationState _target) in ["", "unconscious", "deadstate"]}} + (isAwake _target != alive _target) && // not ragdolled + {!(lifeState _target in ["HEALTHY", "INJURED"]) || + {_target getHitPointDamage "HitLegs" >= 0.5}} }; // Check max items for WeaponHolders From 573bfbb92d80ba4ee7816870294461b5a81eb45e Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 7 Jan 2024 16:48:40 +0100 Subject: [PATCH 14/39] Fix not hidden --- addons/dragging/functions/fnc_createClone.sqf | 2 +- addons/dragging/functions/fnc_dropClone.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 3d454aea9c3..6330be72f8f 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -28,7 +28,7 @@ private _clone = createVehicle [QGVAR(clone), _posATL]; // Hide unit until it can be moved below terrain private _isObjectHidden = isObjectHidden _target; -if (_isObjectHidden) then { +if (!_isObjectHidden) then { [QEGVAR(common,hideObjectGlobal), [_target, true]] call CBA_fnc_serverEvent; }; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 4832740e0f4..cee2932eacd 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -43,7 +43,7 @@ if (!isNull _target) then { [{ params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled"]; - if (_isObjectHidden) then { + if (!_isObjectHidden) then { [QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent; }; From 3387898441f71b5b81317ec15e8a40ff246a21dd Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 7 Jan 2024 17:46:20 +0100 Subject: [PATCH 15/39] Check correct ragdoll state --- addons/dragging/functions/fnc_canCarry.sqf | 2 +- addons/dragging/functions/fnc_canDrag.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index 6d45d2df713..732b619e6f2 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -33,7 +33,7 @@ if (_target isKindOf "StaticWeapon") exitWith { // Units need to be unconscious or limping; Units also need to not be in ragdoll, as that causes desync issues if (_target isKindOf "CAManBase") exitWith { - (isAwake _target != alive _target) && // not ragdolled + (isAwake _target == alive _target) && // not ragdolled {!(lifeState _target in ["HEALTHY", "INJURED"]) || {_target getHitPointDamage "HitLegs" >= 0.5}} }; diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index ad1f0d40b49..1e2155a4007 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -29,7 +29,7 @@ if (_target isKindOf "StaticWeapon") exitWith { // Units need to be unconscious or limping; Units also need to not be in ragdoll, as that causes desync issues if (_target isKindOf "CAManBase") exitWith { - (isAwake _target != alive _target) && // not ragdolled + (isAwake _target == alive _target) && // not ragdolled {!(lifeState _target in ["HEALTHY", "INJURED"]) || {_target getHitPointDamage "HitLegs" >= 0.5}} }; From d1755af35be1ffb5d49a27527b26d15ab0d1ba79 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 7 Jan 2024 18:02:12 +0100 Subject: [PATCH 16/39] Remove body moving under terrain --- addons/dragging/functions/fnc_createClone.sqf | 21 +++------------- addons/dragging/functions/fnc_dropClone.sqf | 24 +++++++++---------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 6330be72f8f..9457612b368 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -14,6 +14,7 @@ * * Public: No */ + params ["_target"]; // Get current position of unit, -10 m below surface @@ -25,19 +26,13 @@ private _clone = createVehicle [QGVAR(clone), _posATL]; // Clone loadout [_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; -// Hide unit until it can be moved below terrain +// Hide unit private _isObjectHidden = isObjectHidden _target; if (!_isObjectHidden) then { [QEGVAR(common,hideObjectGlobal), [_target, true]] call CBA_fnc_serverEvent; }; -private _simulationEnabled = simulationEnabled _target; - -if (_simulationEnabled) then { - [QEGVAR(common,enableSimulationGlobal), [_target, false]] call CBA_fnc_serverEvent; -}; - private _isInRemainsCollector = isInRemainsCollector _target; // Make sure corpse isn't deleted by engine's garbage collector @@ -47,17 +42,7 @@ if (_isInRemainsCollector) then { // Disable all damage _clone allowDamage false; -_clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden, _simulationEnabled], true]; - -// Turn on PhysX so that unit is not desync when moving with 'setPos' commands -[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; - -[{ - params ["_target", "_posATL"]; - - // Move unit below terrain in order to hide it - _target setPosATL _posATL; -}, [_target, _posATL], 0.1] call CBA_fnc_waitAndExecute; +_clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden], true]; // Sets the facial expression [[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index cee2932eacd..b37f57247d7 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -16,13 +16,14 @@ * * Public: No */ + params ["_unit", "_clone", "_inBuilding"]; -(_clone getVariable [QGVAR(original), []]) params [["_target", objNull], ["_isInRemainsCollector", true], ["_isObjectHidden", false], ["_simulationEnabled", true]]; +(_clone getVariable [QGVAR(original), []]) params [["_target", objNull], ["_isInRemainsCollector", true], ["_isObjectHidden", false]]; // Check if unit was deleted if (!isNull _target) then { - // Turn on PhysX so that unit is not desync when moving + // Turn on PhysX so that unit doesn't desync when moving [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; private _posASL = getPosASL _clone; @@ -31,29 +32,28 @@ if (!isNull _target) then { _posASL = _posASL vectorAdd [0, 0, 0.05]; }; - // Set the unit's direction - [QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; - [{ - params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled", "_posASL"]; + params ["_target", "_clone", "_isObjectHidden", "_posASL"]; + + // Make sure PhysX is on + [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + + // Set the unit's direction + [QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; // Bring unit back to clone's position _target setPosASL _posASL; [{ - params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled"]; + params ["_target", "_clone", "_isObjectHidden"]; if (!_isObjectHidden) then { [QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent; }; - if (_simulationEnabled) then { - [QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent; - }; - deleteVehicle _clone; }, _this, 0.1] call CBA_fnc_waitAndExecute; - }, [_target, _clone, _isObjectHidden, _simulationEnabled, _posASL], 0.1] call CBA_fnc_waitAndExecute; + }, [_target, _clone, _isObjectHidden, _posASL], 0.1] call CBA_fnc_waitAndExecute; if (_isInRemainsCollector) then { addToRemainsCollector [_target]; From 884bccf1cb614f5a31e3bd1d1a288b9e15763418 Mon Sep 17 00:00:00 2001 From: LinkIsGrim Date: Mon, 8 Jan 2024 04:40:28 -0300 Subject: [PATCH 17/39] add wound texture handling --- addons/dragging/functions/fnc_createClone.sqf | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 9457612b368..381b980376d 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -40,6 +40,17 @@ if (_isInRemainsCollector) then { removeFromRemainsCollector [_target]; }; +// Make sure clone has the same wound textures as the corpse +private _targetDamage = damage _target; +if (_targetDamage != 0) then { + _clone setDamage (_targetDamage min 0.99); // Don't kill the clone +}; +private _relevantHitpoints = ["HitHead", "HitBody", "HitHands", "HitLegs"]; +{ + private _hitpointDamage = _target getHitPointDamage _x; + _clone setHitPointDamage [_x, _hitpointDamage min 0.99]; +} forEach _relevantHitpoints; + // Disable all damage _clone allowDamage false; _clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden], true]; From 594e1187a9824b89b686e0086d0cf52bfaea0653 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 9 Jan 2024 19:37:24 +0100 Subject: [PATCH 18/39] Readd body moving under terrain --- addons/dragging/functions/fnc_createClone.sqf | 23 +++++++++++++++++-- addons/dragging/functions/fnc_dropClone.sqf | 23 +++++++++++++------ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 381b980376d..db0b51bba27 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -26,13 +26,19 @@ private _clone = createVehicle [QGVAR(clone), _posATL]; // Clone loadout [_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; -// Hide unit +// Hide unit until it can be moved below terrain private _isObjectHidden = isObjectHidden _target; if (!_isObjectHidden) then { [QEGVAR(common,hideObjectGlobal), [_target, true]] call CBA_fnc_serverEvent; }; +private _simulationEnabled = simulationEnabled _target; + +if (_simulationEnabled) then { + [QEGVAR(common,enableSimulationGlobal), [_target, false]] call CBA_fnc_serverEvent; +}; + private _isInRemainsCollector = isInRemainsCollector _target; // Make sure corpse isn't deleted by engine's garbage collector @@ -53,7 +59,20 @@ private _relevantHitpoints = ["HitHead", "HitBody", "HitHands", "HitLegs"]; // Disable all damage _clone allowDamage false; -_clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden], true]; +_clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden, _simulationEnabled], true]; + +// Turn on PhysX so that the corpse doesn't desync when moved +[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + +[{ + params ["_target", "_posATL"]; + + // Make sure PhysX is on + [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + + // Move unit below terrain in order to hide it and remove its inventory access + _target setPosATL _posATL; +}, [_target, _posATL], 0.1] call CBA_fnc_waitAndExecute; // Sets the facial expression [[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index b37f57247d7..b373856e0c7 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -19,11 +19,16 @@ params ["_unit", "_clone", "_inBuilding"]; -(_clone getVariable [QGVAR(original), []]) params [["_target", objNull], ["_isInRemainsCollector", true], ["_isObjectHidden", false]]; +(_clone getVariable [QGVAR(original), []]) params [ + ["_target", objNull], + ["_isInRemainsCollector", true], + ["_isObjectHidden", false], + ["_simulationEnabled", true] +]; // Check if unit was deleted if (!isNull _target) then { - // Turn on PhysX so that unit doesn't desync when moving + // Turn on PhysX so that the corpse doesn't desync when moved [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; private _posASL = getPosASL _clone; @@ -33,27 +38,31 @@ if (!isNull _target) then { }; [{ - params ["_target", "_clone", "_isObjectHidden", "_posASL"]; + params ["_target", "", "", "", "_posASL", "_dir"]; // Make sure PhysX is on [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; // Set the unit's direction - [QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; + [QEGVAR(common,setDir), [_target, _dir], _target] call CBA_fnc_targetEvent; // Bring unit back to clone's position _target setPosASL _posASL; [{ - params ["_target", "_clone", "_isObjectHidden"]; + params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled"]; if (!_isObjectHidden) then { [QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent; }; + if (_simulationEnabled) then { + [QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent; + }; + deleteVehicle _clone; - }, _this, 0.1] call CBA_fnc_waitAndExecute; - }, [_target, _clone, _isObjectHidden, _posASL], 0.1] call CBA_fnc_waitAndExecute; + }, _this, 0.25] call CBA_fnc_waitAndExecute; + }, [_target, _clone, _isObjectHidden, _simulationEnabled, _posASL, getDir _unit + 180], 0.25] call CBA_fnc_waitAndExecute; if (_isInRemainsCollector) then { addToRemainsCollector [_target]; From c8b3c15ba778691a393e1d73f10c7c39efd14712 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:37:05 +0100 Subject: [PATCH 19/39] Update dragging.md --- docs/wiki/feature/dragging.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/wiki/feature/dragging.md b/docs/wiki/feature/dragging.md index 0d42240a238..aa462d2e64d 100644 --- a/docs/wiki/feature/dragging.md +++ b/docs/wiki/feature/dragging.md @@ -20,7 +20,9 @@ This adds the option to drag or carry units or objects. ## 2. Usage ### 2.1 Dragging / Carrying units and objects -- You can only drag or carry an unconscious unit. +- You can drag or carry dead or unconscious units. These units can't be in a ragdoll state. +- You can drag or carry units whose legs are broken. +- You can't carry if you have broken legs. - Interact with the unit or object ⊞ Win (ACE3 default key bind `Interact Key`). - Select `Drag` or `Carry`. - To release, use the mouse wheel and select `Release` or use Self Interaction Ctrl+⊞ Win and select `Release`. From 15b581b4cc75bad98dd2cc173fa972dc3a7d9d61 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Thu, 11 Jan 2024 11:56:25 +0100 Subject: [PATCH 20/39] Update fnc_createClone.sqf --- addons/dragging/functions/fnc_createClone.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index db0b51bba27..4228356ac8e 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -72,7 +72,7 @@ _clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectH // Move unit below terrain in order to hide it and remove its inventory access _target setPosATL _posATL; -}, [_target, _posATL], 0.1] call CBA_fnc_waitAndExecute; +}, [_target, _posATL], 0.25] call CBA_fnc_waitAndExecute; // Sets the facial expression [[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; From 824a9f6afecc71b85f5bb8df2a8239387cd70212 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:19:43 +0100 Subject: [PATCH 21/39] Another attempt --- addons/dragging/XEH_postInit.sqf | 15 ++++++ addons/dragging/functions/fnc_createClone.sqf | 12 ++--- addons/dragging/functions/fnc_dropClone.sqf | 46 ++++++++----------- addons/interact_menu/XEH_preInit.sqf | 14 ++++++ 4 files changed, 51 insertions(+), 36 deletions(-) diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 8690f90149d..14a1c1e3634 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -67,6 +67,21 @@ if (isNil QGVAR(maxWeightCarryRun)) then { _clone setMimic "unconscious"; }] call CBA_fnc_addEventHandler; +[QGVAR(moveCorpse), { + params ["_corpse", "_dir", "_pos"]; + + // Set direction before position + _corpse setDir _dir; + + // Bring corpse back to clone's position + _corpse setPosATL _pos; + + // Sync the corpse + [QEGVAR(common,awake), [_corpse, true]] call CBA_fnc_globalEvent; + [QEGVAR(common,awake), [_corpse, false]] call CBA_fnc_globalEvent; + [QEGVAR(common,awake), [_corpse, true]] call CBA_fnc_globalEvent; +}] call CBA_fnc_addEventHandler; + // Display event handler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler; diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index e22f553c82e..8aec7f71fe2 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -29,6 +29,9 @@ private _clone = createVehicle [QGVAR(clone), ASLToAGL _posATL, [], 0, "CAN_COLL // Move unit -10 m below terrain in order to hide it and remove its inventory access _posATL set [2, -10]; +// Corpse is desynced, but it doesn't matter here +_target setPosATL _posATL; + // Hide unit until it can be moved below terrain private _isObjectHidden = isObjectHidden _target; @@ -66,9 +69,6 @@ private _relevantHitpoints = ["HitHead", "HitBody", "HitHands", "HitLegs"]; _clone allowDamage false; _clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden, _simulationEnabled], true]; -// Turn on PhysX so that the corpse doesn't desync when moved -[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; - [{ params ["_clone", "_target", "_posATL"]; @@ -77,18 +77,12 @@ _clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectH [QEGVAR(zeus,removeObjects), [[_clone]]] call CBA_fnc_serverEvent; }; - // Make sure PhysX is on - [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; - // Clone loadout (sometimes default loadouts are randomised, so overwrite those) [_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; // Sets the facial expression [[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; - // Corpse is desynced, but it doesn't matter here - _target setPosATL _posATL; - // Release claim on corpse [objNull, _target] call EFUNC(common,claim); }, [_clone, _target, _posATL], 0.25] call CBA_fnc_waitAndExecute; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 010ebebf3ee..2b8e3ac61b9 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -28,41 +28,33 @@ params ["_unit", "_clone", "_inBuilding"]; // Check if unit was deleted if (!isNull _target) then { - // Turn on PhysX so that the corpse doesn't desync when moved - [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; - - private _posASL = getPosASL _clone; + private _pos = getPosATL _clone; if (_inBuilding) then { - _posASL = _posASL vectorAdd [0, 0, 0.05]; + _pos = _pos vectorAdd [0, 0, 0.05]; }; - // Set the unit's direction - [QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; - - [{ - params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled", "_posASL"]; - - // Make sure PhysX is on - [QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + // Make sure position is not underground + if (_pos select 2 < 0.05) then { + _pos set [2, 0.05]; + }; - // Bring unit back to clone's position - _target setPosASL _posASL; + // Move the unit where it is local + [QGVAR(moveCorpse), [_target, getDir _unit + 180, ], _target] call CBA_fnc_targetEvent; - // Unhide unit - if (!_isObjectHidden) then { - [QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent; - }; + // Unhide unit + if (!_isObjectHidden) then { + [QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent; + }; - // Enable simulation again - if (_simulationEnabled) then { - [QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent; - }; + // Enable simulation again + if (_simulationEnabled) then { + [QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent; + }; - // Detach first to prevent objNull in attachedObjects - detach _clone; - deleteVehicle _clone; - }, [_target, _clone, _isObjectHidden, _simulationEnabled, _posASL], 0.25] call CBA_fnc_waitAndExecute; + // Detach first to prevent objNull in attachedObjects + detach _clone; + deleteVehicle _clone; // Get which curators had this object as editable if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index b60f1bb7451..59b2f4c5015 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -80,6 +80,20 @@ GVAR(inheritedClassesAll) = []; GVAR(inheritedActionsMan) = []; GVAR(inheritedClassesMan) = []; +// Extended EH doesn't fire for dead units, so add interactions manually +{ + private _type = typeOf _x; + + if (GVAR(inheritedClassesMan) pushBackUnique _type == -1) then { + continue; + }; + + { + _x params ["_typeNum", "_parentPath", "_action"]; + [_type, _typeNum, _parentPath, _action] call FUNC(addActionToClass); + } forEach GVAR(inheritedActionsMan); +} forEach allDeadMen; + ["All", "InitPost", { BEGIN_COUNTER(InitPost); params ["_object"]; From f805604901e41cf048185453113ed7f9bdab4ec5 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:47:47 -0800 Subject: [PATCH 22/39] Update addons/dragging/functions/fnc_dropClone.sqf Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/dragging/functions/fnc_dropClone.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 2b8e3ac61b9..0ef9d9b7d28 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -40,7 +40,7 @@ if (!isNull _target) then { }; // Move the unit where it is local - [QGVAR(moveCorpse), [_target, getDir _unit + 180, ], _target] call CBA_fnc_targetEvent; + [QGVAR(moveCorpse), [_target, getDir _unit + 180, _pos], _target] call CBA_fnc_targetEvent; // Unhide unit if (!_isObjectHidden) then { From 43fb2613be43e1f252fac5f15680577c933369ee Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 2 Feb 2024 14:54:19 -0800 Subject: [PATCH 23/39] Update addons/dragging/functions/fnc_createClone.sqf Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/dragging/functions/fnc_createClone.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 8aec7f71fe2..8194d9f5f1f 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -18,10 +18,10 @@ params ["_unit", "_target"]; -private _posATL = getPosASL _target; +private _posATL = getPosATL _target; // Create clone -private _clone = createVehicle [QGVAR(clone), ASLToAGL _posATL, [], 0, "CAN_COLLIDE"]; +private _clone = createVehicle [QGVAR(clone), _posATL, [], 0, "CAN_COLLIDE"]; // Claim the clone [_unit, _clone] call EFUNC(common,claim); From 2d8dc01f2c950a8df4c4e63eebbfcdee9a51f72f Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 2 Feb 2024 23:59:10 +0100 Subject: [PATCH 24/39] Cleanup --- addons/dragging/functions/fnc_createClone.sqf | 16 ++++++++-------- .../dragging/functions/fnc_startCarryLocal.sqf | 10 +++++----- addons/dragging/functions/fnc_startDragLocal.sqf | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 8194d9f5f1f..da27e269973 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -39,6 +39,7 @@ if (!_isObjectHidden) then { [QEGVAR(common,hideObjectGlobal), [_target, true]] call CBA_fnc_serverEvent; }; +// Prevents unit from falling when below terrain private _simulationEnabled = simulationEnabled _target; if (_simulationEnabled) then { @@ -69,23 +70,22 @@ private _relevantHitpoints = ["HitHead", "HitBody", "HitHands", "HitLegs"]; _clone allowDamage false; _clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden, _simulationEnabled], true]; +[_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; + +// Sets the facial expression +[[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; + [{ - params ["_clone", "_target", "_posATL"]; + params ["_clone", "_target"]; // Remove clone from all zeuses if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { [QEGVAR(zeus,removeObjects), [[_clone]]] call CBA_fnc_serverEvent; }; - // Clone loadout (sometimes default loadouts are randomised, so overwrite those) - [_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; - - // Sets the facial expression - [[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; - // Release claim on corpse [objNull, _target] call EFUNC(common,claim); -}, [_clone, _target, _posATL], 0.25] call CBA_fnc_waitAndExecute; +}, [_clone, _target], 0.25] call CBA_fnc_waitAndExecute; // Save which curators had this object as editable if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { diff --git a/addons/dragging/functions/fnc_startCarryLocal.sqf b/addons/dragging/functions/fnc_startCarryLocal.sqf index b4fb05c7a92..b30c2bf79e0 100644 --- a/addons/dragging/functions/fnc_startCarryLocal.sqf +++ b/addons/dragging/functions/fnc_startCarryLocal.sqf @@ -34,15 +34,15 @@ if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith { [LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); }; -// Create clone for dead units -if (!alive _target) then { - _target = [_unit, _target] call FUNC(createClone); -}; - private _timer = CBA_missionTime + 5; // Handle objects vs. persons if (_target isKindOf "CAManBase") then { + // Create clone for dead units + if (!alive _target) then { + _target = [_unit, _target] call FUNC(createClone); + }; + private _primaryWeapon = primaryWeapon _unit; // Add a primary weapon if the unit has none diff --git a/addons/dragging/functions/fnc_startDragLocal.sqf b/addons/dragging/functions/fnc_startDragLocal.sqf index e969fb0f793..0187e2ebb0d 100644 --- a/addons/dragging/functions/fnc_startDragLocal.sqf +++ b/addons/dragging/functions/fnc_startDragLocal.sqf @@ -34,11 +34,6 @@ if (_weight > GETMVAR(ACE_maxWeightDrag,1E11)) exitWith { [LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); }; -// Create clone for dead units -if (!alive _target) then { - _target = [_unit, _target] call FUNC(createClone); -}; - private _primaryWeapon = primaryWeapon _unit; // Add a primary weapon if the unit has none @@ -89,6 +84,11 @@ if !(_unit call EFUNC(common,isSwimming)) then { // Move a bit closer and adjust direction when trying to pick up a person if (_target isKindOf "CAManBase") then { + // Create clone for dead units + if (!alive _target) then { + _target = [_unit, _target] call FUNC(createClone); + }; + [QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; _target setPosASL (getPosASL _unit vectorAdd (vectorDir _unit vectorMultiply 1.5)); From 58e220b1b18ced6dd3ee7134c939e09348d1bab9 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 3 Feb 2024 09:25:58 +0100 Subject: [PATCH 25/39] Update XEH_preInit.sqf --- addons/interact_menu/XEH_preInit.sqf | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 59b2f4c5015..b60f1bb7451 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -80,20 +80,6 @@ GVAR(inheritedClassesAll) = []; GVAR(inheritedActionsMan) = []; GVAR(inheritedClassesMan) = []; -// Extended EH doesn't fire for dead units, so add interactions manually -{ - private _type = typeOf _x; - - if (GVAR(inheritedClassesMan) pushBackUnique _type == -1) then { - continue; - }; - - { - _x params ["_typeNum", "_parentPath", "_action"]; - [_type, _typeNum, _parentPath, _action] call FUNC(addActionToClass); - } forEach GVAR(inheritedActionsMan); -} forEach allDeadMen; - ["All", "InitPost", { BEGIN_COUNTER(InitPost); params ["_object"]; From fdbaeabc476f6676d814da9fd16eb2f6abbee98e Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 1 Apr 2024 16:33:08 +0200 Subject: [PATCH 26/39] Try syncing individually on each client --- addons/common/XEH_postInit.sqf | 5 ----- addons/dragging/XEH_postInit.sqf | 18 ++++++++++++++---- addons/dragging/functions/fnc_createClone.sqf | 10 ++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index e669243ee38..1f259c2e3d5 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -122,11 +122,6 @@ _object setMass _mass; }] call CBA_fnc_addEventHandler; -[QGVAR(awake), { - params ["_object", "_awake"]; - _object awake _awake; -}] call CBA_fnc_addEventHandler; - [QGVAR(disableWeaponAssembly), { params ["_object", "_set"]; _object enableWeaponDisassembly (_set < 1); diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 14a1c1e3634..1aef704226c 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -67,6 +67,18 @@ if (isNil QGVAR(maxWeightCarryRun)) then { _clone setMimic "unconscious"; }] call CBA_fnc_addEventHandler; +[QGVAR(syncCorpse),{ + params ["_corpse"]; + + [{ + _this awake true; + + [{ + _this awake false; + }, _this] call CBA_fnc_execNextFrame; + }, _corpse] call CBA_fnc_execNextFrame; +}] call CBA_fnc_addEventHandler; + [QGVAR(moveCorpse), { params ["_corpse", "_dir", "_pos"]; @@ -76,10 +88,8 @@ if (isNil QGVAR(maxWeightCarryRun)) then { // Bring corpse back to clone's position _corpse setPosATL _pos; - // Sync the corpse - [QEGVAR(common,awake), [_corpse, true]] call CBA_fnc_globalEvent; - [QEGVAR(common,awake), [_corpse, false]] call CBA_fnc_globalEvent; - [QEGVAR(common,awake), [_corpse, true]] call CBA_fnc_globalEvent; + // Sync the corpse with its position + [QGVAR(syncCorpse), _corpse] call CBA_fnc_globalEvent; }] call CBA_fnc_addEventHandler; // Display event handler diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index da27e269973..e80724682bf 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -54,17 +54,11 @@ if (_isInRemainsCollector) then { }; // Make sure clone has the same wound textures as the corpse -private _targetDamage = damage _target; - -if (_targetDamage != 0) then { - _clone setDamage (_targetDamage min 0.99); // don't kill the clone -}; - -private _relevantHitpoints = ["HitHead", "HitBody", "HitHands", "HitLegs"]; +_clone setDamage ((damage _target) min 0.99); // don't kill the clone { _clone setHitPointDamage [_x, (_target getHitPointDamage _x) min 0.99]; -} forEach _relevantHitpoints; +} forEach ["HitHead", "HitBody", "HitHands", "HitLegs"]; // relevant hitpoints // Disable all damage _clone allowDamage false; From 04564b4e4fb8000fbc6c1a5abe71e6e5b280655e Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 9 Apr 2024 22:08:43 +0200 Subject: [PATCH 27/39] `setPosATL` globally --- addons/dragging/XEH_postInit.sqf | 38 +++++++++++++-------- addons/dragging/functions/fnc_dropClone.sqf | 4 +-- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 1aef704226c..745803bf33e 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -67,9 +67,30 @@ if (isNil QGVAR(maxWeightCarryRun)) then { _clone setMimic "unconscious"; }] call CBA_fnc_addEventHandler; -[QGVAR(syncCorpse),{ - params ["_corpse"]; +[QGVAR(moveCorpse), { + params ["_corpse", "_dir", "_pos"]; + _pos params ["_xPos", "_yPos", "_zPos"]; + + private _currentPos = getPosATL _corpse; + + // Check if the corpse is already close to the target + // If so, don't teleport + if !( + (_currentPos select 0 <= _xPos + 0.25) && + {_currentPos select 0 >= _xPos - 0.25} && + {_currentPos select 1 <= _yPos + 0.25} && + {_currentPos select 1 >= _yPos - 0.25} && + {_currentPos select 2 <= _zPos + 0.25} && + {_currentPos select 2 >= _zPos - 0.25} + ) then { + // Set direction before position + _corpse setDir _dir; + + // Bring corpse back to clone's position + _corpse setPosATL _pos; + }; + // Sync the corpse with its position [{ _this awake true; @@ -79,19 +100,6 @@ if (isNil QGVAR(maxWeightCarryRun)) then { }, _corpse] call CBA_fnc_execNextFrame; }] call CBA_fnc_addEventHandler; -[QGVAR(moveCorpse), { - params ["_corpse", "_dir", "_pos"]; - - // Set direction before position - _corpse setDir _dir; - - // Bring corpse back to clone's position - _corpse setPosATL _pos; - - // Sync the corpse with its position - [QGVAR(syncCorpse), _corpse] call CBA_fnc_globalEvent; -}] call CBA_fnc_addEventHandler; - // Display event handler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 0ef9d9b7d28..0f00609e8c0 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -39,8 +39,8 @@ if (!isNull _target) then { _pos set [2, 0.05]; }; - // Move the unit where it is local - [QGVAR(moveCorpse), [_target, getDir _unit + 180, _pos], _target] call CBA_fnc_targetEvent; + // Move the unit globally (important, as it doesn't work otherwise) + [QGVAR(moveCorpse), [_target, getDir _unit + 180, _pos]] call CBA_fnc_globalEvent; // Unhide unit if (!_isObjectHidden) then { From 28560b9ad9de301e5702f2a03ed4d4f2d34e7e69 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:36:37 +0200 Subject: [PATCH 28/39] Sync corpses when JIP to avoid weird hitbox collision, renamed function and added API The idea behind the API is for 3rd party mods that include garbage collectors to exclude corpses that are being dragged/carried. --- addons/dragging/XEH_PREP.hpp | 2 +- addons/dragging/XEH_postInit.sqf | 108 +++++++++++------- addons/dragging/functions/fnc_createClone.sqf | 14 ++- ...{fnc_dropClone.sqf => fnc_deleteClone.sqf} | 19 +-- addons/dragging/functions/fnc_dropObject.sqf | 2 +- .../functions/fnc_dropObject_carry.sqf | 2 +- docs/wiki/framework/events-framework.md | 7 ++ 7 files changed, 100 insertions(+), 54 deletions(-) rename addons/dragging/functions/{fnc_dropClone.sqf => fnc_deleteClone.sqf} (75%) diff --git a/addons/dragging/XEH_PREP.hpp b/addons/dragging/XEH_PREP.hpp index a5afd0367eb..aeba3135ab5 100644 --- a/addons/dragging/XEH_PREP.hpp +++ b/addons/dragging/XEH_PREP.hpp @@ -6,9 +6,9 @@ PREP(canRun_carry); PREP(carryObject); PREP(carryObjectPFH); PREP(createClone); +PREP(deleteClone); PREP(dragObject); PREP(dragObjectPFH); -PREP(dropClone); PREP(dropObject); PREP(dropObject_carry); PREP(getWeight); diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 745803bf33e..942fffd4b8d 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -1,9 +1,72 @@ // by PabstMirror, commy2 #include "script_component.hpp" +[QGVAR(moveCorpse), { + params ["_corpse", "_dir", "_posATL"]; + _posATL params ["_xPos", "_yPos", "_zPos"]; + + if (isNull _corpse) exitWith {}; + + private _currentPos = getPosATL _corpse; + + // Check if the corpse is already close to the target + // If so, don't teleport + if !( + (_currentPos select 0 <= _xPos + 0.25) && + {_currentPos select 0 >= _xPos - 0.25} && + {_currentPos select 1 <= _yPos + 0.25} && + {_currentPos select 1 >= _yPos - 0.25} && + {_currentPos select 2 <= _zPos + 0.25} && + {_currentPos select 2 >= _zPos - 0.25} + ) then { + // Set direction before position + _corpse setDir _dir; + + // Bring corpse back to clone's position + _corpse setPosATL _posATL; + }; + + // Sync the corpse with its position + [{ + _this awake true; + + [{ + _this awake false; + }, _this] call CBA_fnc_execNextFrame; + }, _corpse] call CBA_fnc_execNextFrame; + + // Allow the corpse to be synced for JIP players + if (isServer) exitWith { + GVAR(movedCorpses) pushBackUnique _corpse; + }; +}] call CBA_fnc_addEventHandler; + if (isServer) then { // Release object on disconnection. Function is identical to killed addMissionEventHandler ["HandleDisconnect", LINKFUNC(handleKilled)]; + + GVAR(movedCorpses) = []; + + ["CAManBase", "Deleted", { + GVAR(movedCorpses) deleteAt (GVAR(movedCorpses) find (_this select 0)); + }, true, [], true] call CBA_fnc_addClassEventHandler; + + [QGVAR(disableSyncMovedCorpseOnJIP), { + params ["_corpse"]; + + GVAR(movedCorpses) deleteAt (GVAR(movedCorpses) find _corpse); + }] call CBA_fnc_addEventHandler; + + // Sync position of dead corpse for JIP unit (prevents weird invisible hitboxes on corpses) + [QGVAR(requestSyncMovedCorpsesJIP), { + params ["_clientOwner"]; + + { + [QGVAR(moveCorpse), [_x, getDir _x, getPosATL _x], _clientOwner] call CBA_fnc_ownerEvent; + } forEach GVAR(movedCorpses); + }] call CBA_fnc_addEventHandler; +} else { + [QGVAR(requestSyncMovedCorpsesJIP), clientOwner] call CBA_fnc_serverEvent; }; if (!hasInterface) exitWith {}; @@ -59,50 +122,17 @@ if (isNil QGVAR(maxWeightCarryRun)) then { // 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 local effect commands for clones -[QGVAR(cloneCreated), { - params ["_unit", "_clone"]; +[QGVAR(setCloneFace), { + params ["_clone", "_corpse"]; - _clone setFace face _unit; + _clone setFace face _corpse; _clone setMimic "unconscious"; }] call CBA_fnc_addEventHandler; -[QGVAR(moveCorpse), { - params ["_corpse", "_dir", "_pos"]; - _pos params ["_xPos", "_yPos", "_zPos"]; - - private _currentPos = getPosATL _corpse; - - // Check if the corpse is already close to the target - // If so, don't teleport - if !( - (_currentPos select 0 <= _xPos + 0.25) && - {_currentPos select 0 >= _xPos - 0.25} && - {_currentPos select 1 <= _yPos + 0.25} && - {_currentPos select 1 >= _yPos - 0.25} && - {_currentPos select 2 <= _zPos + 0.25} && - {_currentPos select 2 >= _zPos - 0.25} - ) then { - // Set direction before position - _corpse setDir _dir; - - // Bring corpse back to clone's position - _corpse setPosATL _pos; - }; - - // Sync the corpse with its position - [{ - _this awake true; - - [{ - _this awake false; - }, _this] call CBA_fnc_execNextFrame; - }, _corpse] call CBA_fnc_execNextFrame; -}] 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"]; diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index e80724682bf..5c0ffb4d763 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -11,13 +11,16 @@ * Cloned unit * * Example: - * [player] call ace_dragging_fnc_createClone; + * [player, cursorObject] call ace_dragging_fnc_createClone; * * Public: No */ params ["_unit", "_target"]; +// Don't sync corpse when a player joins in progress until the corpse is in its proper position +[QGVAR(disableSyncMovedCorpseOnJIP), _target] call CBA_fnc_serverEvent; + private _posATL = getPosATL _target; // Create clone @@ -54,11 +57,11 @@ if (_isInRemainsCollector) then { }; // Make sure clone has the same wound textures as the corpse -_clone setDamage ((damage _target) min 0.99); // don't kill the clone +_clone setDamage ((damage _target) min 0.99); // Don't kill the clone { _clone setHitPointDamage [_x, (_target getHitPointDamage _x) min 0.99]; -} forEach ["HitHead", "HitBody", "HitHands", "HitLegs"]; // relevant hitpoints +} forEach ["HitHead", "HitBody", "HitHands", "HitLegs"]; // Relevant hitpoints // Disable all damage _clone allowDamage false; @@ -67,7 +70,10 @@ _clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectH [_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; // Sets the facial expression -[[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; +[[QGVAR(setCloneFace), [_clone, _target]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; + +// API +[QGVAR(cloneCreated), [_clone, _target]] call CBA_fnc_localEvent; [{ params ["_clone", "_target"]; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_deleteClone.sqf similarity index 75% rename from addons/dragging/functions/fnc_dropClone.sqf rename to addons/dragging/functions/fnc_deleteClone.sqf index 0f00609e8c0..148b88a3a31 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_deleteClone.sqf @@ -12,7 +12,7 @@ * Original unit * * Example: - * [player, cursorObject, false] call ace_dragging_fnc_dropClone; + * [player, cursorObject, false] call ace_dragging_fnc_deleteClone; * * Public: No */ @@ -26,21 +26,24 @@ params ["_unit", "_clone", "_inBuilding"]; ["_simulationEnabled", true] ]; +// API +[QGVAR(cloneDeleted), [_clone, _target]] call CBA_fnc_localEvent; + // Check if unit was deleted if (!isNull _target) then { - private _pos = getPosATL _clone; + private _posATL = getPosATL _clone; if (_inBuilding) then { - _pos = _pos vectorAdd [0, 0, 0.05]; + _posATL = _posATL vectorAdd [0, 0, 0.05]; }; - // Make sure position is not underground - if (_pos select 2 < 0.05) then { - _pos set [2, 0.05]; + // Make sure position isn't underground + if (_posATL select 2 < 0.05) then { + _posATL set [2, 0.05]; }; - // Move the unit globally (important, as it doesn't work otherwise) - [QGVAR(moveCorpse), [_target, getDir _unit + 180, _pos]] call CBA_fnc_globalEvent; + // Move the unit globally (important, as it desyncs the corpse position otherwise) + [QGVAR(moveCorpse), [_target, getDir _unit + 180, _posATL]] call CBA_fnc_globalEvent; // Unhide unit if (!_isObjectHidden) then { diff --git a/addons/dragging/functions/fnc_dropObject.sqf b/addons/dragging/functions/fnc_dropObject.sqf index 5b59f7d9005..c5b0dff4891 100644 --- a/addons/dragging/functions/fnc_dropObject.sqf +++ b/addons/dragging/functions/fnc_dropObject.sqf @@ -35,7 +35,7 @@ private _isClone = _target isKindOf QGVAR(clone); // Drop cloned dead units if (_isClone) then { - _target = [_unit, _target, _inBuilding] call FUNC(dropClone); + _target = [_unit, _target, _inBuilding] call FUNC(deleteClone); }; // Play release animation diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index 960a42e74f2..9a96515223f 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -29,7 +29,7 @@ private _isClone = _target isKindOf QGVAR(clone); // Drop cloned dead units if (_isClone) then { - _target = [_unit, _target, _inBuilding] call FUNC(dropClone); + _target = [_unit, _target, _inBuilding] call FUNC(deleteClone); }; // Prevent collision damage diff --git a/docs/wiki/framework/events-framework.md b/docs/wiki/framework/events-framework.md index 5155cf75937..956048e8014 100644 --- a/docs/wiki/framework/events-framework.md +++ b/docs/wiki/framework/events-framework.md @@ -167,6 +167,13 @@ MenuType: 0 = Interaction, 1 = Self Interaction | `ace_headless_groupTransferPre` | [_group, _HC (OBJECT), _previousOwner, _idHC] | Target | Listen | Called just before a group is transferred from any machine to a HC. Called where group currently is local and on the HC, where group is going to be local. | `ace_headless_groupTransferPost` | [_group, _HC (OBJECT), _previousOwner, _idHC, _transferredSuccessfully] | Target | Listen | Called just after a group is transferred from a machine to a HC. Called where group was local and on the HC, where group is now local. `_transferredSuccessfully` is passed so mods can actually check if the locality was properly transferred, as ownership transfer is not guaranteed. +### 2.18 Interaction (`ace_dragging`) + +| Event Key | Parameters | Locality | Type | Description | +|---------- |------------|----------|------|-------------| +| `ace_dragging_cloneCreated` | [_clone, _corpse] | Local | Listen | Called when a clone used for dragging/carrying corpses is created +| `ace_dragging_cloneDeleted` | [_clone, _corpse] | Local | Listen | Called when a clone used for dragging/carrying corpses is deleted + ## 3. Usage Also Reference [CBA Events System](https://github.com/CBATeam/CBA_A3/wiki/Custom-Events-System){:target="_blank"} documentation. From b5205c1fd07804045c53bbaf899314865566d340 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:13:01 -0700 Subject: [PATCH 29/39] Update addons/dragging/XEH_postInit.sqf Co-authored-by: Joko --- addons/dragging/XEH_postInit.sqf | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 942fffd4b8d..a3bc9036292 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -12,12 +12,7 @@ // Check if the corpse is already close to the target // If so, don't teleport if !( - (_currentPos select 0 <= _xPos + 0.25) && - {_currentPos select 0 >= _xPos - 0.25} && - {_currentPos select 1 <= _yPos + 0.25} && - {_currentPos select 1 >= _yPos - 0.25} && - {_currentPos select 2 <= _zPos + 0.25} && - {_currentPos select 2 >= _zPos - 0.25} + _currentPos distance _posATL > 0.25 ) then { // Set direction before position _corpse setDir _dir; From 471d33ae324fb194730a9d629e27100816325722 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 1 Jul 2024 19:15:37 +0200 Subject: [PATCH 30/39] More cleanup --- addons/dragging/XEH_postInit.sqf | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index a3bc9036292..b0468d46507 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -3,17 +3,12 @@ [QGVAR(moveCorpse), { params ["_corpse", "_dir", "_posATL"]; - _posATL params ["_xPos", "_yPos", "_zPos"]; if (isNull _corpse) exitWith {}; - private _currentPos = getPosATL _corpse; - // Check if the corpse is already close to the target // If so, don't teleport - if !( - _currentPos distance _posATL > 0.25 - ) then { + if ((getPosATL _corpse) distance _posATL > 0.25) then { // Set direction before position _corpse setDir _dir; From de1c2a5805203899335b46acaba6fb00b4dfc878 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 20 Jul 2024 08:42:38 +0200 Subject: [PATCH 31/39] Update docs/wiki/framework/events-framework.md --- docs/wiki/framework/events-framework.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/wiki/framework/events-framework.md b/docs/wiki/framework/events-framework.md index 956048e8014..c8ddd5808e6 100644 --- a/docs/wiki/framework/events-framework.md +++ b/docs/wiki/framework/events-framework.md @@ -167,7 +167,7 @@ MenuType: 0 = Interaction, 1 = Self Interaction | `ace_headless_groupTransferPre` | [_group, _HC (OBJECT), _previousOwner, _idHC] | Target | Listen | Called just before a group is transferred from any machine to a HC. Called where group currently is local and on the HC, where group is going to be local. | `ace_headless_groupTransferPost` | [_group, _HC (OBJECT), _previousOwner, _idHC, _transferredSuccessfully] | Target | Listen | Called just after a group is transferred from a machine to a HC. Called where group was local and on the HC, where group is now local. `_transferredSuccessfully` is passed so mods can actually check if the locality was properly transferred, as ownership transfer is not guaranteed. -### 2.18 Interaction (`ace_dragging`) +### 2.18 Dragging (`ace_dragging`) | Event Key | Parameters | Locality | Type | Description | |---------- |------------|----------|------|-------------| From f93ac13ca473725a72ef54b34bb089c9edcb8875 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 20 Jul 2024 08:44:56 +0200 Subject: [PATCH 32/39] Remove ; in headers --- addons/dragging/functions/fnc_startCarry.sqf | 2 +- addons/dragging/functions/fnc_startCarryLocal.sqf | 2 +- addons/dragging/functions/fnc_startDrag.sqf | 2 +- addons/dragging/functions/fnc_startDragLocal.sqf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index 55535936294..99652fc263d 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -11,7 +11,7 @@ * None * * Example: - * [player, cursorTarget] call ace_dragging_fnc_startCarry; + * [player, cursorTarget] call ace_dragging_fnc_startCarry * * Public: No */ diff --git a/addons/dragging/functions/fnc_startCarryLocal.sqf b/addons/dragging/functions/fnc_startCarryLocal.sqf index 2ab4936c1f8..4383e8f9ce3 100644 --- a/addons/dragging/functions/fnc_startCarryLocal.sqf +++ b/addons/dragging/functions/fnc_startCarryLocal.sqf @@ -12,7 +12,7 @@ * None * * Example: - * [player, cursorTarget, true] call ace_dragging_fnc_startCarryLocal; + * [player, cursorTarget, true] call ace_dragging_fnc_startCarryLocal * * Public: No */ diff --git a/addons/dragging/functions/fnc_startDrag.sqf b/addons/dragging/functions/fnc_startDrag.sqf index 085aa605d85..d65f218acd7 100644 --- a/addons/dragging/functions/fnc_startDrag.sqf +++ b/addons/dragging/functions/fnc_startDrag.sqf @@ -11,7 +11,7 @@ * None * * Example: - * [player, cursorTarget] call ace_dragging_fnc_startDrag; + * [player, cursorTarget] call ace_dragging_fnc_startDrag * * Public: No */ diff --git a/addons/dragging/functions/fnc_startDragLocal.sqf b/addons/dragging/functions/fnc_startDragLocal.sqf index a0a07b6bada..2d1ee0d16b0 100644 --- a/addons/dragging/functions/fnc_startDragLocal.sqf +++ b/addons/dragging/functions/fnc_startDragLocal.sqf @@ -12,7 +12,7 @@ * None * * Example: - * [player, cursorTarget, true] call ace_dragging_fnc_startDragLocal; + * [player, cursorTarget, true] call ace_dragging_fnc_startDragLocal * * Public: No */ From a5d047cdc85e5e1da4b1b6aef4978dd74ddae773 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Wed, 28 Aug 2024 05:29:27 -0700 Subject: [PATCH 33/39] Update addons/dragging/functions/fnc_canCarry.sqf Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/dragging/functions/fnc_canCarry.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index 64511fe410c..c99e2802e68 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -33,7 +33,7 @@ if ((_unit getHitPointDamage "HitLegs") >= 0.5) exitWith {false}; if (_isPerson) exitWith { !_alive || {(isAwake _target) && // not ragdolled if alive - {!(lifeState _target in ["HEALTHY", "INJURED"]) || + {!(_target call EFUNC(common,isAwake)) || {_target getHitPointDamage "HitLegs" >= 0.5}}} }; From 5ea5330c70cd4d37aa57e64d9d7abb77260398cc Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Wed, 28 Aug 2024 14:33:16 +0200 Subject: [PATCH 34/39] Update fnc_canDrag.sqf --- addons/dragging/functions/fnc_canDrag.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index 51aa2d8cde1..374b0692fcd 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -29,7 +29,7 @@ if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exi if (_isPerson) exitWith { !_alive || {(isAwake _target) && // not ragdolled if alive - {!(lifeState _target in ["HEALTHY", "INJURED"]) || + {!(_target call EFUNC(common,isAwake)) || {_target getHitPointDamage "HitLegs" >= 0.5}}} }; From 0a6ec071b1849d68d2ac46b289bb0f024b69fcb5 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 29 Aug 2024 01:34:23 -0500 Subject: [PATCH 35/39] Fix opening backpack of clone while dragging and patient moved warning --- addons/medical_gui/functions/fnc_displayPatientInformation.sqf | 1 + addons/medical_status/functions/fnc_addInventoryActions.sqf | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/medical_gui/functions/fnc_displayPatientInformation.sqf b/addons/medical_gui/functions/fnc_displayPatientInformation.sqf index 65660eec798..abea0ec07bb 100644 --- a/addons/medical_gui/functions/fnc_displayPatientInformation.sqf +++ b/addons/medical_gui/functions/fnc_displayPatientInformation.sqf @@ -40,6 +40,7 @@ if (isNull _display) then { if (ACE_player distance _target > MAX_DISTANCE && {vehicle _target != vehicle ACE_player}) exitWith { [_pfhID] call CBA_fnc_removePerFrameHandler; QGVAR(RscPatientInfo) cutFadeOut 0.3; + if (((getPosATL _target) # 2) < -9) exitWith {}; // handle dragging corpse/clone [[ELSTRING(medical,DistanceToFar), _target call EFUNC(common,getName)], 2] call EFUNC(common,displayTextStructured); }; diff --git a/addons/medical_status/functions/fnc_addInventoryActions.sqf b/addons/medical_status/functions/fnc_addInventoryActions.sqf index 8041eb06135..ef89317f209 100644 --- a/addons/medical_status/functions/fnc_addInventoryActions.sqf +++ b/addons/medical_status/functions/fnc_addInventoryActions.sqf @@ -46,5 +46,6 @@ _unit addAction ["OpenBag", { {!lockedInventory _backpackContainer} && {maxLoad _backpackContainer > 0} && {getNumber (_backpackConfig >> "disableInventory") != 1} && + {(typeOf _target) != QEGVAR(dragging,clone)} && {_target setUserActionText [_actionId, format [localize "STR_ACTION_OPEN_BAG", getText (_backpackConfig >> "displayName")]]; true} }, 2]; From b3abb78c7c672c222d4977d9a12de4e68b5ed20d Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:08:02 -0700 Subject: [PATCH 36/39] Update addons/dragging/functions/fnc_canCarry.sqf Co-authored-by: PabstMirror --- addons/dragging/functions/fnc_canCarry.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index c99e2802e68..a38f37a02ee 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -31,7 +31,7 @@ if ((_unit getHitPointDamage "HitLegs") >= 0.5) exitWith {false}; // Units need to be unconscious or limping; Units also need to not be in ragdoll if alive, as that causes desync issues if (_isPerson) exitWith { - !_alive || + ((!_alive) && {missionNamespace getVariable [QGVAR(canMoveDead), true]}) || {(isAwake _target) && // not ragdolled if alive {!(_target call EFUNC(common,isAwake)) || {_target getHitPointDamage "HitLegs" >= 0.5}}} From b5579eb0bda54cdccb858ac3f7b54e347bc58fd7 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:08:12 -0700 Subject: [PATCH 37/39] Update addons/dragging/functions/fnc_canDrag.sqf Co-authored-by: PabstMirror --- addons/dragging/functions/fnc_canDrag.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index 374b0692fcd..2616d6d1447 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -27,7 +27,7 @@ if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exi // Units need to be unconscious or limping; Units also need to not be in ragdoll if alive, as that causes desync issues if (_isPerson) exitWith { - !_alive || + ((!_alive) && {missionNamespace getVariable [QGVAR(canMoveDead), true]}) || {(isAwake _target) && // not ragdolled if alive {!(_target call EFUNC(common,isAwake)) || {_target getHitPointDamage "HitLegs" >= 0.5}}} From 752993183ef5a62f92a21ef75b04b5dbd45c13e1 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:25:05 -0700 Subject: [PATCH 38/39] Update addons/medical_status/functions/fnc_addInventoryActions.sqf Co-authored-by: PabstMirror --- addons/medical_status/functions/fnc_addInventoryActions.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical_status/functions/fnc_addInventoryActions.sqf b/addons/medical_status/functions/fnc_addInventoryActions.sqf index ef89317f209..1f75519f2c5 100644 --- a/addons/medical_status/functions/fnc_addInventoryActions.sqf +++ b/addons/medical_status/functions/fnc_addInventoryActions.sqf @@ -46,6 +46,6 @@ _unit addAction ["OpenBag", { {!lockedInventory _backpackContainer} && {maxLoad _backpackContainer > 0} && {getNumber (_backpackConfig >> "disableInventory") != 1} && - {(typeOf _target) != QEGVAR(dragging,clone)} && + {!(_target isKindOf QEGVAR(dragging,clone)} && {_target setUserActionText [_actionId, format [localize "STR_ACTION_OPEN_BAG", getText (_backpackConfig >> "displayName")]]; true} }, 2]; From ba1bda87b53c2760ca807e417ea81cbeb250f0df Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:05:23 +0200 Subject: [PATCH 39/39] Improve corpse dragging - Fix drowning issue - Add 3rd party support - Remove "moved too far away" message if started carrying/dragging from medical menu --- addons/dragging/functions/fnc_createClone.sqf | 2 +- .../dragging/functions/fnc_dragObjectPFH.sqf | 5 ++++ addons/medical_gui/functions/fnc_menuPFH.sqf | 2 ++ .../functions/fnc_addInventoryActions.sqf | 2 +- docs/wiki/framework/dragging-framework.md | 24 +++++++++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index 5c0ffb4d763..6cb4aa0ec69 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -24,7 +24,7 @@ params ["_unit", "_target"]; private _posATL = getPosATL _target; // Create clone -private _clone = createVehicle [QGVAR(clone), _posATL, [], 0, "CAN_COLLIDE"]; +private _clone = createVehicle [[configOf _target >> QGVAR(cloneClass), "TEXT", QGVAR(clone)] call CBA_fnc_getConfigEntry, _posATL, [], 0, "CAN_COLLIDE"]; // Claim the clone [_unit, _clone] call EFUNC(common,claim); diff --git a/addons/dragging/functions/fnc_dragObjectPFH.sqf b/addons/dragging/functions/fnc_dragObjectPFH.sqf index 249f3866bb5..13400aa349f 100644 --- a/addons/dragging/functions/fnc_dragObjectPFH.sqf +++ b/addons/dragging/functions/fnc_dragObjectPFH.sqf @@ -62,3 +62,8 @@ if (_target isKindOf "StaticWeapon" && {((crew _target) - (_target getVariable [ _idPFH call CBA_fnc_removePerFrameHandler; }; + +// Clones can die of drowning if oxygen is under 0.5, so refill their oxygen from time to time +if (_target isKindOf QGVAR(clone) && {getOxygenRemaining _target < 0.8}) then { + _target setOxygenRemaining 1; +}; diff --git a/addons/medical_gui/functions/fnc_menuPFH.sqf b/addons/medical_gui/functions/fnc_menuPFH.sqf index b3d51c2dc9c..0e213eaf5ec 100644 --- a/addons/medical_gui/functions/fnc_menuPFH.sqf +++ b/addons/medical_gui/functions/fnc_menuPFH.sqf @@ -23,6 +23,8 @@ if !( closeDialog 0; // Show hint if distance condition failed if ((ACE_player distance GVAR(target) > GVAR(maxDistance)) && {vehicle ACE_player != vehicle GVAR(target)}) then { + if (((getPosATL GVAR(target)) # 2) < -9) exitWith {}; // handle dragging corpse/clone + [[ELSTRING(medical,DistanceToFar), GVAR(target) call EFUNC(common,getName)], 2] call EFUNC(common,displayTextStructured); }; }; diff --git a/addons/medical_status/functions/fnc_addInventoryActions.sqf b/addons/medical_status/functions/fnc_addInventoryActions.sqf index 1f75519f2c5..e4e65a31649 100644 --- a/addons/medical_status/functions/fnc_addInventoryActions.sqf +++ b/addons/medical_status/functions/fnc_addInventoryActions.sqf @@ -46,6 +46,6 @@ _unit addAction ["OpenBag", { {!lockedInventory _backpackContainer} && {maxLoad _backpackContainer > 0} && {getNumber (_backpackConfig >> "disableInventory") != 1} && - {!(_target isKindOf QEGVAR(dragging,clone)} && + {!(_target isKindOf QEGVAR(dragging,clone))} && {_target setUserActionText [_actionId, format [localize "STR_ACTION_OPEN_BAG", getText (_backpackConfig >> "displayName")]]; true} }, 2]; diff --git a/docs/wiki/framework/dragging-framework.md b/docs/wiki/framework/dragging-framework.md index 56bfba2801a..256d41570d4 100644 --- a/docs/wiki/framework/dragging-framework.md +++ b/docs/wiki/framework/dragging-framework.md @@ -98,3 +98,27 @@ You will **not** be able to carry / drag objects that are too heavy, the mass is | 1 | `true`| Carrying is enabled | | 2 | `[0,2,0]` | 0 meters sideways, 3 meters forward, 1 meter upwards | | 3 | `10` | Rotated by 10° | + +## 3. Corpse moving +Added in 3.18.0, ACE allows you to drag and carry corpses. + +### 3.1 Config Values + +```cpp +class CfgVehicles { + class MyUnit { + ace_dragging_cloneClass = "MyClone"; // Allows you to define what type of clone is used for moving the corpse (default: "ace_dragging_clone") + }; + + class ace_dragging_clone; + class MyClone: ace_dragging_clone {}; // Custom clones must inherit from ace_dragging_clone +}; +``` + +### 3.2 Enabling / disabling corpse moving + +By default, corpse moving is enabled. If you wish to disable it, you can set the variable below to `false`: + +```sqf +ace_dragging_canMoveDead = false; +```