From ac7e398df7377bd64e68ebcade05ec4267a3b461 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:34:14 +0200 Subject: [PATCH] Add ViV cargo - Paradrop handling is missing - See what items should be able to be loaded via ViV or not --- addons/cargo/CfgActions.hpp | 6 -- addons/cargo/XEH_PREP.hpp | 5 -- addons/cargo/XEH_postInit.sqf | 59 ++++++++------ addons/cargo/config.cpp | 1 - .../functions/fnc_addCargoVehiclesActions.sqf | 19 +++-- addons/cargo/functions/fnc_canItemCargo.sqf | 32 -------- addons/cargo/functions/fnc_canLoadItemIn.sqf | 13 +++- .../fnc_canShowUnloadAllVehicles.sqf | 26 ------- addons/cargo/functions/fnc_canUnloadItem.sqf | 8 +- addons/cargo/functions/fnc_deployConfirm.sqf | 30 ++++++-- .../cargo/functions/fnc_getSelectedItem.sqf | 8 +- addons/cargo/functions/fnc_getSurfaceItem.sqf | 26 ------- .../cargo/functions/fnc_getVehicleCargo.sqf | 22 ------ addons/cargo/functions/fnc_loadItem.sqf | 61 +++------------ addons/cargo/functions/fnc_onMenuOpen.sqf | 76 ++++++++++++++----- addons/cargo/functions/fnc_paradropItem.sqf | 2 +- addons/cargo/functions/fnc_startDeploy.sqf | 8 +- addons/cargo/functions/fnc_startLoadIn.sqf | 30 ++++++-- addons/cargo/functions/fnc_startUnload.sqf | 38 +++++++--- addons/cargo/functions/fnc_unload.sqf | 44 ++++------- .../cargo/functions/fnc_unloadAllVehicles.sqf | 26 ------- addons/cargo/initSettings.inc.sqf | 9 --- addons/cargo/menu.hpp | 8 ++ addons/cargo/stringtable.xml | 14 +--- 24 files changed, 241 insertions(+), 330 deletions(-) delete mode 100644 addons/cargo/CfgActions.hpp delete mode 100644 addons/cargo/functions/fnc_canItemCargo.sqf delete mode 100644 addons/cargo/functions/fnc_canShowUnloadAllVehicles.sqf delete mode 100644 addons/cargo/functions/fnc_getSurfaceItem.sqf delete mode 100644 addons/cargo/functions/fnc_getVehicleCargo.sqf delete mode 100644 addons/cargo/functions/fnc_unloadAllVehicles.sqf diff --git a/addons/cargo/CfgActions.hpp b/addons/cargo/CfgActions.hpp deleted file mode 100644 index 6ab5949419..0000000000 --- a/addons/cargo/CfgActions.hpp +++ /dev/null @@ -1,6 +0,0 @@ -class CfgActions { - class None; - class UnloadAllVehicles: None { - show = 0; - }; -}; diff --git a/addons/cargo/XEH_PREP.hpp b/addons/cargo/XEH_PREP.hpp index 33374668c5..4ef38e7ccf 100644 --- a/addons/cargo/XEH_PREP.hpp +++ b/addons/cargo/XEH_PREP.hpp @@ -1,8 +1,6 @@ PREP(addCargoItem); PREP(addCargoVehiclesActions); -PREP(canItemCargo); PREP(canLoadItemIn); -PREP(canShowUnloadAllVehicles); PREP(canUnloadItem); PREP(deployCancel); PREP(deployConfirm); @@ -10,8 +8,6 @@ PREP(getCargoSpaceLeft); PREP(getNameItem); PREP(getSelectedItem); PREP(getSizeItem); -PREP(getSurfaceItem); -PREP(getVehicleCargo); PREP(handleDestroyed); PREP(handleDeployInterrupt); PREP(handleScrollWheel); @@ -29,6 +25,5 @@ PREP(startDeploy); PREP(startLoadIn); PREP(startUnload); PREP(unload); -PREP(unloadAllVehicles); PREP(unloadCarryItem); PREP(unloadItem); diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 4cc48d221a..1232979239 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -86,7 +86,13 @@ GVAR(vehicleAction) = [ GVAR(enable) && {alive _target} && {locked _target < 2} && - {_target getVariable [QGVAR(hasCargo), getNumber (configOf _target >> QGVAR(hasCargo)) == 1]} && + { + private _config = configOf _target; + + // https://feedback.bistudio.com/T182949 + (vehicleCargoEnabled _target && {isClass (_config >> "VehicleTransport" >> "Carrier")}) || + {_target getVariable [QGVAR(hasCargo), getNumber (_config >> QGVAR(hasCargo)) == 1]} + } && {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && {[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} && {([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} @@ -121,6 +127,7 @@ GVAR(objectActions) = [ GVAR(enable) && {alive _target} && {locked _target < 2} && + {isNull isVehicleCargo _target} && {_target getVariable [QGVAR(canLoad), getNumber (configOf _target >> QGVAR(canLoad)) == 1]} && {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && {[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} && @@ -132,29 +139,34 @@ GVAR(objectActions) = [ {([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} }) != -1} }, - LINKFUNC(addCargoVehiclesActions) + {_target call FUNC(addCargoVehiclesActions)} + ] call EFUNC(interact_menu,createAction), + [QGVAR(loadViv), LLSTRING(loadObjectViv), "a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa", + { + //IGNORE_PRIVATE_WARNING ["_target", "_player"]; + [_player, _target, objNull, true] call FUNC(startLoadIn); + }, + { + //IGNORE_PRIVATE_WARNING ["_target", "_player"]; + GVAR(enable) && + {alive _target} && + {locked _target < 2} && + {isNull isVehicleCargo _target} && + {_target getVariable [QGVAR(canLoad), getNumber (configOf _target >> QGVAR(canLoad)) == 1]} && + {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && + {[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} && + {((nearestObjects [_target, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE + 10]) findIf { + _x != _target && + {alive _x} && + {locked _x < 2} && + {(_x canVehicleCargo _target) select 0} && + {([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} + }) != -1} + }, + {[_target, true] call FUNC(addCargoVehiclesActions)} ] call EFUNC(interact_menu,createAction) ]; -{ - [_x, "InitPost", { - params ["_vehicle"]; - - private _actionID = _vehicle addAction [ - "", - FUNC(unloadAllVehicles), - nil, - 3, - false, - true, - "", - '[_target, _this] call FUNC(canShowUnloadAllVehicles)' - ]; - _vehicle setUserActionText [_actionID, localize "STR_A3_ACTION_UNLOAD_ALL_VEHICLES", ""]; - _vehicle setVariable [QGVAR(unloadAllVehiclesAction), _actionID]; - }, nil, nil, true] call CBA_fnc_addClassEventHandler; -} forEach ["LandVehicle", "Ship", "Air"]; - // Find all remaining configured classes and init them, see XEH_preStart.sqf private _vehicleClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedVehicleClasses), {[]}]); @@ -202,10 +214,7 @@ if (isServer) then { GVAR(selectedItem) = objNull; GVAR(itemPreviewObject) = objNull; GVAR(deployPFH) = -1; -GVAR(deployDistance) = -1; -GVAR(deployDirection) = 0; -GVAR(deployHeight) = 0; -GVAR(canDeploy) = false; +GVAR(isViv) = false; if (!hasInterface) exitWith {}; diff --git a/addons/cargo/config.cpp b/addons/cargo/config.cpp index 28c539e84a..2bdb3c7e65 100644 --- a/addons/cargo/config.cpp +++ b/addons/cargo/config.cpp @@ -20,4 +20,3 @@ class CfgPatches { #include "CfgVehicles.hpp" #include "menu.hpp" #include "renameMenu.hpp" -#include "CfgActions.hpp" diff --git a/addons/cargo/functions/fnc_addCargoVehiclesActions.sqf b/addons/cargo/functions/fnc_addCargoVehiclesActions.sqf index 4aa18867d6..981b25163b 100644 --- a/addons/cargo/functions/fnc_addCargoVehiclesActions.sqf +++ b/addons/cargo/functions/fnc_addCargoVehiclesActions.sqf @@ -5,6 +5,7 @@ * * Arguments: * 0: Holder object (vehicle) + * 1: Is item to be loaded as ViV? (default: false) * * Return Value: * Child actions @@ -15,20 +16,22 @@ * Public: No */ -params ["_vehicle"]; +params ["_vehicle", ["_isViv", false]]; -private _statement = { - params ["_item", "_loader", "_vehicle"]; - - [_loader, _item, _vehicle] call FUNC(startLoadIn); -}; +private _statement = compile format [QUOTE([ARR_4(_this select 1,_this select 0,_this select 2,%1)] call FUNC(startLoadIn)), _isViv]; private _vehicles = (nearestObjects [_vehicle, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE + 10]) select { _x != _vehicle && {alive _x} && {locked _x < 2} && - {_x getVariable [QGVAR(hasCargo), getNumber (configOf _x >> QGVAR(hasCargo)) == 1]} && + { + if (_isViv) then { + (_x canVehicleCargo _vehicle) select 0 + } else { + _x getVariable [QGVAR(hasCargo), getNumber (configOf _x >> QGVAR(hasCargo)) == 1] + } + } && {([_vehicle, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} }; -[_vehicles, _statement, _vehicle] call EFUNC(interact_menu,createVehiclesActions) +[_vehicles, _statement, _vehicle] call EFUNC(interact_menu,createVehiclesActions) // return diff --git a/addons/cargo/functions/fnc_canItemCargo.sqf b/addons/cargo/functions/fnc_canItemCargo.sqf deleted file mode 100644 index c248822cc9..0000000000 --- a/addons/cargo/functions/fnc_canItemCargo.sqf +++ /dev/null @@ -1,32 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: Vdauphin - * Checks if an item would fit in the space currently used by loaded items. - * - * Arguments: - * 0: Item - * 1: Vehicle - * 2: Items from vehicle cargo - * - * Return Value: - * Ig the item would fit or not - * - * Example: - * ["ACE_Wheel", cursorObject, []] call ace_cargo_fnc_canItemCargo - * - * Public: No - */ - -params ["_item", "_vehicle", "_items"]; - -// 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 _itemsSurface = 0; - -{ - _itemsSurface = _itemsSurface + (_item call FUNC(getSurfaceItem)); -} forEach _items; - -_itemSurface <= _itemsSurface diff --git a/addons/cargo/functions/fnc_canLoadItemIn.sqf b/addons/cargo/functions/fnc_canLoadItemIn.sqf index 6a45593297..cae853f3ac 100644 --- a/addons/cargo/functions/fnc_canLoadItemIn.sqf +++ b/addons/cargo/functions/fnc_canLoadItemIn.sqf @@ -7,6 +7,7 @@ * 0: Item to be loaded or * 1: Holder object (vehicle) * 2: Ignore interaction distance and stability checks (default: false) + * 3: Is item to be loaded as ViV? (default: false) * * Return Value: * Can be loaded @@ -17,7 +18,7 @@ * Public: No */ -params ["_item", "_vehicle", ["_ignoreInteraction", false]]; +params ["_item", "_vehicle", ["_ignoreInteraction", false], ["_isViv", false]]; // Check if vehicle is stable if (!_ignoreInteraction && {speed _vehicle > 1 || {((getPos _vehicle) select 2) > 3}}) exitWith { @@ -52,6 +53,12 @@ private _validItem = if (_item isEqualType "") then { _validItem && {alive _vehicle} && {locked _vehicle < 2} && -{_vehicle getVariable [QGVAR(hasCargo), getNumber (configOf _vehicle >> QGVAR(hasCargo)) == 1]} && +{ + if (_isViv) then { + (_vehicle canVehicleCargo _item) select 0 + } else { + _vehicle getVariable [QGVAR(hasCargo), getNumber (configOf _vehicle >> QGVAR(hasCargo)) == 1] + } +} && {_itemSize >= 0} && -{_itemSize <= (_vehicle call FUNC(getCargoSpaceLeft)) max 0} +{_isViv || {_itemSize <= (_vehicle call FUNC(getCargoSpaceLeft)) max 0}} diff --git a/addons/cargo/functions/fnc_canShowUnloadAllVehicles.sqf b/addons/cargo/functions/fnc_canShowUnloadAllVehicles.sqf deleted file mode 100644 index 04f5c8dc4a..0000000000 --- a/addons/cargo/functions/fnc_canShowUnloadAllVehicles.sqf +++ /dev/null @@ -1,26 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: Vdauphin - * Checks if unload all vehicles interaction can be show. - * - * Arguments: - * 0: Vehicle - * 1: Unit - * - * Return Value: - * Can show menu - * - * Example: - * [vehicle player, player] call ace_cargo_fnc_canShowUnloadAllVehicles - * - * Public: No - */ - -params [ - "_vehicle", - ["_unit", player, [objNull]] -]; - -driver _vehicle isEqualTo _unit && -{isClass (configOf _vehicle >> "VehicleTransport" >> "Carrier")} && -{!([_vehicle] call FUNC(getVehicleCargo) isEqualTo [])} diff --git a/addons/cargo/functions/fnc_canUnloadItem.sqf b/addons/cargo/functions/fnc_canUnloadItem.sqf index 357ba78f21..c69ed73850 100644 --- a/addons/cargo/functions/fnc_canUnloadItem.sqf +++ b/addons/cargo/functions/fnc_canUnloadItem.sqf @@ -9,6 +9,7 @@ * 2: Unit doing the unloading (default: objNull) * 3: Ignore interaction distance and stability checks (default: false) * 4: Ignore finding a suitable position (default: false) + * 5: Is item loaded as ViV? (default: false) * * Return Value: * Can be unloaded @@ -19,7 +20,7 @@ * Public: No */ -params ["_item", "_vehicle", ["_unloader", objNull], ["_ignoreInteraction", false], ["_ignoreFindPosition", false]]; +params ["_item", "_vehicle", ["_unloader", objNull], ["_ignoreInteraction", false], ["_ignoreFindPosition", false], ["_isViv", false]]; TRACE_2("params",_item,_vehicle); // Get config sensitive case name @@ -27,7 +28,8 @@ if (_item isEqualType "") then { _item = _item call EFUNC(common,getConfigName); }; -if !(_item in (_vehicle getVariable [QGVAR(loaded), []])) exitWith {false}; +if (_isViv && {_vehicle != isVehicleCargo _item}) exitWith {false}; +if !(_isViv || {_item in (_vehicle getVariable [QGVAR(loaded), []])}) exitWith {false}; private _validItem = if (_item isEqualType objNull) then { alive _item @@ -38,7 +40,7 @@ private _validItem = if (_item isEqualType objNull) then { _validItem && {alive _vehicle} && {locked _vehicle < 2} && -{_vehicle getVariable [QGVAR(hasCargo), getNumber (configOf _vehicle >> QGVAR(hasCargo)) == 1]} && +{_isViv || {_vehicle getVariable [QGVAR(hasCargo), getNumber (configOf _vehicle >> QGVAR(hasCargo)) == 1]}} && {_item call FUNC(getSizeItem) >= 0} && {_ignoreInteraction || {([_unloader, _vehicle] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}} && {_ignoreFindPosition || {([_vehicle, _item, _unloader, MAX_LOAD_DISTANCE, !_ignoreInteraction] call EFUNC(common,findUnloadPosition)) isNotEqualTo []}} diff --git a/addons/cargo/functions/fnc_deployConfirm.sqf b/addons/cargo/functions/fnc_deployConfirm.sqf index 27674b0515..45854c8f9e 100644 --- a/addons/cargo/functions/fnc_deployConfirm.sqf +++ b/addons/cargo/functions/fnc_deployConfirm.sqf @@ -20,7 +20,7 @@ if (GVAR(deployPFH) == -1) exitWith {}; params ["_unit"]; // Delete placement dummy and unload real item from cargo at dummy position -if (!isNull GVAR(itemPreviewObject) && {[GVAR(selectedItem), GVAR(interactionVehicle), _unit, false, true] call FUNC(canUnloadItem)}) then { +if (!isNull GVAR(itemPreviewObject) && {[GVAR(selectedItem), GVAR(interactionVehicle), _unit, false, true, GVAR(isViv)] call FUNC(canUnloadItem)}) then { // Position is AGL for unloading event private _position = ASLToAGL getPosASL GVAR(itemPreviewObject); private _direction = getDir GVAR(itemPreviewObject); @@ -28,25 +28,43 @@ if (!isNull GVAR(itemPreviewObject) && {[GVAR(selectedItem), GVAR(interactionVeh // If unload time is 0, don't show a progress bar if (_duration <= 0) exitWith { - ["ace_unloadCargo", [GVAR(selectedItem), GVAR(interactionVehicle), _unit, [_position, _direction]]] call CBA_fnc_localEvent; + if (GVAR(isViv)) then { + objNull setVehicleCargo GVAR(selectedItem); + + GVAR(selectedItem) setDir _direction; + GVAR(selectedItem) setPosASL _position; + } else { + ["ace_unloadCargo", [GVAR(selectedItem), GVAR(interactionVehicle), _unit, [_position, _direction]]] call CBA_fnc_localEvent; + }; }; [ _duration, - [GVAR(selectedItem), GVAR(interactionVehicle), _unit, [_position, _direction]], + [GVAR(selectedItem), GVAR(interactionVehicle), _unit, [_position, _direction], GVAR(isViv)], { TRACE_1("deploy finish",_this); - ["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent; + (_this select 0) params ["_item", "", "", "_posAndDir"]; + + // Is ViV + // Don't want to pass the isViv parameter to the ace_unloadCargo EH + if ((_this select 0) deleteAt 4) then { + objNull setVehicleCargo _item; + + _item setDir (_posAndDir select 1); + _item setPosASL (AGLtoASL (_posAndDir select 0)); + } else { + ["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent; + }; }, { TRACE_1("deploy fail",_this); }, format [LLSTRING(unloadingItem), [GVAR(selectedItem), true] call FUNC(getNameItem), getText (configOf GVAR(interactionVehicle) >> "displayName")], { - (_this select 0) params ["_item", "_vehicle", "_unit"]; + (_this select 0) params ["_item", "_vehicle", "_unit", "", "_isViv"]; - [_item, _vehicle, _unit, false, true] call FUNC(canUnloadItem) // don't check for a suitable unloading position when deploying + [_item, _vehicle, _unit, false, true, _isViv] call FUNC(canUnloadItem) // Don't check for a suitable unloading position when deploying }, ["isNotSwimming"] ] call EFUNC(common,progressBar); diff --git a/addons/cargo/functions/fnc_getSelectedItem.sqf b/addons/cargo/functions/fnc_getSelectedItem.sqf index a6f9141ae1..1758d6e4bb 100644 --- a/addons/cargo/functions/fnc_getSelectedItem.sqf +++ b/addons/cargo/functions/fnc_getSelectedItem.sqf @@ -15,13 +15,19 @@ * Public: No */ +params [["_isViv", false]]; + disableSerialization; private _display = uiNamespace getVariable QGVAR(menuDisplay); if (isNil "_display") exitWith {}; -private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []]; +private _loaded = if (_isViv) then { + getVehicleCargo GVAR(interactionVehicle) +} else { + GVAR(interactionVehicle) getVariable [QGVAR(loaded), []] +}; if (_loaded isEqualTo []) exitWith {}; diff --git a/addons/cargo/functions/fnc_getSurfaceItem.sqf b/addons/cargo/functions/fnc_getSurfaceItem.sqf deleted file mode 100644 index 761157b42c..0000000000 --- a/addons/cargo/functions/fnc_getSurfaceItem.sqf +++ /dev/null @@ -1,26 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: Vdauphin - * Gets surface of an item. - * - * Arguments: - * 0: Object - * - * Return Value: - * Surface in m² - * - * Example: - * cursorObject 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 diff --git a/addons/cargo/functions/fnc_getVehicleCargo.sqf b/addons/cargo/functions/fnc_getVehicleCargo.sqf deleted file mode 100644 index c71375b074..0000000000 --- a/addons/cargo/functions/fnc_getVehicleCargo.sqf +++ /dev/null @@ -1,22 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: Vdauphin - * Get vehicle in cargo. - * - * Arguments: - * 0: Vehicle - * - * Return Value: - * Loaded vehicles not part of ACE Cargo - * - * Example: - * [vehicle player] call ace_cargo_fnc_getVehicleCargo - * - * Public: No - */ - -params ["_vehicle"]; - -(getVehicleCargo _vehicle - (_vehicle getVariable [QGVAR(loaded), []])) select { - !(_x getVariable [QGVAR(isCargoNet), false]) -} diff --git a/addons/cargo/functions/fnc_loadItem.sqf b/addons/cargo/functions/fnc_loadItem.sqf index 2930075d2a..619763b8b0 100644 --- a/addons/cargo/functions/fnc_loadItem.sqf +++ b/addons/cargo/functions/fnc_loadItem.sqf @@ -47,61 +47,22 @@ _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 _itemsViVCargo = _loaded arrayIntersect (getVehicleCargo _vehicle); - private _cargoNet = createVehicle [GVAR(cargoNetType), [0, 0, 0], [], 0, "CAN_COLLIDE"]; + _item attachTo [_vehicle, [0, 0, -100]]; + [QEGVAR(common,hideObjectGlobal), [_item, true]] call CBA_fnc_serverEvent; - 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; - }; + if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { + private _objectCurators = objectCurators _item; - private _itemViV = _itemsViVCargo deleteAt 0; + // Save which curators had this object as editable + _item setVariable [QGVAR(objectCurators), _objectCurators, true]; - // If the ViV object couldn't be unloaded, quit - if !(objNull setVehicleCargo _itemViV) exitWith { - deleteVehicle _cargoNet; - }; + if (_objectCurators isEqualTo []) exitWith {}; - // If the ViV object was unloaded, store it as regular cargo - _itemViV setVariable [QGVAR(cargoNet), _cargoNet, true]; - _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, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set); - }; - } 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]]; - [QEGVAR(common,hideObjectGlobal), [_item, true]] call CBA_fnc_serverEvent; - - if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { - private _objectCurators = objectCurators _item; - - // Save which curators had this object as editable - _item setVariable [QGVAR(objectCurators), _objectCurators, true]; - - if (_objectCurators isEqualTo []) exitWith {}; - - [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); + [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); }; // Invoke listenable event diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf index f99999aabf..4c093a8e58 100644 --- a/addons/cargo/functions/fnc_onMenuOpen.sqf +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -25,11 +25,25 @@ if (GVAR(interactionParadrop)) then { (_display displayCtrl 12) ctrlSetText LLSTRING(paradropButton); }; +// https://feedback.bistudio.com/T182949 +private _config = configOf GVAR(interactionVehicle); +private _isVivCapable = isClass (_config >> "VehicleTransport" >> "Carrier"); + +// Make sure that correct menu is displayed at start, if there are limitations +if !(GVAR(interactionVehicle) getVariable [QGVAR(hasCargo), getNumber (_config >> QGVAR(hasCargo)) == 1]) then { + GVAR(isViv) = true; +} else { + if !(_isVivCapable && {vehicleCargoEnabled GVAR(interactionVehicle)}) then { + GVAR(isViv) = false; + }; +}; + // Disable deploy option if paradropping or in Zeus (_display displayCtrl 13) ctrlEnable (GVAR(enableDeploy) && !GVAR(interactionParadrop) && {isNull curatorCamera}); [{ - params ["_vehicle", "_pfhID"]; + params ["_args", "_pfhID"]; + _args params ["_vehicle", "_isVivCapable"]; disableSerialization; @@ -46,7 +60,15 @@ if (GVAR(interactionParadrop)) then { !alive ACE_player || {!alive _vehicle} || {locked _vehicle >= 2} || - {!(_vehicle getVariable [QGVAR(hasCargo), true])} || // if the cargo menu could be opened, the vehicle has QGVAR(hasCargo) in its config or the variable is set using FUNC(setSpace) + { + // If the cargo menu could be opened, the vehicle has QGVAR(hasCargo) in its config or the variable is set using FUNC(setSpace) + // or ViV was enabled via config + if (GVAR(isViv)) then { + !vehicleCargoEnabled _vehicle + } else { + !(_vehicle getVariable [QGVAR(hasCargo), true]) + }; + } || { isNull curatorCamera && // if in Zeus, ignore the checks that follow {([ACE_player, _vehicle] call EFUNC(interaction,getInteractionDistance)) >= MAX_LOAD_DISTANCE} && @@ -60,27 +82,39 @@ if (GVAR(interactionParadrop)) then { _pfhID call CBA_fnc_removePerFrameHandler; }; + // Set ViV on button + (_display displayCtrl 14) ctrlSetText localize ([LSTRING(vehicleInVehicle), LSTRING(openMenu)] select (GVAR(isViv))); + + // Don't allow switching to other menu if vehicle doesn't have capability for other menu + if (GVAR(isViv)) then { + (_display displayCtrl 14) ctrlEnable (_vehicle getVariable [QGVAR(hasCargo), true]); + } else { + (_display displayCtrl 14) ctrlEnable (_isVivCapable && {vehicleCargoEnabled _vehicle}); + }; + private _ctrl = _display displayCtrl 100; private _label = _display displayCtrl 2; // Remove previous entries lbClear _ctrl; - // Display item names - private _displayName = ""; - private _itemSize = 0; - private _index = -1; - private _damageStr = "0%"; - private _damage = 0; + private _loaded = if (GVAR(isViv)) then { + getVehicleCargo _vehicle + } else { + _vehicle getVariable [QGVAR(loaded), []] + }; + private _maxMass = getNumber (configOf _vehicle >> "VehicleTransport" >> "Carrier" >> "maxLoadMass"); + + // Display item names { - _displayName = [_x, true] call FUNC(getNameItem); - _itemSize = _x call FUNC(getSizeItem); - _damage = if (_x isEqualType "") then {0} else {damage _x}; - _damageStr = ((_damage * 100) toFixed 0) + "%"; + private _displayName = [_x, true] call FUNC(getNameItem); + private _itemSize = _x call FUNC(getSizeItem); + private _damage = if (_x isEqualType "") then {0} else {damage _x}; + private _damageStr = ((_damage * 100) toFixed 0) + "%"; if (_itemSize >= 0) then { - _index = if (GVAR(interactionParadrop)) then { + private _index = if (GVAR(interactionParadrop)) then { _ctrl lbAdd format ["%1. %2 (%3s)", _forEachIndex + 1, _displayName, GVAR(paradropTimeCoefficent) * _itemSize] } else { _ctrl lbAdd format ["%1. %2", _forEachIndex + 1, _displayName] @@ -90,13 +124,21 @@ if (GVAR(interactionParadrop)) then { _ctrl lbSetTooltip [_index, _tooltip]; } else { // If item has a size < 0, it means it's not loadable - _index = _ctrl lbAdd _displayName; + private _index = _ctrl lbAdd _displayName; _ctrl lbSetTooltip [_index, LLSTRING(unloadingImpossible)]; _ctrl lbSetColor [_index, [1, 0, 0, 1]]; // set text to red _ctrl lbSetSelectColor [_index, [1, 0, 0, 1]]; }; - } forEach (_vehicle getVariable [QGVAR(loaded), []]); - _label ctrlSetText format [LLSTRING(labelSpace), (_vehicle call FUNC(getCargoSpaceLeft)) max 0]; -}, 0, GVAR(interactionVehicle)] call CBA_fnc_addPerFrameHandler; + if (GVAR(isViv)) then { + _maxMass = _maxMass - getMass _x; + }; + } forEach _loaded; + + if (GVAR(isViv)) then { + _label ctrlSetText format [LLSTRING(labelSpace), _maxMass max 0]; + } else { + _label ctrlSetText format [LLSTRING(labelSpace), (_vehicle call FUNC(getCargoSpaceLeft)) max 0]; + }; +}, 0, [GVAR(interactionVehicle), _isVivCapable]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/cargo/functions/fnc_paradropItem.sqf b/addons/cargo/functions/fnc_paradropItem.sqf index 5107bc0c57..00e714d7cd 100644 --- a/addons/cargo/functions/fnc_paradropItem.sqf +++ b/addons/cargo/functions/fnc_paradropItem.sqf @@ -68,7 +68,7 @@ private _object = [_item, _vehicle, _posBehindVehicleAGL, false] call FUNC(unloa // Prevent collision damage [QEGVAR(common,fixCollision), _parachute] call CBA_fnc_localEvent; - [QEGVAR(common,fixCollision), _object] call CBA_fnc_localEvent; + [QEGVAR(common,fixCollision), _object, _object] call CBA_fnc_targetEvent; // Cannot use setPos on parachutes without them closing down _parachute attachTo [_object, [0, 0, 0]]; diff --git a/addons/cargo/functions/fnc_startDeploy.sqf b/addons/cargo/functions/fnc_startDeploy.sqf index 185f71c712..b99e468787 100644 --- a/addons/cargo/functions/fnc_startDeploy.sqf +++ b/addons/cargo/functions/fnc_startDeploy.sqf @@ -24,7 +24,7 @@ params ["_unit"]; if (_unit getVariable [QGVAR(isDeploying), false]) exitWith {}; // This can be an object or a classname string -private _item = call FUNC(getSelectedItem); +private _item = GVAR(isViv) call FUNC(getSelectedItem); if (isNil "_item") exitWith {}; @@ -64,15 +64,15 @@ _itemPreviewObject attachTo [_unit, [0, 1.5 * _itemPreviewObjectRadius, _offset] // PFH that runs while the deployment is in progress GVAR(deployPFH) = [{ - (_this select 0) params ["_unit", "_vehicle", "_item", "_itemPreviewObject"]; + (_this select 0) params ["_unit", "_vehicle", "_item", "_itemPreviewObject", "_isViv"]; if !( !isNull _itemPreviewObject && - {[_item, _vehicle, _unit, false, true] call FUNC(canUnloadItem)} // don't check for a suitable unloading position when deploying + {[_item, _vehicle, _unit, false, true, _isViv] call FUNC(canUnloadItem)} // Don't check for a suitable unloading position when deploying ) exitWith { _unit call FUNC(deployCancel); }; -}, 0.5, [_unit, GVAR(interactionVehicle), _item, _itemPreviewObject]] call CBA_fnc_addPerFrameHandler; +}, 0.5, [_unit, GVAR(interactionVehicle), _item, _itemPreviewObject, GVAR(isViv)]] call CBA_fnc_addPerFrameHandler; // Add mouse button action and hint [LLSTRING(unloadObject), localize "STR_DISP_CANCEL", LLSTRING(scrollAction)] call EFUNC(interaction,showMouseHint); diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index 7212d89c22..cacc1ca44c 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -7,6 +7,7 @@ * 0: Unit doing the loading * 1: Item to be loaded * 2: Holder object (vehicle) (default: objNull) + * 3: Is item to be loaded as ViV? (default: false) * * Return Value: * Load ProgressBar Started @@ -17,12 +18,12 @@ * Public: No */ -params ["_loader", "_item", ["_vehicle", objNull]]; +params ["_loader", "_item", ["_vehicle", objNull], ["_isViv", false]]; TRACE_3("params",_loader,_item,_vehicle); if (isNull _vehicle) then { { - if ([_item, _x] call FUNC(canLoadItemIn)) exitWith { + if ([_item, _x, false, _isViv] call FUNC(canLoadItemIn)) exitWith { _vehicle = _x; }; } forEach (nearestObjects [_loader, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE + 10]); @@ -35,12 +36,16 @@ if (isNull _vehicle) exitWith { }; // Start progress bar -if ([_item, _vehicle] call FUNC(canLoadItemIn)) then { +if ([_item, _vehicle, false, _isViv] call FUNC(canLoadItemIn)) then { private _duration = GVAR(loadTimeCoefficient) * (_item call FUNC(getSizeItem)); // If load time is 0, don't show a progress bar if (_duration <= 0) exitWith { - ["ace_loadCargo", [_item, _vehicle]] call CBA_fnc_localEvent; + if (_isViv) then { + _vehicle setVehicleCargo _item; + } else { + ["ace_loadCargo", [_item, _vehicle]] call CBA_fnc_localEvent; + }; true // return }; @@ -50,13 +55,20 @@ if ([_item, _vehicle] call FUNC(canLoadItemIn)) then { [ _duration, - [_item, _vehicle], + [_item, _vehicle, _isViv], { TRACE_1("load finish",_this); + (_this select 0) params ["_item", "_vehicle"]; - [objNull, _this select 0 select 0, true] call EFUNC(common,claim); + [objNull, _item, true] call EFUNC(common,claim); - ["ace_loadCargo", _this select 0] call CBA_fnc_localEvent; + // Is ViV + // Don't want to pass the isViv parameter to the ace_unloadCargo EH + if ((_this select 0) deleteAt 2) then { + _vehicle setVehicleCargo _item; + } else { + ["ace_loadCargo", _this select 0] call CBA_fnc_localEvent; + }; }, { TRACE_1("load fail",_this); @@ -80,7 +92,9 @@ if ([_item, _vehicle] call FUNC(canLoadItemIn)) then { }, format [LLSTRING(loadingItem), [_item, true] call FUNC(getNameItem), getText (configOf _vehicle >> "displayName")], { - (_this select 0) call FUNC(canLoadItemIn) + (_this select 0) params ["_item", "_vehicle", "_isViv"]; + + [_item, _vehicle, false, _isViv] call FUNC(canLoadItemIn) }, ["isNotSwimming"] ] call EFUNC(common,progressBar); diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index 39dbf59f48..df7c6d2c96 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -15,13 +15,13 @@ * Public: No */ +params ["_unit"]; + // This can be an object or a classname string -private _item = call FUNC(getSelectedItem); +private _item = GVAR(isViv) call FUNC(getSelectedItem); if (isNil "_item") exitWith {}; -params ["_unit"]; - if (GVAR(interactionParadrop)) exitWith { // Close the cargo menu closeDialog 0; @@ -66,18 +66,24 @@ if (GVAR(interactionParadrop)) exitWith { // If in zeus if (!isNull curatorCamera) exitWith { // Do not check distance to unit, but do check for valid position - if !([_item, GVAR(interactionVehicle), objNull, true] call FUNC(canUnloadItem)) exitWith { + // If ViV, ignore position, as engine will find one + if !([_item, GVAR(interactionVehicle), objNull, true, GVAR(isViv), GVAR(isViv)] call FUNC(canUnloadItem)) exitWith { [[LSTRING(unloadingFailed), [_item, true] call FUNC(getNameItem)], 3] call EFUNC(common,displayTextStructured); }; // Close the cargo menu closeDialog 1; - ["ace_unloadCargo", [_item, GVAR(interactionVehicle)]] call CBA_fnc_localEvent; + if (GVAR(isViv)) then { + objNull setVehicleCargo _item; + } else { + ["ace_unloadCargo", [_item, GVAR(interactionVehicle)]] call CBA_fnc_localEvent; + }; }; // Start progress bar - normal ground unload -if ([_item, GVAR(interactionVehicle), _unit] call FUNC(canUnloadItem)) then { +// If ViV, ignore position, as engine will find one +if ([_item, GVAR(interactionVehicle), _unit, false, GVAR(isViv), GVAR(isViv)] call FUNC(canUnloadItem)) then { // Close the cargo menu closeDialog 0; @@ -85,25 +91,35 @@ if ([_item, GVAR(interactionVehicle), _unit] call FUNC(canUnloadItem)) then { // If unload time is 0, don't show a progress bar if (_duration <= 0) exitWith { - ["ace_unloadCargo", [_item, GVAR(interactionVehicle), _unit]] call CBA_fnc_localEvent; + if (GVAR(isViv)) then { + objNull setVehicleCargo _item; + } else { + ["ace_unloadCargo", [_item, GVAR(interactionVehicle), _unit]] call CBA_fnc_localEvent; + }; }; [ _duration, - [_item, GVAR(interactionVehicle), _unit], + [_item, GVAR(interactionVehicle), _unit, GVAR(isViv)], { TRACE_1("unload finish",_this); - ["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent; + // Is ViV + // Don't want to pass the isViv parameter to the ace_unloadCargo EH + if ((_this select 0) deleteAt 3) then { + objNull setVehicleCargo (_this select 0 select 0); + } else { + ["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent; + }; }, { TRACE_1("unload fail",_this); }, format [LLSTRING(unloadingItem), [_item, true] call FUNC(getNameItem), getText (configOf GVAR(interactionVehicle) >> "displayName")], { - (_this select 0) params ["_item", "_vehicle", "_unit"]; + (_this select 0) params ["_item", "_vehicle", "_unit", "_isViv"]; - [_item, _vehicle, _unit, false, true] call FUNC(canUnloadItem) // don't check for a suitable unloading position every frame + [_item, _vehicle, _unit, false, true, _isViv] call FUNC(canUnloadItem) // Don't check for a suitable unloading position every frame }, ["isNotSwimming"] ] call EFUNC(common,progressBar); diff --git a/addons/cargo/functions/fnc_unload.sqf b/addons/cargo/functions/fnc_unload.sqf index 71b48df23f..b019af4400 100644 --- a/addons/cargo/functions/fnc_unload.sqf +++ b/addons/cargo/functions/fnc_unload.sqf @@ -33,38 +33,22 @@ _vehicle setVariable [QGVAR(space), _cargoSpace + (_item call FUNC(getSizeItem)) private _object = _item; if (_object isEqualType objNull) then { - if (isNull isVehicleCargo _object) then { - detach _object; + detach _object; - // If player unloads via deployment, set direction first, then unload - if (_deployed) then { - [QGVAR(setDirAndUnload), [_object, _posAGL, _direction], _object] call CBA_fnc_targetEvent; - } else { - [QGVAR(serverUnload), [_object, _posAGL]] 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]; - - // 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; - }; + // If player unloads via deployment, set direction first, then unload + if (_deployed) then { + [QGVAR(setDirAndUnload), [_object, _posAGL, _direction], _object] call CBA_fnc_targetEvent; } else { - objNull setVehicleCargo _object; - _object setPosASL (AGLtoASL _posAGL); + [QGVAR(serverUnload), [_object, _posAGL]] 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; }; } else { _object = createVehicle [_item, _posAGL, [], 0, "NONE"]; diff --git a/addons/cargo/functions/fnc_unloadAllVehicles.sqf b/addons/cargo/functions/fnc_unloadAllVehicles.sqf deleted file mode 100644 index 7edaa3083d..0000000000 --- a/addons/cargo/functions/fnc_unloadAllVehicles.sqf +++ /dev/null @@ -1,26 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: Vdauphin - * Unload all vehicles but not ACE Cargo. - * - * Arguments: - * 0: Vehicle - * - * Return Value: - * Loaded vehicles not part of ACE Cargo - * - * Example: - * [vehicle player] call ace_cargo_fnc_unloadAllVehicles - * - * Public: No - */ - -params ["_vehicle"]; - -private _loadedVehicles = [_vehicle] call FUNC(getVehicleCargo); -private _unloadingInterval = getNumber (configOf _vehicle >> "VehicleTransport" >> "Carrier" >> "unloadingInterval"); -{ - [{objnull setVehicleCargo _this}, _x, _forEachIndex * _unloadingInterval] call CBA_fnc_waitAndExecute; -} forEach _loadedVehicles; - -_loadedVehicles diff --git a/addons/cargo/initSettings.inc.sqf b/addons/cargo/initSettings.inc.sqf index e319490ebd..4f92934d46 100644 --- a/addons/cargo/initSettings.inc.sqf +++ b/addons/cargo/initSettings.inc.sqf @@ -59,12 +59,3 @@ 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; diff --git a/addons/cargo/menu.hpp b/addons/cargo/menu.hpp index 1811369d7d..2dfb07b699 100644 --- a/addons/cargo/menu.hpp +++ b/addons/cargo/menu.hpp @@ -5,6 +5,7 @@ class GVAR(menu) { movingEnable = 1; onLoad = QUOTE([_this select 0] call FUNC(onMenuOpen)); onUnload = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(menuDisplay),nil)]); + class controlsBackground { class HeaderBackground: ACE_gui_backgroundBase { idc = -1; @@ -106,5 +107,12 @@ class GVAR(menu) { action = QUOTE(ACE_player call FUNC(startDeploy)); colorDisabled[] = {0.25, 0.25, 0.25, 1}; }; + class btnViv: btnCancel { + text = CSTRING(vehicleInVehicle); + idc = 14; + y = "15.2 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; + action = QUOTE(GVAR(isViv) = !GVAR(isViv)); + colorDisabled[] = {0.25, 0.25, 0.25, 1}; + }; }; }; diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index fa831e451a..d1cdad6df2 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -603,17 +603,11 @@ Steuert, ob Frachtgegenstände über die Aufbaumethode entladen werden können. Controla si los objetos de la carga pueden ser descargados mediante el método de despliegue. - - Type of cargo + + ViV - - Choose which cargo type will fit the period of history you are playing. - - - Modern style - - - World War 2 + + Load to ViV