From 7ef48ecaa2786424eb74b16fc37f01977677f5b9 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 3 Feb 2024 18:40:18 -0800 Subject: [PATCH] move to cfg, update createbox, create /defines --- defines/ApprovedAssets.hpp | 22 ++ .../definitions => defines}/BattalionInfo.hpp | 0 .../DisallowedEquipment.hpp | 0 defines/SupplyCrates.hpp | 180 ++++++++++++++++ description.ext | 7 +- functions/CfgFunctions.hpp | 25 ++- functions/client/fn_addZenModules.sqf | 34 +-- functions/definitions/ApprovedAssets.hpp | 22 -- functions/init/fn_initPlayerLocal.sqf | 3 - functions/init/fn_initServer.sqf | 3 - functions/resupply/fn_crateDefinitions.sqf | 201 ------------------ functions/resupply/fn_createBox.sqf | 132 +++++++++--- functions/resupply/fn_getSupplyCratesCfg.sqf | 1 + 13 files changed, 339 insertions(+), 291 deletions(-) create mode 100644 defines/ApprovedAssets.hpp rename {functions/definitions => defines}/BattalionInfo.hpp (100%) rename {functions/definitions => defines}/DisallowedEquipment.hpp (100%) create mode 100644 defines/SupplyCrates.hpp delete mode 100644 functions/definitions/ApprovedAssets.hpp delete mode 100644 functions/resupply/fn_crateDefinitions.sqf create mode 100644 functions/resupply/fn_getSupplyCratesCfg.sqf diff --git a/defines/ApprovedAssets.hpp b/defines/ApprovedAssets.hpp new file mode 100644 index 0000000..32a80f5 --- /dev/null +++ b/defines/ApprovedAssets.hpp @@ -0,0 +1,22 @@ +// Lists approved fixed-wing and rotary vehicle types that mission makers can use in their missions. + +class ApprovedAssets { + // Fixed-wing aircraft + class USAF_A10 {callsign = "Ares";}; + class RHSGREF_A29B_HIDF {callsign = "Odyssey";}; + class USAF_C130J {callsign = "Hercules";}; + // Rotary aircraft + class RHS_MELB_MH6M {callsign = "Apollo";}; + class RHS_MELB_AH6M {callsign = "Artemis";}; + class RHS_MELB_H6M {callsign = "Icarus";}; + class RHS_CH_47F {callsign = "Achilles";}; + class ej_MH60MDAP4 {callsign = "Hades";}; + class RHS_UH60M {callsign = "Griffin";}; + class RHS_UH60M_MEV2 {callsign = "Dustoff";}; + class B_T_VTOL_01_INFANTRY_F {callsign = "Pegasus";}; + class B_T_VTOL_01_ARMED_F {callsign = "Spartan";}; + class RHS_AH64D {callsign = "Orion";}; + class RHS_AH1Z {callsign = "Athena";}; + class RHS_UH1Y {callsign = "Homer";}; + class rhsusf_CH53E_USMC {callsign = "Atlas";}; +}; \ No newline at end of file diff --git a/functions/definitions/BattalionInfo.hpp b/defines/BattalionInfo.hpp similarity index 100% rename from functions/definitions/BattalionInfo.hpp rename to defines/BattalionInfo.hpp diff --git a/functions/definitions/DisallowedEquipment.hpp b/defines/DisallowedEquipment.hpp similarity index 100% rename from functions/definitions/DisallowedEquipment.hpp rename to defines/DisallowedEquipment.hpp diff --git a/defines/SupplyCrates.hpp b/defines/SupplyCrates.hpp new file mode 100644 index 0000000..a1cebac --- /dev/null +++ b/defines/SupplyCrates.hpp @@ -0,0 +1,180 @@ +class SupplyCrates { + class AmmoSquad { + boxClass = "Box_Syndicate_Ammo_F"; + displayName = "Squad Ammo"; + tooltip = "A crate containing general ammunition and equipment for an infantry squad."; + icon = "\A3\ui_f\data\map\vehicleicons\iconCrateAmmo_ca.paa"; + + backpacks[] = {}; + weapons[] = { + {"rhs_weap_M136",4}, + {"rhs_weap_M136_hp",4}, + {"rhs_weap_m72a7",2} + }; + magazines[] = { + {"1Rnd_SmokePurple_Grenade_shell",12}, + {"1Rnd_SmokeBlue_Grenade_shell",24}, + {"1Rnd_SmokeOrange_Grenade_shell",12}, + {"rhs_mag_M441_HE",25}, + {"rhs_mag_M433_HEDP",15}, + {"ACE_40mm_Flare_ir",12}, + {"rhsusf_200Rnd_556x45_mixed_soft_pouch_coyote",25}, + {"rhsusf_20Rnd_762x51_m993_Mag",25}, + {"SmokeShell",12}, + {"rhs_mag_m67",12}, + {"1Rnd_Smoke_Grenade_shell",24}, + {"1Rnd_SmokeRed_Grenade_shell",24}, + {"1Rnd_SmokeGreen_Grenade_shell",24}, + {"1Rnd_SmokeYellow_Grenade_shell",12}, + {"Tier1_30Rnd_556x45_M856A1_EMag",25}, + {"Tier1_30Rnd_556x45_Mk318Mod0_EMag",75}, + {"ACE_30Rnd_65_Creedmor_mag",25}, + {"SMA_30Rnd_762x35_BLK_EPR",25}, + {"Tier1_30Rnd_762x35_300BLK_SMK_PMAG",25}, + {"SMA_30Rnd_68x43_SPC_FMJ",25}, + {"SMA_30Rnd_68x43_SPC_FMJ_Tracer",25}, + {"SMA_20Rnd_762x51mm_M80A1_EPR",25}, + {"SMA_20Rnd_762x51mm_M80A1_EPR_Tracer",25}, + {"SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range",25}, + {"SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range_Tracer",25}, + {"Tier1_250Rnd_762x51_Belt_M993_AP",15}, + {"ACE_20Rnd_762x51_Mag_Tracer",25}, + {"ACE_20Rnd_762x51_M993_AP_Mag",25}, + {"rhsusf_20Rnd_762x51_SR25_m993_Mag",25}, + {"Tier1_20Rnd_762x51_M993_SR25_Mag",25}, + {"Tier1_20Rnd_65x48_Creedmoor_SR25_Mag",25}, + {"rhssaf_30rnd_556x45_EPR_G36", 25}, + {"DemoCharge_Remote_Mag",16} + }; + items[] = {}; + }; + + class AmmoHeavy { + boxClass = "Box_NATO_Wps_F"; + displayName = "Heavy Ammo"; + tooltip = "A crate containing mixed ammo for rifles, ARs, MAT, and HAT."; + icon = "\A3\ui_f\data\map\vehicleicons\iconCrateWpns_ca.paa"; + + backpacks[] = {}; + weapons[] = {}; + magazines[] = { + {"MRAWS_HEAT_F",35}, + {"MRAWS_HE_F",15}, + {"Tier1_250Rnd_762x51_Belt_M993_AP",50}, + {"Tier1_30Rnd_556x45_M856A1_EMag",25}, + {"Tier1_30Rnd_556x45_Mk318Mod0_EMag",50}, + {"Titan_AA",10}, + {"Titan_AT",10}, + {"200Rnd_65x39_cased_Box_Tracer_Red",50} + }; + items[] = {}; + }; + + class MedicalSupplies { + boxClass = "ACE_medicalSupplyCrate_advanced"; + displayName = "Medical Crate"; + tooltip = "A crate containing medical supplies."; + icon = "\A3\ui_f\data\map\vehicleicons\pictureHeal_ca.paa"; + + backpacks[] = {}; + weapons[] = {}; + magazines[] = {}; + items[] = { + {"ACE_packingBandage",100}, + {"ACE_elasticBandage",100}, + {"ACE_tourniquet",48}, + {"ACE_splint",48}, + {"ACE_morphine",50}, + {"ACE_epinephrine",50}, + {"ACE_bloodIV",75}, + {"ACE_bloodIV_500",50}, + {"ACE_bloodIV_250",25}, + {"ACE_quikclot",75}, + {"ACE_personalAidKit", 5}, + {"ACE_surgicalKit", 5} + }; + }; + + class Launchers { + boxClass = "Box_NATO_WpsLaunch_F"; + displayName = "Launcher Crate"; + tooltip = "A crate containing missile launchers and ammunition."; + icon = "\A3\ui_f\data\map\vehicleicons\iconCrateLong_ca.paa"; + + backpacks[] = {}; + weapons[] = { + {"launch_B_Titan_short_F",2}, + {"launch_NLAW_F",2}, + {"rhs_weap_fim92",2} + }; + magazines[] = { + {"Titan_AA",6}, + {"Titan_AT",6} + }; + items[] = {}; + }; + + class CrewServedWeapons { + boxClass = "Box_NATO_Equip_F"; + displayName = "CSW Crate"; + tooltip = "A crate containing backpacks that assemble into static weapons."; + icon = "\A3\ui_f\data\igui\cfg\simpleTasks\types\defend_ca.paa"; + + backpacks[] = { + {"RHS_M2_Gun_Bag",2}, + {"RHS_M2_Tripod_Bag",2}, + {"RHS_M2_MiniTripod_Bag",2}, + {"rhs_Tow_Gun_Bag",2}, + {"rhs_TOW_Tripod_Bag",2}, + {"UK3CB_Static_M240_Elcan_Gun_Bag",2}, + {"UK3CB_B_Static_M240_Elcan_Tripod_Low_Bag_US_D",2}, + {"RHS_Mk19_Gun_Bag",2}, + {"RHS_Mk19_Tripod_Bag",2} + }; + weapons[] = {}; + magazines[] = {}; + items[] = {}; + }; + + class MortarMk6Resupply { + boxClass = "Box_NATO_WpsSpecial_F"; + displayName = "Mortar MK6 Supply Crate"; + tooltip = "A crate containing Mk6 mortar resupply (tubes) and tools."; + icon = "\A3\ui_f\data\map\vehicleicons\iconStaticMortar_ca.paa"; + + backpacks[] = { + {"B_Mortar_01_support_F",3}, + {"B_Mortar_01_weapon_F",6}, + {"UK3CB_LSM_B_B_CARRYALL_RADIO_TIG_STRIPE_01",1} + }; + weapons[] = { + {"ACE_Vector",2} + }; + magazines[] = { + {"acex_intelitems_notepad",2} + }; + items[] = { + {"ACE_artilleryTable",2}, + {"ACE_RangeTable_82mm",2}, + {"ACE_microDAGR",2}, + {"ACE_MapTools",2} + }; + }; + + class Mortar60mmCommandoResupply { + boxClass = "Box_NATO_WpsSpecial_F"; + displayName = "Mortar 60mm Commando Supply Crate"; + tooltip = "A crate containing COMMANDO 60mm mortar shells and some STANAGs."; + icon = "\A3\ui_f\data\igui\cfg\simpleTasks\types\scout_ca.paa"; + + backpacks[] = {}; + weapons[] = {}; + magazines[] = { + {"twc_2inch_he_1rnd",70}, + {"twc_2inch_smoke_1rnd",15}, + {"twc_2inch_illum_1rnd",15}, + {"Tier1_30Rnd_556x45_Mk318Mod0_EMag",20} + }; + items[] = {}; + }; +}; \ No newline at end of file diff --git a/description.ext b/description.ext index 232b61e..9781ede 100644 --- a/description.ext +++ b/description.ext @@ -17,9 +17,10 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "mission_settings.hpp" -#include "functions\definitions\DisallowedEquipment.hpp" -#include "functions\definitions\BattalionInfo.hpp" -#include "functions\definitions\ApprovedAssets.hpp" +#include "defines\ApprovedAssets.hpp" +#include "defines\BattalionInfo.hpp" +#include "defines\DisallowedEquipment.hpp" +#include "defines\SupplyCrates.hpp" //-------------------------------------------MISSION INFO-------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index d8d6331..68eae3c 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -49,17 +49,6 @@ class milsim class logPlayerInventory {}; }; - class resupply { - class crateDefinitions {}; - class createAmmoBox {}; - class createBox {}; - class createCSWBox {}; - class createLaunchersBox {}; - class createMedicalBox {}; - class createMortarBox {}; - class createWeaponsBox {}; - } - class ambience { class flakInitVehicle {}; class flakEH {}; @@ -88,6 +77,20 @@ class milsim }; }; +class milsim_resupply { + class functions { + file = "functions\resupply"; + class createAmmoBox {}; + class createBox {}; + class createCSWBox {}; + class createLaunchersBox {}; + class createMedicalBox {}; + class createMortarBox {}; + class createWeaponsBox {}; + class getSupplyCratesCfg {}; + }; +}; + class milsim_fbcb2_assets { class functions { file = "functions\fbcb2\assets"; diff --git a/functions/client/fn_addZenModules.sqf b/functions/client/fn_addZenModules.sqf index ec7ca94..211aa43 100644 --- a/functions/client/fn_addZenModules.sqf +++ b/functions/client/fn_addZenModules.sqf @@ -5,24 +5,28 @@ if ( !hasInterface ) exitWith {}; "Create Resupply Box", { params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; - _keysSorted = keys milsim_resupply_crateDefinitions; - _keysSorted sort true; - _comboOptions = []; - _comboOptions resize (count _keysSorted); - for "_i" from 0 to (count _keysSorted) - 1 do { - private _definition = milsim_resupply_crateDefinitions get (_keysSorted select _i); - _comboOptions set [_i, [ - _definition getOrDefault ["displayName", "ERROR"], // display name - _definition getOrDefault ["description", "No description"], // tooltip - _definition getOrDefault ["icon", "No icon"] // icon - ]]; + // get parent definition + private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; + // get the subclass names + private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses; + + _boxTypesAvailable sort true; + _comboOptions = _boxTypesAvailable apply { + [ + // display name + [_supplyCratesCfg >> _x >> "displayName", "STRING", "ERROR"] call CBA_fnc_getConfigEntry, + // tooltip + [_supplyCratesCfg >> _x >> "tooltip", "STRING", "ERROR"] call CBA_fnc_getConfigEntry, + // icon + [_supplyCratesCfg >> _x >> "icon", "STRING", "ERROR"] call CBA_fnc_getConfigEntry + ] }; [ "Resupply Box Options", [ // [ "COMBO", "Box Type", [[1,2,3], [["Ammo"],["Weapons"],["Medical"]],0] ] - ["COMBO", "Box Type", [_keysSorted, _comboOptions, 0]] + ["COMBO", "Box Type", [_boxTypesAvailable, _comboOptions, 0]] ], { @@ -32,14 +36,14 @@ if ( !hasInterface ) exitWith {}; _args params ["_pos", "_target", "_keysSorted"]; - private _box = [_target, _typeOptionSelected, _pos] call milsim_fnc_createBox; + private _box = [_target, _typeOptionSelected, _pos] call milsim_resupply_fnc_createBox; if (isNull _box) exitWith { ["Resupply Box", "WARNING: Failed to locate or create box!"] call BIS_fnc_curatorHint; }; - ["Resupply Box", format["Created a %1 box", _typeOptionSelected]] call BIS_fnc_curatorHint; + ["Resupply Box", format["Created box from class %1", _typeOptionSelected]] call BIS_fnc_curatorHint; }, {}, - [_pos, _target, _options] + [_pos, _target] ] call zen_dialog_fnc_create; } ] call zen_custom_modules_fnc_register; diff --git a/functions/definitions/ApprovedAssets.hpp b/functions/definitions/ApprovedAssets.hpp deleted file mode 100644 index b9af09e..0000000 --- a/functions/definitions/ApprovedAssets.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Lists approved fixed-wing and rotary vehicle types that mission makers can use in their missions. - -class ApprovedAssets { - // Fixed-wing aircraft - class USAF_A10 {callsign = "Ares";assetType = "FixedWing";}; - class RHSGREF_A29B_HIDF {callsign = "Odyssey";assetType = "FixedWing";}; - class USAF_C130J {callsign = "Hercules";assetType = "FixedWing";}; - // Rotary aircraft - class RHS_MELB_MH6M {callsign = "Apollo";assetType = "Rotary";}; - class RHS_MELB_AH6M {callsign = "Artemis";assetType = "Rotary";}; - class RHS_MELB_H6M {callsign = "Icarus";assetType = "Rotary";}; - class RHS_CH_47F {callsign = "Achilles";assetType = "Rotary";}; - class ej_MH60MDAP4 {callsign = "Hades";assetType = "Rotary";}; - class RHS_UH60M {callsign = "Griffin";assetType = "Rotary";}; - class RHS_UH60M_MEV2 {callsign = "Dustoff";assetType = "Rotary";}; - class B_T_VTOL_01_INFANTRY_F {callsign = "Pegasus";assetType = "Rotary";}; - class B_T_VTOL_01_ARMED_F {callsign = "Spartan";assetType = "Rotary";}; - class RHS_AH64D {callsign = "Orion";assetType = "Rotary";}; - class RHS_AH1Z {callsign = "Athena";assetType = "Rotary";}; - class RHS_UH1Y {callsign = "Homer";assetType = "Rotary";}; - class rhsusf_CH53E_USMC {callsign = "Atlas";assetType = "Rotary";}; -}; \ No newline at end of file diff --git a/functions/init/fn_initPlayerLocal.sqf b/functions/init/fn_initPlayerLocal.sqf index efdebe5..d72495f 100644 --- a/functions/init/fn_initPlayerLocal.sqf +++ b/functions/init/fn_initPlayerLocal.sqf @@ -9,9 +9,6 @@ if (!isServer) then { }] call CBA_fnc_addEventHandler; }; -// define milsim_resupply_crateDefinitions -call milsim_fnc_crateDefinitions; - ["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; nil; \ No newline at end of file diff --git a/functions/init/fn_initServer.sqf b/functions/init/fn_initServer.sqf index b3f1e57..d70c518 100644 --- a/functions/init/fn_initServer.sqf +++ b/functions/init/fn_initServer.sqf @@ -1,8 +1,5 @@ if (!isServer) exitWith {}; -// define milsim_resupply_crateDefinitions -call milsim_fnc_crateDefinitions; - milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; publicVariable "milsim_baseObjects"; diff --git a/functions/resupply/fn_crateDefinitions.sqf b/functions/resupply/fn_crateDefinitions.sqf deleted file mode 100644 index 17bb3e8..0000000 --- a/functions/resupply/fn_crateDefinitions.sqf +++ /dev/null @@ -1,201 +0,0 @@ -milsim_resupply_crateDefinitions = createHashMapFromArray [ - ["AMMO LIGHT", createHashMapFromArray [ - ["className", "Box_Syndicate_Ammo_F"], - ["displayName", "Ammo Crate"], - ["description", "A crate containing general ammunition and equipment for an infantry squad."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\rifle_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", [ - ["rhs_weap_M136",4], - ["rhs_weap_M136_hp",4], - ["rhs_weap_m72a7",2] - ]], - ["magazines", [ - ["1Rnd_SmokePurple_Grenade_shell",12], - ["1Rnd_SmokeBlue_Grenade_shell",24], - ["1Rnd_SmokeOrange_Grenade_shell",12], - ["rhs_mag_M441_HE",25], - ["rhs_mag_M433_HEDP",15], - ["ACE_40mm_Flare_ir",12], - ["rhsusf_200Rnd_556x45_mixed_soft_pouch_coyote",25], - ["rhsusf_20Rnd_762x51_m993_Mag",25], - ["SmokeShell",12], - ["rhs_mag_m67",12], - ["1Rnd_Smoke_Grenade_shell",24], - ["1Rnd_SmokeRed_Grenade_shell",24], - ["1Rnd_SmokeGreen_Grenade_shell",24], - ["1Rnd_SmokeYellow_Grenade_shell",12], - ["Tier1_30Rnd_556x45_M856A1_EMag",25], - ["Tier1_30Rnd_556x45_Mk318Mod0_EMag",75], - ["ACE_30Rnd_65_Creedmor_mag",25], - ["SMA_30Rnd_762x35_BLK_EPR",25], - ["Tier1_30Rnd_762x35_300BLK_SMK_PMAG",25], - ["SMA_30Rnd_68x43_SPC_FMJ",25], - ["SMA_30Rnd_68x43_SPC_FMJ_Tracer",25], - ["SMA_20Rnd_762x51mm_M80A1_EPR",25], - ["SMA_20Rnd_762x51mm_M80A1_EPR_Tracer",25], - ["SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range",25], - ["SMA_20Rnd_762x51mm_Mk316_Mod_0_Special_Long_Range_Tracer",25], - ["Tier1_250Rnd_762x51_Belt_M993_AP",15], - ["ACE_20Rnd_762x51_Mag_Tracer",25], - ["ACE_20Rnd_762x51_M993_AP_Mag",25], - ["rhsusf_20Rnd_762x51_SR25_m993_Mag",25], - ["Tier1_20Rnd_762x51_M993_SR25_Mag",25], - ["Tier1_20Rnd_65x48_Creedmoor_SR25_Mag",25], - ["rhssaf_30rnd_556x45_EPR_G36", 25], - ["DemoCharge_Remote_Mag",16] - ]], - ["items", []] - ] - ]]], - ["AMMO HEAVY", createHashMapFromArray [ - ["className", "Box_NATO_Wps_F"], - ["displayName", "Heavy Ammo Crate"], - ["description", "A crate containing mixed ammo for rifles, ARs, MAT, and HAT."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\heli_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", []], - ["magazines", [ - ["MRAWS_HEAT_F",35], - ["MRAWS_HE_F",15], - ["Tier1_250Rnd_762x51_Belt_M993_AP",50], - ["Tier1_30Rnd_556x45_M856A1_EMag",25], - ["Tier1_30Rnd_556x45_Mk318Mod0_EMag",50], - ["Titan_AA",10], - ["Titan_AT",10], - ["200Rnd_65x39_cased_Box_Tracer_Red",50] - ]], - ["items", []] - ] - ]]], - ["AMMO MORTAR", createHashMapFromArray [ - ["className", "Box_Syndicate_Wps_F"], - ["displayName", "Mortar Ammo Crate"], - ["description", "A crate containing mortar ammunition."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\scout_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", []], - ["magazines", [ - ["ACE_1Rnd_82mm_Mo_HE",24], - ["ACE_1Rnd_82mm_Mo_Smoke",12], - ["ACE_1Rnd_82mm_Mo_Illum",12] - ]], - ["items", []] - ] - ]]], - ["MEDICAL", createHashMapFromArray [ - ["className", "ACE_medicalSupplyCrate_advanced"], - ["displayName", "Medical Crate"], - ["description", "A crate containing medical supplies."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\heal_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", []], - ["magazines", []], - ["items", [ - ["ACE_packingBandage",100], - ["ACE_elasticBandage",100], - ["ACE_tourniquet",48], - ["ACE_splint",48], - ["ACE_morphine",50], - ["ACE_epinephrine",50], - ["ACE_bloodIV",75], - ["ACE_bloodIV_500",50], - ["ACE_bloodIV_250",25], - ["ACE_quikclot",75], - ["ACE_personalAidKit", 5], - ["ACE_surgicalKit", 5] - ]] - ] - ]]], - ["LAUNCHERS", createHashMapFromArray [ - ["className", "Box_NATO_WpsLaunch_F"], - ["displayName", "Launcher Crate"], - ["description", "A crate containing missile launchers and ammunition."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\heli_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", [ - - ]], - ["weapons", [ - ["launch_B_Titan_short_F",2], - ["launch_NLAW_F",2], - ["rhs_weap_fim92",2] - ]], - ["magazines", [ - ["Titan_AA",6], - ["Titan_AT",6] - ]], - ["items", [ - - ]] - ] - ]]], - ["CSW", createHashMapFromArray [ - ["className", "Box_NATO_Equip_F"], - ["displayName", "CSW Crate"], - ["description", "A crate containing backpacks that assemble into static weapons."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\defend_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", [ - ["RHS_M2_Gun_Bag",2], - ["RHS_M2_Tripod_Bag",2], - ["RHS_M2_MiniTripod_Bag",2], - ["rhs_Tow_Gun_Bag",2], - ["rhs_TOW_Tripod_Bag",2], - ["UK3CB_Static_M240_Elcan_Gun_Bag",2], - ["UK3CB_B_Static_M240_Elcan_Tripod_Low_Bag_US_D",2], - ["RHS_Mk19_Gun_Bag",2], - ["RHS_Mk19_Tripod_Bag",2] - ]], - ["weapons", []], - ["magazines", []], - ["items", []] - ] - ]]], - ["MORTAR MK6", createHashMapFromArray [ - ["className", "Box_NATO_WpsSpecial_F"], - ["displayName", "Mortar MK6 Supply Crate"], - ["description", "A crate containing Mk6 mortar resupply (tubes) and tools."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\scout_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", [ - ["B_Mortar_01_support_F",3], - ["B_Mortar_01_weapon_F",6], - ["UK3CB_LSM_B_B_CARRYALL_RADIO_TIG_STRIPE_01",1] - ]], - ["weapons", [ - ["ACE_Vector",2] - ]], - ["magazines", [ - ["acex_intelitems_notepad",2] - ]], - ["items", [ - ["ACE_artilleryTable",2], - ["ACE_RangeTable_82mm",2], - ["ACE_microDAGR",2], - ["ACE_MapTools",2] - ]] - ] - ]]], - ["MORTAR 60MM COMMANDO", createHashMapFromArray [ - ["className", "Box_NATO_WpsSpecial_F"], - ["displayName", "Mortar 60mm Commando Supply Crate"], - ["description", "A crate containing COMMANDO 60mm mortar shells and some STANAGs."], - ["icon", "\A3\ui_f\data\igui\cfg\simpleTasks\types\scout_ca.paa"], - ["items", createHashMapFromArray [ - ["backpacks", []], - ["weapons", []], - ["magazines", [ - ["twc_2inch_he_1rnd",70], - ["twc_2inch_smoke_1rnd",15], - ["twc_2inch_illum_1rnd",15], - ["Tier1_30Rnd_556x45_Mk318Mod0_EMag",20] - ]], - ["items", []] - ] - ]]] -]; \ No newline at end of file diff --git a/functions/resupply/fn_createBox.sqf b/functions/resupply/fn_createBox.sqf index 0917746..b4576ef 100644 --- a/functions/resupply/fn_createBox.sqf +++ b/functions/resupply/fn_createBox.sqf @@ -1,18 +1,19 @@ /* * Author: Hizumi & IndigoFox * - * Create Mortar resupply box for the 17th Battalion + * Create Mortar resupply box for the 17th Battalion. Primarily called from milsim_fnc_addZenModules * * Arguments: * 0: Vehicle - - * 1: Position - + * 1: Type - + * 2: Position - * * Return Value: * Function executed * * Example: - * [box] call milsim_fnc_createBox; // create mortar ammo box via init line of editor object - * [objNull, pos] call milsim_fnc_createBox; // create mortar ammo box via zeus module + * [box, "AmmoSquad"] call milsim_fnc_createBox; // create mortar ammo box via init line of editor object + * [objNull, "AmmoHeavy", pos] call milsim_fnc_createBox; // create mortar ammo box via zeus module * * Public: Yes * @@ -34,68 +35,133 @@ params [ ["_pos", [0,0,0], [[]], 3] ]; -if (isNil "milsim_resupply_crateDefinitions") exitWith { - format["Resupply Boxes: milsim_resupply_crateDefinitions is not defined, possibly a bad edit?"] remoteExec ["systemChat", 0]; - false; +// get defs class +private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg; +if (!isClass _supplyCratesCfg) exitWith { + ["Resupply Boxes: Failed to load crate definitions, possibly a bad edit?"] call BIS_fnc_error; + objNull; }; +// get the subclass names +private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses; + +// if no type is provided, show the available types if (_type isEqualTo "") exitWith { - format["Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox"] remoteExec ["systemChat", 0]; - format["Please use one of the following types for _type:"] remoteExec ["systemChat", 0]; - format["%1", (keys milsim_resupply_crateDefinitions)] remoteExec ["systemChat", 0]; - false; + [ + "%1 | %2 %3", + "Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox", + "No type provided. Please use one of the following types for _type:", + _boxTypesAvailable joinString ", " + ] call BIS_fnc_error; + objNull; }; -private _boxData = milsim_resupply_crateDefinitions getOrDefault [_type, createHashMap]; -if (count _boxData isEqualTo 0) exitWith { - format["Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox"] remoteExec ["systemChat", 0]; - format["%1 is not a valid type for _type", _type] remoteExec ["systemChat", 0]; - format["Please use one of the following types for _type:"] remoteExec ["systemChat", 0]; - format["%1", (keys milsim_resupply_crateDefinitions)] remoteExec ["systemChat", 0]; - false; + +////////////////////////////////////////////////////////////////////////// +// get the box definition class +////////////////////////////////////////////////////////////////////////// +private _boxDef = (_supplyCratesCfg >> _type); +// validate it exists +if (!isClass _boxDef) exitWith { + [ + "%1 | %2 %3", + "Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox", + "Invalid type provided. Please use one of the following types for _type:", + _boxTypesAvailable joinString ", " + ] call BIS_fnc_error; + objNull; }; -private _boxItems = _boxData getOrDefault ["items", createHashMap]; - +////////////////////////////////////////////////////////////////////////// +// Create box if one wasn't provided in parameters +////////////////////////////////////////////////////////////////////////// if (isNull _box) then { - _box = (_boxData get "className") createVehicle _pos; + private _neededBoxType = getText(_boxDef >> "boxClass"); + if (_neededBoxType isEqualTo "") exitWith { + [ + "Resupply Boxes: Failed to create box. No boxClass defined in the box definition." + ] call BIS_fnc_error; + objNull; + }; + _box = _neededBoxType createVehicle _pos; }; + +////////////////////////////////////////////////////////////////////////// +// Clear box +////////////////////////////////////////////////////////////////////////// clearBackpackCargoGlobal _box; clearItemCargoGlobal _box; clearMagazineCargoGlobal _box; clearWeaponCargoGlobal _box; +////////////////////////////////////////////////////////////////////////// +// Get [item, quantity] arrays from definition +////////////////////////////////////////////////////////////////////////// +private _backpacks = ([_boxDef >> "backpacks"] call BIS_fnc_getCfgDataArray); +if (isNil "_backpacks") exitWith { + [ + "Resupply Boxes: Failed to create box. No backpacks defined in the box definition." + ] call BIS_fnc_error; + objNull; +}; + +private _weapons = ([_boxDef >> "weapons"] call BIS_fnc_getCfgDataArray); +if (isNil "_weapons") exitWith { + [ + "Resupply Boxes: Failed to create box. No weapons defined in the box definition." + ] call BIS_fnc_error; + objNull; +}; + +private _magazines = ([_boxDef >> "magazines"] call BIS_fnc_getCfgDataArray); +if (isNil "_magazines") exitWith { + [ + "Resupply Boxes: Failed to create box. No magazines defined in the box definition." + ] call BIS_fnc_error; + objNull; +}; + +private _items = ([_boxDef >> "items"] call BIS_fnc_getCfgDataArray); +if (isNil "_items") exitWith { + [ + "Resupply Boxes: Failed to create box. No items defined in the box definition." + ] call BIS_fnc_error; + objNull; +}; + +////////////////////////////////////////////////////////////////////////// +// Add stuff to box +////////////////////////////////////////////////////////////////////////// { _x params ["_class", "_qty"]; - _box addBackpackCargoGlobal [_class, _qty] - -} foreach (_boxItems getOrDefault ["backpacks", []]); +} foreach _backpacks; { _x params ["_class", "_qty"]; - _box addItemCargoGlobal [_class, _qty] - -} foreach (_boxItems getOrDefault ["items", []]); +} foreach _items; { _x params ["_class", "_qty"]; - _box addMagazineCargoGlobal [_class, _qty] - -} foreach (_boxItems getOrDefault ["magazines", []]); +} foreach _magazines; { _x params ["_class", "_qty"]; - _box addWeaponCargoGlobal [_class, _qty] - -} foreach (_boxItems getOrDefault ["weapons", []]); +} foreach _weapons; + +////////////////////////////////////////////////////////////////////////// +// Adjust ACE settings +////////////////////////////////////////////////////////////////////////// +// set box size [_box,1] call ace_cargo_fnc_setSize; // ignore weight restrictions for carry/drag _box setVariable ["ace_ignoreWeightCarry", true, true]; + +// Return the box _box; \ No newline at end of file diff --git a/functions/resupply/fn_getSupplyCratesCfg.sqf b/functions/resupply/fn_getSupplyCratesCfg.sqf new file mode 100644 index 0000000..2bf1a5f --- /dev/null +++ b/functions/resupply/fn_getSupplyCratesCfg.sqf @@ -0,0 +1 @@ +(missionConfigFile >> "SupplyCrates"); \ No newline at end of file