diff --git a/addons/cargo/functions/fnc_unload.sqf b/addons/cargo/functions/fnc_unload.sqf index a2f0c1c875..2bf7e7ec76 100644 --- a/addons/cargo/functions/fnc_unload.sqf +++ b/addons/cargo/functions/fnc_unload.sqf @@ -5,35 +5,51 @@ * * Arguments: * 0: Item - * 1: Empty position - * 2: Items loaded in cargo - * 3: Vehicle with the item loaded + * 1: Vehicle with the item loaded + * 2: Unloading position + * 3: If the object was deployed * * Return Value: * Object unloaded * * Example: - * [item, posAGL, loaded, vehicle] call ace_cargo_fnc_unload + * ["ACE_Wheel", cursorObject, getPos player, false] call ace_cargo_fnc_unload * * Public: No */ -params ["_item", "_posAGL", "_loaded", "_vehicle"]; +params ["_item", "_posAGL", "_vehicle", "_deployed"]; +// Unload item from cargo +private _loaded = _vehicle getVariable [QGVAR(loaded), []]; _loaded deleteAt (_loaded find _item); _vehicle setVariable [QGVAR(loaded), _loaded, true]; -private _space = [_vehicle] call FUNC(getCargoSpaceLeft); -private _itemSize = [_item] call FUNC(getSizeItem); -_vehicle setVariable [QGVAR(space), _space + _itemSize, true]; +// Update cargo space remaining +private _cargoSpace = _vehicle call FUNC(getCargoSpaceLeft); +_vehicle setVariable [QGVAR(space), _cargoSpace + _itemSize, true]; private _object = _item; + if (_object isEqualType objNull) then { if (isNull isVehicleCargo _object) then { detach _object; - // hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly - // do both on server to ensure they are executed in the correct order - [QGVAR(serverUnload), [_object, _posAGL]] call CBA_fnc_serverEvent; + + // If player unloads via deployment, set direction first, then unload + if (_deployed) then { + [QGVAR(setDirAndUnload), [_object, _emptyPosAGL, _direction], _object] call CBA_fnc_targetEvent; + } else { + [QGVAR(serverUnload), [_object, _emptyPosAGL]] call CBA_fnc_serverEvent; + }; + + if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { + // Get which curators had this object as editable + private _objectCurators = _object getVariable [QGVAR(objectCurators), []]; + + if (_objectCurators isEqualTo []) exitWith {}; + + [QEGVAR(zeus,addObjects), [[_object], _objectCurators]] call CBA_fnc_serverEvent; + }; private _cargoNet = _object getVariable [QGVAR(cargoNet), objNull]; if !(isNull _cargoNet) then { @@ -50,8 +66,14 @@ if (_object isEqualType objNull) then { _object setPosASL (AGLtoASL _posAGL); }; } else { - _object = createVehicle [_item, _posAGL, [], 0, "NONE"]; - _object setPosASL (AGLtoASL _posAGL); + _object = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"]; + + // If player unloads via deployment, set direction. Must happen before setPosASL command according to wiki + if (_deployed) then { + _object setDir _direction; + }; + + _object setPosASL (AGLtoASL _emptyPosAGL); [QEGVAR(common,fixCollision), _object] call CBA_fnc_localEvent; [QEGVAR(common,fixPosition), _object] call CBA_fnc_localEvent; diff --git a/addons/cargo/initSettings.inc.sqf b/addons/cargo/initSettings.inc.sqf index 4f92934d46..e319490ebd 100644 --- a/addons/cargo/initSettings.inc.sqf +++ b/addons/cargo/initSettings.inc.sqf @@ -59,3 +59,12 @@ private _category = [ELSTRING(main,Category_Logistics), LSTRING(openMenu)]; _category, true ] call CBA_fnc_addSetting; + +[ + QGVAR(cargoNetType), + "LIST", + [LSTRING(cargoNetType), LSTRING(cargoNetType_description)], + _category, + [["CargoNet_01_box_F", "Land_WoodenBox_02_F"], [LSTRING(cargoNetType_modernStyle), LSTRING(cargoNetType_ww2)], 0], + 1 +] call CBA_fnc_addSetting;