Jump to content
  • 0

Gem spawn rate


Achmed

Question

Im thinking of using gems as high value item you can trade in your briefcases for as a way of taking up less space and something to work towards

 

looking at the gem code it looks as if there is the same chance for them all to spawn rather then some more rare then others

		if (_isMine) then {
			if((random 10) <= 4) then {
				_gems = ["ItemTopaz","ItemObsidian","ItemSapphire","ItemAmethyst","ItemEmerald","ItemCitrine","ItemRuby"];
				_gem = _gems select (floor(random (count _gems)));
				_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
			};
		};

Would the code below work to make it so each gem has a different spawn chance?

		if (_isMine) then {
			if((random 20) <= 7) then {
				_gems = ["ItemTopaz"];
				_gem = _gems select (floor(random (count _gems)));
				_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
			};
			{else}
			if((random 20) <= 6) then {
				_gems = ["ItemObsidian"];
				_gem = _gems select (floor(random (count _gems)));
				_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
			};
			{else}
			if((random 20) <= 5) then {
				_gems = ["ItemSapphire"];
				_gem = _gems select (floor(random (count _gems)));
				_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
			};
			{else}
			if((random 20) <= 4) then {
				_gems = ["ItemAmethyst"];
				_gem = _gems select (floor(random (count _gems)));
				_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
			};
			{else}
			if((random 20) <= 3) then {
				_gems = ["ItemEmerald"];
				_gem = _gems select (floor(random (count _gems)));
				_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
			};
			{else}
			if((random 20) <= 2) then {
				_gems = ["ItemCitrine"];
				_gem = _gems select (floor(random (count _gems)));
				_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
			};
			{else}
			if((random 20) <= 1) then {
				_gems = ["ItemRuby"];
				_gem = _gems select (floor(random (count _gems)));
				_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
			};
		};
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Try this:

_randomMineCount = floor(random 21); //0-20
if (_isMine) then {
if (_randomMineCount <= 7) then {
_gems = ["ItemTopaz"];
_gem = _gems select (floor(random (count _gems)));
_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};
if (_randomMineCount <= 6) then {
_gems = ["ItemObsidian"];
_gem = _gems select (floor(random (count _gems)));
_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};
if (_randomMineCount <= 5) then {
_gems = ["ItemSapphire"];
_gem = _gems select (floor(random (count _gems)));
_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};
if (_randomMineCount <= 4) then {
_gems = ["ItemAmethyst"];
_gem = _gems select (floor(random (count _gems)));
_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};
if (_randomMineCount <= 3) then {
_gems = ["ItemEmerald"];
_gem = _gems select (floor(random (count _gems)));
_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};
if (_randomMineCount <= 2) then {
_gems = ["ItemCitrine"];
_gem = _gems select (floor(random (count _gems)));
_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};
if (_randomMineCount <= 1) then {
_gems = ["ItemRuby"];
_gem = _gems select (floor(random (count _gems)));
_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};
};
This is untested. You can also do it with "Switch do" .
 
Link to comment
Share on other sites

  • 0

Try something like this:

if (_isMine) then {
	_rnd = random 100;
	if (_rnd < 40) then {_gem = "ItemTopaz";};       //13.6%
	if (_rnd < 26.4) then {_gem = "ItemObsidian";};  //9.2%
	if (_rnd < 17.2) then {_gem = "ItemSapphire";};  //6.4%
	if (_rnd < 10.8) then {_gem = "ItemAmethyst";};  //4.4%
	if (_rnd < 6.4) then {_gem = "ItemEmerald";};    //3.2%
	if (_rnd < 3.2) then {_gem = "ItemCitrine";};    //2%
	if (_rnd < 1.2) then {_gem = "ItemRuby";};       //1.2%
	_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};
Link to comment
Share on other sites

  • 0

 

Try something like this:

if (_isMine) then {
	_rnd = random 100;
	if (_rnd < 40) then {_gem = "ItemTopaz";};       //13.6%
	if (_rnd < 26.4) then {_gem = "ItemObsidian";};  //9.2%
	if (_rnd < 17.2) then {_gem = "ItemSapphire";};  //6.4%
	if (_rnd < 10.8) then {_gem = "ItemAmethyst";};  //4.4%
	if (_rnd < 6.4) then {_gem = "ItemEmerald";};    //3.2%
	if (_rnd < 3.2) then {_gem = "ItemCitrine";};    //2%
	if (_rnd < 1.2) then {_gem = "ItemRuby";};       //1.2%
	_selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]];
};

I tried using this but when i do no gems spawn at all. I must be doing something wrong. Does this work on your server?

 

I figured it out. I had to add "_gem" to the list of private variables at the top.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...