Advertisement
Guest User

My Mission

a guest
May 6th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.94 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.01,
  122. 0.15,
  123. 0.05,
  124. 0.03,
  125. 0.13,
  126. 0.05,
  127. 0.03,
  128. 0.08,
  129. 0.06,
  130. 2,
  131. 0.06,
  132. 0.04,
  133. 0.05, //12
  134. 0.04, // 12-0
  135. 0.02, //16
  136. 0.02, //16
  137. 0.01, //18
  138. 0.01,
  139. 0.01,
  140. 0.03,
  141. 0.5,
  142. 0.01,
  143. 0.06,
  144. 0.06,
  145. 0.01,
  146. 0.01,
  147. 0.08,
  148. 0.03
  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. ];
  169. _itemChance = [
  170. 0.18,
  171. 0.29,
  172. 0.04,
  173. 0.04,
  174. 0.05,
  175. 0.02,
  176. 0.02,
  177. 0.04,
  178. 0.01,
  179. 0.04,
  180. 0.11,
  181. 0.07,
  182. 0.06,
  183. 0.01,
  184. 0.04
  185. ];
  186. };
  187. case "Farm": {
  188. _itemTypes = [
  189. ["WeaponHolder_ItemJerrycan","object"],
  190. ["","generic"],
  191. ["huntingrifle","weapon"],
  192. ["LeeEnfield","weapon"],
  193. ["Winchester1866","weapon"],
  194. ["","trash"],
  195. ["Crossbow_DZ","weapon"],
  196. ["PartWoodPile","magazine"],
  197. ["WeaponHolder_ItemHatchet","object"],
  198. ["MR43","weapon"],
  199. ["WeaponHolder_ItemMachete","object"]
  200. ];
  201. _itemChance = [
  202. 0.06,
  203. 0.28,
  204. 0.01,
  205. 0.04,
  206. 0.03,
  207. 0.22,
  208. 0.03,
  209. 0.11,
  210. 0.17,
  211. 0.06,
  212. 0.03
  213. ];
  214. };
  215. case "Supermarket": {
  216. _itemTypes = [
  217. ["ItemWatch","generic"],
  218. ["ItemCompass","generic"],
  219. ["ItemMap","weapon"],
  220. ["Makarov","weapon"],
  221. ["Colt1911","weapon"],
  222. ["ItemFlashlight","generic"],
  223. ["ItemKnife","generic"],
  224. ["ItemMatchbox","generic"],
  225. ["","generic"],
  226. ["LeeEnfield","weapon"],
  227. ["revolver_EP1","weapon"],
  228.  
  229. ["DZ_Assault_Pack_EP1","object"], // 12
  230. ["DZ_Czech_Vest_Puch","object"], // 12-0
  231. ["DZ_ALICE_Pack_EP1","object"], // 16
  232. ["DZ_TK_Assault_Pack_EP1","object"], // 16
  233. ["DZ_British_ACU","object"], // 18
  234.  
  235. ["Winchester1866","weapon"],
  236. ["WeaponHolder_ItemTent","object"],
  237. ["","food"],
  238. ["","trash"],
  239. ["Crossbow_DZ","weapon"],
  240. ["Binocular","weapon"],
  241. ["PartWoodPile","magazine"],
  242. ["MR43","weapon"]
  243. ];
  244. _itemChance = [
  245. 0.15,
  246. 0.01,
  247. 0.05,
  248. 0.02,
  249. 0.02,
  250. 0.05,
  251. 0.02,
  252. 0.05,
  253. 0.05,
  254. 0.01,
  255. 0.01,
  256. 0.05, //12
  257. 0.04, // 12-0
  258. 0.02, //16
  259. 0.02, //16
  260. 0.01, //18
  261. 0.01,
  262. 0.01,
  263. 0.3,
  264. 0.15,
  265. 0.01,
  266. 0.05,
  267. 0.02,
  268. 0.01
  269. ];
  270. };
  271. case "Hospital": {
  272. _itemTypes = [
  273. ["","trash"],
  274. ["","hospital"],
  275. ["MedBox0","object"]
  276. ];
  277. _itemChance = [
  278. 0.2,
  279. 1,
  280. 0.2
  281. ];
  282. };
  283. case "Military": {
  284. _itemTypes = [
  285. ["M9","weapon"],
  286. ["M16A2","weapon"],
  287. ["M16A2GL","weapon"],
  288. ["M9SD","weapon"],
  289. ["AK_74","weapon"],
  290. ["M4A1_Aim","weapon"],
  291. ["AKS_74_kobra","weapon"],
  292. ["AKS_74_U","weapon"],
  293. ["AK_47_M","weapon"],
  294. ["M24","weapon"],
  295. ["M1014","weapon"],
  296. ["DMR","weapon"],
  297. ["M4A1","weapon"],
  298. ["M14_EP1","weapon"],
  299. ["UZI_EP1","weapon"],
  300. ["Remington870_lamp","weapon"],
  301. ["glock17_EP1","weapon"],
  302. ["MP5A5","weapon"],
  303. ["MP5SD","weapon"],
  304. ["M4A3_CCO_EP1","weapon"],
  305. ["Binocular","weapon"],
  306. ["ItemFlashlightRed","military"],
  307. ["ItemKnife","military"],
  308. ["ItemGPS","weapon"],
  309. ["ItemMap","military"],
  310.  
  311. ["DZ_ALICE_Pack_EP1","object"], // 16
  312. ["DZ_TK_Assault_Pack_EP1","object"], // 16
  313. ["DZ_British_ACU","object"], // 18
  314. ["DZ_CivilBackpack_EP1","object"], // 24
  315. ["DZ_Backpack_EP1","object"], // 24
  316.  
  317. //Normal
  318. ["","medical"],
  319. ["","generic"],
  320. ["","military"],
  321. //["Body","object"],
  322. ["ItemEtool","weapon"],
  323. ["ItemSandbag","magazine"],
  324. ["Sa58P_EP1","weapon"],
  325. ["Sa58V_EP1","weapon"],
  326. ["BAF_L85A2_RIS_Holo","weapon"]
  327. ];
  328. _itemChance = [
  329. 0.05,
  330. 0.05,
  331. 0.01,
  332. 0.02,
  333. 0.15,
  334. 0.01,
  335. 0.08,
  336. 0.05,
  337. 0.05,
  338. 0.01,
  339. 0.10,
  340. 0.01,
  341. 0.02,
  342. 0.01,
  343. 0.05,
  344. 0.08,
  345. 0.10,
  346. 0.04,
  347. 0.02,
  348. 0.01,
  349. 0.06,
  350. 0.10,
  351. 0.10,
  352. 0.01,
  353. 0.05,
  354. //Bags
  355. 0.08, //16
  356. 0.08, //16
  357. 0.06, //18
  358. 0.01, //24
  359. 0.01, //DZ_Backpack_EP1 24
  360. 0.10,
  361. 1.00,
  362. 2.50,
  363. //0.20,
  364. 0.05,
  365. 0.02,
  366. 0.03,
  367. 0.03,
  368. 0.01
  369. ];
  370. };
  371. case "MilitarySpecial": {
  372. _itemTypes = [
  373. ["SCAR_L_CQC","weapon"],
  374. ["M16A2","weapon"],
  375. ["M16A2GL","weapon"],
  376. ["M249_DZ","weapon"],
  377. ["M9SD","weapon"],
  378. //["M136","weapon"],
  379. ["AK_74","weapon"],
  380. ["M4A1_Aim","weapon"],
  381. ["AKS_74_kobra","weapon"],
  382. ["AKS_74_U","weapon"],
  383. ["AK_47_M","weapon"],
  384. ["M24","weapon"],
  385. ["SVD_CAMO","weapon"],
  386. ["M1014","weapon"],
  387. ["M107_DZ","weapon"],
  388. ["DMR","weapon"],
  389. ["M4A1","weapon"],
  390. ["M14_EP1","weapon"],
  391. ["UZI_EP1","weapon"],
  392. ["Remington870_lamp","weapon"],
  393. ["glock17_EP1","weapon"],
  394. ["M240_DZ","weapon"],
  395. ["M4A1_AIM_SD_camo","weapon"],
  396. ["M16A4_ACG","weapon"],
  397. ["M4A1_HWS_GL_camo","weapon"],
  398. ["Mk_48_DZ","weapon"],
  399. ["M4A3_CCO_EP1","weapon"],
  400. //Ammo
  401. ["AmmoBoxSmall_556","object"],
  402. ["AmmoBoxSmall_762","object"],
  403.  
  404. ["NVGoggles","weapon"],
  405. ["Binocular","weapon"],
  406. ["ItemFlashlightRed","military"],
  407. ["ItemKnife","military"],
  408. ["ItemGPS","weapon"],
  409. ["ItemMap","military"],
  410. ["Binocular_Vector","military"],
  411.  
  412. ["DZ_ALICE_Pack_EP1","object"], // 16
  413. ["DZ_TK_Assault_Pack_EP1","object"], // 16
  414. ["DZ_British_ACU","object"], // 18
  415. ["DZ_CivilBackpack_EP1","object"], // 24
  416. ["DZ_Backpack_EP1","object"], // 24
  417.  
  418. ["","medical"],
  419. ["","generic"],
  420. ["","military"],
  421. //["Body","object"],
  422. ["PipeBomb","magazine"],
  423. ["Sa58V_RCO_EP1","weapon"],
  424. ["Sa58V_CCO_EP1","weapon"],
  425. //["G36_C_SD_camo","weapon"],
  426. ["M40A3","weapon"],
  427. ["100Rnd_762x54_PK","magazine"]
  428. ];
  429. _itemChance = [
  430. 0.20,
  431. 0.10,
  432. 0.05,
  433. 0.01,
  434. 0.02,
  435. //0.01, //m136
  436. 0.10,
  437. 0.02,
  438. 0.10,
  439. 0.10,
  440. 0.10,
  441. 0.01,
  442. 0.01,
  443. 0.20,
  444. 0.01,
  445. 0.02,
  446. 0.10,
  447. 0.03,
  448. 0.20,
  449. 0.10,
  450. 0.20,
  451. 0.01,
  452. 0.04,
  453. 0.05,
  454. 0.02,
  455. 0.01,
  456. 0.08,
  457. 0.04,
  458. 0.02,
  459. 0.30,
  460. 0.10,
  461. 0.05,
  462. 0.15,
  463. 0.10,
  464. 0.03,
  465. 0.10,
  466. //Bags
  467. 0.08, //16
  468. 0.08, //16
  469. 0.06, //18
  470. 0.01, //24
  471. 0.01, //DZ_Backpack_EP1 24
  472. 0.30,
  473. 1.00,
  474. 5.00, //military
  475. //0.20,
  476. 0.01, //PipeBomb
  477. 0.01, //Sa58V_RCO_EP1
  478. 0.01, //Sa58V_CCO_EP1
  479. //0.01, //["G36_C_SD_camo","weapon"],
  480. 0.02, // M40A3
  481. 0.01 //["100Rnd_762x54_PK","magazine"]
  482. ];
  483. };
  484. case "Hunting": {
  485. _itemTypes = [
  486. ["ItemMap","weapon"],
  487. ["ItemFlashlight","generic"],
  488. ["ItemKnife","generic"],
  489. ["ItemMatchbox","generic"],
  490. ["Crossbow_DZ","weapon"],
  491. ["","military"],
  492. ["WeaponHolder_ItemMachete", "object"],
  493. ["huntingrifle","weapon"],
  494. ["","hunter"]
  495. ];
  496. _itemChance = [
  497. 0.08,
  498. 0.05,
  499. 0.04,
  500. 0.06,
  501. 0.03,
  502. 2.00,
  503. 0.03,
  504. 0.04,
  505. 3.00
  506. ];
  507. };
  508. };
  509. //------------------//
  510. //CUSTOM LOOT SPAWNS//
  511. //------------------//
  512. {
  513. if ((random 1) < _lootChance) then {
  514. _iPos = _obj modelToWorld _x;
  515. _nearBy = nearestObjects [_iPos, ["WeaponHolder","WeaponHolderBase"], 1];
  516. if (count _nearBy == 0) then {
  517. private["_index"];
  518. _weights = [_itemTypes,_itemChance] call fnc_buildWeightedArray;
  519. _index = _weights call BIS_fnc_selectRandom;
  520. _itemType = _itemTypes select _index;
  521. [_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot;
  522. };
  523. };
  524. } forEach _positions;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement