mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Make the item load throught ACE ViV working with vehicle already loaded with BI system
This commit is contained in:
parent
d8118ac3aa
commit
ba3726c697
@ -1,10 +1,12 @@
|
|||||||
PREP(addCargoItem);
|
PREP(addCargoItem);
|
||||||
PREP(addCargoVehiclesActions);
|
PREP(addCargoVehiclesActions);
|
||||||
|
PREP(canItemCargo);
|
||||||
PREP(canLoadItemIn);
|
PREP(canLoadItemIn);
|
||||||
PREP(canShowUnloadAllVehicles);
|
PREP(canShowUnloadAllVehicles);
|
||||||
PREP(canUnloadItem);
|
PREP(canUnloadItem);
|
||||||
PREP(getCargoSpaceLeft);
|
PREP(getCargoSpaceLeft);
|
||||||
PREP(getSizeItem);
|
PREP(getSizeItem);
|
||||||
|
PREP(getSurfaceItem);
|
||||||
PREP(getVehicleCargo);
|
PREP(getVehicleCargo);
|
||||||
PREP(handleDeleted);
|
PREP(handleDeleted);
|
||||||
PREP(handleDestroyed);
|
PREP(handleDestroyed);
|
||||||
|
37
addons/cargo/functions/fnc_canItemCargo.sqf
Normal file
37
addons/cargo/functions/fnc_canItemCargo.sqf
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: Vdauphin
|
||||||
|
* Check if an item will fit in the empty space already used by loaded items.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Vehicle <OBJECT>
|
||||||
|
* 1: Item <OBJECT>
|
||||||
|
* 2: Items from vehicle cargo <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Will fit or not the space occupied by items <BOOL>
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [] call ace_cargo_fnc_canItemCargo
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params [
|
||||||
|
"_vehicle",
|
||||||
|
"_item",
|
||||||
|
["_items", [], [[]]]
|
||||||
|
];
|
||||||
|
|
||||||
|
if (
|
||||||
|
_items isEqualTo [] ||
|
||||||
|
{!((_vehicle canVehicleCargo _item) select 1)}
|
||||||
|
) exitWith {false};
|
||||||
|
|
||||||
|
private _itemSurface = [_item] call FUNC(getSurfaceItem);
|
||||||
|
private _itemsSurface = 0;
|
||||||
|
{
|
||||||
|
_itemsSurface = _itemsSurface + ([_item] call FUNC(getSurfaceItem));
|
||||||
|
} forEach _items;
|
||||||
|
|
||||||
|
_itemSurface <= _itemsSurface
|
26
addons/cargo/functions/fnc_getSurfaceItem.sqf
Normal file
26
addons/cargo/functions/fnc_getSurfaceItem.sqf
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: Vdauphin
|
||||||
|
* Get surface of an item.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Object <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Surface in m² <NUMBER>
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [player] call ace_cargo_fnc_getSurfaceItem
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_object"];
|
||||||
|
|
||||||
|
private _bbr = 0 boundingBoxReal _object;
|
||||||
|
private _p1 = _bbr select 0;
|
||||||
|
private _p2 = _bbr select 1;
|
||||||
|
private _width = abs ((_p2 select 0) - (_p1 select 0));
|
||||||
|
private _length = abs ((_p2 select 1) - (_p1 select 1));
|
||||||
|
|
||||||
|
_width * _length
|
@ -18,5 +18,5 @@
|
|||||||
params ["_vehicle"];
|
params ["_vehicle"];
|
||||||
|
|
||||||
(getVehicleCargo _vehicle - (_vehicle getVariable [QGVAR(loaded), []])) select {
|
(getVehicleCargo _vehicle - (_vehicle getVariable [QGVAR(loaded), []])) select {
|
||||||
!(_x getVariable [QGVAR(isCargoNet), false])
|
!(_x getVariable [QGVAR(isCargoNet), false])
|
||||||
}
|
}
|
||||||
|
@ -36,39 +36,30 @@ _vehicle setVariable [QGVAR(space), _space - _itemSize, true];
|
|||||||
if (_item isEqualType objNull) then {
|
if (_item isEqualType objNull) then {
|
||||||
detach _item;
|
detach _item;
|
||||||
if !(_vehicle setVehicleCargo _item) then {
|
if !(_vehicle setVehicleCargo _item) then {
|
||||||
private _vehicleCargo = getVehicleCargo _vehicle;
|
private _itemsCargo = _loaded arrayIntersect getVehicleCargo _vehicle;
|
||||||
if (
|
private _cargoNet = createVehicle ["CargoNet_01_box_F", [0, 0, 0], [], 0, "CAN_COLLIDE"];
|
||||||
(_vehicle canVehicleCargo _item) isEqualTo [false, true] && // Could be loaded if _vehicle was empty
|
if ([_vehicle, _cargoNet, _itemsCargo] call FUNC(canItemCargo)) then {
|
||||||
{_vehicleCargo findIf {
|
while {!(_vehicle setVehicleCargo _cargoNet)} do { // Move ViV cargo to ACE Cargo
|
||||||
!(_x in _loaded) && // Don't use ViV if ViV was used outside of ACE Cargo
|
if (_itemsCargo isEqualTo []) exitWith {deleteVehicle _cargoNet; /*Should not happen*/};
|
||||||
!(_x getVariable [QGVAR(isCargoNet), false])
|
private _itemViV = _itemsCargo deleteAt 0;
|
||||||
} isEqualTo -1}
|
|
||||||
) then {
|
|
||||||
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
|
|
||||||
private _itemViV = _vehicleCargo deleteAt 0;
|
|
||||||
if (_itemViV getVariable [QGVAR(isCargoNet), false]) exitWith { // The vehicle is already full of cargo net
|
|
||||||
deleteVehicle _cargoNet;
|
|
||||||
_item setVariable [QGVAR(cargoNet), _itemViV, true];
|
|
||||||
};
|
|
||||||
if !(objNull setVehicleCargo _itemViV) exitWith {deleteVehicle _cargoNet;};
|
|
||||||
|
|
||||||
_itemViV setVariable [QGVAR(cargoNet), _cargoNet, true];
|
if !(objNull setVehicleCargo _itemViV) exitWith {deleteVehicle _cargoNet;};
|
||||||
_itemViV attachTo [_vehicle, [0,0,-100]];
|
|
||||||
[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 setVariable [QGVAR(cargoNet), _cargoNet, true];
|
||||||
[_itemViV, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set);
|
_itemViV attachTo [_vehicle, [0,0,-100]];
|
||||||
};
|
[QEGVAR(common,hideObjectGlobal), [_itemViV, true]] call CBA_fnc_serverEvent;
|
||||||
if !(isNull _cargoNet) then {
|
|
||||||
_cargoNet setVariable [QGVAR(isCargoNet), true, true];
|
// Some objects below water will take damage over time and eventualy become "water logged" and unfixable (because of negative z attach)
|
||||||
_item setVariable [QGVAR(cargoNet), _cargoNet, true];
|
[_itemViV, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set);
|
||||||
};
|
|
||||||
} else {
|
|
||||||
deleteVehicle _cargoNet;
|
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
deleteVehicle _cargoNet;
|
||||||
};
|
};
|
||||||
|
if !(isNull _cargoNet) then {
|
||||||
|
_cargoNet setVariable [QGVAR(isCargoNet), true, true];
|
||||||
|
_item setVariable [QGVAR(cargoNet), _cargoNet, true];
|
||||||
|
};
|
||||||
|
|
||||||
_item attachTo [_vehicle, [0,0,-100]];
|
_item attachTo [_vehicle, [0,0,-100]];
|
||||||
[QEGVAR(common,hideObjectGlobal), [_item, true]] call CBA_fnc_serverEvent;
|
[QEGVAR(common,hideObjectGlobal), [_item, true]] call CBA_fnc_serverEvent;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user