2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-08-10 21:07:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
2015-08-16 20:41:35 +00:00
|
|
|
* Load object into vehicle.
|
2015-09-27 16:19:40 +00:00
|
|
|
* Objects loaded via classname remain virtual until unloaded.
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-09-27 16:19:40 +00:00
|
|
|
* 0: Item <OBJECT or STRING>
|
2015-08-10 21:07:47 +00:00
|
|
|
* 1: Vehicle <OBJECT>
|
2018-10-08 20:23:59 +00:00
|
|
|
* 2: Ignore interaction distance and stability checks <BOOL>
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-08-16 20:48:52 +00:00
|
|
|
* Object loaded <BOOL>
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
2015-08-16 20:41:35 +00:00
|
|
|
* Example:
|
|
|
|
* [object, vehicle] call ace_cargo_fnc_loadItem
|
|
|
|
*
|
2017-06-08 19:31:27 +00:00
|
|
|
* Public: Yes
|
2015-08-10 21:07:47 +00:00
|
|
|
*/
|
|
|
|
|
2018-06-18 20:01:09 +00:00
|
|
|
params [["_item","",[objNull,""]], ["_vehicle",objNull,[objNull]], ["_ignoreInteraction", false]];
|
2016-01-27 20:56:25 +00:00
|
|
|
TRACE_2("params",_item,_vehicle);
|
2015-08-16 20:41:35 +00:00
|
|
|
|
2018-06-18 20:01:09 +00:00
|
|
|
if !([_item, _vehicle, _ignoreInteraction] call FUNC(canLoadItemIn)) exitWith {TRACE_2("cannot load",_item,_vehicle); false};
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
2015-11-30 16:21:28 +00:00
|
|
|
_loaded pushBack _item;
|
2015-08-16 20:41:35 +00:00
|
|
|
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2015-09-20 15:05:34 +00:00
|
|
|
TRACE_1("added to loaded array",_loaded);
|
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
|
|
|
private _itemSize = [_item] call FUNC(getSizeItem);
|
2015-08-16 20:41:35 +00:00
|
|
|
_vehicle setVariable [QGVAR(space), _space - _itemSize, true];
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2015-11-20 17:40:31 +00:00
|
|
|
if (_item isEqualType objNull) then {
|
2015-09-27 16:19:40 +00:00
|
|
|
detach _item;
|
2020-11-04 12:43:35 +00:00
|
|
|
if !(_vehicle setVehicleCargo _item) then {
|
2020-11-04 21:58:52 +00:00
|
|
|
private _vehicleCargo = getVehicleCargo _vehicle;
|
|
|
|
if (
|
|
|
|
(_vehicle canVehicleCargo _item) isEqualTo [false, true] && // Could be loaded if _vehicle was empty
|
|
|
|
{_vehicleCargo findIf {
|
2020-11-05 21:47:13 +00:00
|
|
|
!(_x in _loaded) && // Don't use ViV if ViV was used outside of ACE Cargo
|
2020-11-04 21:58:52 +00:00
|
|
|
!(typeOf _x isEqualTo "CargoNet_01_box_F")
|
2020-11-05 21:47:13 +00:00
|
|
|
} isEqualTo -1}
|
2020-11-04 21:58:52 +00:00
|
|
|
) then {
|
2020-11-05 21:47:13 +00:00
|
|
|
private _cargoNet = createVehicle ["CargoNet_01_box_F", [0, 0, 0], [], 0, "CAN_COLLIDE"];
|
|
|
|
if ((_vehicle canVehicleCargo _cargoNet) select 1) then {
|
|
|
|
while {!(_vehicle setVehicleCargo _cargoNet)} do { // Move ViV cargo to ACE Cargo
|
2020-11-04 21:58:52 +00:00
|
|
|
private _itemViV = _vehicleCargo deleteAt 0;
|
2020-11-05 21:47:13 +00:00
|
|
|
if (typeOf _itemViV isEqualTo "CargoNet_01_box_F") exitWith { // The vehicle is already full of "CargoNet_01_box_F")
|
|
|
|
deleteVehicle _cargoNet;
|
|
|
|
_item setVariable [QGVAR(cargoNet), _itemViV, true];
|
|
|
|
};
|
|
|
|
if !(objNull setVehicleCargo _itemViV) exitWith {deleteVehicle _cargoNet;};
|
2020-11-04 21:58:52 +00:00
|
|
|
|
2020-11-05 21:47:13 +00:00
|
|
|
_itemViV setVariable [QGVAR(cargoNet), _cargoNet, true];
|
|
|
|
_itemViV attachTo [_vehicle, [0,0,-100]];
|
2020-11-04 21:58:52 +00:00
|
|
|
[QEGVAR(common,hideObjectGlobal), [_itemViV, true]] call CBA_fnc_serverEvent;
|
|
|
|
|
|
|
|
// Some objects below water will take damage over time and eventualy become "water logged" and unfixable (because of negative z attach)
|
|
|
|
[_itemViV, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set);
|
|
|
|
};
|
2020-11-05 21:47:13 +00:00
|
|
|
if !(isNull _cargoNet) then {
|
|
|
|
_item setVariable [QGVAR(cargoNet), _cargoNet, true];
|
|
|
|
};
|
2020-11-04 21:58:52 +00:00
|
|
|
} else {
|
2020-11-05 21:47:13 +00:00
|
|
|
deleteVehicle _cargoNet;
|
2020-11-04 21:58:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
_item attachTo [_vehicle, [0,0,-100]];
|
2020-11-04 12:43:35 +00:00
|
|
|
[QEGVAR(common,hideObjectGlobal), [_item, true]] call CBA_fnc_serverEvent;
|
2020-10-10 16:58:38 +00:00
|
|
|
|
2020-11-04 12:43:35 +00:00
|
|
|
// Some objects below water will take damage over time and eventualy become "water logged" and unfixable (because of negative z attach)
|
|
|
|
[_item, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set);
|
|
|
|
};
|
2015-09-27 16:19:40 +00:00
|
|
|
};
|
2015-08-18 16:48:21 +00:00
|
|
|
|
2015-08-16 20:48:52 +00:00
|
|
|
true
|