Jump to content

New BIS_fnc_selectRandom Function


Donnovan

Recommended Posts

SYNTAX:

result = [array,factor] call LOL_fnc_selectRandomFactor;

array is an array with elements. Those elements can be of type array.

factor is how much the elements with lower index will be priorized (look the image on the link bellow).

result is an element of "array".

EXAMPLE 1:

//EXAMPLE
//_randomVeh have a 55% chance to be "car_hatchback"
//_randomVeh have a 20% chance to be "hilux1_civil_3_open"
//_randomVeh have a 15% chance to be "UAZ_CDF"
//_randomVeh have a 10% chance to be "HMMWV"

_vehicles = ["car_hatchback","hilux1_civil_3_open","UAZ_CDF","HMMWV"];
_randomVeh = [_vehicles,2.25] call LOL_fnc_selectRandomFactor;

EXAMPLE 2 (making it like BIS_fnc_selectRandom):

//EXAMPLE
//_randomVeh have a 25% chance to be "car_hatchback"
//_randomVeh have a 25% chance to be "hilux1_civil_3_open"
//_randomVeh have a 25% chance to be "UAZ_CDF"
//_randomVeh have a 25% chance to be "HMMWV"

_vehicles = ["car_hatchback","hilux1_civil_3_open","UAZ_CDF","HMMWV"];
_randomVeh = [_vehicles,1] call LOL_fnc_selectRandomFactor;

THE FUNCTION:

LOL_fnc_selectRandomFactor = {
	_array = _this select 0;
	_factor = _this select 1;
	_array select (floor ((random ((count _array)^(1/_factor)))^(_factor)))
};

SHART ANALISYS OF THE FUNCTION:

new%20select%20random_zpsfuals8n4.png

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...