View difference between Paste ID: bWNUV2xm and TQNKdg3W
SHOW: | | - or go back to the newest paste.
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
	case "Land_stodola_old_open": { _LootClass = "Farm"; };
80
	case "Land_Farm_Cowshed_a": { _LootClass = "Farm"; };
81
	case "Land_stodola_open": { _LootClass = "Farm"; };
82
	case "Land_Barn_W_01": { _LootClass = "Farm"; };
83
	case "Land_Barn_W_02": { _LootClass = "Farm"; };
84
	default { _LootClass = "Residential"; };
85
};
86
87
switch (_LootClass) do { //Find correct loot
88
	case "Residential": {
89
		_itemTypes = [
90
			["ItemSodaMdew","magazine"],
91
			["ItemWatch","generic"],
92
			["ItemCompass","generic"],
93
			["ItemMap","weapon"],
94
			["Makarov","weapon"],
95
			["Colt1911","weapon"],
96
			["ItemFlashlight","generic"],
97
			["ItemKnife","generic"],
98
			["ItemMatchbox","generic"],
99
			["","generic"],
100
			["LeeEnfield","weapon"],
101
			["revolver_EP1","weapon"],
102
			
103
			["DZ_Assault_Pack_EP1","object"], // 12
104
			["DZ_Czech_Vest_Puch","object"], // 12-0
105
			["DZ_ALICE_Pack_EP1","object"], // 16
106
			["DZ_TK_Assault_Pack_EP1","object"], // 16
107
			["DZ_British_ACU","object"], // 18
108
			
109
			["Winchester1866","weapon"],
110
			["WeaponHolder_ItemTent","object"],
111
			["","military"],
112
			["","trash"],
113
			["Crossbow_DZ","weapon"],
114
			["Binocular","weapon"],
115
			["PartWoodPile","magazine"],
116
			["Skin_Camo1_DZ","magazine"],
117
			["Skin_Sniper1_DZ","magazine"],
118
			["WeaponHolder_ItemCrowbar","object"],
119
			["MR43","weapon"] // Remember the last object doesn't not need a comma
120
		 ];
121
		_itemChance = [
122
			0.01,
123
			0.15,
124
			0.05,
125
			0.03,
126
			0.13,
127
			0.05,
128
			0.03,
129
			0.08,
130
			0.06,
131
			2,
132
			0.06,
133
			0.04,
134
			0.05, //12
135
			0.04, // 12-0
136
			0.02, //16
137
			0.02, //16
138
			0.01, //18
139
			0.01,
140
			0.01,
141
			0.03,
142
			0.5,
143
			0.01,
144
			0.06,
145
			0.06,
146
			0.01,
147
			0.01,
148
			0.08,
149
			0.03
150
		];
151
	};
152
	case "Industrial": {
153
		_itemTypes = [
154
			["","generic"],
155
			["","trash"],
156
			["","military"],
157
			["WeaponHolder_PartGeneric","object"],
158
			["WeaponHolder_PartWheel","object"],
159
			["WeaponHolder_PartFueltank","object"],
160
			["WeaponHolder_PartEngine","object"],
161
			["WeaponHolder_PartGlass","object"],
162
			["WeaponHolder_PartVRotor","object"],
163
			["WeaponHolder_ItemJerrycan","object"],
164
			["WeaponHolder_ItemHatchet","object"],
165
			["ItemKnife","military"],
166
			["ItemToolbox","weapon"],
167
			["ItemWire","magazine"],
168
			["ItemTankTrap","magazine"]
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
		];
187
	};
188
	case "Farm": {
189
		_itemTypes = [
190
			["WeaponHolder_ItemJerrycan","object"],
191
			["","generic"],
192
			["huntingrifle","weapon"],
193
			["LeeEnfield","weapon"],
194
			["Winchester1866","weapon"],
195
			["","trash"],
196
			["Crossbow_DZ","weapon"],
197
			["PartWoodPile","magazine"],
198
			["WeaponHolder_ItemHatchet","object"],
199
			["MR43","weapon"],
200
			["WeaponHolder_ItemMachete","object"]
201
		];
202
		_itemChance = [
203
			0.06,
204
			0.28,
205
			0.01,
206
			0.04,
207
			0.03,
208
			0.22,
209
			0.03,
210
			0.11,
211
			0.17,
212
			0.06,
213
			0.03
214
		];
215
	};
216
	case "Supermarket": {
217
		_itemTypes = [
218
			["ItemWatch","generic"],
219
			["ItemCompass","generic"],
220
			["ItemMap","weapon"],
221
			["Makarov","weapon"],
222
			["Colt1911","weapon"],
223
			["ItemFlashlight","generic"],
224
			["ItemKnife","generic"],
225
			["ItemMatchbox","generic"],
226
			["","generic"],
227
			["LeeEnfield","weapon"],
228
			["revolver_EP1","weapon"],
229
					
230
			["DZ_Assault_Pack_EP1","object"], // 12
231
			["DZ_Czech_Vest_Puch","object"], // 12-0
232
			["DZ_ALICE_Pack_EP1","object"], // 16
233
			["DZ_TK_Assault_Pack_EP1","object"], // 16
234
			["DZ_British_ACU","object"], // 18
235
			
236
			["Winchester1866","weapon"],
237
			["WeaponHolder_ItemTent","object"],
238
			["","food"],
239
			["","trash"],
240
			["Crossbow_DZ","weapon"],
241
			["Binocular","weapon"],
242
			["PartWoodPile","magazine"],
243
			["MR43","weapon"]
244
		];
245
		_itemChance = [
246
			0.15,
247
			0.01,
248
			0.05,
249
			0.02,
250
			0.02,
251
			0.05,
252
			0.02,
253
			0.05,
254
			0.05,
255
			0.01,
256
			0.01,
257
			0.05, //12
258
			0.04, // 12-0
259
			0.02, //16
260
			0.02, //16
261
			0.01, //18
262
			0.01,
263
			0.01,
264
			0.3,
265
			0.15,
266
			0.01,
267
			0.05,
268
			0.02,
269
			0.01
270
		];
271
	};
272
	case "Hospital": {
273
		_itemTypes =	[
274
			["","trash"],
275
			["","hospital"],
276
			["MedBox0","object"]
277
		];
278
		_itemChance = [
279
			0.2,
280
			1,
281
			0.2
282
		];
283
	};
284
	case "Military": {
285
		_itemTypes = [
286
			["M9","weapon"],
287
			["M16A2","weapon"],
288
			["M16A2GL","weapon"],
289
			["M9SD","weapon"],
290
			["AK_74","weapon"],
291
			["M4A1_Aim","weapon"],
292
			["AKS_74_kobra","weapon"],
293
			["AKS_74_U","weapon"],
294
			["AK_47_M","weapon"],
295
			["M24","weapon"],
296
			["M1014","weapon"],
297
			["DMR","weapon"],
298
			["M4A1","weapon"],
299
			["M14_EP1","weapon"],
300
			["UZI_EP1","weapon"],
301
			["Remington870_lamp","weapon"],
302
			["glock17_EP1","weapon"],
303
			["MP5A5","weapon"],
304
			["MP5SD","weapon"],
305
			["M4A3_CCO_EP1","weapon"],
306
			["Binocular","weapon"],
307
			["ItemFlashlightRed","military"],
308
			["ItemKnife","military"],
309
			["ItemGPS","weapon"],
310
			["ItemMap","military"],
311
			
312
			["DZ_ALICE_Pack_EP1","object"], // 16
313
			["DZ_TK_Assault_Pack_EP1","object"], // 16
314
			["DZ_British_ACU","object"], // 18
315
			["DZ_CivilBackpack_EP1","object"], // 24
316
			["DZ_Backpack_EP1","object"], // 24
317
			
318
			//Normal
319
			["","medical"],
320
			["","generic"],
321
			["","military"],
322
			//["Body","object"],
323
			["ItemEtool","weapon"],
324
			["ItemSandbag","magazine"],
325
			["Sa58P_EP1","weapon"],
326
			["Sa58V_EP1","weapon"],
327
			["BAF_L85A2_RIS_Holo","weapon"]
328
		];
329
		_itemChance = [
330
			0.05,
331
			0.05,
332
			0.01,
333
			0.02,
334
			0.15,
335
			0.01,
336
			0.08,
337
			0.05,
338
			0.05,
339
			0.01,
340
			0.10,
341
			0.01,
342
			0.02,
343
			0.01,
344
			0.05,
345
			0.08,
346
			0.10,
347
			0.04,
348
			0.02,
349
			0.01,
350
			0.06,
351
			0.10,
352
			0.10,
353
			0.01,
354
			0.05,
355
			//Bags
356
			0.08, //16
357
			0.08, //16
358
			0.06, //18
359
			0.01, //24
360
			0.01, //DZ_Backpack_EP1 24
361
			0.10, 
362
			1.00,
363
			2.50,
364
			//0.20,
365
			0.05,
366
			0.02,
367
			0.03,
368
			0.03,
369
			0.01
370
		];
371
	};
372
	case "MilitarySpecial": {
373
		_itemTypes = [
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.10,
431
			0.05,
432
			0.01,
433
			0.02,
434
			//0.01, //m136
435
			0.10,
436
			0.02,
437
			0.10,
438
			0.10,
439
			0.10,
440
			0.01,
441
			0.01,
442
			0.20,
443
			0.01,
444
			0.02,
445
			0.10,
446
			0.03,
447
			0.20,
448
			0.10,
449
			0.20,
450
			0.01,
451
			0.04,
452
			0.05,
453
			0.02,
454
			0.01,
455
			0.08,
456
			0.04,
457
			0.02,
458
			//0.01, //NVGoggles
459
			0.10,
460
			0.05,
461
			0.15,
462
			0.01, //ItemGPS
463
			0.03,
464
			0.01,
465
			//Bags
466
			0.08, //16
467
			0.08, //16
468
			0.06, //18
469
			0.01, //24
470
			0.01, //DZ_Backpack_EP1 24
471
			0.30,
472
			1.00,
473
			5.00, //military
474
			//0.20,
475
			0.01, //PipeBomb
476
			0.01, //Sa58V_RCO_EP1
477
			0.01, //Sa58V_CCO_EP1
478
			//0.01, //["G36_C_SD_camo","weapon"],
479
			0.02, // M40A3
480
			0.01	//["100Rnd_762x54_PK","magazine"]
481
		];
482
	};
483
	case "Hunting": {
484
		_itemTypes = [
485
			["ItemMap","weapon"],
486
			["ItemFlashlight","generic"],
487
			["ItemKnife","generic"],
488
			["ItemMatchbox","generic"],
489
			["Crossbow_DZ","weapon"],
490
			["","military"],
491
			["WeaponHolder_ItemMachete", "object"],
492
			["huntingrifle","weapon"],
493
			["","hunter"]
494
		];
495
		_itemChance = [
496
			0.08,
497
			0.05,
498
			0.04,
499
			0.06,
500
			0.03,
501
			2.00,
502
			0.03,
503
			0.04,
504
			3.00
505
		];
506
	};
507
};
508
//------------------//
509
//CUSTOM LOOT SPAWNS//
510
//------------------//
511
{
512
	if ((random 1) < _lootChance) then {
513
		_iPos = _obj modelToWorld _x;
514
		_nearBy = nearestObjects [_iPos, ["WeaponHolder","WeaponHolderBase"], 1];
515
		if (count _nearBy == 0) then {
516
			private["_index"];
517
			_weights = [_itemTypes,_itemChance] call fnc_buildWeightedArray;
518
			_index = _weights call BIS_fnc_selectRandom;
519
			_itemType = _itemTypes select _index;
520
			[_itemType select 0, _itemType select 1 , _iPos, 0.0]  call spawn_loot;
521
		};
522
	};
523
} forEach _positions;