Skip to content

Commit

Permalink
Merge pull request #1371 from Vdauphin/Add-log_copypaste_inventory
Browse files Browse the repository at this point in the history
Add: Copy and paste inventory from any boxes/vehicles to any objects with inventory
  • Loading branch information
Vdauphin authored Jun 17, 2022
2 parents aa55584 + 40fc9ca commit 1184fa0
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 9 deletions.
6 changes: 4 additions & 2 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,9 @@ if (isServer) then {
//LOG
btc_log_fnc_createVehicle = compileScript ["core\fnc\log\createVehicle.sqf"];
btc_log_fnc_init = compileScript ["core\fnc\log\init.sqf"];
btc_log_fnc_inventorySet = compileScript ["core\fnc\log\inventorySet.sqf"];
btc_log_fnc_server_delete = compileScript ["core\fnc\log\server_delete.sqf"];
btc_log_fnc_create_s = compileScript ["core\fnc\log\create_s.sqf"];
btc_log_fnc_server_repair_wreck = compileScript ["core\fnc\log\server_repair_wreck.sqf"];
btc_log_fnc_inventoryGet = compileScript ["core\fnc\log\inventoryGet.sqf"];

//DEAF
btc_deaf_fnc_earringing = compileScript ["core\fnc\deaf\earringing.sqf"];
Expand Down Expand Up @@ -270,6 +268,8 @@ btc_int_fnc_ask_var = compileScript ["core\fnc\int\ask_var.sqf"];

//LOG
btc_log_fnc_place_destroy_camera = compileScript ["core\fnc\log\place_destroy_camera.sqf"];
btc_log_fnc_inventoryGet = compileScript ["core\fnc\log\inventoryGet.sqf"];
btc_log_fnc_inventorySet = compileScript ["core\fnc\log\inventorySet.sqf"];

//MIL
btc_mil_fnc_class = compileScript ["core\fnc\mil\class.sqf"];
Expand Down Expand Up @@ -390,6 +390,8 @@ if (!isDedicated) then {
btc_log_fnc_paste = compileScript ["core\fnc\log\paste.sqf"];
btc_log_fnc_refuelSource = compileScript ["core\fnc\log\refuelSource.sqf"];
btc_log_fnc_rearmSource = compileScript ["core\fnc\log\rearmSource.sqf"];
btc_log_fnc_inventoryCopy = compileScript ["core\fnc\log\inventoryCopy.sqf"];
btc_log_fnc_inventoryPaste = compileScript ["core\fnc\log\inventoryPaste.sqf"];

//REP
btc_rep_fnc_treatment = compileScript ["core\fnc\rep\treatment.sqf"];
Expand Down
30 changes: 23 additions & 7 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/int/add_actions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ _action = ["Search_intel", localize "STR_A3_Showcase_Marksman_BIS_tskIntel_title
{
_x params ["_object", "_helipad"];

//Logistic
_action = ["Logistic", localize "STR_BTC_HAM_ACTION_LOC_MAIN", "\A3\ui_f\data\igui\cfg\simpleTasks\letters\L_ca.paa", {}, {true}] call ace_interact_menu_fnc_createAction;
[_object, 0, ["ACE_MainActions"], _action] call ace_interact_menu_fnc_addActionToObject;
_action = ["Require_object", localize "STR_BTC_HAM_ACTION_LOGPOINT_REQOBJ", "\A3\ui_f\data\igui\cfg\simpleTasks\letters\D_ca.paa", {
Expand All @@ -69,25 +70,40 @@ _action = ["Search_intel", localize "STR_A3_Showcase_Marksman_BIS_tskIntel_title
[_object, 0, ["ACE_MainActions", "Logistic"], _action] call ace_interact_menu_fnc_addActionToObject;
_action = ["Require_veh", localize "STR_BTC_HAM_ACTION_LOGPOINT_REQVEH", "\A3\ui_f\data\map\vehicleicons\iconCar_ca.paa", {
params ["", "", "_params"];
_params spawn btc_arsenal_fnc_garage}, {(serverCommandAvailable "#logout" || !isMultiplayer) and btc_p_garage}, {}, [_helipad], [0, 0, 0], 5] call ace_interact_menu_fnc_createAction;
_params spawn btc_arsenal_fnc_garage
}, {(serverCommandAvailable "#logout" || !isMultiplayer) and btc_p_garage}, {}, [_helipad], [0, 0, 0], 5] call ace_interact_menu_fnc_createAction;
[_object, 0, ["ACE_MainActions", "Logistic"], _action] call ace_interact_menu_fnc_addActionToObject;
_action = ["Require_delete", localize "STR_3DEN_Delete", "\z\ace\addons\arsenal\data\iconClearContainer.paa", {
params ["", "", "_params"];
_params call btc_log_fnc_delete
}, {true}, {}, [_helipad], [0, 0, 0.4], 5] call ace_interact_menu_fnc_createAction;
[_object, 0, ["ACE_MainActions", "Logistic"], _action] call ace_interact_menu_fnc_addActionToObject;

//Tool
_action = ["Tool", localize "str_3den_display3den_menubar_tools_text", "\A3\ui_f\data\igui\cfg\simpleTasks\letters\T_ca.paa", {}, {true}] call ace_interact_menu_fnc_createAction;
[_object, 0, ["ACE_MainActions"], _action] call ace_interact_menu_fnc_addActionToObject;
_action = ["Copy", localize "STR_BTC_HAM_ACTION_COPYPASTE_COPY", "\A3\ui_f\data\igui\cfg\simpleTasks\types\download_ca.paa", {
_action = ["Copy_container", localize "STR_BTC_HAM_ACTION_COPYPASTE_COPY", "\A3\ui_f\data\igui\cfg\simpleTasks\types\download_ca.paa", {
params ["", "", "_params"];
_params call btc_log_fnc_copy
}, {true}, {}, [_helipad], [0, 0, 0.4], 5] call ace_interact_menu_fnc_createAction;
[_object, 0, ["ACE_MainActions", "Tool"], _action] call ace_interact_menu_fnc_addActionToObject;
_action = ["Paste", localize "STR_BTC_HAM_ACTION_COPYPASTE_PASTE", "\A3\ui_f\data\igui\cfg\simpleTasks\types\upload_ca.paa", {
_action = ["Paste_container", localize "STR_BTC_HAM_ACTION_COPYPASTE_PASTE", "\A3\ui_f\data\igui\cfg\simpleTasks\types\upload_ca.paa", {
params ["", "", "_params"];
[btc_copy_container, _params] call btc_log_fnc_paste
}, {!isNil "btc_copy_container"}, {}, _helipad, [0, 0, 0.4], 5] call ace_interact_menu_fnc_createAction;
[_object, 0, ["ACE_MainActions", "Tool"], _action] call ace_interact_menu_fnc_addActionToObject;
_action = ["Require_delete", localize "STR_3DEN_Delete", "\z\ace\addons\arsenal\data\iconClearContainer.paa", {
_action = ["Copy_inventory", localize "STR_BTC_HAM_ACTION_COPYPASTE_COPYI", "\A3\ui_f\data\igui\cfg\simpleTasks\types\download_ca.paa", {
params ["", "", "_params"];
_params call btc_log_fnc_delete
_params call btc_log_fnc_inventoryCopy
}, {true}, {}, [_helipad], [0, 0, 0.4], 5] call ace_interact_menu_fnc_createAction;
[_object, 0, ["ACE_MainActions", "Logistic"], _action] call ace_interact_menu_fnc_addActionToObject;
[_object, 0, ["ACE_MainActions", "Tool"], _action] call ace_interact_menu_fnc_addActionToObject;
_action = ["Paste_inventory", localize "STR_BTC_HAM_ACTION_COPYPASTE_PASTEI", "\A3\ui_f\data\igui\cfg\simpleTasks\types\upload_ca.paa", {
params ["", "", "_params"];
[btc_copy_inventory, _params] call btc_log_fnc_inventoryPaste
}, {!isNil "btc_copy_inventory"}, {}, _helipad, [0, 0, 0.4], 5] call ace_interact_menu_fnc_createAction;
[_object, 0, ["ACE_MainActions", "Tool"], _action] call ace_interact_menu_fnc_addActionToObject;

//Bodybag
if (btc_p_respawn_ticketsAtStart isNotEqualTo -1) then {
_action = ["Bodybag", localize "STR_BTC_HAM_ACTION_LOGPOINT_BODYBAG", "\A3\Data_F_AoW\Logos\arma3_aow_logo_ca.paa", {
params ["", "", "_params"];
Expand All @@ -97,7 +113,7 @@ _action = ["Search_intel", localize "STR_A3_Showcase_Marksman_BIS_tskIntel_title
};
} forEach [[btc_create_object, btc_create_object_point]];

//Logistic
//Place
_action = ["Logistic", localize "STR_BTC_HAM_ACTION_LOC_MAIN", "\A3\ui_f\data\igui\cfg\simpleTasks\letters\L_ca.paa", {}, {true}] call ace_interact_menu_fnc_createAction;
{[_x, 0, ["ACE_MainActions"], _action] call ace_interact_menu_fnc_addActionToClass;} forEach btc_log_def_loadable;
_action = ["Place", localize "STR_ACE_Dragging_Carry", "\z\ace\addons\dragging\UI\icons\box_carry.paa", {_target call btc_log_fnc_place}, {!btc_log_placing && !(player getVariable ["ace_dragging_isCarrying", false])}] call ace_interact_menu_fnc_createAction;
Expand Down
33 changes: 33 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/log/inventoryCopy.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

/* ----------------------------------------------------------------------------
Function: btc_log_fnc_inventoryCopy
Description:
Fill me when you edit me !
Parameters:
_searchLocation - Object to search around. [Object]
Returns:
Examples:
(begin example)
_result = [] call btc_log_fnc_inventoryCopy;
(end)
Author:
Vdauphin
---------------------------------------------------------------------------- */

params [
["_searchLocation", objNull, [objNull]]
];

private _objects = nearestObjects [_searchLocation, ["AllVehicles", "ThingX"], 3];

if (_objects isEqualTo []) exitWith {(localize "STR_BTC_HAM_O_COPY_NOOBJECTS") call CBA_fnc_notify};

btc_copy_inventory = [_objects select 0] call btc_log_fnc_inventoryGet;

(localize "str_mission_completed") call CBA_fnc_notify;
39 changes: 39 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/log/inventoryPaste.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

/* ----------------------------------------------------------------------------
Function: btc_log_fnc_inventoryPaste
Description:
Fill me when you edit me !
Parameters:
_copy_container - [Array]
_searchLocation - Object to search around. [Object]
Returns:
Examples:
(begin example)
_result = [] call btc_log_fnc_inventoryPaste;
(end)
Author:
Vdauphin
---------------------------------------------------------------------------- */

params [
["_inventory", [], [[]]],
["_searchLocation", objNull, [objNull]]
];

private _objects = nearestObjects [_searchLocation, ["AllVehicles", "ThingX"], 3];

if (
isNil "_inventory" ||
{flatten _inventory isEqualTo []}
) exitWith {(localize "STR_BTC_HAM_O_PASTE_NOCOPIEDI") call CBA_fnc_notify};
if (_objects isEqualTo []) exitWith {(localize "STR_BTC_HAM_O_COPY_NOOBJECTS") call CBA_fnc_notify};

[_objects select 0, _inventory] call btc_log_fnc_inventorySet;

(localize "str_mission_completed") call CBA_fnc_notify;
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ _inventory params [
];

{
if (load _object > 1) exitWith {};
_object addMagazineCargoGlobal [_x, (_magazines select 1) select _forEachIndex];
} forEach (_magazines select 0);

{
if (load _object > 1) exitWith {};
_object addWeaponWithAttachmentsCargoGlobal [_x, 1];
} forEach _weapons;

{
if (load _object > 1) exitWith {};
private _containerType = _x select 0;
if (_containerType in _items) then {
_object addItemCargoGlobal [_containerType, 1];
Expand All @@ -60,5 +63,6 @@ _inventory params [
} forEach _everyContainer;

{
if (load _object > 1) exitWith {};
_object addItemCargoGlobal [_x, 1];
} forEach _items;
12 changes: 12 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,12 @@
<French>Coller le conteneur</French>
<Czech>Vložit kontejner</Czech>
</Key>
<Key ID="STR_BTC_HAM_ACTION_COPYPASTE_COPYI">
<Original>Copy inventory</Original>
</Key>
<Key ID="STR_BTC_HAM_ACTION_COPYPASTE_PASTEI">
<Original>Paste inventory</Original>
</Key>
</Container>
<Container name="Action(ACE): Door">
<Key ID="STR_BTC_HAM_ACTION_DOOR_BREAK">
Expand Down Expand Up @@ -2791,6 +2797,12 @@
<French>Conteneur et cargaison copiés ! Nettoyez la zone avant de faire un coller.</French>
<Czech>Kontejner a obsah zkopírovány! Vyčistěte oblast pro přidání nové.</Czech>
</Key>
<Key ID="STR_BTC_HAM_O_PASTE_NOCOPIEDI">
<Original>No copied inventory!</Original>
</Key>
<Key ID="STR_BTC_HAM_O_COPY_NOOBJECTS">
<Original>No objects around!</Original>
</Key>
</Container>
<Container name="Other: Endmission">
<Key ID="STR_BTC_HAM_O_COMMON_ENDMISSION">
Expand Down

0 comments on commit 1184fa0

Please sign in to comment.