Jump to content
Ricardo

Randomize Custom Box's

Recommended Posts

Hello,

 

I have created Static box's so the loot inside it's not randomize, however i would like to know how can i randomize my static box's?

 

What i mean is, not randomize the loot inside the box but the box that it chooses to spawn from the static ones i created.

 

This is my DZMSBox.sqf

/*


Usage: [_crate,"type"] execVM "dir\DZMSBox.sqf";
_crate is the crate to fill
"type" is the type of crate
"type" can be weapons or medical
*/
_crate = _this select 0;
_type = _this select 1;

// Clear the current cargo
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;

// Define lists. Some lists are defined in DZMSWeaponCrateList.sqf in the ExtConfig.
_bpackList = ["DZ_Patrol_Pack_EP1","DZ_Assault_Pack_EP1","DZ_Czech_Vest_Puch","DZ_ALICE_Pack_EP1","DZ_TK_Assault_Pack_EP1","DZ_British_ACU","DZ_CivilBackpack_EP1","DZ_Backpack_EP1"];
_gshellList = ["HandGrenade_west","FlareGreen_M203","FlareWhite_M203"];
_medical = ["ItemBandage","ItemMorphine","ItemEpinephrine","ItemPainkiller","ItemWaterbottle","FoodMRE","ItemAntibiotic","ItemBloodbag"];
_money = ["ItemSilverBar","ItemSilverBar10oz","ItemGoldBar","ItemGoldBar10oz"];
_box = ["weapons","weapons1","weapons3","weapons4"];
_box2 = ["weapons","weapons1","weapons3","weapons4"];
_box3 = ["medical","medical2","food"];
_box4 = ["supply","supply2"];

//////////////////////////////////////////////////////////////////
// Medical Crates
if (_type == "medical") then {
// load medical
// Add Ammunition
_crate addMagazineCargoGlobal ["ItemBandage",20];
_crate addMagazineCargoGlobal ["ItemMorphine",10];
_crate addMagazineCargoGlobal ["ItemEpinephrine",10];
_crate addMagazineCargoGlobal ["ItemPainkiller",10];
_crate addMagazineCargoGlobal ["ItemBloodbag",10];
_crate addMagazineCargoGlobal ["ItemAntibiotic",5];
_crate addMagazineCargoGlobal ["SmokeShell",2];
_crate addMagazineCargoGlobal ["SmokeShellYellow",2];
_crate addMagazineCargoGlobal ["SmokeShellRed",2];
_crate addMagazineCargoGlobal ["SmokeShellGreen",2];
_crate addMagazineCargoGlobal ["SmokeShellPurple",2];
_crate addMagazineCargoGlobal ["SmokeShellBlue",2];
_crate addMagazineCargoGlobal ["SmokeShellOrange",2];

// Add Weapons
_crate addWeaponCargoGlobal ["Binocular_Vector",1];
_crate addWeaponCargoGlobal ["ItemToolbox",2];
_crate addWeaponCargoGlobal ["ItemEtool",2];

// Add Backpacks
_crate addBackpackCargoGlobal ["DZ_GunBag_EP1",2];
_crate addBackpackCargoGlobal ["DZ_Backpack_EP1",1];
_crate addBackpackCargoGlobal ["DZ_LargeGunBag_EP1",1];
};
if (_type == "medical2") then {
// load medical
// Add Ammunition
_crate addMagazineCargoGlobal ["ItemBandage",15];
_crate addMagazineCargoGlobal ["ItemMorphine",12];
_crate addMagazineCargoGlobal ["ItemEpinephrine",15];
_crate addMagazineCargoGlobal ["ItemPainkiller",15];
_crate addMagazineCargoGlobal ["ItemBloodbag",12];
_crate addMagazineCargoGlobal ["ItemAntibiotic",7];
_crate addMagazineCargoGlobal ["SmokeShell",2];
_crate addMagazineCargoGlobal ["SmokeShellYellow",2];
_crate addMagazineCargoGlobal ["SmokeShellRed",2];
_crate addMagazineCargoGlobal ["SmokeShellGreen",2];
_crate addMagazineCargoGlobal ["SmokeShellPurple",2];
_crate addMagazineCargoGlobal ["SmokeShellBlue",2];
_crate addMagazineCargoGlobal ["SmokeShellOrange",2];

// Add Weapons
_crate addWeaponCargoGlobal ["ItemGPS",1];
_crate addWeaponCargoGlobal ["ItemCrowbar",2];
_crate addWeaponCargoGlobal ["Binoculars",2];

// Add Backpacks
_crate addBackpackCargoGlobal ["DZ_GunBag_EP1",1];
_crate addBackpackCargoGlobal ["DZ_Backpack_EP1",2];
_crate addBackpackCargoGlobal ["DZ_LargeGunBag_EP1",1];
};

//////////////////////////////////////////////////////////////////
// Food Crates
if (_type == "food") then {
// load Food
// Add Ammunition
_crate addMagazineCargoGlobal ["FoodMRE",5];
_crate addMagazineCargoGlobal ["FoodSteakCooked",2];
_crate addMagazineCargoGlobal ["FoodCanBoneboy",2];
_crate addMagazineCargoGlobal ["FoodCanGriff",2];
_crate addMagazineCargoGlobal ["FoodCanCorn",2];
_crate addMagazineCargoGlobal ["FoodCanBadguy",2];
_crate addMagazineCargoGlobal ["FoodCanCurgon",2];
_crate addMagazineCargoGlobal ["FoodCanDemon",2];
_crate addMagazineCargoGlobal ["FoodCanFraggleos",2];
_crate addMagazineCargoGlobal ["FoodCanHerpy",2];
_crate addMagazineCargoGlobal ["ItemWaterbottle",5];
_crate addMagazineCargoGlobal ["ItemSodaR4z0r",2];
_crate addMagazineCargoGlobal ["ItemSodaClays",2];
_crate addMagazineCargoGlobal ["ItemSodaSmasht",2];
_crate addMagazineCargoGlobal ["ItemSodaDrwaste",2];
_crate addMagazineCargoGlobal ["ItemSodaLemonade",2];
_crate addMagazineCargoGlobal ["ItemSodaLvg",2];
_crate addMagazineCargoGlobal ["ItemSodaMzly",2];
_crate addMagazineCargoGlobal ["ItemSodaRabbit",2];
_crate addMagazineCargoGlobal ["ItemSodaRbull",1];
};

///////////////////////////////////////////////////////////////////
// Weapon Crates
if (_type == "weapons") then {
// load Weapons
// Add weapons

// Add Weapons
_crate addWeaponCargoGlobal ["M16A2",3];
_crate addWeaponCargoGlobal ["M4A1_HWS_GL_SD_Camo",3];
_crate addWeaponCargoGlobal ["G36K",2];
_crate addWeaponCargoGlobal ["M9SD",2];
_crate addWeaponCargoGlobal ["M1014",2];
_crate addWeaponCargoGlobal ["AKS_74_U",2];
_crate addWeaponCargoGlobal ["m8_Sharpshooter",1];
_crate addWeaponCargoGlobal ["AK_74_GL",1];
_crate addWeaponCargoGlobal ["M24",1];
_crate addWeaponCargoGlobal ["M40A3",1];

// Add Ammunition
_crate addMagazineCargoGlobal ["30Rnd_556x45_Stanag",20];
_crate addMagazineCargoGlobal ["30Rnd_556x45_StanagSD",10];
_crate addMagazineCargoGlobal ["15Rnd_9x19_M9SD",10];
_crate addMagazineCargoGlobal ["8Rnd_B_Beneli_74Slug",15];
_crate addMagazineCargoGlobal ["5Rnd_762x51_M24",10];
_crate addMagazineCargoGlobal ["20Rnd_762x51_DMR",5];
_crate addMagazineCargoGlobal ["30Rnd_545x39_AK",10];
_crate addMagazineCargoGlobal ["1Rnd_SMOKE_GP25",4];

// Add Backpacks
_crate addBackpackCargoGlobal ["DZ_GunBag_EP1",1];
_crate addBackpackCargoGlobal ["DZ_Backpack_EP1",2];
_crate addBackpackCargoGlobal ["DZ_LargeGunBag_EP1",1];

};
if (_type == "weapons2") then {
// load Weapons
// Add weapons

// Add Weapons
_crate addWeaponCargoGlobal ["G36A",3];
_crate addWeaponCargoGlobal ["G36_C_SD_Eotech",3];
_crate addWeaponCargoGlobal ["G36C",2];
_crate addWeaponCargoGlobal ["MakarovSD",2];
_crate addWeaponCargoGlobal ["m8_Carbine",2];
_crate addWeaponCargoGlobal ["MP5A5",2];
_crate addWeaponCargoGlobal ["m8_Sharpshooter",1];
_crate addWeaponCargoGlobal ["Mk_48_DZ",1];
_crate addWeaponCargoGlobal ["SVD_Camo",1];
_crate addWeaponCargoGlobal ["KSVK_DZE",1];
_crate addWeaponCargoGlobal ["RPK_74",1];

// Add Ammunition
_crate addMagazineCargoGlobal ["30Rnd_556x45_G36",20];
_crate addMagazineCargoGlobal ["30Rnd_556x45_G36SD",15];
_crate addMagazineCargoGlobal ["8Rnd_9x18_MakarovSD",10];
_crate addMagazineCargoGlobal ["100Rnd_762x51_M240",5];
_crate addMagazineCargoGlobal ["10Rnd_762x54_SVD",10];
_crate addMagazineCargoGlobal ["5Rnd_127x108_KSVK",5];
_crate addMagazineCargoGlobal ["75Rnd_545x39_RPK",5];
_crate addMagazineCargoGlobal ["30rnd_9x19_MP5",5];
_crate addMagazineCargoGlobal ["HandGrenade",5];

};
if (_type == "weapons3") then {
// load Weapons3
// Add weapons

// Add Weapons
_crate addWeaponCargoGlobal ["SCAR_L_CQC",3];
_crate addWeaponCargoGlobal ["SCAR_L_CQC_CCO_SD",3];
_crate addWeaponCargoGlobal ["Sa58V_CCO_EP1",2];
_crate addWeaponCargoGlobal ["Colt1911",2];
_crate addWeaponCargoGlobal ["bizon_silenced",2];
_crate addWeaponCargoGlobal ["AKS_74_U",2];
_crate addWeaponCargoGlobal ["M8_carbineGL",1];
_crate addWeaponCargoGlobal ["AK_74_GL",1];
_crate addWeaponCargoGlobal ["VSS_vintorez",1];
_crate addWeaponCargoGlobal ["M40A3",1];
_crate addWeaponCargoGlobal ["M240_DZ",1];
_crate addWeaponCargoGlobal ["RPG7V",1];

// Add Ammunition
_crate addMagazineCargoGlobal ["30Rnd_556x45_Stanag",15];
_crate addMagazineCargoGlobal ["30Rnd_556x45_StanagSD",10];
_crate addMagazineCargoGlobal ["7Rnd_45ACP_1911",10];
_crate addMagazineCargoGlobal ["64Rnd_9x19_SD_Bizon",15];
_crate addMagazineCargoGlobal ["5Rnd_762x51_M24",10];
_crate addMagazineCargoGlobal ["100Rnd_762x51_M240",5];
_crate addMagazineCargoGlobal ["30Rnd_545x39_AK",10];
_crate addMagazineCargoGlobal ["20Rnd_9x39_SP5_VSS",5];

};
if (_type == "weapons4") then {
// load Weapons4
// Add weapons

// Add Weapons
_crate addWeaponCargoGlobal ["AK_47_M",3];
_crate addWeaponCargoGlobal ["Mk_48_DES_EP1",1];
_crate addWeaponCargoGlobal ["Sa58V_CCO_EP1",2];
_crate addWeaponCargoGlobal ["glock17_EP1",2];
_crate addWeaponCargoGlobal ["Saiga12K",2];
_crate addWeaponCargoGlobal ["AK_47_S",2];
_crate addWeaponCargoGlobal ["m8_SAW",1];
_crate addWeaponCargoGlobal ["PK",1];
_crate addWeaponCargoGlobal ["SCAR_H_LNG_Sniper",1];
_crate addWeaponCargoGlobal ["M24_des_EP1",1];
_crate addWeaponCargoGlobal ["M110_NVG_EP1",1];
_crate addWeaponCargoGlobal ["M4SPR",1];

// Add Ammunition
_crate addMagazineCargoGlobal ["30Rnd_556x45_Stanag",15];
_crate addMagazineCargoGlobal ["30Rnd_556x45_StanagSD",10];
_crate addMagazineCargoGlobal ["17Rnd_9x19_glock17",10];
_crate addMagazineCargoGlobal ["100Rnd_762x51_M240",5];
_crate addMagazineCargoGlobal ["8Rnd_B_Saiga12_74Slug",15];
_crate addMagazineCargoGlobal ["5Rnd_762x51_M24",10];
_crate addMagazineCargoGlobal ["100Rnd_762x54_PK",5];
_crate addMagazineCargoGlobal ["30Rnd_762x39_AK47",10];
_crate addMagazineCargoGlobal ["20Rnd_762x51_B_SCAR",5];

};

///////////////////////////////////////////////////////////////////
// Ammo Crates
if (_type == "ammo") then {
// load Ammo

// Add Ammunition
_crate addMagazineCargoGlobal ["30Rnd_556x45_Stanag",25];
_crate addMagazineCargoGlobal ["30Rnd_556x45_StanagSD",10];
_crate addMagazineCargoGlobal ["20Rnd_762x51_B_SCAR",10];
_crate addMagazineCargoGlobal ["20Rnd_762x51_SB_SCAR",5];
_crate addMagazineCargoGlobal ["10Rnd_762x54_SVD",10];
_crate addMagazineCargoGlobal ["20Rnd_762x51_DMR",10];
_crate addMagazineCargoGlobal ["5Rnd_762x51_M24",15];
_crate addMagazineCargoGlobal ["30Rnd_545x39_AK",15];
_crate addMagazineCargoGlobal ["30Rnd_556x45_G36",15];
_crate addMagazineCargoGlobal ["30Rnd_762x39_AK4",10];
_crate addMagazineCargoGlobal ["20Rnd_762x51_FNFAL",7];
_crate addMagazineCargoGlobal ["100Rnd_762x51_M240",5];
_crate addMagazineCargoGlobal ["100Rnd_762x54_PK",5];
_crate addMagazineCargoGlobal ["200Rnd_556x45_M249",3];
_crate addMagazineCargoGlobal ["15Rnd_9x19_M9SD",3];
_crate addMagazineCargoGlobal ["17Rnd_9x19_glock17",5];
_crate addMagazineCargoGlobal ["6Rnd_45ACP",5];
_crate addMagazineCargoGlobal ["8Rnd_9x18_MakarovSD",5];
_crate addMagazineCargoGlobal ["30Rnd_9x19_UZI_SD",5];
_crate addMagazineCargoGlobal ["64Rnd_9x19_SD_Bizon",10];
_crate addMagazineCargoGlobal ["30rnd_9x19_MP5",10];
_crate addMagazineCargoGlobal ["PG7V",1];
};

///////////////////////////////////////////////////////////////////
// Epoch Supply Crates
if (_type == "supply") then {
// load Supply
// Add weapons / Tools

// Add Weapons
_crate addWeaponCargoGlobal ["ItemCrowbar",3];
_crate addWeaponCargoGlobal ["ItemEtool",3];
_crate addWeaponCargoGlobal ["ItemHatchet_DZE",2];
_crate addWeaponCargoGlobal ["ItemKnife",2];
_crate addWeaponCargoGlobal ["ItemMachete",2];
_crate addWeaponCargoGlobal ["ItemToolbox",2];
_crate addWeaponCargoGlobal ["ItemSledgeHead",1];
_crate addWeaponCargoGlobal ["ItemSledgeHandle",1];
_crate addWeaponCargoGlobal ["ItemGPS",1];
_crate addWeaponCargoGlobal ["ItemKeyKit",1];

// Add Ammunition
_crate addMagazineCargoGlobal ["CinderBlocks",15];
_crate addMagazineCargoGlobal ["MortarBucket",10];
_crate addMagazineCargoGlobal ["ItemWire",10];
_crate addMagazineCargoGlobal ["ItemTankTrap",5];
_crate addMagazineCargoGlobal ["ItemSandbag",10];
_crate addMagazineCargoGlobal ["PartPlankPack",15];
_crate addMagazineCargoGlobal ["PartPlyWoodPack",10];
_crate addMagazineCargoGlobal ["ItemPole",10];
_crate addMagazineCargoGlobal ["ItemComboLock",1];
};

if (_type == "supply2") then {
// load Supply2
// Add weapons / Tools

// Add Weapons
_crate addWeaponCargoGlobal ["ItemCrowbar",1];
_crate addWeaponCargoGlobal ["ItemEtool",1];
_crate addWeaponCargoGlobal ["ItemHatchet_DZE",2];
_crate addWeaponCargoGlobal ["ItemKnife",2];
_crate addWeaponCargoGlobal ["ItemMachete",2];
_crate addWeaponCargoGlobal ["ItemToolbox",5];
_crate addWeaponCargoGlobal ["ItemGPS",1];
_crate addWeaponCargoGlobal ["ItemKeyKit",3];

// Add Ammunition
_crate addMagazineCargoGlobal ["PartEngine",2];
_crate addMagazineCargoGlobal ["PartGeneric",6];
_crate addMagazineCargoGlobal ["PartFueltank",2];
_crate addMagazineCargoGlobal ["PartGlass",5];
_crate addMagazineCargoGlobal ["PartVRotor",1];
_crate addMagazineCargoGlobal ["PartWheel",4];
_crate addMagazineCargoGlobal ["ItemJerrycan",3];
_crate addMagazineCargoGlobal ["ItemFuelPump",1];
_crate addMagazineCargoGlobal ["ItemFuelBarrel",2];

};

///////////////////////////////////////////////////////////////////
// Epoch Money Crates
if (_type == "money") then {
// load money
_scount = count _money;
for "_x" from 0 to 3 do {
_sSelect = floor(random _sCount);
_item = _money select _sSelect;
_crate addMagazineCargoGlobal [_item,1];
};
};

 

This is the box creating inside one of my missions.

//Add and fill the crate
_crate = createVehicle ["RULaunchersBox",[(_coords select 0) - 14, _coords select 1,0],[], 0, "CAN_COLLIDE"];
[_crate = _box select (random (count _box - 1)] ExecVM DZMSBoxSetup;
[_crate] call DZMSProtectObj;

This is what i have come up so far, but im not sure if i am doing it correctly, can anyone tell me if what im doing is wrong or not?

Share this post


Link to post
Share on other sites

Something like this:

//Add and fill the crate
_box = ["RULaunchersBox","RULaunchersBox","RULaunchersBox"]; // Box Classnames
_fBox = _box select (random (count _box - 1)); // Picks a Classname
_crate = createVehicle [_fBox,[(_coords select 0) - 14, _coords select 1,0],[], 0, "CAN_COLLIDE"]; // Creates the Box
[_crate] ExecVM DZMSBoxSetup;
[_crate] call DZMSProtectObj;

Share this post


Link to post
Share on other sites

Thanks for the quick reply!

 

 

Something like this:

//Add and fill the crate
_box = ["RULaunchersBox","RULaunchersBox","RULaunchersBox"]; // Box Classnames
_fBox = _box select (random (count _box - 1)); // Picks a Classname
_crate = createVehicle [_fBox,[(_coords select 0) - 14, _coords select 1,0],[], 0, "CAN_COLLIDE"]; // Creates the Box
[_crate] ExecVM DZMSBoxSetup;
[_crate] call DZMSProtectObj;

 

But im a bit  confused, im trying to understand your solution to my problem, so...

_box = ["RULaunchersBox","RULaunchersBox","RULaunchersBox"]; // Box Classnames
_fBox = _box select (random (count _box - 1)); // Picks a Classname

_box defines what box can choose, in this case ["USLaunchersBox","RULaunchersBox","USBasicAmmunitionBox"] right?

_fbox randomizes which box will be choosen within all those 4 box's, then:

_crate = createVehicle [_fBox,[(_coords select 0) - 14, _coords select 1,0],[], 0, "CAN_COLLIDE"]; // Creates the Box

Creates the box choosen in _fbox to the mission location, but this for in my understanding spawns a box with the loot that Arma has inside the box or this chooses one of my static box's i defined in DZMSBox.sqf?

 

In this case:

_box = ["weapons","weapons1","weapons3","weapons4"];

Maybe im completly wrong

Im sorry, im not that good with scripting :P

Share this post


Link to post
Share on other sites

Thanks for the quick reply!

 

 

But im a bit  confused, im trying to understand your solution to my problem, so...

_box = ["RULaunchersBox","RULaunchersBox","RULaunchersBox"]; // Box Classnames
_fBox = _box select (random (count _box - 1)); // Picks a Classname

_box defines what box can choose, in this case ["USLaunchersBox","RULaunchersBox","USBasicAmmunitionBox"] right?

_fbox randomizes which box will be choosen within all those 4 box's, then:

_crate = createVehicle [_fBox,[(_coords select 0) - 14, _coords select 1,0],[], 0, "CAN_COLLIDE"]; // Creates the Box

Creates the box choosen in _fbox to the mission location, but this for in my understanding spawns a box with the loot that Arma has inside the box or this chooses one of my static box's i defined in DZMSBox.sqf?

 

In this case:

_box = ["weapons","weapons1","weapons3","weapons4"];

Maybe im completly wrong

Im sorry, im not that good with scripting :P

 

You have it partly right.

_box is the array of classnames to choose from.

_fBox is where it actually chooses one of those classnames from _box randomly. _fBox now contains the name of the box that was chosen.

Now instead of putting the boxname in the createVehicle, we just use _fBox.

When createVehicle creates it, it will have the default Arma loot, yes.

However you now have _crate which refers to the physical box on the map.

You execute DZMSBoxSetup on the _crate which empties it, and fills it with the correct loot.

You then call DZMSProtectObj which prevents the box from disappearing until DZMS decides to remove it.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...