Halvhjearne

DZMSBox.sqf

Feb 28th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.20 KB | None | 0 0
  1. /*
  2.     Usage: [_crate,"type"] execVM "dir\DZMSBox.sqf";
  3.         _crate is the crate to fill
  4.         "type" is the type of crate
  5.         "type" can be weapons or medical
  6. */
  7. _crate = _this select 0;
  8. _type = _this select 1;
  9.  
  10. // Clear the current cargo
  11. clearWeaponCargoGlobal _crate;
  12. clearMagazineCargoGlobal _crate;
  13.  
  14. // Define lists. Some lists are defined in DZMSWeaponCrateList.sqf in the ExtConfig.
  15. _bpackList = [
  16. "DZ_Patrol_Pack_EP1","DZ_Assault_Pack_EP1","DZ_Czech_Vest_Puch","DZ_ALICE_Pack_EP1","DZ_TK_Assault_Pack_EP1","DZ_British_ACU",
  17. "DZ_CivilBackpack_EP1","DZ_Backpack_EP1"
  18. ];
  19. _gshellList = [
  20. "1Rnd_HE_GP25","1Rnd_Smoke_GP25","1Rnd_SmokeGreen_GP25","1Rnd_SmokeRed_GP25","1Rnd_SmokeYellow_GP25",
  21. "6Rnd_HE_M203","BAF_ied_v1","FlareGreen_GP25","FlareRed_GP25","FlareWhite_GP25","FlareYellow_GP25",
  22. "SmokeShell","SmokeShellOrange","HandGrenade_west","FlareGreen_M203","FlareWhite_M203","FlareRed_M203","HandGrenade_east",
  23. "SmokeShellRed","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellYellow","1Rnd_SmokeRed_M203",
  24. "1Rnd_SmokeGreen_M203","1Rnd_Smoke_M203","1Rnd_SmokeYellow_M203","FlareYellow_M203","1Rnd_HE_M203","PipeBomb"
  25. ];
  26. _medical = [
  27. "ItemBandage","ItemMorphine","ItemEpinephrine","ItemPainkiller","ItemWaterbottle","FoodMRE","ItemAntibiotic","ItemBloodbag",
  28. "ItemHeatPack"
  29. ];
  30. _money = [
  31. "ItemSilverBar","ItemSilverBar10oz","ItemGoldBar","ItemGoldBar10oz"
  32. ];
  33.  
  34. //////////////////////////////////////////////////////////////////
  35. //better switch code, could be optimized better tho
  36. switch(_type)do{
  37.     case "medical":{
  38.         // load medical
  39.         _scount = count _medical;
  40.         for "_x" from 0 to 40 do {
  41.             _sSelect = floor(random _sCount);
  42.             _item = _medical select _sSelect;
  43.             _crate addMagazineCargoGlobal [_item,(round(random 2))];
  44.         };
  45.     };
  46.     case "weapons":{
  47.         // load grenades
  48.         _scount = count _gshellList;
  49.         _rnd=round(random 4);
  50.         for "_x" from 0 to _rnd do {
  51.             _sSelect = floor(random _sCount);
  52.             _item = _gshellList select _sSelect;
  53.             _crate addMagazineCargoGlobal [_item,(round(random 8))];
  54.         };
  55.        
  56.         // load packs
  57.         _scount = count _bpackList;
  58.         _rnd=round(random 4);
  59.         for "_x" from 0 to _rnd do {
  60.             _sSelect = floor(random _sCount);
  61.             _item = _bpackList select _sSelect;
  62.             _crate addBackpackCargoGlobal [_item,1];
  63.         };
  64.          
  65.         // load pistols
  66.         _scount = count DZMSpistolList;
  67.         _rnd=round(random 3);
  68.         for "_x" from 0 to _rnd do {
  69.             _sSelect = floor(random _sCount);
  70.             _item = DZMSpistolList select _sSelect;
  71.             _crate addWeaponCargoGlobal [_item,1];
  72.             _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  73.             if (count _ammo > 0) then {
  74.                 {
  75.                     _crate addMagazineCargoGlobal [_x,(round(random 8))];
  76.                 }forEach _ammo;
  77.     //          _crate addMagazineCargoGlobal [(_ammo select 0),(round(random 8))];
  78.             };
  79.         };
  80.  
  81.         //load sniper
  82.         _scount = count DZMSsniperList;
  83.         for "_x" from 0 to 1 do {
  84.             _sSelect = floor(random _sCount);
  85.             _item = DZMSsniperList select _sSelect;
  86.             _crate addWeaponCargoGlobal [_item,1];
  87.             _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  88.             if (count _ammo > 0) then {
  89.                 {
  90.                     _crate addMagazineCargoGlobal [_x,(round(random 8))];
  91.                 }forEach _ammo;
  92.     //          _crate addMagazineCargoGlobal [(_ammo select 0),(round(random 8))];
  93.             };
  94.         };
  95.  
  96.         //load mg
  97.         _scount = count DZMSmgList;
  98.         for "_x" from 0 to 1 do {
  99.             _sSelect = floor(random _sCount);
  100.             _item = DZMSmgList select _sSelect;
  101.             _crate addWeaponCargoGlobal [_item,1];
  102.             _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  103.             if (count _ammo > 0) then {
  104.                 {
  105.                     _crate addMagazineCargoGlobal [_x,(round(random 8))];
  106.                 }forEach _ammo;
  107.     //          _crate addMagazineCargoGlobal [(_ammo select 0),(round(random 8))];
  108.             };
  109.         };
  110.  
  111.         //load primary
  112.         _scount = count DZMSprimaryList;
  113.         for "_x" from 0 to 2 do {
  114.             _sSelect = floor(random _sCount);
  115.             _item = DZMSprimaryList select _sSelect;
  116.             _crate addWeaponCargoGlobal [_item,1];
  117.             _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  118.             if (count _ammo > 0) then {
  119.                 {
  120.                     _crate addMagazineCargoGlobal [_x,(round(random 8))];
  121.                 }forEach _ammo;
  122.     //          _crate addMagazineCargoGlobal [(_ammo select 0),(round(random 8))];
  123.             };
  124.         };
  125.     };
  126.     case "supply":{
  127.         // load tools
  128.         _scount = count DZMSConTools;
  129.         for "_x" from 0 to 2 do {
  130.             _sSelect = floor(random _sCount);
  131.             _item = DZMSConTools select _sSelect;
  132.             _crate addWeaponCargoGlobal [_item, 1];
  133.         };
  134.        
  135.         // load construction
  136.         _scount = count DZMSConSupply;
  137.         for "_x" from 0 to 30 do {
  138.             _sSelect = floor(random _sCount);
  139.             _item = DZMSConSupply select _sSelect;
  140.             _crate addMagazineCargoGlobal [_item,1];
  141.         };
  142.     };
  143.     case "money":{
  144.         // load money
  145.         _scount = count _money;
  146.         for "_x" from 0 to 3 do {
  147.             _sSelect = floor(random _sCount);
  148.             _item = _money select _sSelect;
  149.             _crate addMagazineCargoGlobal [_item,1];
  150.         };
  151.     };
  152. };
  153.  
  154. //adding a some extra random loot with chance ["Item",25] = 25% chance for "Item" to be in box
  155. _rndtools=[
  156. ["ChainSaw",5],["ItemFlashlight",10],["ItemShovel",10],["ItemSledge",10],["ItemRadio",10],["ItemKeyKit",5],["ItemMap",10],
  157. ["ItemWatch",10],["ItemHatchet_DZE",10],["ItemMatchbox_DZE",10],["ItemEtool",5],["ItemKnife",10],["Binocular_Vector",2],
  158. ["NVGoggles",2],["ItemGPS",3],["ItemToolbox",10]
  159. ];
  160. _rndmags=[
  161. //skins
  162. ["Skin_Rocker2_DZ",15],["Skin_SurvivorW2_DZ",15],["Skin_Functionary1_EP1_DZ",15],["Skin_Haris_Press_EP1_DZ",15],
  163. ["Skin_Priest_DZ",15],["Skin_SurvivorWpink_DZ",15],["Skin_SurvivorWurban_DZ",15],["Skin_SurvivorWcombat_DZ",15],
  164. ["Skin_SurvivorWdesert_DZ",15],["Skin_Survivor2_DZ",15],["Skin_Rocker1_DZ",15],["Skin_Rocker3_DZ",15],
  165. ["Skin_RU_Policeman_DZ",15],["Skin_Pilot_EP1_DZ",15],["Skin_Rocker4_DZ",15],["Skin_Bandit1_DZ",15],["Skin_Bandit2_DZ",15],
  166. ["Skin_GUE_Commander_DZ",15],["Skin_GUE_Soldier_2_DZ",15],["Skin_GUE_Soldier_CO_DZ",15],["Skin_GUE_Soldier_Crew_DZ",15],
  167. ["Skin_GUE_Soldier_MG_DZ",15],["Skin_GUE_Soldier_Sniper_DZ",15],["Skin_Ins_Soldier_GL_DZ",15],
  168. ["Skin_TK_INS_Soldier_EP1_DZ",15],["Skin_TK_INS_Warlord_EP1_DZ",15],["Skin_BanditW1_DZ",15],["Skin_BanditW2_DZ",15],
  169. ["Skin_CZ_Special_Forces_GL_DES_EP1_DZ",15],["Skin_Drake_Light_DZ",15],["Skin_Soldier_Sniper_PMC_DZ",15],
  170. ["Skin_FR_OHara_DZ",15],["Skin_FR_Rodriguez_DZ",15],["Skin_CZ_Soldier_Sniper_EP1_DZ",15],["Skin_Graves_Light_DZ",15],
  171. ["Skin_Soldier_Bodyguard_AA12_PMC_DZ",15],["Skin_Camo1_DZ",15],["Skin_Rocket_DZ",15],["Skin_Sniper1_DZ",15],
  172. ["Skin_Soldier1_DZ",15],["Skin_Soldier_TL_PMC_DZ",15],
  173. //random stuff
  174. ["ItemCanvas",10],["ItemBurlap",10],["PartWoodLumber",10],["PartWoodPlywood",10],["ItemCopperBar10oz",5],["PartPlankPack",10],
  175. ["ItemSledgeHead",5],["ItemSledgeHandle",5],["20Rnd_B_AA12_74Slug",25],["20Rnd_B_AA12_Pellets",25],["20Rnd_B_AA12_HE",10],
  176. ["HandRoadFlare",10],["HandChemRed",20],["HandChemBlue",20],["HandChemGreen",20],["ItemTrashToiletpaper",25],["ItemOilBarrel",5],
  177. ["ItemSodaRabbit",10],["ItemSodaPepsi",10],["FoodCanFrankBeans",25],["FoodNutmix",20],["ItemSilverBar",5],["ItemCopperBar",5],
  178. ["ItemBronzeBar",5],["ItemAluminumBar",5],["PartOreSilver",5],["HandGrenade_Stone",10],["ItemTinBar",5],
  179. ["30Rnd_9x19_UZI_SD",25],["20Rnd_762x51_FNFAL",25],["TrapBear",10],["ItemFuelBarrel",5],["PartOreGold",5],["ItemKiloHemp",10],
  180. ["ItemSodaMdew",10],["ItemSodaSmasht",10],["FoodSteakCooked",25],["ItemSodaLvg",10],["ItemJerrycan",5],["PartEngine",5],
  181. ["TrashTinCan",20],["TrashJackDaniels",20],["FoodMRE",25],["ItemTentDomed",2],["ItemTentDomed2",2],["ItemTentOld",2],
  182. ["ItemBandage",35],["ItemMorphine",10],["ItemEpinephrine",10],["ItemPainkiller",25],["ItemAntibiotic",10],["ItemBloodbag",15],
  183. ["ItemHeatPack",20],["ItemWaterbottle",25],["ItemSodaCoke",10],["FoodCanBakedBeans",20],["PartGeneric",25],
  184. ["SmokeShellRed",20],["SmokeShellGreen",20],["SmokeShellPurple",20],["SmokeShellBlue",20],["SmokeShellYellow",20],
  185. ["1Rnd_SmokeRed_M203",20],["1Rnd_SmokeGreen_M203",20],["1Rnd_Smoke_M203",20],["30Rnd_545x39_AK",30],["20Rnd_762x51_B_SCAR",30],
  186. ["20Rnd_762x51_SB_SCAR",30],["100Rnd_762x51_M240",10],["20Rnd_762x51_DMR",30],["30Rnd_762x39_AK47",30]
  187. ];
  188.  
  189. //adding a few extra special things with low chance
  190. //["Itemname",chn]
  191. _specialmaglist=[
  192. ["ItemWoodFloorHalf",33],["ItemWoodWallDoorLg",33],["ItemWoodWallLg",33],["ItemWoodWallWindowLg",33],
  193. ["ItemWoodFloorQuarter",33],["ItemWoodWallDoor",33],["ItemWoodWall",33],["ItemWoodWallWindow",33],["ItemWoodWallThird",33],
  194. ["ItemWoodLadder",33],["ItemWoodFloor",50],["ItemWoodStairs",33],["ItemSandbagLarge",50],["ItemPole",50],["ItemCorrugated",33],
  195. ["bulk_empty",50],["stick_fence_kit",50],["sandbag_nest_kit",50],["sun_shade_kit",33],["rusty_gate_kit",33],["ItemLightBulb",50],
  196. ["metal_panel_kit",33],["ItemFireBarrel_kit",33],["ItemGunRackKit",33],["metal_floor_kit",33],
  197. ["ItemSandbagExLarge",50],["MortarBucket",50],["CinderBlocks",50],["ItemSandbag",50],["ItemTankTrap",50],["ItemWire",50],
  198. ["ItemSilverBar10oz",50],["cinder_garage_kit",25],["cinder_door_kit",33],["ItemGenerator",50],["cinder_wall_kit",50],
  199. ["30m_plot_kit",33],["park_bench_kit",33],["wood_ramp_kit",25],["deer_stand_kit",33],["light_pole_kit",50],
  200. ["storage_shed_kit",50],["outhouse_kit",50],["ItemWoodStairsSupport",55],["ItemWoodWallWithDoorLocked",55],
  201. ["ItemWoodWallWithDoorLgLocked",55],["ItemWoodWallGarageDoorLocked",55],["ItemWoodWallGarageDoor",55],["wood_shack_kit",33],
  202. ["wooden_shed_kit",33],["desert_net_kit",25],["forest_net_kit",25],["desert_large_net_kit",25],["forest_large_net_kit",25],
  203. ["cinder_garage_kit",25],["cinder_door_kit",25],["30m_plot_kit",50],["ItemSandbagExLarge",50],["wood_ramp_kit",25],["Mine",10],
  204. ["MineE",10],["ItemHotwireKit",12],["HandGrenade_West",15],["HandGrenade_east",15],["Laserbatteries",5],
  205. ["ItemBriefcase100oz",10],["ItemGoldBar10oz",15],["ItemGoldBar",25]
  206. ];
  207. //["Itemname",chn]
  208. _specialweapslist=[
  209. ["Igla",5],["Strela",5],["SMAW",5],["RPG7V",5],["Stinger",5],["Laserdesignator",5],
  210. ["FN_FAL_ANPVS4",25],["BAF_AS50_Scoped",5],["m107",7.5],["M110_NVG_EP1",10],["ItemKeyKit",15],["KSVK_DZE",10],["AA12_PMC",25]
  211. ];
  212.  
  213. //adding some extra fill to boxes that arent "medical","supply","money"
  214. if ((_type != "medical") and (_type != "supply") and (_type != "money")) then {
  215.     //adding random trash/mags
  216.     _rnd = floor(random 25);
  217.     for "_x" from 0 to _rnd do{
  218.         _rnditem = _rndmags call bis_fnc_selectrandom;
  219.         _item = _rnditem select 0;
  220.         _max = _rnditem select 1;
  221.         _amt = (round(random _max));
  222.         _crate addMagazineCargoGlobal [_item,_amt];
  223. //      diag_log format ["[DZMS]: Added %3 %1 (max %2) to the box",_item,_max,_amt];
  224.     };
  225.     //adding random tools/weapons
  226.     _rnd = floor(random 5);
  227.     for "_x" from 0 to _rnd do{
  228.         _rnditem = _rndtools call bis_fnc_selectrandom;
  229.         _item = _rnditem select 0;
  230.         _max = _rnditem select 1;
  231.         _amt = (round(random _max));
  232.         _crate addWeaponCargoGlobal [_item,_amt];
  233. //      diag_log format ["[DZMS]: Added %3 %1 (max %2) to the box",_item,_max,_amt];
  234.         _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  235.         if (count _ammo > 0) then {
  236.             {
  237.                 _crate addMagazineCargoGlobal [_x,(round(random 6))];
  238.             }forEach _ammo;
  239.         };
  240.     };
  241.     //adding some extra specials with low random chance
  242.     for "_x" from 0 to 4 do {
  243.         _rnd=floor(random 99);
  244.         _magnchn = _specialmaglist call bis_fnc_selectrandom;
  245.         _mag = _magnchn select 0;
  246.         _mchn = _magnchn select 1;
  247.         if(_rnd < _mchn)then{
  248.             _amt = (round(random 4));
  249.             _crate addMagazineCargoGlobal [_mag,_amt];
  250. //          diag_log format ["[DZMS]: Added Special %3 %1 (%2%4 chance) to the box",_mag,_mchn,_amt,"%"];
  251.         };
  252.         _rnd=floor(random 99);
  253.         _weapnchn = _specialweapslist call bis_fnc_selectrandom;
  254.         _weap = _weapnchn select 0;
  255.         _wchn = _weapnchn select 1;
  256.         if(_rnd < _wchn)then{
  257.             _amt = (round(random 2));
  258.             _crate addWeaponCargoGlobal [_weap,_amt];
  259. //          diag_log format ["[DZMS]: Added Special %1 (%2%3 chance) to the box",_weap,_wchn,"%"];
  260.             _ammo = [] + getArray (configFile >> "cfgWeapons" >> _weap >> "magazines");
  261.             if (count _ammo > 0) then {
  262.                 {
  263.                     _crate addMagazineCargoGlobal [_x,(round(random 6))];
  264.                 }forEach _ammo;
  265.             };
  266.         };
  267.     };
  268. };
  269.  
  270. /*
  271. //////////////////////////////////////////////////////////////////
  272. // Medical Crates
  273. if (_type == "medical") then {
  274.     // load medical
  275.     _scount = count _medical;
  276.     for "_x" from 0 to 40 do {
  277.         _sSelect = floor(random _sCount);
  278.         _item = _medical select _sSelect;
  279.         _crate addMagazineCargoGlobal [_item,(round(random 2))];
  280.     };
  281. };
  282.  
  283. ///////////////////////////////////////////////////////////////////
  284. // Weapon Crates
  285. if (_type == "weapons") then {
  286.     // load grenades
  287.     _scount = count _gshellList;
  288.     for "_x" from 0 to 2 do {
  289.         _sSelect = floor(random _sCount);
  290.         _item = _gshellList select _sSelect;
  291.         _crate addMagazineCargoGlobal [_item,(round(random 2))];
  292.     };
  293.    
  294.     // load packs
  295.     _scount = count _bpackList;
  296.     for "_x" from 0 to 3 do {
  297.         _sSelect = floor(random _sCount);
  298.         _item = _bpackList select _sSelect;
  299.         _crate addBackpackCargoGlobal [_item,1];
  300.     };
  301.      
  302.     // load pistols
  303.     _scount = count DZMSpistolList;
  304.     for "_x" from 0 to 2 do {
  305.         _sSelect = floor(random _sCount);
  306.         _item = DZMSpistolList select _sSelect;
  307.         _crate addWeaponCargoGlobal [_item,1];
  308.         _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  309.         if (count _ammo > 0) then {
  310.             _crate addMagazineCargoGlobal [(_ammo select 0),(round(random 8))];
  311.         };
  312.     };
  313.  
  314.     //load sniper
  315.     _scount = count DZMSsniperList;
  316.     for "_x" from 0 to 1 do {
  317.         _sSelect = floor(random _sCount);
  318.         _item = DZMSsniperList select _sSelect;
  319.         _crate addWeaponCargoGlobal [_item,1];
  320.         _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  321.         if (count _ammo > 0) then {
  322.             _crate addMagazineCargoGlobal [(_ammo select 0),(round(random 8))];
  323.         };
  324.     };
  325.  
  326.     //load mg
  327.     _scount = count DZMSmgList;
  328.     for "_x" from 0 to 1 do {
  329.         _sSelect = floor(random _sCount);
  330.         _item = DZMSmgList select _sSelect;
  331.         _crate addWeaponCargoGlobal [_item,1];
  332.         _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  333.         if (count _ammo > 0) then {
  334.             _crate addMagazineCargoGlobal [(_ammo select 0),(round(random 8))];
  335.         };
  336.     };
  337.  
  338.     //load primary
  339.     _scount = count DZMSprimaryList;
  340.     for "_x" from 0 to 2 do {
  341.         _sSelect = floor(random _sCount);
  342.         _item = DZMSprimaryList select _sSelect;
  343.         _crate addWeaponCargoGlobal [_item,1];
  344.         _ammo = [] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines");
  345.         if (count _ammo > 0) then {
  346.             _crate addMagazineCargoGlobal [(_ammo select 0),(round(random 8))];
  347.         };
  348.     };
  349. };
  350.  
  351. ///////////////////////////////////////////////////////////////////
  352. // Epoch Supply Crates
  353. if (_type == "supply") then {
  354.     // load tools
  355.     _scount = count DZMSConTools;
  356.     for "_x" from 0 to 2 do {
  357.         _sSelect = floor(random _sCount);
  358.         _item = DZMSConTools select _sSelect;
  359.         _crate addWeaponCargoGlobal [_item, 1];
  360.     };
  361.    
  362.     // load construction
  363.     _scount = count DZMSConSupply;
  364.     for "_x" from 0 to 30 do {
  365.         _sSelect = floor(random _sCount);
  366.         _item = DZMSConSupply select _sSelect;
  367.         _crate addMagazineCargoGlobal [_item,1];
  368.     };
  369. };
  370.  
  371. ///////////////////////////////////////////////////////////////////
  372. // Epoch Money Crates
  373. if (_type == "money") then {
  374.     // load money
  375.     _scount = count _money;
  376.     for "_x" from 0 to 3 do {
  377.         _sSelect = floor(random _sCount);
  378.         _item = _money select _sSelect;
  379.         _crate addMagazineCargoGlobal [_item,1];
  380.     };
  381. };
  382. */
Advertisement
Add Comment
Please, Sign In to add comment