Advertisement
Guest User

Untitled

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