Guest User

Untitled

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