Jump to content

Recommended Posts

The script I'm working on calls for random sqf selection. I found this, here, and I want to make sure I understand the function. Please advise if my comments to the script are correct.

_script = [1,3] call BIS_fnc_randomInt;  //defines a range for cases, actually says 1-3 or 1, 2, 3. Selects one randomly.
switch (_script) do { // -- I think it says if "_script" is defined, do
case 1 : { [] execVM "1.sqf"; };  //put script names here
case 2 : { [] execVM "2.sqf"; };
case 3 : { [] execVM "3.sqf"; };
};

SwitchDo
So I could,

EMERGENCY = [1,3] call BIS_fnc_randomInt;
switch (EMERGENCY) do {
case 1 : { [] execVM "searchZONE.sqf"; };
case 2: { [] execVM "searchZONE2.sqf"; };
case 3 : { [] execVM "noEMERG.sqf"; };
};

Can I increase the probability of a script by using it for multiple cases? Or would I use something like selectRandomWeighted?

Share this post


Link to post
Share on other sites

you could:

_scripts = ["searchZONE.sqf", "searchZONE2.sqf", "noEMERG.sqf"];

_selected = selectRandom _scripts;

[] execVM _selected;

 

  • Thanks 1

Share this post


Link to post
Share on other sites
5 minutes ago, wogz187 said:

Can I increase the probability of a script by using it for multiple cases? Or would I use something like selectRandomWeighted?

 

Yes use that.

 

You can also do:


 

_scriptFile = selectRandom ["searchZONE.sqf","searchZONE2.sqf"];

execVM _scriptFile;

 

 

Edit: sarogahtyp beat me 🙂

 

  • Thanks 1

Share this post


Link to post
Share on other sites

@gc8, @sarogahtyp,

LOL!

Answered twice and simplified before I even finished editing the topic. Lemme try this out and we'll wrap this thread up. 😄

Share this post


Link to post
Share on other sites

Or with selectRandomWeighted:


 

_scriptFile = ["searchZONE.sqf","searchZONE2.sqf"] selectRandomWeighted [0.1, 0.5];

execVM _scriptFile;

 

  • Like 1

Share this post


Link to post
Share on other sites

@gc8,

You don't want the radio call to fail with "noEMERG.sqf". LOL!

Thanks again, man. You know where I'm going with this.

  • Like 1

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

×