Advertisement
Guest User

Untitled

a guest
Jan 24th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.12 KB | None | 0 0
  1. /*
  2.  
  3. Spawn ammo crates in buildings.
  4.  
  5. By Merg
  6.  
  7. */
  8.  
  9. private ["_iItem","_iPos","_radius","_box","_boxType","_boxLoadout","_boxAmount","_boxMulti","_loaded"];
  10.  
  11. // Core variables
  12. _iItem = _this select 0;
  13. _iPos = _this select 1;
  14. _radius = _this select 2;
  15. _loaded = false;
  16. _boxEmptied = false;
  17. _boxType = "RUBasicAmmunitionBox"; // default Russian Basic Ammo Box
  18. _boxLoadout = "ammo"; // default; options are "ammo", "weapon", and "multi"
  19. _boxAmount = 1; // default; defines amount of how much of specified item will be added to box
  20. // Crates with multiple
  21. _boxMagTypes = []; // default empty
  22. _boxMagAmounts = []; // default empty
  23. _boxWeaponTypes = []; // default empty
  24. _boxWeaponAmounts = []; // default empty
  25.  
  26. _Debug = false; // flag to true to get spawned box info in RPT file
  27.  
  28. /*
  29.     Box Types (to name a few):
  30.    
  31.     Russian/CDF
  32.     "RUBasicAmmunitionBox" - Ammo magazines for weapons/vehicle guns' ammo
  33.     "RUBasicWeaponsBox" - Box for a specific weapon/gun
  34.     "RUOrdnanceBox" - Russian tank, etc big boom/HE/bomb
  35.     "RULaunchersBox" - Box for hand-held rockets/vehicle rocket ammo/vehicle bombs etc
  36.    
  37.     American/BLUFOR
  38.     "USBasicAmmunitionBox" - Ammo Mags
  39.     "USBasicWeaponsBox" - Specific weapons/guns
  40.     "USLaunchersBox" - Hand-held rockets, vehicle rocket ammo/vehicle bombs etc
  41.    
  42.     Box types can be found at the two websites below:
  43.     http://dayzsuperhive.co.uk/arma-ii-ammo-boxes.html
  44.     http://dayzsuperhive.co.uk/arma-oa-ammo-boxes.html
  45. */
  46.  
  47. // Determine ammobox type based upon _iItem name fed from missionConfigfile >> CfgBuildingLoot.hpp
  48. switch (_iItem) do {
  49.     // Russian/CDF
  50.     case "AK_MAGS": { // Ural ZU23 AA gun
  51.         _boxType = "RUBasicAmmunitionBox";
  52.         _boxMagTypes = ["30Rnd_545x39_AK","30Rnd_545x39_AKSD"];
  53.         _boxMagAmounts = [10,10];
  54.         _boxAmount = 1;
  55.     };
  56.  
  57.     /* To add more, add case statements with the item name listed in CfgBuildingLoot
  58.         Template (for single item):
  59.         case "BoxNameHere": { // Item Description
  60.             _boxType = "RUBasicAmmunitionBox"; // box type
  61.             _boxLoadout = "ammo"; // or "weapon" (default is ammo; no entry needed)
  62.             _boxAmount = 1; (default is 1; no entry needed if just 1)
  63.         _item addMagazineCargoGlobal ["ItemNameHere", AmountToAdd];
  64.         Template (for multiple items):
  65.         case "BoxNameHere": {
  66.             _boxLoadout = "multi"; // signifies crate with multiple mags and weapons in any combination
  67.             _boxMagTypes = ["Magtype1","Magtype2"]; // etc
  68.             _boxMagAmounts = [50,25]; // 50 of Magtype1 and 25 of magtype2
  69.             _boxWeaponTypes = ["MyWeapon1","MyWeapon2"];
  70.             _boxWeaponAmounts = [10,15];
  71.         };
  72.     };
  73.     */
  74. };
  75.  
  76. if (_Debug) then {
  77. //diag_log(format["Spawn_rMod_Loot: Attempting to spawn loot box %1 at worldspace %2 at grid location %3",_iItem,_iPos,_iPos call fa_coor2str]);
  78. };
  79.  
  80. // Create the box
  81. _box = createVehicle [_boxType, _iPos, [], _radius, "CAN_COLLIDE"];
  82.  
  83. waitUntil {!isNull _box};
  84.  
  85. // Clear all items in default box
  86. clearMagazineCargoGlobal _box;
  87. clearWeaponCargoGlobal _box;
  88. _boxEmptied = true;
  89.  
  90. waitUntil {_boxEmptied};
  91.  
  92. // Add specified cargo
  93. if (_boxLoadout == "ammo") then { // default is ammo
  94.     _box addMagazineCargoGlobal [_iItem, _boxAmount];
  95.     _loaded = true;
  96. };
  97. if (_boxLoadout == "weapon") then {
  98.     _box addWeaponCargoGlobal [_iItem, _boxAmount];
  99.     _loaded = true;
  100. };
  101. if (_boxLoadout == "multi") then {
  102.     //
  103.     if (count _boxMagTypes > 0) then {
  104.         _count = count _boxMagTypes;
  105.         for "_x" from 0 to _count do {
  106.             _MagName = _boxMagTypes select _x;
  107.             _MagAmount = _boxMagAmounts select _x;
  108.             if (_MagAmount <= 0) then { _MagAmount = 1; };
  109.             _box addMagazineCargoGlobal [_MagName,_MagAmount];
  110.         };
  111.     };
  112.     // Process weaponry
  113.     if (count _boxWeaponTypes > 0) then {
  114.         _count = count _boxWeaponTypes;
  115.         for "_x" from 0 to _count do {
  116.             _WeaponName = _boxWeaponTypes select _x;
  117.             _WeaponAmount = _boxWeaponAmounts select _x;
  118.             if (_WeaponAmount <= 0) then { _WeaponAmount = 1; };
  119.             _box addWeaponCargoGlobal [_WeaponName,_WeaponAmount];
  120.         };
  121.     };
  122.     _loaded = true;
  123. };
  124.  
  125. waitUntil {_loaded};
  126.  
  127. // Report to RPT file
  128. if (_Debug) then {
  129.     //diag_log(format["Spawn_Box_Barrack: Spawned loot box %1 at worldspace %2 at grid location %3",_iItem,_iPos,_iPos call fa_coor2str]);
  130. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement