move to cfg, update createbox, create /defines

This commit is contained in:
2024-02-03 18:40:18 -08:00
parent 6764186794
commit 7ef48ecaa2
13 changed files with 339 additions and 291 deletions

View File

@@ -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", []]
]
]]]
];

View File

@@ -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 - <OBJECT>
* 1: Position - <ARRAY>
* 1: Type - <STRING>
* 2: Position - <ARRAY>
*
* Return Value:
* Function executed <BOOL>
*
* 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;

View File

@@ -0,0 +1 @@
(missionConfigFile >> "SupplyCrates");