wogz187 1085 Posted July 10, 2019 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
sarogahtyp 1104 Posted July 10, 2019 you could: _scripts = ["searchZONE.sqf", "searchZONE2.sqf", "noEMERG.sqf"]; _selected = selectRandom _scripts; [] execVM _selected; 2 1 Share this post Link to post Share on other sites
gc8 970 Posted July 10, 2019 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 🙂 2 1 Share this post Link to post Share on other sites
wogz187 1085 Posted July 10, 2019 @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
gc8 970 Posted July 10, 2019 Or with selectRandomWeighted: _scriptFile = ["searchZONE.sqf","searchZONE2.sqf"] selectRandomWeighted [0.1, 0.5]; execVM _scriptFile; 4 Share this post Link to post Share on other sites
wogz187 1085 Posted July 10, 2019 @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. 1 1 Share this post Link to post Share on other sites
Joe98 90 Posted May 9, 2020 Arma 3. How to select a script and random. On 7/11/2019 at 1:18 AM, sarogahtyp said: you could: _scripts = ["searchZONE.sqf", "searchZONE2.sqf", "noEMERG.sqf"]; _selected = selectRandom _scripts; [] execVM _selected; I put this here so I can find it again easily! Fabulous! Share this post Link to post Share on other sites
wogz187 1085 Posted May 9, 2020 @Joe98, A year later and this can be simplified, _selected = selectRandom ["searchZONE.sqf", "searchZONE2.sqf", "noEMERG.sqf"]; [] execVM _selected; But I wouldn't do it like that anymore. Instead of a bunch of .sqf files-- I'd just use a single configurable function. _selected = selectRandom [1,2,3]; [_selected] spawn you_fnc_searchZone; In dealing with randomness I've found it's a good idea to record what is currently active for other scripts to reference. missionNameSpace setVariable ["mission_type", _selected]; Have fun! 3 Share this post Link to post Share on other sites
sarogahtyp 1104 Posted May 12, 2020 depends always on OPs knowledge at the time he is asking. a year ago u didn't know 'bout function library I guess. So at this time it was the easiest way to get a working solution for you. also there is nothing wrong with seperating things in different files. the real advantage comes with using precompiled functions... 3 Share this post Link to post Share on other sites