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] 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 381b980376..db0b51bba2 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 b37f57247d..b373856e0c 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];