Address more merge conflicts

This commit is contained in:
johnb432 2024-07-17 12:35:10 +02:00
parent 9a1b24df27
commit 7c40b13e5e
5 changed files with 59 additions and 50 deletions

View File

@ -1,37 +1,32 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Vdauphin
* Check if an item will fit in the empty space already used by loaded items.
* Checks if an item would fit in the space currently used by loaded items.
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Item <OBJECT>
* 0: Item <OBJECT>
* 1: Vehicle <OBJECT>
* 2: Items from vehicle cargo <OBJECT>
*
* Return Value:
* Will fit or not the space occupied by items <BOOL>
* Ig the item would fit or not <BOOL>
*
* Example:
* [] call ace_cargo_fnc_canItemCargo
* ["ACE_Wheel", cursorObject, []] call ace_cargo_fnc_canItemCargo
*
* Public: No
*/
params [
"_vehicle",
"_item",
["_items", [], [[]]]
];
params ["_item", "_vehicle", "_items"];
if (
_items isEqualTo [] ||
{!((_vehicle canVehicleCargo _item) select 1)}
) exitWith {false};
// If there are no items or if the item can't fit in the vehicle when empty, skip
if (_items isEqualTo [] || {!((_vehicle canVehicleCargo _item) select 1)}) exitWith {false};
private _itemSurface = [_item] call FUNC(getSurfaceItem);
private _itemSurface = _item call FUNC(getSurfaceItem);
private _itemsSurface = 0;
{
_itemsSurface = _itemsSurface + ([_item] call FUNC(getSurfaceItem));
_itemsSurface = _itemsSurface + (_item call FUNC(getSurfaceItem));
} forEach _items;
_itemSurface <= _itemsSurface

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Vdauphin
* Get surface of an item.
* Gets surface of an item.
*
* Arguments:
* 0: Object <OBJECT>
@ -10,7 +10,7 @@
* Surface in m² <NUMBER>
*
* Example:
* [player] call ace_cargo_fnc_getSurfaceItem
* cursorObject call ace_cargo_fnc_getSurfaceItem
*
* Public: No
*/

View File

