private["_itemType","_iPos","_indexLootSpawn","_iArray","_iItem","_iClass","_item","_qty","_max","_tQty","_arrayLootSpawn","_canType"];
// [_itemType,_weights]
_iItem = _this select 0;
_iClass = _this select 1;
_iPos = _this select 2;
_radius = _this select 3;
_holderItem = _iItem;
switch (_iItem) do {
case "BAF_AS50_scoped": { _holderItem = "BAF_LRR_scoped_W"};
case "M107_DZ": { _holderItem = "SVD"};
case "M1014": { _holderItem= "Saiga12K"};
case "Mk_48_DZ": { _holderItem= "Pecheneg"};
case "M4A1_AIM_SD_camo": { _holderItem = "G36K"};
case "FN_FAL_ANPVS4": { _holderItem = "AK_107_pso"};
case "10Rnd_127x99_m107": { _holderItem = "5Rnd_86x70_L115A1"};
case "ItemFlashlightRed": { _holderItem = "DZ_Assault_Pack_EP1"};
case "ItemWire": { _holderItem = ""};
case "8Rnd_B_Beneli_74Slug": { _holderItem = "8Rnd_B_Saiga12_74Slug"};
case "30Rnd_556x45_G36": { _holderItem = "100Rnd_762x54_PK"};
case "2Rnd_shotgun_74Slug": { _holderItem = "8Rnd_B_Beneli_74Slug"};
case "2Rnd_shotgun_74Pellets": { _holderItem = "8Rnd_B_Beneli_Pellets"};
case "DMR": { _holderItem = "Huntingrifle"};
case "20Rnd_762x51_DMR": { _holderItem = "5x_22_LR_17_HMR"};
case "MP5SD": { _holderItem = "MP5A5"};
case "30Rnd_9x19_MP5SD": { _holderItem = "30Rnd_9x19_MP5"};
case "bizon_silenced": { _holderItem = "Bizon"};
case "64Rnd_9x19_SD_Bizon": { _holderItem = "64Rnd_9x19_Bizon"};
case "ItemMap": { _holderItem = "ItemBandage"};
default {};
};
_iItem = _holderItem;
switch (_iClass) do {
default {
//Item is food, add random quantity of cans along with an item (if exists)
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_arrayLootSpawn = [] + getArray (configFile >> "cfgLoot" >> _iClass);
_itemType = _arrayLootSpawn select 0;
_weights = _arrayLootSpawn call fnc_buildWeightedArray;
_qty = 0;
_max = ceil(random 4) + 1;
//diag_log ("LOOTSPAWN: QTY: " + str(_max) + " ARRAY: " + str(_arrayLootSpawn));
while {_qty < _max} do {
private["_tQty","_indexLootSpawn","_canType"];
_tQty = floor(random 1) + 1;
//diag_log ("LOOTSPAWN: ITEM QTY: " + str(_tQty));
_indexLootSpawn = _weights call BIS_fnc_selectRandom;
_canType = _itemType select _indexLootSpawn;
_holderItem = _canType;
switch (_canType) do {
case "10Rnd_127x99_m107": { _holderItem = "5Rnd_86x70_L115A1"};
case "2Rnd_shotgun_74Slug": { _holderItem = "8Rnd_B_Beneli_74Slug"};
case "2Rnd_shotgun_74Pellets": { _holderItem = "8Rnd_B_Beneli_Pellets"};
case "64Rnd_9x19_SD_Bizon": { _holderItem = "64Rnd_9x19_Bizon"};
case "30Rnd_9x19_MP5SD": { _holderItem = "30Rnd_9x19_MP5"};
case "20Rnd_762x51_DMR": { _holderItem = "5x_22_LR_17_HMR"};
default {};
};
_canType = _holderItem;
//diag_log ("LOOTSPAWN: ITEM: " + str(_canType));
_item addMagazineCargoGlobal [_canType,_tQty];
_qty = _qty + _tQty;
};
if (_iItem != "") then {
_item addWeaponCargoGlobal [_iItem,1];
};
};
case "weapon": {
//Item is a weapon, add it and a random quantity of magazines
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addWeaponCargoGlobal [_iItem,1];
_mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines");
if (count _mags > 0) then {
_item addMagazineCargoGlobal [(_mags select 0),(round(random 2))];
};
};
case "magazine": {
//Item is one magazine
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addMagazineCargoGlobal [_iItem,1];
};
case "object": {
//Item is one magazine
_item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"];
};
};
if (count _iPos > 2) then {
_item setPosATL _ipos;
};