Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private["_iItem","_iClass","_iPos","_obj","_type","_config","_itemChances","_lootChance","_cfgLoot","_radius","_itemTypes","_index","_item","_qty","_max","_tQty","_canType","_weights","_cntWeights","_dateNow"];
- _iItem = _this select 0;
- _iClass = _this select 1;
- _iPos = _this select 2;
- _radius = _this select 3;
- _obj = _this select 0;
- _type = typeOf _obj;
- _config = configFile >> "cfgLoot" >> _type;
- _lootChance = getNumber (_config >> "lootChance");
- //Custom Loot Config. //
- //___________________//
- _itemTypes = []; //Initialise array
- _itemChance = []; //Initialise array
- switch (_cfgLoot) do {
- case "Trash": {
- _itemTypes = [
- ["TrashTinCan"],
- ["TrashJackDaniels"],
- ["ItemSodaEmpty"],
- ["ItemTrashToiletpaper"],
- ["ItemTrashRazor"]
- ];
- _itemChance = [
- 1,
- 0.1,
- 0.5,
- 0.4,
- 0.2
- ];
- };
- case "Civilian": {
- _itemTypes = [
- ["TrashTinCan"],
- ["TrashJackDaniels"],
- ["ItemSodaEmpty"],
- ["ItemSodaCoke"],
- ["ItemSodaPepsi"],
- ["FoodCanBakedBeans"],
- ["FoodCanSardines"],
- ["FoodCanFrankBeans"],
- ["FoodCanPasta"],
- ["8Rnd_9x18_Makarov"],
- ["7Rnd_45ACP_1911"],
- ["2Rnd_shotgun_74Slug"],
- ["2Rnd_shotgun_74Pellets"],
- ["ItemBandage"],
- ["ItemPainkiller"]
- ];
- _itemChance = [
- 0.09,
- 0.09,
- 0.09,
- 0.12,
- 0.09,
- 0.05,
- 0.05,
- 0.05,
- 0.05,
- 0.07,
- 0.05,
- 0.05,
- 0.05,
- 0.06,
- 0.06
- ];
- };
- case "Food": {
- _itemTypes = [
- ["TrashTinCan"],
- ["TrashJackDaniels"],
- ["ItemSodaEmpty"],
- ["ItemSodaCoke"],
- ["ItemSodaPepsi"],
- ["FoodCanBakedBeans"],
- ["FoodCanSardines"],
- ["FoodCanFrankBeans"],
- ["FoodCanPasta"],
- ["FoodCanUnlabeled"],
- //Bags
- ["FoodPistachio"],
- ["FoodNutmix"]
- ];
- _itemChance = [
- 0.13,
- 0.13,
- 0.13,
- 0.09,
- 0.13,
- 0.09,
- 0.09,
- 0.09,
- 0.09,
- 0.06,
- //Bags
- 0.05,
- 0.04
- ];
- };
- case "Generic": {
- _itemTypes = [
- ["TrashTinCan"],
- ["ItemSodaEmpty"],
- ["ItemSodaCoke"],
- ["ItemSodaPepsi"],
- ["TrashJackDaniels"],
- ["FoodCanBakedBeans"],
- ["FoodCanSardines"],
- ["FoodCanFrankBeans"],
- ["FoodCanPasta"],
- ["ItemWaterbottleUnfilled"],
- ["ItemWaterbottle"],
- ["ItemBandage"],
- ["7Rnd_45ACP_1911"],
- ["5x_22_LR_17_HMR"],
- ["10x_303"],
- ["6Rnd_45ACP"],
- ["2Rnd_shotgun_74Slug"],
- ["2Rnd_shotgun_74Pellets]",
- ["8Rnd_9x18_Makarov"],
- ["15Rnd_W1866_Slug"],
- ["WoodenArrow"],
- ["HandRoadFlare"],
- ["ItemPainkiller"],
- ["HandChemGreen"],
- ["HandChemBlue"],
- ["HandChemRed"],
- ["ItemHeatPack"]
- ];
- _itemChance = [
- 0.06,
- 0.06,
- 0.06,
- 0.04,
- 0.04,
- 0.01,
- 0.01,
- 0.01,
- 0.01,
- 0.01,
- 0.01,
- 0.11,
- 0.03,
- 0.01,
- 0.04,
- 0.04,
- 0.05,
- 0.05,
- 0.09,
- 0.02,
- 0.04,
- 0.07,
- 0.02,
- 0.01,
- 0.03,
- 0.03,
- 0.04
- ];
- };
- case "Hospital": {
- _itemTypes = [
- ["ItemBandage"],
- ["ItemPainkiller"],
- ["ItemMorphine"],
- ["ItemEpinephrine"],
- ["ItemBloodbag"],
- ["ItemAntibiotic"]
- ];
- _itemChance = [
- 0.33,
- 0.17,
- 0.13,
- 0.09,
- 0.17,
- 0.12
- ];
- };
- case "Military": {
- _itemTypes = [
- ["TrashTinCan"],
- ["ItemSodaEmpty"],
- ["ItemSodaCoke"],
- ["ItemSodaPepsi"],
- ["ItemBandage"],
- ["ItemAntibiotic"],
- ["ItemPainkiller"],
- ["ItemMorphine"],
- ["30Rnd_556x45_Stanag"],
- ["20Rnd_762x51_DMR"],
- ["17Rnd_9x19_glock17"],
- ["15Rnd_9x19_M9SD"],
- ["15Rnd_9x19_M9"],
- ["30Rnd_762x39_AK47"],
- ["30Rnd_545x39_AK"],
- ["5Rnd_762x51_M24"],
- ["10Rnd_127x99_m107"],
- ["8Rnd_B_Beneli_74Slug"],
- ["1Rnd_HE_M203"],
- ["FlareWhite_M203"],
- ["FlareGreen_M203"],
- ["1Rnd_Smoke_M203"],
- ["200Rnd_556x45_M249"],
- ["HandGrenade_west"],
- ["SmokeShell"],
- ["SmokeShellRed"],
- ["SmokeShellGreen"],
- ["8Rnd_B_Beneli_Pellets"],
- ["30Rnd_556x45_StanagSD"],
- ["30Rnd_9x19_MP5"],
- ["30Rnd_9x19_MP5SD"],
- ["100Rnd_762x51_M240"],
- ["HandChemGreen"],
- ["HandChemBlue"],
- ["HandChemRed"],
- ["ItemHeatPack"],
- ["FoodMRE"]
- ];
- _itemChance = [
- 0.18,
- 0.09,
- 0.01,
- 0.01,
- 0.04,
- 0.04,
- 0.04,
- 0.01,
- 0.04,
- 0.04,
- 0.05,
- 0.01,
- 0.02,
- 0.04,
- 0.04,
- 0.01,
- 0.01,
- 0.04,
- 0.01,
- 0.01,
- 0.01,
- 0.01,
- 0.01,
- 0.01,
- 0.04,
- 0.02,
- 0.02,
- 0.04,
- 0.01,
- 0.02,
- 0.01,
- 0.01,
- 0.02,
- 0.02,
- 0.02,
- 0.04,
- 0.03
- ];
- };
- case "Policeman": {
- _itemTypes = [
- ["ItemBandage"],
- ["7Rnd_45ACP_1911"],
- ["6Rnd_45ACP"],
- ["15Rnd_W1866_Slug"],
- ["8Rnd_B_Beneli_74Slug"],
- ["HandRoadFlare"]
- ];
- _itemChance = [
- 1,
- 0.8,
- 0.3,
- 0.3,
- 0.5,
- 0.3
- ];
- };
- case "Hunter": {
- _itemTypes = [
- ["ItemBandage"],
- ["5x_22_LR_17_HMR"],
- ["7Rnd_45ACP_1911"],
- ["10x_303"],
- ["ItemWaterbottleUnfilled"],
- ["WoodenArrow"],
- ["ItemHeatPack"],
- ["FoodMRE"],
- ["FoodNutmix"]
- ];
- _itemChance = [
- 1,
- 0.5,
- 0.2,
- 0.5,
- 0.2,
- 1,
- 0.2,
- 0.04,
- 0.1
- ];
- }:
- };
- //Custom Loot Cfg.//
- //________________//
- 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"];
- _itemTypes = _itemTypes select _index;
- _index = _weights call BIS_fnc_selectRandom;
- _weights = [_itemTypes,_itemChance] call fnc_buildWeightedArray;
- _cntWeights = count _weights;
- _qty = 0;
- _max = ceil(random 2) + 1;
- while {_qty < _max} do {
- _tQty = round(random 1) + 1;
- _index = floor(random _cntWeights);
- _index = _weights select _index;
- _canType = _itemTypes select _index;
- _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 {
- if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver
- _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"];
- };
- };
- // timestamp for later clearing
- _dateNow = (DateToNumber date);
- _item setVariable ["looted",_dateNow,true];
- if ((count _iPos) > 2) then {
- _item setPosATL _iPos;
- };
Advertisement
Add Comment
Please, Sign In to add comment