From 68f0232fd619b7d453d491c0648a3d77e86c7f22 Mon Sep 17 00:00:00 2001 From: "Mr. Zorn" <56258612+PulsarNeutronStar@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:11:35 +0200 Subject: [PATCH 1/3] init --- Addons/csc/$PBOPREFIX$ | 1 + Addons/csc/config.cpp | 61 ++++++++ Addons/csc/functions/fn_addCSC.sqf | 138 ++++++++++++++++++ Addons/csc/functions/fn_spawnCSC.sqf | 72 +++++++++ Addons/others/config.cpp | 8 +- .../{JND_debugv2.sqf => fn_JND_debugv2.sqf} | 0 6 files changed, 276 insertions(+), 4 deletions(-) create mode 100644 Addons/csc/$PBOPREFIX$ create mode 100644 Addons/csc/config.cpp create mode 100644 Addons/csc/functions/fn_addCSC.sqf create mode 100644 Addons/csc/functions/fn_spawnCSC.sqf rename Addons/others/{JND_debugv2.sqf => fn_JND_debugv2.sqf} (100%) diff --git a/Addons/csc/$PBOPREFIX$ b/Addons/csc/$PBOPREFIX$ new file mode 100644 index 0000000..e5ca2c6 --- /dev/null +++ b/Addons/csc/$PBOPREFIX$ @@ -0,0 +1 @@ +cvo\auxiliary\csc \ No newline at end of file diff --git a/Addons/csc/config.cpp b/Addons/csc/config.cpp new file mode 100644 index 0000000..5b9a4e6 --- /dev/null +++ b/Addons/csc/config.cpp @@ -0,0 +1,61 @@ +class CfgPatches { + + class CVO_CSC + { + // Meta information for editor + name = "CVO Custom Supply Crate"; + version = "1.0.0"; + + author[]= {"Overlord Zorn [CVO]"}; + url = "http://chronivoron.net"; + + // Minimum compatible version. When the game's version is lower, pop-up warning will appear when launching the game. + requiredVersion = 2.0; + + // Required addons, used for setting load order. + // When any of the addons is missing, pop-up warning will appear when launching the game. + requiredAddons[] = {"ace_interaction","cba_common"}; + + // Optional. If this is 1, if any of requiredAddons[] entry is missing in your game the entire config will be ignored and return no error (but in rpt) so useful to make a compat Mod (Since Arma 3 2.14) + skipWhenMissingDependencies = 1; + + // List of objects (CfgVehicles classes) contained in the addon. Important also for Zeus content (units and groups) + units[] = {}; + + // List of weapons (CfgWeapons classes) contained in the addon. + weapons[] = {}; + + }; + +}; + +class CfgFunctions +{ + class CVO_CSC // Tag + { + class CSC // Category + { + class addCSC // Function name -> Final Function will be: TAG_FN_filename + { + file = "cvo\auxiliary\CSC\functions\fn_addCSC.sqf"; + preInit = 0; // force call the function upon mission start, *before* objects areinitialized + postInit = 0; // force call the function upon mission start, *after* objects areinitialized + ext = "sqf"; // Alternative: ".fsm" + preStart = 0; // force call the function upon game start, before title screen, after all addons. + recompille = 1; // recompile the function upon mission start (Functions in editor are always compiled upon mission (re)start) + headerType = 0; // + }; + class spawnCSC // Function name -> Final Function will be: TAG_FN_filename + { + file = "cvo\auxiliary\CSC\functions\fn_spawnCSC.sqf"; + preInit = 0; // force call the function upon mission start, *before* objects areinitialized + postInit = 0; // force call the function upon mission start, *after* objects areinitialized + ext = "sqf"; // Alternative: ".fsm" + preStart = 0; // force call the function upon game start, before title screen, after all addons. + recompille = 1; // recompile the function upon mission start (Functions in editor are always compiled upon mission (re)start) + headerType = 0; // + }; + }; + }; +}; + diff --git a/Addons/csc/functions/fn_addCSC.sqf b/Addons/csc/functions/fn_addCSC.sqf new file mode 100644 index 0000000..8c9315b --- /dev/null +++ b/Addons/csc/functions/fn_addCSC.sqf @@ -0,0 +1,138 @@ +/* + * Author: Zorn + * Creates an ACE INTERACTION on the Target to request an AmmoCrate and fills it with a custom Array. + * + * Arguments: + * 0: Target supplySpawner, where the ace action should be added or + * 1: Name of the supplyCrateAction + * 2: Nested Array of content EXCEPT BACKPACKS [["class0", amount], ["classN",#]] + * 3: Class of Crate to be used + * 4: Nested Array of Content BACKPACKS Only [[class0, #], [classN,#]] + * 5: Spawn Location - ideally a invisible helipad or Tarp_01_Large_Black_F + * + * Return Value: + * None + * + * Examples: + * + * [ + * ourSupplyTruck, + * "Monkey Care Package", + * [ + * ["Ace_banana", 100], + * ["ace_maptools",100] + * ] + * ] call cvo_logistics_fnc_addCustomSupplyBoxAceActionToObject; + * + * [ + * "ACM_APD_Unimog", + * "CBRN Package", + * [ + * ["U_C_CBRN_Suit_01_Blue_F",6], + * ["G_RegulatorMask_F",6] + * ], + * "LandWoodenBox_F", + * objNull, + * [ + * ["B_SCBA_01_F",6] + * ] + * ] call cvo_logistics_fnc_addCustomSupplyBoxAceActionToObject; + * + * + * + * + * Public: yes + * + * +*/ + +params [ + ["_spawner", objNull], + ["_name", "defaultName", ["String"]], + ["_array",[]], + ["_BoxType","Land_WoodenBox_F", ["String"]], + ["_backpacks", []], + ["_spawnloc", objNull] +]; + +// ########## Creates the CSC Parent Ace Interaction Node ########## +// ### Creates an Array to store all already existing "Menu Nodes" when the Array doesnt exist yet. +if (isNil "CVO_CSC_array") then { + CVO_CSC_array = []; + diag_log ("[CVO] [LOGISTICS] (CSC) created CVO_CSC_Array."); +}; + +// ### Creates CSC Menu Node if the _spawner does not carries a CSC Menu Node yet. +if (!(_spawner in CVO_CSC_array)) then { + private _root = [ + "cvo_csc_root", // Action Name + "Take Custom Supply Crates", // Name for the ACE Interaction Menu + "\A3\ui_f\data\igui\cfg\simpleTasks\types\box_ca.paa", // Custom Icon + {}, // Statement + {true} // Condition + ] call ace_interact_menu_fnc_createAction; + + if (typeName _spawner isEqualTo "OBJECT") then { + _test = [ + _spawner, // Object the action should be assigned to + 0, // Type of action, 0 for action, 1 for self-actionIDs + ["ACE_MainActions"], // Parent path of the new action + _root + ] call ace_interact_menu_fnc_addActionToObject; + + } else { + + _test = [ + _spawner, // Class(string) the action should be assigned to + 0, // Type of action, 0 for action, 1 for self-actionIDs + ["ACE_MainActions"], // Parent path of the new action + _root + ] call ace_interact_menu_fnc_addActionToClass; + }; + + CVO_CSC_array pushBack _spawner; +}; + +// ########## Creates the individual CSC ACE Interaction ########## + +// ### Adapts Names for the Ace action +private _actionname = ("CVO_spawnbox_" + str _name); +private _actionstring = ( "" + str _name); + + +// ## Creating the ACTION itself. should be universal for OBJ and Class +private _action = [ + _actionname, // Action Name + _actionstring, // Name for the ACE Interaction Menu + "\A3\ui_f\data\igui\cfg\simpleTasks\types\box_ca.paa", // Custom Icon + {_this call cvo_CSC_fn_spawnCSC}, // Statement + {true}, // Condition + {}, + [_BoxType, _spawnloc, _name, _array, _backpacks] +] call ace_interact_menu_fnc_createAction; + + +// ## ATTACHING THE ACTION to class OR OBJECT + +if (typeName _spawner isEqualTo "OBJECT") then { + + // TO OBJECT + [ + _spawner, // Class the action should be assigned to + 0, // Type of action, 0 for action, 1 for self-actionIDs + ["ACE_MainActions","cvo_csc_root"], // Parent path of the new action + _action + ] call ace_interact_menu_fnc_addActionToObject; // Alternative: ace_interact_menu_fnc_addActionToClass + +} else { + + // TO CLASS + [ + _spawner, // Class the action should be assigned to + 0, // Type of action, 0 for action, 1 for self-actionIDs + ["ACE_MainActions","cvo_csc_root"], // Parent path of the new action + _action + ] call ace_interact_menu_fnc_addActionToClass; + +}; +diag_log format ["[CVO] [LOGISTICS] (CSC) - Successful => Carrier: %1 - CSC: %2", _spawner, _name]; \ No newline at end of file diff --git a/Addons/csc/functions/fn_spawnCSC.sqf b/Addons/csc/functions/fn_spawnCSC.sqf new file mode 100644 index 0000000..af1f0a1 --- /dev/null +++ b/Addons/csc/functions/fn_spawnCSC.sqf @@ -0,0 +1,72 @@ +/* + Author: CVO - Mr. Zorn + [Description] + Spawns the Actual crate with the required content. + + Public: No +*/ + +// Defines the Params +_parameter = _this select 2; +_parameter params["_BoxType", "_spawnloc", "_name", "_array", "_backpacks"]; + +diag_log (format ["Parameters: %1", _this]); + + +private ["_spawnPos", "_size"]; + +_spawnPos = []; +_size = _target call BIS_fnc_boundingBoxDimensions; +diag_log (format ["_target: %1 - _size = %2", _target, _size]); + + +if (_spawnloc isEqualTo "REL") then { + + _spawnPos = _target getRelPos [(_size#0 / 2) + 3 ,180]; + diag_log (format ["post getRelPos _spawnPos: %1", _spawnPos]); + +} else { + + _spawnPos = getPosATL _spawnloc; + + }; + + +diag_log (format ["pre set[2,1] _spawnPos: %1", _spawnPos]); +_spawnPos set [2,1]; +diag_log (format ["post set [2,1] _spawnPos: %1", _spawnPos]); + + +diag_log ("[CVO] [LOGISTICS] (CSC) - " + _name + " - Start"); + + +// spawn the desired box at the desired location. + +_box = createVehicle [_BoxType, _spawnPos,[],2,"CAN_COLLIDE"]; +diag_log ("[CVO] [LOGISTICS] (CSC) - " + _name + " - Box Created"); + + +// set the custom name for Ace Cargo +_box setVariable ["ace_cargo_customname", _name, true]; + + +// Empties the inventory of the Box +clearBackpackCargoGlobal _box; +clearMagazineCargoGlobal _box; +clearWeaponCargoGlobal _box; +clearItemCargoGlobal _box; +diag_log ("[CVO] [LOGISTICS] (CSC) - " + _name + " - Cleared Default Inventory"); + + +// Fills the Box with anything in the array that isnt a backpack +if (count _array > 0) then { + {_box addItemCargoGlobal [_x select 0, _x select 1];} forEach _array; +}; + +// Fills the Box with with backpacks +if (count _backpacks > 0) then { + {_box addBackpackCargoGlobal [_x select 0, _x select 1];} forEach _backpacks; +}; +diag_log ("[CVO] [LOGISTICS] (CSC) - " + _name + " - Added Custom Inventory"); + +diag_log ("[CVO] [LOGISTICS] (CSC) - " + _name + " - Spawning Complete"); diff --git a/Addons/others/config.cpp b/Addons/others/config.cpp index c8cd963..32152bf 100644 --- a/Addons/others/config.cpp +++ b/Addons/others/config.cpp @@ -37,12 +37,12 @@ class CfgFunctions { class JND_debugv2 // Function name -> Final Function will be: TAG_FNC_FunctionName { - file = "cvo\auxiliary\others\JND_debugv2.sqf"; + file = "cvo\auxiliary\others\fn_JND_debugv2.sqf"; preInit = 1; // force call the function upon mission start, *before* objects areinitialized - postInit = 0; // force call the function upon mission start, *after* objects areinitialized + postInit = 1; // force call the function upon mission start, *after* objects areinitialized ext = "sqf"; // Alternative: ".fsm" - preStart = 0; // force call the function upon game start, before title screen, after all addons. - recompille = 0; // recompile the function upon mission start (Functions in editor are always compiled upon mission (re)start) + preStart = 1; // force call the function upon game start, before title screen, after all addons. + recompille = 1; // recompile the function upon mission start (Functions in editor are always compiled upon mission (re)start) headerType = 0; // }; }; diff --git a/Addons/others/JND_debugv2.sqf b/Addons/others/fn_JND_debugv2.sqf similarity index 100% rename from Addons/others/JND_debugv2.sqf rename to Addons/others/fn_JND_debugv2.sqf From 3a6f4f5805120fad39ce0b93567c3ee255ad10b1 Mon Sep 17 00:00:00 2001 From: "Mr. Zorn" <56258612+PulsarNeutronStar@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:27:55 +0200 Subject: [PATCH 2/3] removed not used tags --- Addons/csc/config.cpp | 23 +++-------------------- Addons/others/config.cpp | 8 +------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/Addons/csc/config.cpp b/Addons/csc/config.cpp index 5b9a4e6..db167cf 100644 --- a/Addons/csc/config.cpp +++ b/Addons/csc/config.cpp @@ -35,26 +35,9 @@ class CfgFunctions { class CSC // Category { - class addCSC // Function name -> Final Function will be: TAG_FN_filename - { - file = "cvo\auxiliary\CSC\functions\fn_addCSC.sqf"; - preInit = 0; // force call the function upon mission start, *before* objects areinitialized - postInit = 0; // force call the function upon mission start, *after* objects areinitialized - ext = "sqf"; // Alternative: ".fsm" - preStart = 0; // force call the function upon game start, before title screen, after all addons. - recompille = 1; // recompile the function upon mission start (Functions in editor are always compiled upon mission (re)start) - headerType = 0; // - }; - class spawnCSC // Function name -> Final Function will be: TAG_FN_filename - { - file = "cvo\auxiliary\CSC\functions\fn_spawnCSC.sqf"; - preInit = 0; // force call the function upon mission start, *before* objects areinitialized - postInit = 0; // force call the function upon mission start, *after* objects areinitialized - ext = "sqf"; // Alternative: ".fsm" - preStart = 0; // force call the function upon game start, before title screen, after all addons. - recompille = 1; // recompile the function upon mission start (Functions in editor are always compiled upon mission (re)start) - headerType = 0; // - }; + file = "cvo\auxiliary\CSC\functions"; + class addCSC {}; + class spawnCSC {}; }; }; }; diff --git a/Addons/others/config.cpp b/Addons/others/config.cpp index 32152bf..1111293 100644 --- a/Addons/others/config.cpp +++ b/Addons/others/config.cpp @@ -38,14 +38,8 @@ class CfgFunctions class JND_debugv2 // Function name -> Final Function will be: TAG_FNC_FunctionName { file = "cvo\auxiliary\others\fn_JND_debugv2.sqf"; - preInit = 1; // force call the function upon mission start, *before* objects areinitialized postInit = 1; // force call the function upon mission start, *after* objects areinitialized - ext = "sqf"; // Alternative: ".fsm" - preStart = 1; // force call the function upon game start, before title screen, after all addons. - recompille = 1; // recompile the function upon mission start (Functions in editor are always compiled upon mission (re)start) - headerType = 0; // }; }; }; -}; - +}; \ No newline at end of file From f3e000d0919651bd959d85fea209d1a395148963 Mon Sep 17 00:00:00 2001 From: "Mr. Zorn" <56258612+PulsarNeutronStar@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:28:10 +0200 Subject: [PATCH 3/3] updated description --- Addons/csc/functions/fn_addCSC.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Addons/csc/functions/fn_addCSC.sqf b/Addons/csc/functions/fn_addCSC.sqf index 8c9315b..70852e0 100644 --- a/Addons/csc/functions/fn_addCSC.sqf +++ b/Addons/csc/functions/fn_addCSC.sqf @@ -22,7 +22,7 @@ * ["Ace_banana", 100], * ["ace_maptools",100] * ] - * ] call cvo_logistics_fnc_addCustomSupplyBoxAceActionToObject; + * ] call CVO_CSC_fnc_addCSC; * * [ * "ACM_APD_Unimog", @@ -36,7 +36,7 @@ * [ * ["B_SCBA_01_F",6] * ] - * ] call cvo_logistics_fnc_addCustomSupplyBoxAceActionToObject; + * ] call CVO_CSC_fnc_addCSC; * * *