@ -47,18 +47,30 @@ _vehicle setVariable [QGVAR(space), _cargoSpace - _itemSize, true];
if (_item isEqualType objNull) then {
detach _item;
// If the object couldn't be loaded as ViV, try to compact the existing ViV cargo
if !(_vehicle setVehicleCargo _item) then {
private _itemsCargo = _loaded arrayIntersect getVehicleCargo _vehicle;
private _itemsViVCargo = _loaded arrayIntersect (getVehicleCargo _vehicle);
private _cargoNet = createVehicle [GVAR(cargoNetType), [0, 0, 0], [], 0, "CAN_COLLIDE"];
if ([_vehicle, _cargoNet, _itemsCargo] call FUNC(canItemCargo)) then {
while {!(_vehicle setVehicleCargo _cargoNet)} do { // Move ViV cargo to ACE Cargo
if (_itemsCargo isEqualTo []) exitWith {deleteVehicle _cargoNet; /*Should not happen*/};
private _itemViV = _itemsCargo deleteAt 0;
if !(objNull setVehicleCargo _itemViV) exitWith {deleteVehicle _cargoNet;};
if ([_cargoNet, _vehicle, _itemsViVCargo] call FUNC(canItemCargo)) then {
// Move ViV cargo to ACE Cargo
while {!(_vehicle setVehicleCargo _cargoNet)} do {
if (_itemsViVCargo isEqualTo []) exitWith {
// Should not happen
deleteVehicle _cargoNet;
};
private _itemViV = _itemsViVCargo deleteAt 0;
// If the ViV object couldn't be unloaded, quit
if !(objNull setVehicleCargo _itemViV) exitWith {
deleteVehicle _cargoNet;
};
// If the ViV object was unloaded, store it as regular cargo
_itemViV setVariable [QGVAR(cargoNet), _cargoNet, true];
_itemViV attachTo [_vehicle, [0,0,-100]];
_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)
@ -67,7 +79,8 @@ if (_item isEqualType objNull) then {
} else {
deleteVehicle _cargoNet;
};
if !(isNull _cargoNet) then {
if (!isNull _cargoNet) then {
_cargoNet setVariable [QGVAR(isCargoNet), true, true];
_item setVariable [QGVAR(cargoNet), _cargoNet, true];
};
@ -85,7 +98,7 @@ if (_item isEqualType objNull) then {
[QEGVAR(zeus,removeObjects), [[_item], _objectCurators]] call CBA_fnc_serverEvent;
};
// Some objects below water will take damage over time, eventually becoming "water logged" and unfixable (because of negative z attach)
[_item, "blockDamage", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
};

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Glowbal, ViperMaul
* Unload object from vehicle.
@ -8,9 +8,10 @@
* 1: Vehicle with the item loaded <OBJECT>
* 2: Unloading position <ARRAY>
* 3: If the object was deployed <BOOL>
* 4: Object's direction, used when deployed <NUMBER>
*
* Return Value:
* Object unloaded <OBJECT>
* Object that was unloaded <OBJECT>
*
* Example:
* ["ACE_Wheel", cursorObject, getPos player, false] call ace_cargo_fnc_unload
@ -18,7 +19,7 @@
* Public: No
*/
params ["_item", "_posAGL", "_vehicle", "_deployed"];
params ["_item", "_vehicle", "_posAGL", "_deployed", "_direction"];
// Unload item from cargo
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
@ -27,7 +28,7 @@ _vehicle setVariable [QGVAR(loaded), _loaded, true];
// Update cargo space remaining
private _cargoSpace = _vehicle call FUNC(getCargoSpaceLeft);
_vehicle setVariable [QGVAR(space), _cargoSpace + _itemSize, true];
_vehicle setVariable [QGVAR(space), _cargoSpace + (_item call FUNC(getSizeItem)), true];
private _object = _item;
@ -37,9 +38,9 @@ if (_object isEqualType objNull) then {
// If player unloads via deployment, set direction first, then unload
if (_deployed) then {
[QGVAR(setDirAndUnload), [_object, _emptyPosAGL, _direction], _object] call CBA_fnc_targetEvent;
[QGVAR(setDirAndUnload), [_object, _posAGL, _direction], _object] call CBA_fnc_targetEvent;
} else {
[QGVAR(serverUnload), [_object, _emptyPosAGL]] call CBA_fnc_serverEvent;
[QGVAR(serverUnload), [_object, _posAGL]] call CBA_fnc_serverEvent;
};
if (["ace_zeus"] call EFUNC(common,isModLoaded)) then {
@ -52,28 +53,28 @@ if (_object isEqualType objNull) then {
};
private _cargoNet = _object 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;
};
// Delete cargo net if no items remain on it
if (
!isNull _cargoNet &&
{(_loaded findIf {_x isEqualType objNull && {_x getVariable [QGVAR(cargoNet), objNull] == _cargoNet}}) == -1}
) then {
objNull setVehicleCargo _cargoNet;
deleteVehicle _cargoNet;
};
} else {
objNull setVehicleCargo _object;
_object setPosASL (AGLtoASL _posAGL);
};
} else {
_object = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"];
_object = createVehicle [_item, _posAGL, [], 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);
_object setPosASL (AGLtoASL _posAGL);
[QEGVAR(common,fixCollision), _object] call CBA_fnc_localEvent;
[QEGVAR(common,fixPosition), _object] call CBA_fnc_localEvent;

View File

@ -8,8 +8,8 @@
* 1: Holder object (vehicle) <OBJECT> (default: objNull)
* 2: Unloader <OBJECT> (default: objNull)
* 3: Deploy parameters <ARRAY> (default: [])
* - 0: Position AGL <ARRAY>
* - 1: Direction <NUMBER>
* - 0: Position AGL <ARRAY> (default: [])
* - 1: Direction <NUMBER> (default: 0)
*
* Return Value:
* Object unloaded <BOOL>
@ -20,8 +20,8 @@
* Public: Yes
*/
params [["_item", "", [objNull, ""]], ["_vehicle", objNull, [objNull]], ["_unloader", objNull, [objNull]], ["_deploy", []]];
_deploy params ["_emptyPosAGL", "_direction"];
params [["_item", "", [objNull, ""]], ["_vehicle", objNull, [objNull]], ["_unloader", objNull, [objNull]], ["_deploy", [], [[]]]];
_deploy params [["_emptyPosAGL", [], [[]], 3], ["_direction", 0, [0]]];
TRACE_4("params",_item,_vehicle,_unloader,_deploy);
@ -68,7 +68,7 @@ if (_emptyPosAGL isEqualTo []) exitWith {
false // return
};
private _object = [_item, _vehicle, _emptyPosAGL, _deployed] call FUNC(unload);
private _object = [_item, _vehicle, _emptyPosAGL, _deployed, _direction] call FUNC(unload);
// Dragging integration
if (!_deployed) then {