Advertisement
Guest User

Untitled

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