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)