Jump to content
Sign in to follow this  
icebreakr

RPG content: random stuff in crates

Recommended Posts

I have 10 crates randomly scattered all over the island (preset positions). How do I make a init command to randomly fill them with one of the 5 content possibilities:

1. empty

2. empty

3. empty

4. pistols + rifles

5. sniper rifle

?

This should get initialized (filled) on game start only. Does anyone have a MP compatible script for that?

Share this post


Link to post
Share on other sites

Would probably have to be a script to make it work:

Init: handle = this execVM "crate_content.sqf";

crate_content.sqf:

_r = floor random 5; // Gives a number from 0-4, i.e. 5 different ones
switch (_r) do {
   case 3: {
       this addWeaponCargo ["ClassName",Number];
       this addMagazineCargo ["ClassName",Number];
   };
   case 4: {
       this addWeaponCargo ["ClassName",Number];
       this addMagazineCargo ["ClassName",Number];
   };
};

Share this post


Link to post
Share on other sites

You might want to add an array of box names, then have a script for the sniper rifle, another for pistols and so on, and have each choose a random box to populate then delete the entry from the array. That would avoid ten empty boxes, or ten sniper boxes...

Hmm...

array = [box1,box2,box3]
_varName = array select (random (count array));
_varName addWeapon "whatever";
_tempArray = [_varName];
array = array - _tempArray;

Something along those lines.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×