Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Spawn ammo crates in buildings.
- By Merg
- */
- private ["_iItem","_iPos","_radius","_box","_boxType","_boxLoadout","_boxAmount","_boxMulti","_loaded"];
- // Core variables
- _iItem = _this select 0;
- _iPos = _this select 1;
- _radius = _this select 2;
- _loaded = false;
- _boxEmptied = false;
- _boxType = "RUBasicAmmunitionBox"; // default Russian Basic Ammo Box
- _boxLoadout = "ammo"; // default; options are "ammo", "weapon", and "multi"
- _boxAmount = 1; // default; defines amount of how much of specified item will be added to box
- // Crates with multiple
- _boxMagTypes = []; // default empty
- _boxMagAmounts = []; // default empty
- _boxWeaponTypes = []; // default empty
- _boxWeaponAmounts = []; // default empty
- _Debug = false; // flag to true to get spawned box info in RPT file
- /*
- Box Types (to name a few):
- Russian/CDF
- "RUBasicAmmunitionBox" - Ammo magazines for weapons/vehicle guns' ammo
- "RUBasicWeaponsBox" - Box for a specific weapon/gun
- "RUOrdnanceBox" - Russian tank, etc big boom/HE/bomb
- "RULaunchersBox" - Box for hand-held rockets/vehicle rocket ammo/vehicle bombs etc
- American/BLUFOR
- "USBasicAmmunitionBox" - Ammo Mags
- "USBasicWeaponsBox" - Specific weapons/guns
- "USLaunchersBox" - Hand-held rockets, vehicle rocket ammo/vehicle bombs etc
- Box types can be found at the two websites below:
- http://dayzsuperhive.co.uk/arma-ii-ammo-boxes.html
- http://dayzsuperhive.co.uk/arma-oa-ammo-boxes.html
- */
- // Determine ammobox type based upon _iItem name fed from missionConfigfile >> CfgBuildingLoot.hpp
- switch (_iItem) do {
- // Russian/CDF
- case "AK_MAGS": { // Ural ZU23 AA gun
- _boxType = "RUBasicAmmunitionBox";
- _boxMagTypes = ["30Rnd_545x39_AK","30Rnd_545x39_AKSD"];
- _boxMagAmounts = [10,10];
- _boxAmount = 1;
- };
- /* To add more, add case statements with the item name listed in CfgBuildingLoot
- Template (for single item):
- case "BoxNameHere": { // Item Description
- _boxType = "RUBasicAmmunitionBox"; // box type
- _boxLoadout = "ammo"; // or "weapon" (default is ammo; no entry needed)
- _boxAmount = 1; (default is 1; no entry needed if just 1)
- _item addMagazineCargoGlobal ["ItemNameHere", AmountToAdd];
- Template (for multiple items):
- case "BoxNameHere": {
- _boxLoadout = "multi"; // signifies crate with multiple mags and weapons in any combination
- _boxMagTypes = ["Magtype1","Magtype2"]; // etc
- _boxMagAmounts = [50,25]; // 50 of Magtype1 and 25 of magtype2
- _boxWeaponTypes = ["MyWeapon1","MyWeapon2"];
- _boxWeaponAmounts = [10,15];
- };
- };
- */
- };
- if (_Debug) then {
- //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]);
- };
- // Create the box
- _box = createVehicle [_boxType, _iPos, [], _radius, "CAN_COLLIDE"];
- waitUntil {!isNull _box};
- // Clear all items in default box
- clearMagazineCargoGlobal _box;
- clearWeaponCargoGlobal _box;
- _boxEmptied = true;
- waitUntil {_boxEmptied};
- // Add specified cargo
- if (_boxLoadout == "ammo") then { // default is ammo
- _box addMagazineCargoGlobal [_iItem, _boxAmount];
- _loaded = true;
- };
- if (_boxLoadout == "weapon") then {
- _box addWeaponCargoGlobal [_iItem, _boxAmount];
- _loaded = true;
- };
- if (_boxLoadout == "multi") then {
- //
- if (count _boxMagTypes > 0) then {
- _count = count _boxMagTypes;
- for "_x" from 0 to _count do {
- _MagName = _boxMagTypes select _x;
- _MagAmount = _boxMagAmounts select _x;
- if (_MagAmount <= 0) then { _MagAmount = 1; };
- _box addMagazineCargoGlobal [_MagName,_MagAmount];
- };
- };
- // Process weaponry
- if (count _boxWeaponTypes > 0) then {
- _count = count _boxWeaponTypes;
- for "_x" from 0 to _count do {
- _WeaponName = _boxWeaponTypes select _x;
- _WeaponAmount = _boxWeaponAmounts select _x;
- if (_WeaponAmount <= 0) then { _WeaponAmount = 1; };
- _box addWeaponCargoGlobal [_WeaponName,_WeaponAmount];
- };
- };
- _loaded = true;
- };
- waitUntil {_loaded};
- // Report to RPT file
- if (_Debug) then {
- //diag_log(format["Spawn_Box_Barrack: Spawned loot box %1 at worldspace %2 at grid location %3",_iItem,_iPos,_iPos call fa_coor2str]);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement