2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2022-05-08 03:45:57 +00:00
|
|
|
/*
|
2023-06-19 13:31:17 +00:00
|
|
|
* Author: Grim
|
2022-05-08 03:45:57 +00:00
|
|
|
* Dragging integration. Unloader starts carrying unloaded object.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2023-11-17 23:07:28 +00:00
|
|
|
* 0: Unit doing the unloading <OBJECT>
|
|
|
|
* 1: Unloaded item <OBJECT>
|
2022-05-08 03:45:57 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2023-11-17 23:07:28 +00:00
|
|
|
* [player, cursorObject] call ace_cargo_fnc_unloadCarryItem
|
2022-05-08 03:45:57 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2022-05-08 03:45:57 +00:00
|
|
|
params ["_unloader", "_object"];
|
|
|
|
TRACE_2("unloadCarryItem-start",_unloader,_object);
|
|
|
|
|
|
|
|
if !(["ace_dragging"] call EFUNC(common,isModLoaded)) exitWith {};
|
2022-09-01 19:06:24 +00:00
|
|
|
if (!GVAR(carryAfterUnload) || {getNumber (configOf _object >> QGVAR(blockUnloadCarry)) > 0}) exitWith {};
|
2022-05-08 03:45:57 +00:00
|
|
|
|
|
|
|
// When unloading attached objects, this code will run before server has finished moving object to the safe position
|
|
|
|
[{
|
|
|
|
params ["_unloader", "_object"];
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2022-05-08 03:45:57 +00:00
|
|
|
(_unloader distance _object) < 10
|
|
|
|
}, {
|
|
|
|
params ["_unloader", "_object"];
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2022-05-08 03:45:57 +00:00
|
|
|
TRACE_2("unloadCarryItem-unloaded",_unloader,_object);
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2022-05-08 03:45:57 +00:00
|
|
|
if ([_unloader, _object] call EFUNC(dragging,canCarry)) exitWith {
|
|
|
|
[_unloader, _object] call EFUNC(dragging,startCarry);
|
|
|
|
};
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2022-05-08 03:45:57 +00:00
|
|
|
if ([_unloader, _object] call EFUNC(dragging,canDrag)) exitWith {
|
|
|
|
[_unloader, _object] call EFUNC(dragging,startDrag);
|
|
|
|
};
|
2023-11-17 23:07:28 +00:00
|
|
|
}, _this, 1, { // Delay is based on how long it will take server event to trigger and take effect
|
|
|
|
// Not a hard error if this fails, could have just unloaded to other side of vehicle because of findSafePos
|
2022-09-01 19:06:24 +00:00
|
|
|
TRACE_1("unloadCarryItem-failed to unload nearby player",_this);
|
2022-05-08 03:45:57 +00:00
|
|
|
}] call CBA_fnc_waitUntilAndExecute;
|