Advertisement
Guest User

fn_random_crateLoot.sqf

a guest
May 25th, 2015
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.63 KB | None | 0 0
  1. //Random Loot Crates by Darth_Rogue & Chisel (tdwhite)
  2. //HUGE thanks to deadeye & Robio for helping work out the last bugs!
  3. // Modified by Ghostrider-DBD- for better random loot distribution and adding vehicle crashes
  4. //fn_random_crateLoot.sqf
  5. //To be run server side via addon PBO
  6.  
  7.  
  8. //*****************************LOOT LISTS************************
  9. /*
  10. Loot types:
  11. 0 = randomly selected loadout from the list below
  12. 1 = building materials, sledges, hatchets and chainsaws.
  13. 2 = weapons, mines, NVG, range finder, radios
  14. 3 = misc loot, multiguns, other utility items.
  15. 4 = weapons, vests, backpacks and headgear.
  16. */
  17. diag_log "Loading Static Loot Container Spawning System";
  18.  
  19. _lootBoxes = [];
  20.  
  21. _worldName = toLower format ["%1", worldName];
  22.  
  23. _smokeNearCrate = true; //turns on or off wrecks near crates Recommended to turn this off if you need crates spawning in specific positions
  24.  
  25. switch (_worldName) do {
  26. case "altis":{
  27. diag_log "Altis-specific settings loaded";
  28. [[3748,11660,0],0],
  29. [[3924,11493,0],0],
  30. [[3681,11530,0],0],
  31. [[3816,11774,0],0]
  32. };
  33. case "stratis":{
  34. [[6386.07,14098.6,0],0],
  35. [[6360.94,14099,0],0]
  36. };
  37. case "chernarus":{
  38. // Setup for Chernarus AI controlled sector
  39. /*_lootBoxes = [ // format as [_position, _lootType (range 1-4)] or [_position, 0] for randomly selected loot.
  40. [[7093.73,12145.4,0],0],
  41. [[7093.73,12140.4,0],0],
  42. [[6386.07,14098.6,0],0],
  43. [[6360.94,14099,0],0],
  44. [[19288.5,22358.8,1.2],0],
  45. [[19633.8,22128.8,0],0],
  46. [[11068.9,7125.94,0],0] // ** Note that there is no comma after the last entry.
  47. ];*/
  48. }; "chernarus_summer":{
  49. };
  50. case "bornholm":{
  51. // Setup for Bornholm AI controlled sector
  52. _lootBoxes = [ // format as [_position, _lootType (range 1-4)] or [_position, 0] for randomly selected loot.
  53. [[7093.73,12145.4,0],0],
  54. [[7093.73,12140.4,0],0],
  55. [[7291.69,12044.5,0],0],
  56. [[7295.69,12044.5,0],0],
  57. [[19288.5,22358.8,1.2],0],
  58. [[19633.8,22128.8,0],0],
  59. [[11068.9,7125.94,0],0] // ** Note that there is no comma after the last entry.
  60. ];
  61. };
  62. case "tavi":{
  63. };
  64. };
  65. diag_log format["[crateLoot.sqf] --- >>> worldname is %1",_worldName];
  66.  
  67.  
  68.  
  69. //Uniforms
  70. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  71. _loot_uniforms = ["U_O_CombatUniform_ocamo", "U_O_GhillieSuit", "U_O_PilotCoveralls", "U_O_Wetsuit", "U_OG_Guerilla1_1", "U_OG_Guerilla2_1", "U_OG_Guerilla2_3", "U_OG_Guerilla3_1", "U_OG_Guerilla3_2", "U_OG_leader", "U_C_Poloshirt_stripped", "U_C_Poloshirt_blue",
  72. "U_C_Poloshirt_burgundy", "U_C_Poloshirt_tricolour", "U_C_Poloshirt_salmon", "U_C_Poloshirt_redwhite", "U_C_Poor_1", "U_C_WorkerCoveralls", "U_C_Journalist", "U_C_Scientist", "U_OrestesBody", "U_Wetsuit_uniform", "U_Wetsuit_White", "U_Wetsuit_Blue",
  73. "U_Wetsuit_Purp", "U_Wetsuit_Camo", "U_CamoRed_uniform", "U_CamoBrn_uniform", "U_CamoBlue_uniform", "U_Camo_uniform", "U_ghillie1_uniform", "U_ghillie2_uniform", "U_ghillie3_uniform","U_B_FullGhillie_ard","U_I_FullGhillie_ard","U_O_FullGhillie_ard",
  74. "Full Ghillie Suit Semi-Arid:","U_B_FullGhillie_sard","U_O_FullGhillie_sard","U_I_FullGhillie_sard","Full Ghillie Suit Lush","U_B_FullGhillie_lsh","U_O_FullGhillie_lsh","U_I_FullGhillie_lsh"];
  75.  
  76. //Weapons
  77. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  78. _loot_pistols = [["hgun_ACPC2_F","9Rnd_45ACP_Mag"],["hgun_Rook40_F","16Rnd_9x21_Mag"],["hgun_P07_F","16Rnd_9x21_Mag"],["hgun_Pistol_heavy_01_F","11Rnd_45ACP_Mag"],["hgun_Pistol_heavy_02_F","6Rnd_45ACP_Cylinder"],["ruger_pistol_epoch","10rnd_22X44_magazine"],["1911_pistol_epoch","9Rnd_45ACP_Mag"]];
  79. _loot_rifles = [["arifle_Katiba_F","30Rnd_65x39_caseless_green"],["arifle_Katiba_C_F","30Rnd_65x39_caseless_green"],["arifle_Katiba_GL_F","30Rnd_65x39_caseless_green"],["arifle_MXC_F","30Rnd_65x39_caseless_mag"],["arifle_MX_F","30Rnd_65x39_caseless_mag"],
  80. ["arifle_MX_GL_F","30Rnd_65x39_caseless_mag"],["arifle_MXM_F","30Rnd_65x39_caseless_mag"],["arifle_SDAR_F","20Rnd_556x45_UW_mag"],[ "arifle_TRG21_F","30Rnd_556x45_Stanag_Tracer_Red"],["arifle_TRG20_F","30Rnd_556x45_Stanag_Tracer_Red"],
  81. ["arifle_TRG21_GL_F","30Rnd_556x45_Stanag_Tracer_Red"],["arifle_Mk20_F","30Rnd_556x45_Stanag_Tracer_Green"],["arifle_Mk20C_F","30Rnd_556x45_Stanag_Tracer_Green"],["arifle_Mk20_GL_F","30Rnd_556x45_Stanag_Tracer_Green"],["arifle_Mk20_plain_F","30Rnd_556x45_Stanag_Tracer_Yellow"],
  82. ["arifle_Mk20C_plain_F","30Rnd_556x45_Stanag_Tracer_Yellow"],["arifle_Mk20_GL_plain_F","30Rnd_556x45_Stanag_Tracer_Yellow"],["SMG_01_F","30Rnd_45ACP_Mag_SMG_01_tracer_green"],["SMG_02_F","30Rnd_9x21_Mag"],["hgun_PDW2000_F","30Rnd_9x21_Mag"],
  83. ["arifle_MXM_Black_F","30Rnd_65x39_caseless_mag_Tracer"],["arifle_MX_GL_Black_F","30Rnd_65x39_caseless_mag_Tracer"],["arifle_MX_Black_F","30Rnd_65x39_caseless_mag"],["arifle_MXC_Black_F","30Rnd_65x39_caseless_mag"],["Rollins_F","5Rnd_rollins_mag"],
  84. ["AKM_EPOCH","30Rnd_762x39_Mag"],["m4a3_EPOCH","30Rnd_556x45_Stanag"],["m16_EPOCH","30Rnd_556x45_Stanag"],["m16Red_EPOCH","30Rnd_556x45_Stanag"]];
  85. _loot_snipers = [["srifle_EBR_F","20Rnd_762x51_Mag"],["srifle_GM6_F","5Rnd_127x108_Mag"],["srifle_LRR_F","7Rnd_408_Mag"],["srifle_DMR_01_F","10Rnd_762x51_Mag"],["M14_EPOCH","20Rnd_762x51_Mag"],["M14Grn_EPOCH","20Rnd_762x51_Mag"],["m107_EPOCH","5Rnd_127x108_Mag"],
  86. ["m107Tan_EPOCH","5Rnd_127x108_Mag"],["SR25_EPOCH","20Rnd_762x51_Mag"],["srifle_DMR_02_camo_F","10Rnd_338_Mag"],["srifle_DMR_02_F","10Rnd_338_Mag"],["srifle_DMR_02_sniper_F","10Rnd_338_Mag"],["srifle_DMR_03_F","10Rnd_338_Mag"],["srifle_DMR_03_tan_F","10Rnd_338_Mag"],
  87. ["srifle_DMR_04_Tan_F","10Rnd_338_Mag"],["srifle_DMR_05_hex_F","10Rnd_338_Mag"],["srifle_DMR_05_tan_F","10Rnd_338_Mag"],["srifle_DMR_06_camo_F","10Rnd_338_Mag"],["srifle_DMR_04_F","10Rnd_127x54_Mag"],["srifle_DMR_05_blk_F","10Rnd_93x64_DMR_05_Mag"],
  88. ["srifle_DMR_06_olive_F","20Rnd_762x51_Mag"]];
  89. _loot_LMG = [["LMG_Zafir_F","150Rnd_762x51_Box_Tracer"],["MMG_01_hex_F","150Rnd_93x64_Mag"],["MMG_01_tan_F","150Rnd_93x64_Mag"],["MMG_02_black_F","150Rnd_93x64_Mag"],["MMG_02_camo_F","150Rnd_93x64_Mag"],["MMG_02_sand_F","150Rnd_93x64_Mag"],
  90. ["m249_EPOCH","200Rnd_556x45_M249"],["m249Tan_EPOCH","200Rnd_556x45_M249"],["LMG_Mk200_F","200Rnd_65x39_cased_Box_Tracer"]];
  91.  
  92. //Silencers
  93. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  94. _loot_silencers = ["muzzle_sr25S_epoch","muzzle_snds_H","muzzle_snds_M","muzzle_snds_L","muzzle_snds_B","muzzle_snds_H_MG","muzzle_snds_acp","muzzle_snds_93mmg","muzzle_snds_93mmg_tan","muzzle_snds_338_black","muzzle_snds_338_greenmuzzle_snds_338_sand"];
  95.  
  96. //Optics
  97. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  98. _loot_optics = ["optic_NVS","optic_tws","optic_tws_mg","optic_SOS","optic_LRPS","optic_DMS","optic_Arco","optic_Hamr","Elcan_epoch","Elcan_reflex_epoch","optic_MRCO","optic_Holosight","optic_Holosight_smg","optic_Aco","optic_ACO_grn","optic_Aco_smg","optic_ACO_grn_smg","optic_Yorris","optic_MRD","optic_AMS","optic_AMS_khk","optic_AMS_snd","optic_KHS_blk","optic_KHS_hex","optic_KHS_old","optic_KHS_tan"];
  99.  
  100. //Backpacks
  101. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  102. _loot_backpacks = ["B_AssaultPack_cbr", "B_AssaultPack_dgtl", "B_AssaultPack_khk", "B_AssaultPack_mcamo", "B_AssaultPack_ocamo", "B_AssaultPack_rgr", "B_AssaultPack_sgg", "B_Carryall_cbr", "B_Carryall_khk", "B_Carryall_mcamo", "B_Carryall_ocamo", "B_Carryall_oli", "B_Carryall_oucamo", "B_FieldPack_blk", "B_FieldPack_cbr", "B_FieldPack_khk", "B_FieldPack_ocamo", "B_FieldPack_oli", "B_FieldPack_oucamo", "B_Kitbag_cbr", "B_Kitbag_mcamo", "B_Kitbag_rgr", "B_Kitbag_sgg", "B_Parachute", "B_TacticalPack_blk", "B_TacticalPack_mcamo", "B_TacticalPack_ocamo", "B_TacticalPack_oli", "B_TacticalPack_rgr", "smallbackpack_red_epoch", "smallbackpack_green_epoch", "smallbackpack_teal_epoch", "smallbackpack_pink_epoch"];
  103.  
  104. //Vests
  105. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  106. _loot_vests = ["V_1_EPOCH", "V_2_EPOCH", "V_3_EPOCH", "V_4_EPOCH", "V_5_EPOCH", "V_6_EPOCH", "V_7_EPOCH", "V_8_EPOCH", "V_9_EPOCH", "V_10_EPOCH", "V_11_EPOCH", "V_12_EPOCH", "V_13_EPOCH", "V_14_EPOCH", "V_15_EPOCH", "V_16_EPOCH", "V_17_EPOCH", "V_18_EPOCH", "V_19_EPOCH", "V_20_EPOCH", "V_21_EPOCH", "V_22_EPOCH", "V_23_EPOCH", "V_24_EPOCH", "V_25_EPOCH", "V_26_EPOCH", "V_27_EPOCH", "V_28_EPOCH", "V_29_EPOCH", "V_30_EPOCH", "V_31_EPOCH", "V_32_EPOCH", "V_33_EPOCH", "V_34_EPOCH", "V_35_EPOCH", "V_36_EPOCH", "V_37_EPOCH", "V_38_EPOCH", "V_39_EPOCH", "V_40_EPOCH","V_PlateCarrierSpec_blk","V_PlateCarrierSpec_mtp","V_PlateCarrierGL_blk","V_PlateCarrierGL_mtp","V_PlateCarrierIAGL_oli"];
  107.  
  108. //Head Gear
  109. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  110. _loot_headgear = ["H_1_EPOCH","H_2_EPOCH","H_3_EPOCH","H_4_EPOCH","H_5_EPOCH","H_6_EPOCH","H_7_EPOCH","H_8_EPOCH","H_9_EPOCH","H_10_EPOCH","H_11_EPOCH","H_12_EPOCH","H_13_EPOCH","H_14_EPOCH","H_15_EPOCH","H_16_EPOCH","H_17_EPOCH","H_18_EPOCH","H_19_EPOCH","H_20_EPOCH","H_21_EPOCH","H_22_EPOCH","H_23_EPOCH","H_24_EPOCH","H_25_EPOCH","H_26_EPOCH","H_27_EPOCH","H_28_EPOCH","H_29_EPOCH","H_30_EPOCH","H_31_EPOCH","H_32_EPOCH","H_33_EPOCH","H_34_EPOCH","H_35_EPOCH","H_36_EPOCH","H_37_EPOCH","H_38_EPOCH","H_39_EPOCH","H_40_EPOCH","H_41_EPOCH","H_42_EPOCH","H_43_EPOCH","H_44_EPOCH","H_45_EPOCH","H_46_EPOCH","H_47_EPOCH","H_48_EPOCH","H_49_EPOCH","H_50_EPOCH","H_51_EPOCH","H_52_EPOCH","H_53_EPOCH","H_54_EPOCH","H_55_EPOCH","H_56_EPOCH","H_57_EPOCH","H_58_EPOCH","H_59_EPOCH","H_60_EPOCH","H_61_EPOCH","H_62_EPOCH","H_63_EPOCH","H_64_EPOCH","H_65_EPOCH","H_66_EPOCH","H_67_EPOCH","H_68_EPOCH","H_69_EPOCH","H_70_EPOCH","H_71_EPOCH","H_72_EPOCH","H_73_EPOCH","H_74_EPOCH","H_75_EPOCH","H_76_EPOCH","H_77_EPOCH","H_78_EPOCH","H_79_EPOCH","H_80_EPOCH","H_81_EPOCH","H_82_EPOCH","H_83_EPOCH","H_84_EPOCH","H_85_EPOCH","H_86_EPOCH","H_87_EPOCH","H_88_EPOCH","H_89_EPOCH","H_90_EPOCH","H_91_EPOCH","H_92_EPOCH","H_93_EPOCH","H_94_EPOCH","H_95_EPOCH","H_96_EPOCH","H_97_EPOCH","H_98_EPOCH","H_99_EPOCH","H_100_EPOCH","H_101_EPOCH","H_102_EPOCH","H_103_EPOCH","H_104_EPOCH"];
  111.  
  112. //Food
  113. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  114. _loot_food = ["FoodSnooter","FoodWalkNSons","FoodBioMeat","ItemSodaOrangeSherbet","ItemSodaPurple","ItemSodaMocha","ItemSodaBurst","ItemSodaRbull","honey_epoch","emptyjar_epoch","sardines_epoch","meatballs_epoch","scam_epoch","sweetcorn_epoch","WhiskeyNoodle","ItemCoolerE","ItemTrout","ItemSeaBass","ItemTuna"];
  115.  
  116. //Misc
  117. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  118. _loot_Misc = ["PaintCanClear","PaintCanBlk","PaintCanBlu","PaintCanBrn","PaintCanGrn","PaintCanOra","PaintCanPur","PaintCanRed","PaintCanTeal","PaintCanYel","ItemDocument","ItemMixOil","emptyjar_epoch","FoodBioMeat","ItemSodaOrangeSherbet","ItemSodaPurple","ItemSodaMocha","ItemSodaBurst","ItemSodaRbull","sardines_epoch","meatballs_epoch","scam_epoch","sweetcorn_epoch","Towelette","HeatPack","ColdPack","VehicleRepair","VehicleRepairLg","CircuitParts","ItemCoolerE","ItemScraps","ItemScraps","lighter_epoch","EnergyPack","EnergyPackLg"];
  119.  
  120. //Construction
  121. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  122. _loot_build = ["MortarBucket","MortarBucket","ItemCorrugated","ItemCorrugatedLg","CinderBlocks","VehicleRepairLg","VehicleRepair","CircuitParts","ItemScraps","KitShelf","KitWoodFloor","KitWoodStairs"];
  123.  
  124. // Define functions
  125. //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  126.  
  127. // allows a visible cue to be spawned near the crate
  128. _fn_smokeAtCrate = { // adapted from Ritchies heli crash addon
  129. private ["_pos","_smokeSource","_smokeTrail","_fire","_posFire","_smoke"];
  130.  
  131. // Use the Land_Fire_burning item if you want a bright visual cue at night but be forewarned that the flames are blinding with NVG at close range
  132. // http://www.antihelios.de/EK/Arma/index.htm
  133. _wrecks = ["Land_Wreck_Car2_F","Land_Wreck_Car3_F","Land_Wreck_Car_F","Land_Wreck_Offroad2_F","Land_Wreck_Offroad_F","Land_Tyres_F","Land_Pallets_F","Land_MetalBarrel_F"];
  134. _smokeSource = _wrecks call BIS_fnc_selectRandom; //other choices might be "Land_CanisterPlastic_F","Land_MetalBarrel_F", "Land_Pallets_F", "Land_Tyres_F", "Land_Wreck_Car2_F", "Land_HumanSkeleton_F", "Land_Wreck_Car2_F";
  135. _smokeTrail = "test_EmptyObjectForFireBig"; // "optiosn are "test_EmptyObjectForFireBig", "test_EmptyObjectForSmoke"
  136. _pos = _this select 0;
  137. _posFire = [_pos, 5, 15, 10, 0, 20, 0] call BIS_fnc_findSafePos; // find a safe spot near the location passed in the call
  138. _fire = createVehicle [_smokeSource, _posFire, [], 0, "can_collide"];
  139. _fire setVariable ["LAST_CHECK", (diag_tickTime + 14400)];
  140. _fire setPos _pos;
  141. _fire setDir floor(random(360));
  142. _smoke = createVehicle [_smokeTrail, _posFire, [], 0, "can_collide"]; // "test_EmptyObjectForSmoke" createVehicle _posFire;
  143. _smoke setVariable ["LAST_CHECK", (diag_tickTime + 14400)];
  144. _smoke attachto [_fire, [0,0,-1]];
  145. };
  146.  
  147. // fill the crate with something
  148. _fn_spawnCrate = {
  149.  
  150. private["_crate1","_lootType","_cratePos","_minDistfromCenter","_maxDistfromCenter","_clossestObj","_spawnOnWater","_spawnAtShore","_pos","_noItemTypes","_partToAdd"];
  151.  
  152. _lootType = [_this, 1, 0] call BIS_fnc_param; // if a loot type is passed us this otherwise use a randomly selected loot type.
  153. _cratePos = _this select 0;
  154.  
  155. // Spawn an Empty a Crate
  156. _crate_1 = objNull;
  157.  
  158. // find a safe location for the crate
  159. _minDistfromCenter = 7; //should be 0 if you want specific crate positions
  160. _maxDistfromCenter = 12; //should be 0 if you want specific crate positions
  161. _clossestObj = 5; //should be 0 if you want specific crate positions
  162. _spawnOnWater = 0; // water mode 0: cannot be in water , 1: can either be in water or not , 2: must be in water
  163. _spawnAtShore = 0; // 0: does not have to be at a shore , 1: must be at a shore
  164. _pos = [_cratePos,_minDistfromCenter,_maxDistfromCenter,_clossestObj,_spawnOnWater,20,_spawnAtShore] call BIS_fnc_findSafePos; // find a random loc
  165.  
  166. // create a crate
  167. _crate_1 = createVehicle ["Land_PaperBox_C_EPOCH", _pos, [] "CAN_COLLIDE"];
  168. _crate_1 setPos _pos;
  169. _crate_1 setDir round(random(36));
  170. _crate_1 setVariable ["LAST_CHECK", (diag_tickTime + 14400)]; // prevent the crate from being cleaned up
  171.  
  172. //Remove whatever the crate spawned with.
  173. clearWeaponCargoGlobal _crate_1;
  174. clearMagazineCargoGlobal _crate_1;
  175. clearBackpackCargoGlobal _crate_1;
  176. clearItemCargoGlobal _crate_1;
  177.  
  178. // a _lootType == 0 means randomly select a crate loadout so lets pick a random number
  179. if (_lootType == 0) then
  180. {
  181. _lootType = floor(random(4)) + 1;
  182. diag_log format["[random loot selects] _lootType = %1",_lootType];
  183. };
  184.  
  185. //diag_log format["--->>> starting crate loader with loottype of %1",_lootType];
  186.  
  187. if (_lootType == 1) then
  188. {
  189. _noItemTypes = 10;
  190. for "_i" from 1 to _noItemTypes do
  191. {
  192. _items = round((_noItemTypes - _i)/2) + floor(random 20 + floor(_i/2)); //change the value '(random X....' to determine the number of items of this type to be in the crate
  193. _crate_1 addMagazineCargoGlobal [_loot_build call BIS_fnc_selectRandom, _items];
  194. };
  195. _crate_1 addWeaponCargoGlobal ["Hatchet",2];
  196. _crate_1 addWeaponCargoGlobal ["MeleeSledge",2];
  197. _crate_1 addWeaponCargoGlobal ["ChainSaw",1];
  198. };
  199.  
  200. if (_lootType == 2) then
  201. {
  202. _noRifles = 3;
  203. for "_i" from 1 to _noRifles do
  204. {
  205. //diag_log format[" ---- <<<< _loot_rifles is %1",_loot_rifles];
  206. _rifle = _loot_rifles call BIS_fnc_selectRandom;
  207. //diag_log format["--->>> parameter _rifle is %1",_rifle];
  208. _crate_1 addWeaponCargoGlobal [_rifle select 0, 1];
  209. _crate_1 addMagazineCargoGlobal [_rifle select 1, (6 + floor(random 3))]; //change the value '(X + floor( random....' to determine X number of items of this type to be in the crate
  210. };
  211. _noPistols = 3;
  212. for "_i" from 1 to _noPistols do
  213. {
  214. _pistol = _loot_pistols call BIS_fnc_selectRandom;
  215. _crate_1 addWeaponCargoGlobal [_pistol select 0,1];
  216. _crate_1 addMagazineCargoGlobal [_pistol select 1, (3 + floor(random 3))]; //change the value '(X + floor( random....' to determine X number of items of this type to be in the crate
  217. };
  218. _noLMG = 3;
  219. for "_i" from 1 to _noLMG do
  220. {
  221. _LMG = _loot_LMGs call BIS_fnc_selectRandom;
  222. _crate_1 addWeaponCargoGlobal [_LMG select 0,1];
  223. _crate_1 addMagazineCargoGlobal [_LMG select 1, (1 + floor(random 3))]; //change the value '(X + floor( random....' to determine X number of items of this type to be in the crate
  224. };
  225. _noSniper = 2;
  226. for "_i" from 1 to _noSniper do
  227. {
  228. _sniper = _loot_snipers call BIS_fnc_selectRandom;
  229. _crate_1 addWeaponCargoGlobal [_sniper select 0,1];
  230. _crate_1 addMagazineCargoGlobal [_sniper select 1, (3 + floor(random 3))]; //change the value '(X + floor( random....' to determine X number of items of this type to be in the crate
  231. };
  232. _noSilencers = 2;
  233. for "_i" from 1 to _noSilencers do
  234. {
  235. _crate_1 addItemCargoGlobal [(_loot_silencers call BIS_fnc_selectRandom),(1 + floor(random 1))]; //change the value '(X + floor( random....' to determine X number of items of this type to be in the crate
  236. };
  237. _noOptics = 3;
  238. for "_i" from 1 to _noOptics do
  239. {
  240. _crate_1 additemCargoGlobal [(_loot_optics call BIS_fnc_selectRandom), (2 + floor(random 1))]; //change the value '(X + floor( random....' to determine X number of items of this type to be in the crate
  241. };
  242. _noVests = 2;
  243. for "_i" from 1 to _noVests do
  244. {
  245. _crate_1 addItemCargoGlobal [(_loot_vests call BIS_fnc_selectRandom),(1 + floor(random 1))]; //change the value '(X + floor( random....' to determine X number of items of this type to be in the crate
  246. };
  247. _noBackpacks = 1;
  248. for "_i" from 1 to _noBackpacks do
  249. {
  250. _crate_1 addBackpackCargoGlobal [(_loot_backpacks call BIS_fnc_selectRandom),(2 + floor(random 1))]; //change the value '(X + floor( random....' to determine X number of items of this type to be in the crate
  251. };
  252. _crate_1 addItemCargoGlobal ["EpochRadio0",2];
  253. _crate_1 additemCargoGlobal ["NVG_EPOCH",2];
  254. _crate_1 additemCargoGlobal ["ItemGPS",2];
  255. _crate_1 addWeaponCargoGlobal ["Rangefinder",2];
  256. _crate_1 addMagazineCargoGlobal ["SatchelCharge_Remote_Mag",2];
  257. _crate_1 addMagazineCargoGlobal ["DemoCharge_Remote_Mag",1];
  258. _crate_1 addMagazineCargoGlobal ["ClaymoreDirectionalMine_Remote_Mag",2];
  259. };
  260.  
  261. if (_lootType == 3) then
  262. {
  263. _noMisc = 10;
  264. for "_i" from 1 to _noMisc do
  265. {
  266. _items = (_noMisc - floor(i/2)) + floor(random _i);
  267. _partToAdd = _loot_misc call BIS_fnc_selectRandom;
  268. diag_log format["<<<<--- for loot type 3 number of parts is %1 and part is %2",_items,_partToAdd];
  269. _crate_1 addMagazineCargoGlobal [_partToAdd,_items];
  270. };
  271. _crate_1 addWeaponCargoGlobal ["MultiGun",1];
  272. _crate_1 addMagazineCargoGlobal ["EnergyPack",2];
  273. _crate_1 addMagazineCargoGlobal ["EnergyPackLg",1];
  274. _crate_1 addMagazineCargoGlobal ["ItemLockBox",2];
  275. _crate_1 addMagazineCargoGlobal ["jerrycan_epoch",2];
  276. _crate_1 addMagazineCargoGlobal ["ItemGoldBar10oz",2];
  277. _crate_1 addMagazineCargoGlobal ["ItemSilverBar",4];
  278. _crate_1 addMagazineCargoGlobal ["ItemKiloHemp",4];
  279.  
  280. };
  281.  
  282. if (_lootType == 4) then
  283. {
  284.  
  285. _noRifles = 3;
  286. for "_i" from 1 to _noRifles do
  287. {
  288. _rifle = _loot_rifles call BIS_fnc_selectRandom;
  289. //diag_log format["[random_crateLoot] -- >> _rifle contains %1",_rifle];
  290. _weap = _rifle select 0;
  291. _ammo = _rifle select 1;
  292. _crate_1 addWeaponCargoGlobal [_weap, 1];
  293. _crate_1 addMagazineCargoGlobal [_ammo, (3 + floor(random 3))]; //change the value '(random X....' to determine the number of items of this type to be in the crate
  294. };
  295. _noPistols = 3;
  296. for "_i" from 1 to _noPistols do
  297. {
  298. _pistol = _loot_pistols call BIS_fnc_selectRandom;
  299. _crate_1 addWeaponCargoGlobal [_pistol select 0,1];
  300. _crate_1 addMagazineCargoGlobal [_pistol select 1, (3 + floor(random 3))]; //change the value '(random X....' to determine the number of items of this type to be in the crate
  301. };
  302. _noLMG = 3;
  303. for "_i" from 1 to _noLMG do
  304. {
  305. _LMG = _loot_LMGs call BIS_fnc_selectRandom;
  306. _crate_1 addWeaponCargoGlobal [_LMG select 0,1];
  307. _crate_1 addMagazineCargoGlobal [_LMG select 1, (1 + floor(random 3))];
  308. };
  309. _noSniper = 2;
  310. for "_i" from 1 to _noSniper do
  311. {
  312. _sniper = _loot_snipers call BIS_fnc_selectRandom;
  313. _crate_1 addWeaponCargoGlobal [_sniper select 0,1];
  314. _crate_1 addMagazineCargoGlobal [_sniper select 1, (3 + floor(random 3))];
  315. };
  316. _noUniforms = 3;
  317. for "_i" from 1 to _noUniforms do
  318. {
  319. _crate_1 addItemCargoGlobal [(_loot_uniforms call BIS_fnc_selectRandom),1];
  320. };
  321. _noVests = 2;
  322. for "_i" from 1 to _noVests do
  323. {
  324. _crate_1 addItemCargoGlobal [(_loot_vests call BIS_fnc_selectRandom),(1 + floor(random 1))];
  325. };
  326. _noHeadgear = 4;
  327. for "_i" from 1 to _noHeadgear do
  328. {
  329. _crate_1 addItemCargoGlobal [(_loot_headgear call BIS_fnc_selectRandom),1];
  330. };
  331. _noBackpacks = 3;
  332. for "_i" from 1 to _noBackpacks do
  333. {
  334. _crate_1 addBackpackCargoGlobal [(_loot_backpacks call BIS_fnc_selectRandom),(1 + floor(random 1))];
  335. };
  336. };
  337. };
  338. // run the above scripts
  339. _fn_Run = {
  340.  
  341. private ["_cratePos","_lootType","_counter"];
  342. _counter = 1;
  343. // spawn and load a crate for each location in _lootBoxes
  344. {
  345.  
  346. _cratePos = _x select 0; // get crate position
  347. _lootType= _x select 1;
  348. [_cratePos, _lootType] call _fn_spawnCrate;
  349. if (_smokeNearCrate) then
  350. {
  351. [_cratePos] call _fn_smokeAtCrate;
  352. };
  353. diag_log format["crateLoot spawning crate %1",_counter];
  354. _counter = _counter + 1;
  355. } forEach _lootBoxes;
  356. };
  357. // Start everything up.
  358. [] call _fn_Run;
  359.  
  360. diag_log "Static crates loaded successfully!";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement