Filling boxes at random?

Filling boxes at random?

« posted: Aug 14, 2015, 08:14 PM »
So, Im wondering how I would make it so that I can have a series of boxes that get filled with random stuff on the fly. So, for example, a mission spawns that has a Standard box. The box that spawns is loaded with random gear of a particular class. So, a box that is labeled as a missile box in the mission files is filled with random missile related gear that is pulled from an array of missile stuff. the same would be with each type of box and gear. This way, hopefully, each box you find would be different in content.
  • Offline Matt76
  • Mercenary
  • *****
  • Posts: 418
  • co founder of customcombatgaming.com

Re: Filling boxes at random?

« Reply #1 posted: Aug 15, 2015, 01:48 AM »
Have you tried looking at different BIS functions?

https://community.bistudio.com/wiki/BIS_fnc_selectRandom

Re: Filling boxes at random?

« Reply #2 posted: Aug 15, 2015, 05:06 AM »
So, I would use it like this?

_LRifleCrate call BIS_fnc_selectRandom;
{
   blah,
   blah,
   blah,
   blah
};

  • Offline Matt76
  • Mercenary
  • *****
  • Posts: 418
  • co founder of customcombatgaming.com

Re: Filling boxes at random?

« Reply #3 posted: Aug 15, 2015, 08:34 AM »
nearly, like this

Code: [Select]
_randomBox = ["mission_USLaunchers","mission_USSpecial","mission_Main_A3snipers","airdrop_DLC_Rifles","airdrop_DLC_LMGs","airdrop_Snipers"] call BIS_fnc_selectRandom;
_randomCase = ["Box_FIA_Support_F","Box_FIA_Wps_F","Box_FIA_Ammo_F","Box_NATO_WpsSpecial_F","Box_East_WpsSpecial_F","Box_NATO_Ammo_F","Box_East_Ammo_F"] call BIS_fnc_selectRandom;

Re: Filling boxes at random?

« Reply #4 posted: Aug 15, 2015, 06:24 PM »
Ok.

My idea would work like this:

I would have an array of crate names eg: Basic rifles, advanced weapons, etc
I would have an array for each type of weapon eg: Rifles, LMGs, Snipers, Rockets, etc
When any crate spawns, it would randomly pick a crate from the array. And when it spawns, it would be filled by random selection from one of the weapon arrays depending on the type of crate spawned.
  • Offline Matt76
  • Mercenary
  • *****
  • Posts: 418
  • co founder of customcombatgaming.com

Re: Filling boxes at random?

« Reply #5 posted: Aug 15, 2015, 07:44 PM »
My example does this,

The case is the type of box to randomly select (cosmetically), the box (badly worded) is what goes inside.

Have a look at the fn_refilbox.sqf to define what is actually in each 'box'

Re: Filling boxes at random?

« Reply #6 posted: Aug 15, 2015, 11:20 PM »
My example does this,

The case is the type of box to randomly select (cosmetically), the box (badly worded) is what goes inside.

Have a look at the fn_refilbox.sqf to define what is actually in each 'box'

So in the file (im at work ATM), there is a section for each box? I could then use the BIS_fnc_selectRandom command to randomly fill each type of box with items from an array in the script?