2023-10-03 06:46:27 +00:00
|
|
|
#include "..\script_component.hpp"
|
2020-10-04 20:39:52 +00:00
|
|
|
/*
|
2023-07-20 17:42:35 +00:00
|
|
|
* Author: BaerMitUmlaut, johnb43
|
2020-10-04 20:39:52 +00:00
|
|
|
* 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>
|
2020-10-04 20:39:52 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2023-07-20 17:42:35 +00:00
|
|
|
* Original unit <OBJECT>
|
2020-10-04 20:39:52 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2023-07-20 17:42:35 +00:00
|
|
|
* [player, cursorObject, false] call ace_dragging_fnc_dropClone;
|
2020-10-04 20:39:52 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2024-01-07 17:02:12 +00:00
|
|
|
|
2023-07-20 17:42:35 +00:00
|
|
|
params ["_unit", "_clone", "_inBuilding"];
|
2020-10-04 20:39:52 +00:00
|
|
|
|
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-02-02 17:19:43 +00:00
|
|
|
private _pos = getPosATL _clone;
|
2023-07-20 17:42:35 +00:00
|
|
|
|
2023-07-21 17:24:25 +00:00
|
|
|
if (_inBuilding) then {
|
2024-02-02 17:19:43 +00:00
|
|
|
_pos = _pos vectorAdd [0, 0, 0.05];
|
2023-07-21 17:24:25 +00:00
|
|
|
};
|
2023-07-20 17:42:35 +00:00
|
|
|
|
2024-02-02 17:19:43 +00:00
|
|
|
// Make sure position is not underground
|
|
|
|
if (_pos select 2 < 0.05) then {
|
|
|
|
_pos set [2, 0.05];
|
|
|
|
};
|
2024-01-07 17:02:12 +00:00
|
|
|
|
2024-04-09 20:08:43 +00:00
|
|
|
// Move the unit globally (important, as it doesn't work otherwise)
|
|
|
|
[QGVAR(moveCorpse), [_target, getDir _unit + 180, _pos]] call CBA_fnc_globalEvent;
|
2023-07-20 17:42:35 +00:00
|
|
|
|
2024-02-02 17:19:43 +00:00
|
|
|
// Unhide unit
|
|
|
|
if (!_isObjectHidden) then {
|
|
|
|
[QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent;
|
|
|
|
};
|
2024-01-14 21:36:10 +00:00
|
|
|
|
2024-02-02 17:19:43 +00:00
|
|
|
// Enable simulation again
|
|
|
|
if (_simulationEnabled) then {
|
|
|
|
[QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent;
|
|
|
|
};
|
2023-07-20 17:42:35 +00:00
|
|
|
|
2024-02-02 17:19:43 +00:00
|
|
|
// Detach first to prevent objNull in attachedObjects
|
|
|
|
detach _clone;
|
|
|
|
deleteVehicle _clone;
|
2023-07-20 17:42:35 +00:00
|
|
|
|
2024-01-14 21:36:10 +00:00
|
|
|
// Get which curators had this object as editable
|
|
|
|
if (["ace_zeus"] call EFUNC(common,isModLoaded)) then {
|
|
|
|
private _objectCurators = _target getVariable [QGVAR(objectCurators), []];
|
2024-01-09 18:37:24 +00:00
|
|
|
|
2024-01-14 21:36:10 +00:00
|
|
|
if (_objectCurators isEqualTo []) exitWith {};
|
|
|
|
|
|
|
|
[QEGVAR(zeus,addObjects), [[_target], _objectCurators]] call CBA_fnc_serverEvent;
|
|
|
|
};
|
2023-07-21 17:24:25 +00:00
|
|
|
|
|
|
|
if (_isInRemainsCollector) then {
|
|
|
|
addToRemainsCollector [_target];
|
|
|
|
};
|
2024-01-14 21:36:10 +00:00
|
|
|
} else {
|
|
|
|
// Detach first to prevent objNull in attachedObjects
|
|
|
|
detach _clone;
|
|
|
|
deleteVehicle _clone;
|
2023-07-21 17:24:25 +00:00
|
|
|
};
|
2020-10-04 20:39:52 +00:00
|
|
|
|
2023-07-20 17:42:35 +00:00
|
|
|
_target
|