ACE3/addons/dragging/functions/fnc_dropClone.sqf

77 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-10-03 06:46:27 +00:00
#include "..\script_component.hpp"
/*
2023-07-20 17:42:35 +00:00
* Author: BaerMitUmlaut, johnb43
* Drops a draggable / carryable clone of a dead unit.
*
* Arguments:
2023-07-20 17:42:35 +00:00
* 0: Unit dragging / carrying <OBJECT>
* 1: Clone <OBJECT>
* 2: If unit is in building <BOOL>
*
* Return Value:
2023-07-20 17:42:35 +00:00
* Original unit <OBJECT>
*
* Example:
2023-07-20 17:42:35 +00:00
* [player, cursorObject, false] call ace_dragging_fnc_dropClone;
*
* Public: No
*/
2024-01-07 17:02:12 +00:00
2023-07-20 17:42:35 +00:00
params ["_unit", "_clone", "_inBuilding"];
2024-01-09 18:37:24 +00:00
(_clone getVariable [QGVAR(original), []]) params [
["_target", objNull],
["_isInRemainsCollector", true],
["_isObjectHidden", false],
["_simulationEnabled", true]
];
2023-07-20 17:42:35 +00:00
2023-07-21 17:24:25 +00:00
// Check if unit was deleted
if (!isNull _target) then {
2024-01-09 18:37:24 +00:00
// Turn on PhysX so that the corpse doesn't desync when moved
2023-07-21 17:24:25 +00:00
[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent;
2023-07-20 17:42:35 +00:00
2023-07-21 17:24:25 +00:00
private _posASL = getPosASL _clone;
2023-07-20 17:42:35 +00:00
2023-07-21 17:24:25 +00:00
if (_inBuilding) then {
_posASL = _posASL vectorAdd [0, 0, 0.05];
};
2023-07-20 17:42:35 +00:00
2023-07-21 17:24:25 +00:00
[{
2024-01-09 18:37:24 +00:00
params ["_target", "", "", "", "_posASL", "_dir"];
2024-01-07 17:02:12 +00:00
// Make sure PhysX is on
[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent;
// Set the unit's direction
2024-01-09 18:37:24 +00:00
[QEGVAR(common,setDir), [_target, _dir], _target] call CBA_fnc_targetEvent;
2023-07-21 17:24:25 +00:00
// Bring unit back to clone's position
_target setPosASL _posASL;
2023-07-20 17:42:35 +00:00
2023-07-21 17:24:25 +00:00
[{
2024-01-09 18:37:24 +00:00
params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled"];
2023-07-20 17:42:35 +00:00
2024-01-07 15:48:40 +00:00
if (!_isObjectHidden) then {
2023-07-21 17:24:25 +00:00
[QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent;
};
2023-07-20 17:42:35 +00:00
2024-01-09 18:37:24 +00:00
if (_simulationEnabled) then {
[QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent;
};
2023-07-21 17:24:25 +00:00
deleteVehicle _clone;
2024-01-09 18:37:24 +00:00
}, _this, 0.25] call CBA_fnc_waitAndExecute;
}, [_target, _clone, _isObjectHidden, _simulationEnabled, _posASL, getDir _unit + 180], 0.25] call CBA_fnc_waitAndExecute;
2023-07-21 17:24:25 +00:00
if (_isInRemainsCollector) then {
addToRemainsCollector [_target];
};
};
// Detach first to prevent objNull in attachedObjects
detach _clone;
deleteVehicle _clone;
2023-07-20 17:42:35 +00:00
_target