Skip to content

Commit

Permalink
Merge pull request #2 from PulsarNeutronStar/dev-CSC
Browse files Browse the repository at this point in the history
merge custom supply crates (CSC)
  • Loading branch information
OverlordZorn authored Sep 22, 2023
2 parents 65cba62 + deadc7c commit dcb04e2
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 8 deletions.
1 change: 1 addition & 0 deletions Addons/csc/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cvo\auxiliary\csc
44 changes: 44 additions & 0 deletions Addons/csc/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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
{
file = "cvo\auxiliary\CSC\functions";
class addCSC {};
class spawnCSC {};
};
};
};

138 changes: 138 additions & 0 deletions Addons/csc/functions/fn_addCSC.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT> or <CLASS as STRING>
* 1: Name of the supplyCrateAction <string>
* 2: Nested Array of content EXCEPT BACKPACKS [["class0", amount], ["classN",#]] <Nested Array>
* 3: Class of Crate to be used <OBJECT> <Optional - Default: "LandWoodenBox_F">
* 4: Nested Array of Content BACKPACKS Only [[class0, #], [classN,#]] <Nested Array > <optional - Default: []>
* 5: Spawn Location - ideally a invisible helipad or Tarp_01_Large_Black_F <Object> <optional - default: objNull>
*
* Return Value:
* None
*
* Examples:
*
* [
* ourSupplyTruck,
* "Monkey Care Package",
* [
* ["Ace_banana", 100],
* ["ace_maptools",100]
* ]
* ] call CVO_CSC_fnc_addCSC;
*
* [
* "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_CSC_fnc_addCSC;
*
*
*
*
* 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 <Array>
_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 <Array>
_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 <Array>
_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 <Array>
_action
] call ace_interact_menu_fnc_addActionToClass;

};
diag_log format ["[CVO] [LOGISTICS] (CSC) - Successful => Carrier: %1 - CSC: %2", _spawner, _name];
72 changes: 72 additions & 0 deletions Addons/csc/functions/fn_spawnCSC.sqf
Original file line number Diff line number Diff line change
@@ -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");
10 changes: 2 additions & 8 deletions Addons/others/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@ class CfgFunctions
{
class JND_debugv2 // Function name -> Final Function will be: TAG_FNC_FunctionName
{
file = "cvo\auxiliary\others\JND_debugv2.sqf";
preInit = 0; // force call the function upon mission start, *before* objects areinitialized
file = "cvo\auxiliary\others\fn_JND_debugv2.sqf";
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)
headerType = 0; //
};
};
};
};

};
File renamed without changes.

0 comments on commit dcb04e2

Please sign in to comment.