BIS_fnc_selectRandom @ Mission

BIS_fnc_selectRandom @ Mission

« posted: Jul 06, 2016, 09:30 AM »
We're on a special mission and need at one point lil' help ..

Code: [Select]
_bargate = createVehicle ["XXX", _missionPos, [], 0, "NONE"];
_bunker1 = createVehicle ["Land_WoodenCrate_01_F", _bargate modelToWorld [6.5,-2,-4.1], [], 0, "NONE"];
_obj1 = createVehicle ["I_HMG_01_high_F", _bargate modelToWorld [6.5,-2,-4.1], [], 0, "NONE"];
_bunker2 = createVehicle ["Land_BagFence_01_round_green_F", _bargate modelToWorld [-8,-2,-4.1], [], 0, "NONE"];
_obj2 = createVehicle ["I_HMG_01_high_F", _bargate modelToWorld [-8,-2,-4.1], [], 0, "NONE"];

XXX is actually one static object. We want this object randomized. Is this code correct then?

Code: [Select]
_bargate = ["XXX","YYY","ZZZ"];
_currbargate = _bargate call BIS_fnc_selectRandom;

  • Offline soulkobk
  • Hardened
  • ****
  • Posts: 100
  • soulkobk.blogspot.com.au

Re: BIS_fnc_selectRandom @ Mission

« Reply #1 posted: Jul 06, 2016, 01:14 PM »
yes, that is correct...

Code: [Select]

// set up the array of objects
_bargateArray = [
"object1",
"object2",
"object3"
];

// select random object from array via BIS function
_bargateChosen = _bargateArray call BIS_fnc_selectRandom;

// or you can do...

// select random object from array via own function
_bargateChosen = _bargateArray select (floor random (count _bargateArray));

// then finish with creating the object
_bargate = createVehicle [_bargateChosen, _missionPos, [], 0, "NONE"];

-soul.

Re: BIS_fnc_selectRandom @ Mission

« Reply #2 posted: Jul 06, 2016, 01:25 PM »
thx!  :)
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2490

Re: BIS_fnc_selectRandom @ Mission

« Reply #3 posted: Jul 06, 2016, 03:06 PM »
Just a very minor side note, BIS_fnc_selectRandom is deprecated, you should use the new selectRandom command instead

Re: BIS_fnc_selectRandom @ Mission

« Reply #4 posted: Jul 06, 2016, 05:34 PM »
Okay. Original code came from the Roadblock Missions. Don't know, if these are deprecated, too.

Anyway: thx  8)

edit: Worked!  :)

Re: BIS_fnc_selectRandom @ Mission

« Reply #5 posted: Aug 15, 2016, 10:07 AM »
Morning.  8)

Again something, I need lil' help.

Code: [Select]
_box1 = createVehicle [_randomCase,[(_geoPos select 0), (_geoPos select 1),200],[], 0, "NONE"];
_box1 setDir random 360;
_box1 addItemCargoGlobal ["O_NVGoggles_ghex_F",1];
_box1 addItemCargoGlobal ["NVGogglesB_grn_F",1];
_box1 addItemCargoGlobal ["H_HelmetO_ViperSP_ghex_F",1];
_box1 addItemCargoGlobal ["H_HelmetB_TI_tna_F",1];
_box1 allowdamage false;
{ _x setVariable ["R3F_LOG_disabled", false, true] } forEach [_box1];

How can I randomize the content of the box? So there's only ONE listed item in it.
  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1077
  • ^_^;;

Re: BIS_fnc_selectRandom @ Mission

« Reply #6 posted: Aug 15, 2016, 12:48 PM »
Not sure I understand ?

Like this?

Code: [Select]
_box1 = createVehicle [_randomCase,[(_geoPos select 0), (_geoPos select 1),200],[], 0, "NONE"];
_box1 setDir random 360;
_boxContents ["O_NVGoggles_ghex_F","NVGogglesB_grn_F","H_HelmetO_ViperSP_ghex_F","H_HelmetB_TI_tna_F"] BIS_fnc_selectRandom; // or use the new selectRandom command like AgentRev said
_box1 addItemCargoGlobal [_boxContents,1];
_box1 allowdamage false;
{ _x setVariable ["R3F_LOG_disabled", false, true] } forEach [_box1];
   

- from the grassy knoll -

Re: BIS_fnc_selectRandom @ Mission

« Reply #7 posted: Aug 15, 2016, 02:45 PM »
Think so, yes!  ;D

Actually, in the para dropped box are 4 items. I want just ONE of these 4. Per random.

Thx m8!
  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1077
  • ^_^;;

Re: BIS_fnc_selectRandom @ Mission

« Reply #8 posted: Aug 16, 2016, 07:37 AM »
Think so, yes!  ;D

Actually, in the para dropped box are 4 items. I want just ONE of these 4. Per random.

Thx m8!

create a new set in fn_refillBox and call that  ?

- from the grassy knoll -

Re: BIS_fnc_selectRandom @ Mission

« Reply #9 posted: Aug 16, 2016, 12:18 PM »
But then each box at other missions will have these stuff in it ..?

Code: [Select]
_randomBox = ["mission_USLaunchers","mission_USSpecial","mission_Main_A3snipers"] call BIS_fnc_selectRandom;
_randomCase = ["Box_FIA_Support_F","Box_FIA_Wps_F","Box_FIA_Ammo_F","Box_NATO_WpsSpecial_F","Box_East_WpsSpecial_F","Box_NATO_Ammo_F","Box_East_Ammo_F"] call BIS_fnc_selectRandom;

We'll try the way u suggested, first.  ;)