Add: Unloading and fix full vehicle

This commit is contained in:
Vdauphin 2020-11-05 22:47:13 +01:00
parent af7a5e94a7
commit a420865b5b
2 changed files with 29 additions and 12 deletions

View File

@ -40,24 +40,32 @@ if (_item isEqualType objNull) then {
if ( if (
(_vehicle canVehicleCargo _item) isEqualTo [false, true] && // Could be loaded if _vehicle was empty (_vehicle canVehicleCargo _item) isEqualTo [false, true] && // Could be loaded if _vehicle was empty
{_vehicleCargo findIf { {_vehicleCargo findIf {
!(_x in _loaded) && !(_x in _loaded) && // Don't use ViV if ViV was used outside of ACE Cargo
!(typeOf _x isEqualTo "CargoNet_01_box_F") !(typeOf _x isEqualTo "CargoNet_01_box_F")
} isEqualTo -1} // Don't use ViV if ViV was used outside of ACE Cargo } isEqualTo -1}
) then { ) then {
private _cargoBox = createVehicle ["CargoNet_01_box_F", [0, 0, 0], [], 0, "CAN_COLLIDE"]; private _cargoNet = createVehicle ["CargoNet_01_box_F", [0, 0, 0], [], 0, "CAN_COLLIDE"];
if ((_vehicle canVehicleCargo _cargoBox) select 1) then { if ((_vehicle canVehicleCargo _cargoNet) select 1) then {
while {!(_vehicle setVehicleCargo _cargoBox)} do { // Move ViV cargo to ACE Cargo while {!(_vehicle setVehicleCargo _cargoNet)} do { // Move ViV cargo to ACE Cargo
private _itemViV = _vehicleCargo deleteAt 0; private _itemViV = _vehicleCargo deleteAt 0;
if !(objNull setVehicleCargo _itemViV) exitWith {deleteVehicle _cargoBox;}; 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;};
_itemViV attachTo [_vehicle,[0,0,-100]]; _itemViV setVariable [QGVAR(cargoNet), _cargoNet, true];
_itemViV attachTo [_vehicle, [0,0,-100]];
[QEGVAR(common,hideObjectGlobal), [_itemViV, true]] call CBA_fnc_serverEvent; [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) // 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); [_itemViV, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set);
}; };
if !(isNull _cargoNet) then {
_item setVariable [QGVAR(cargoNet), _cargoNet, true];
};
} else { } else {
deleteVehicle _cargoBox; deleteVehicle _cargoNet;
}; };
}; };
_item attachTo [_vehicle, [0,0,-100]]; _item attachTo [_vehicle, [0,0,-100]];

View File

@ -48,14 +48,23 @@ private _itemSize = [_item] call FUNC(getSizeItem);
_vehicle setVariable [QGVAR(space), (_space + _itemSize), true]; _vehicle setVariable [QGVAR(space), (_space + _itemSize), true];
if (_item isEqualType objNull) then { if (_item isEqualType objNull) then {
if (isVehicleCargo _item) then { if (isNull isVehicleCargo _item) then {
objNull setVehicleCargo _item;
_item setPosASL (AGLtoASL _emptyPosAGL);
} else {
detach _item; detach _item;
// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly // 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 // do both on server to ensure they are executed in the correct order
[QGVAR(serverUnload), [_item, _emptyPosAGL]] call CBA_fnc_serverEvent; [QGVAR(serverUnload), [_item, _emptyPosAGL]] call CBA_fnc_serverEvent;
private _cargoNet = _item getVariable [QGVAR(cargoNet), objNull];
if !(isNull _cargoNet) then {
private _itemsRemaining = _loaded select {_x getVariable [QGVAR(cargoNet), objNull] isEqualTo _cargoNet};
if (_itemsRemaining isEqualTo []) then {
objNull setVehicleCargo _cargoNet;
deleteVehicle _cargoNet;
};
};
} else {
objNull setVehicleCargo _item;
_item setPosASL (AGLtoASL _emptyPosAGL);
}; };
} else { } else {
private _newItem = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"]; private _newItem = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"];