Guest User

Dayz Custom Loot Tables v2.4

a guest
Mar 30th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private["_obj","_type","_config","_positions","_iPos","_nearBy","_itemType","_itemTypes","_itemChances","_lootChance","_weights","_cntWeights","_index","_LootClass"];
  2.  
  3. _obj =          _this select 0;
  4. _type =         typeOf _obj;
  5. _config =       configFile >> "CfgBuildingLoot" >> _type;
  6. _positions =    [] + getArray (_config >> "lootPos");
  7. //_itemTypes =  [] + getArray (_config >> "itemType"); // Default System
  8. _lootChance =   getNumber (_config >> "lootChance");
  9.  
  10. //------------------//
  11. //CUSTOM LOOT SPAWNS//
  12. //------------------//
  13. _itemTypes = []; //Initialise array
  14. _itemChance = []; //Initialise array
  15.  
  16. diag_log "SPAWNING WITH CUSTOM LOOT";//Remove This line after testing
  17.  
  18. switch (_type) do { //Assign building classes
  19.     case "Land_HouseV_1I4": { _LootClass = "Residential"; };
  20.     case "Land_kulna": { _LootClass = "Residential"; };
  21.     case "Land_Ind_Workshop01_04": { _LootClass = "Residential"; };
  22.     case "Land_hut06": { _LootClass = "Residential"; };
  23.     case "Land_Hlidac_budka": { _LootClass = "Residential"; };
  24.     case "Land_HouseV2_02_Interier": { _LootClass = "Residential"; };
  25.     case "Land_A_Pub_01": { _LootClass = "Residential"; };
  26.     case "Land_Shed_wooden": { _LootClass = "Residential"; };
  27.     case "Land_HouseBlock_A1_1": { _LootClass = "Residential"; };
  28.     case "Land_A_MunicipalOffice": { _LootClass = "Residential"; };
  29.     case "Land_ruin_01": { _LootClass = "Residential"; };
  30.     case "Land_HouseV2_04_interier": { _LootClass = "Residential"; };
  31.     case "Land_HouseV2_01A": { _LootClass = "Residential"; };
  32.     case "Land_psi_bouda": { _LootClass = "Residential"; };
  33.     case "Land_KBud": { _LootClass = "Residential"; };
  34.     case "Land_A_Castle_Bergfrit": { _LootClass = "Residential"; };
  35.     case "Land_A_Castle_Stairs_A": { _LootClass = "Residential"; };
  36.     case "Land_A_Castle_Gate": { _LootClass = "Residential"; };
  37.     case "Land_sara_domek_zluty": { _LootClass = "Residential"; };
  38.     case "Land_Church_01": { _LootClass = "Residential"; };
  39.     case "Land_Church_03": { _LootClass = "Residential"; };
  40.     case "Land_HouseB_Tenement": { _LootClass = "Residential"; };
  41.     case "Land_Panelak": { _LootClass = "Residential"; };
  42.     case "Land_Panelak2": { _LootClass = "Residential"; };
  43.     case "Land_rail_station_big": { _LootClass = "Residential"; };
  44.     case "Land_A_Office01": { _LootClass = "Residential"; };
  45.     case "Land_A_Office02": { _LootClass = "Residential"; };
  46.     case "Land_Ind_Workshop01_01": { _LootClass = "Industrial"; };
  47.     case "Land_Ind_Garage01": { _LootClass = "Industrial"; };
  48.     case "Land_Ind_Workshop01_02": { _LootClass = "Industrial"; };
  49.     case "Land_Ind_Workshop01_L": { _LootClass = "Industrial"; };
  50.     case "Land_Hangar_2": { _LootClass = "Industrial"; };
  51.     case "Land_A_FuelStation_Build": { _LootClass = "Industrial"; };
  52.     case "Land_Shed_Ind02": { _LootClass = "Industrial"; };
  53.     case "Land_Misc_PowerStation": { _LootClass = "Industrial"; };
  54.     case "Land_Shed_W01": { _LootClass = "Industrial"; };
  55.     case "Land_Tovarna2": { _LootClass = "Industrial"; };
  56.     case "Land_Ind_Vysypka": { _LootClass = "Industrial"; };
  57.     case "Land_A_BuildingWIP": { _LootClass = "Industrial"; };
  58.     case "Land_A_TVTower_Base": { _LootClass = "Industrial"; };
  59.     case "Land_Misc_Cargo1Ao": { _LootClass = "Industrial"; };
  60.     case "Land_Misc_Cargo1Bo": { _LootClass = "Industrial"; };
  61.     case "Land_Nav_Boathouse": { _LootClass = "Industrial"; };
  62.     case "Land_wagon_box": { _LootClass = "Industrial"; };
  63.     case "Land_Rail_House_01": { _LootClass = "Industrial"; };
  64.     case "Land_A_GeneralStore_01a": { _LootClass = "Supermarket"; };
  65.     case "Land_A_GeneralStore_01": { _LootClass = "Supermarket"; };
  66.     case "Land_A_Hospital": { _LootClass = "Hospital"; };
  67.     case "MASH": { _LootClass = "Hospital"; };
  68.     case "MASH_EP1": { _LootClass = "Hospital"; };
  69.     case "USMC_WarfareBFieldhHospital": { _LootClass = "Hospital"; };
  70.     case "Land_a_stationhouse": { _LootClass = "Military"; };
  71.     case "Land_Mil_ControlTower": { _LootClass = "Military"; };
  72.     case "Land_SS_hangar": { _LootClass = "Military"; };
  73.     case "Land_Mil_House": { _LootClass = "Military"; };
  74.     case "Camp": { _LootClass = "Military"; };
  75.     case "CampEast": { _LootClass = "Military"; };
  76.     case "CampEast_EP1": { _LootClass = "Military"; };
  77.     case "Land_Mil_Barracks_i": { _LootClass = "MilitarySpecial"; };
  78.     case "Land_Misc_deerstand": { _LootClass = "Hunting"; };
  79.     default { _LootClass = "Residential"; };
  80. };
  81.  
  82. switch (_LootClass) do { //Find correct loot
  83.     case "Residential": {
  84.         _itemTypes = [
  85.             ["ItemSodaMdew","magazine"],
  86.             ["ItemWatch","generic"],
  87.             ["ItemCompass","generic"],
  88.             ["ItemMap","weapon"],
  89.             ["Makarov","weapon"],
  90.             ["Colt1911","weapon"],
  91.             ["ItemFlashlight","generic"],
  92.             ["ItemKnife","generic"],
  93.             ["ItemMatchbox","generic"],
  94.             ["","generic"],
  95.             ["LeeEnfield","weapon"],
  96.             ["revolver_EP1","weapon"],
  97.            
  98.             ["DZ_Assault_Pack_EP1","object"], // 12
  99.             ["DZ_Czech_Vest_Puch","object"], // 12-0
  100.             ["DZ_ALICE_Pack_EP1","object"], // 16
  101.             ["DZ_TK_Assault_Pack_EP1","object"], // 16
  102.             ["DZ_British_ACU","object"], // 18
  103.            
  104.             ["Winchester1866","weapon"],
  105.             ["WeaponHolder_ItemTent","object"],
  106.             ["","military"],
  107.             ["","trash"],
  108.             ["Crossbow_DZ","weapon"],
  109.             ["Binocular","weapon"],
  110.             ["PartWoodPile","magazine"],
  111.             ["Skin_Camo1_DZ","magazine"],
  112.             ["Skin_Sniper1_DZ","magazine"],
  113.             ["WeaponHolder_ItemCrowbar","object"],
  114.             ["MR43","weapon"] // Remember the last object doesn't not need a comma
  115.          ];
  116.         _itemChance = [
  117.             0.01,
  118.             0.15,
  119.             0.05,
  120.             0.03,
  121.             0.13,
  122.             0.05,
  123.             0.03,
  124.             0.08,
  125.             0.06,
  126.             2,
  127.             0.06,
  128.             0.04,
  129.             0.05, //12
  130.             0.04, // 12-0
  131.             0.02, //16
  132.             0.02, //16
  133.             0.01, //18
  134.             0.01,
  135.             0.01,
  136.             0.03,
  137.             0.5,
  138.             0.01,
  139.             0.06,
  140.             0.06,
  141.             0.01,
  142.             0.01,
  143.             0.08,
  144.             0.03
  145.         ];
  146.     };
  147.     case "Industrial": {
  148.         _itemTypes = [
  149.             ["","generic"],
  150.             ["","trash"],
  151.             ["","military"],
  152.             ["WeaponHolder_PartGeneric","object"],
  153.             ["WeaponHolder_PartWheel","object"],
  154.             ["WeaponHolder_PartFueltank","object"],
  155.             ["WeaponHolder_PartEngine","object"],
  156.             ["WeaponHolder_PartGlass","object"],
  157.             ["WeaponHolder_PartVRotor","object"],
  158.             ["WeaponHolder_ItemJerrycan","object"],
  159.             ["WeaponHolder_ItemHatchet","object"],
  160.             ["ItemKnife","military"],
  161.             ["ItemToolbox","weapon"],
  162.             ["ItemWire","magazine"],
  163.             ["ItemTankTrap","magazine"]
  164.         ];
  165.         _itemChance = [
  166.             0.18,
  167.             0.29,
  168.             0.04,
  169.             0.04,
  170.             0.05,
  171.             0.02,
  172.             0.02,
  173.             0.04,
  174.             0.01,
  175.             0.04,
  176.             0.11,
  177.             0.07,
  178.             0.06,
  179.             0.01,
  180.             0.04
  181.         ];
  182.     };
  183.     case "Farm": {
  184.         _itemTypes = [
  185.             ["WeaponHolder_ItemJerrycan","object"],
  186.             ["","generic"],
  187.             ["huntingrifle","weapon"],
  188.             ["LeeEnfield","weapon"],
  189.             ["Winchester1866","weapon"],
  190.             ["","trash"],
  191.             ["Crossbow_DZ","weapon"],
  192.             ["PartWoodPile","magazine"],
  193.             ["WeaponHolder_ItemHatchet","object"],
  194.             ["MR43","weapon"],
  195.             ["WeaponHolder_ItemMachete","object"]
  196.         ];
  197.         _itemChance = [
  198.             0.06,
  199.             0.28,
  200.             0.01,
  201.             0.04,
  202.             0.03,
  203.             0.22,
  204.             0.03,
  205.             0.11,
  206.             0.17,
  207.             0.06,
  208.             0.03
  209.         ];
  210.     };
  211.     case "Supermarket": {
  212.         _itemTypes = [
  213.             ["ItemWatch","generic"],
  214.             ["ItemCompass","generic"],
  215.             ["ItemMap","weapon"],
  216.             ["Makarov","weapon"],
  217.             ["Colt1911","weapon"],
  218.             ["ItemFlashlight","generic"],
  219.             ["ItemKnife","generic"],
  220.             ["ItemMatchbox","generic"],
  221.             ["","generic"],
  222.             ["LeeEnfield","weapon"],
  223.             ["revolver_EP1","weapon"],
  224.                    
  225.             ["DZ_Assault_Pack_EP1","object"], // 12
  226.             ["DZ_Czech_Vest_Puch","object"], // 12-0
  227.             ["DZ_ALICE_Pack_EP1","object"], // 16
  228.             ["DZ_TK_Assault_Pack_EP1","object"], // 16
  229.             ["DZ_British_ACU","object"], // 18
  230.            
  231.             ["Winchester1866","weapon"],
  232.             ["WeaponHolder_ItemTent","object"],
  233.             ["","food"],
  234.             ["","trash"],
  235.             ["Crossbow_DZ","weapon"],
  236.             ["Binocular","weapon"],
  237.             ["PartWoodPile","magazine"],
  238.             ["MR43","weapon"]
  239.         ];
  240.         _itemChance = [
  241.             0.15,
  242.             0.01,
  243.             0.05,
  244.             0.02,
  245.             0.02,
  246.             0.05,
  247.             0.02,
  248.             0.05,
  249.             0.05,
  250.             0.01,
  251.             0.01,
  252.             0.05, //12
  253.             0.04, // 12-0
  254.             0.02, //16
  255.             0.02, //16
  256.             0.01, //18
  257.             0.01,
  258.             0.01,
  259.             0.3,
  260.             0.15,
  261.             0.01,
  262.             0.05,
  263.             0.02,
  264.             0.01
  265.         ];
  266.     };
  267.     case "Hospital": {
  268.         _itemTypes =    [
  269.             ["","trash"],
  270.             ["","hospital"],
  271.             ["MedBox0","object"]
  272.         ];
  273.         _itemChance = [
  274.             0.2,
  275.             1,
  276.             0.2
  277.         ];
  278.     };
  279.     case "Military": {
  280.         _itemTypes = [
  281.             ["M9","weapon"],
  282.             ["M16A2","weapon"],
  283.             ["M16A2GL","weapon"],
  284.             ["M9SD","weapon"],
  285.             ["AK_74","weapon"],
  286.             ["M4A1_Aim","weapon"],
  287.             ["AKS_74_kobra","weapon"],
  288.             ["AKS_74_U","weapon"],
  289.             ["AK_47_M","weapon"],
  290.             ["M24","weapon"],
  291.             ["M1014","weapon"],
  292.             ["DMR","weapon"],
  293.             ["M4A1","weapon"],
  294.             ["M14_EP1","weapon"],
  295.             ["UZI_EP1","weapon"],
  296.             ["Remington870_lamp","weapon"],
  297.             ["glock17_EP1","weapon"],
  298.             ["MP5A5","weapon"],
  299.             ["MP5SD","weapon"],
  300.             ["M4A3_CCO_EP1","weapon"],
  301.             ["Binocular","weapon"],
  302.             ["ItemFlashlightRed","military"],
  303.             ["ItemKnife","military"],
  304.             ["ItemGPS","weapon"],
  305.             ["ItemMap","military"],
  306.            
  307.             ["DZ_ALICE_Pack_EP1","object"], // 16
  308.             ["DZ_TK_Assault_Pack_EP1","object"], // 16
  309.             ["DZ_British_ACU","object"], // 18
  310.             ["DZ_CivilBackpack_EP1","object"], // 24
  311.             ["DZ_Backpack_EP1","object"], // 24
  312.            
  313.             //Normal
  314.             ["","medical"],
  315.             ["","generic"],
  316.             ["","military"],
  317.             //["Body","object"],
  318.             ["ItemEtool","weapon"],
  319.             ["ItemSandbag","magazine"],
  320.             ["Sa58P_EP1","weapon"],
  321.             ["Sa58V_EP1","weapon"],
  322.             ["BAF_L85A2_RIS_Holo","weapon"]
  323.         ];
  324.         _itemChance = [
  325.             0.05,
  326.             0.05,
  327.             0.01,
  328.             0.02,
  329.             0.15,
  330.             0.01,
  331.             0.08,
  332.             0.05,
  333.             0.05,
  334.             0.01,
  335.             0.10,
  336.             0.01,
  337.             0.02,
  338.             0.01,
  339.             0.05,
  340.             0.08,
  341.             0.10,
  342.             0.04,
  343.             0.02,
  344.             0.01,
  345.             0.06,
  346.             0.10,
  347.             0.10,
  348.             0.01,
  349.             0.05,
  350.             //Bags
  351.             0.08, //16
  352.             0.08, //16
  353.             0.06, //18
  354.             0.01, //24
  355.             0.01, //DZ_Backpack_EP1 24
  356.             0.10,
  357.             1.00,
  358.             2.50,
  359.             //0.20,
  360.             0.05,
  361.             0.02,
  362.             0.03,
  363.             0.03,
  364.             0.01
  365.         ];
  366.     };
  367.     case "MilitarySpecial": {
  368.         _itemTypes = [
  369.             ["M16A2","weapon"],
  370.             ["M16A2GL","weapon"],
  371.             ["M249_DZ","weapon"],
  372.             ["M9SD","weapon"],
  373.             //["M136","weapon"],
  374.             ["AK_74","weapon"],
  375.             ["M4A1_Aim","weapon"],
  376.             ["AKS_74_kobra","weapon"],
  377.             ["AKS_74_U","weapon"],
  378.             ["AK_47_M","weapon"],
  379.             ["M24","weapon"],
  380.             ["SVD_CAMO","weapon"],
  381.             ["M1014","weapon"],
  382.             ["M107_DZ","weapon"],
  383.             ["DMR","weapon"],
  384.             ["M4A1","weapon"],
  385.             ["M14_EP1","weapon"],
  386.             ["UZI_EP1","weapon"],
  387.             ["Remington870_lamp","weapon"],
  388.             ["glock17_EP1","weapon"],
  389.             ["M240_DZ","weapon"],
  390.             ["M4A1_AIM_SD_camo","weapon"],
  391.             ["M16A4_ACG","weapon"],
  392.             ["M4A1_HWS_GL_camo","weapon"],
  393.             ["Mk_48_DZ","weapon"],
  394.             ["M4A3_CCO_EP1","weapon"],
  395.             //Ammo
  396.             ["AmmoBoxSmall_556","object"],
  397.             ["AmmoBoxSmall_762","object"],
  398.  
  399.             //["NVGoggles","weapon"],
  400.             ["Binocular","weapon"],
  401.             ["ItemFlashlightRed","military"],
  402.             ["ItemKnife","military"],
  403.             ["ItemGPS","weapon"],
  404.             ["ItemMap","military"],
  405.             ["Binocular_Vector","military"],
  406.  
  407.             ["DZ_ALICE_Pack_EP1","object"], // 16
  408.             ["DZ_TK_Assault_Pack_EP1","object"], // 16
  409.             ["DZ_British_ACU","object"], // 18
  410.             ["DZ_CivilBackpack_EP1","object"], // 24
  411.             ["DZ_Backpack_EP1","object"], // 24    
  412.  
  413.             ["","medical"],
  414.             ["","generic"],
  415.             ["","military"],
  416.             //["Body","object"],
  417.             ["PipeBomb","magazine"],
  418.             ["Sa58V_RCO_EP1","weapon"],
  419.             ["Sa58V_CCO_EP1","weapon"],
  420.             //["G36_C_SD_camo","weapon"],
  421.             ["M40A3","weapon"],
  422.             ["100Rnd_762x54_PK","magazine"]
  423.         ];
  424.         _itemChance = [
  425.             0.10,
  426.             0.05,
  427.             0.01,
  428.             0.02,
  429.             //0.01, //m136
  430.             0.10,
  431.             0.02,
  432.             0.10,
  433.             0.10,
  434.             0.10,
  435.             0.01,
  436.             0.01,
  437.             0.20,
  438.             0.01,
  439.             0.02,
  440.             0.10,
  441.             0.03,
  442.             0.20,
  443.             0.10,
  444.             0.20,
  445.             0.01,
  446.             0.04,
  447.             0.05,
  448.             0.02,
  449.             0.01,
  450.             0.08,
  451.             0.04,
  452.             0.02,
  453.             //0.01, //NVGoggles
  454.             0.10,
  455.             0.05,
  456.             0.15,
  457.             0.01, //ItemGPS
  458.             0.03,
  459.             0.01,
  460.             //Bags
  461.             0.08, //16
  462.             0.08, //16
  463.             0.06, //18
  464.             0.01, //24
  465.             0.01, //DZ_Backpack_EP1 24
  466.             0.30,
  467.             1.00,
  468.             5.00, //military
  469.             //0.20,
  470.             0.01, //PipeBomb
  471.             0.01, //Sa58V_RCO_EP1
  472.             0.01, //Sa58V_CCO_EP1
  473.             //0.01, //["G36_C_SD_camo","weapon"],
  474.             0.02, // M40A3
  475.             0.01    //["100Rnd_762x54_PK","magazine"]
  476.         ];
  477.     };
  478.     case "Hunting": {
  479.         _itemTypes = [
  480.             ["ItemMap","weapon"],
  481.             ["ItemFlashlight","generic"],
  482.             ["ItemKnife","generic"],
  483.             ["ItemMatchbox","generic"],
  484.             ["Crossbow_DZ","weapon"],
  485.             ["","military"],
  486.             ["WeaponHolder_ItemMachete", "object"],
  487.             ["huntingrifle","weapon"],
  488.             ["","hunter"]
  489.         ];
  490.         _itemChance = [
  491.             0.08,
  492.             0.05,
  493.             0.04,
  494.             0.06,
  495.             0.03,
  496.             2.00,
  497.             0.03,
  498.             0.04,
  499.             3.00
  500.         ];
  501.     };
  502. };
  503. //------------------//
  504. //CUSTOM LOOT SPAWNS//
  505. //------------------//
  506. {
  507.     if ((random 1) < _lootChance) then {
  508.         _iPos = _obj modelToWorld _x;
  509.         _nearBy = nearestObjects [_iPos, ["WeaponHolder","WeaponHolderBase"], 1];
  510.         if (count _nearBy == 0) then {
  511.             private["_index"];
  512.             _weights = [_itemTypes,_itemChance] call fnc_buildWeightedArray;
  513.             _index = _weights call BIS_fnc_selectRandom;
  514.             _itemType = _itemTypes select _index;
  515.             [_itemType select 0, _itemType select 1 , _iPos, 0.0]  call spawn_loot;
  516.         };
  517.     };
  518. } forEach _positions;
Advertisement
Add Comment
Please, Sign In to add comment