Hello,
I am attempting to build a weapons/magazine list for AI. I'm using fnc_buildWeightedArray which right now is an agent of Satan in my eyes.
I can build two arrays:
_weapons = [["SCAR_L_STD_EGLM_RCO","30Rnd_556x45_Stanag"],["SCAR_H_CQC_CCO","20Rnd_762x51_B_SCAR"]]; _chance = [0.1,0.2]; _weightedArray = [_weapons,_chance] call fnc_buildWeightedArray;
no big deal, but when the array gets huge... it becomes pretty painful
What I'd really like to do is run a nested array, but I haven't had any luck splitting the data off.
_weaponsList = [ [["SCAR_L_STD_EGLM_RCO","30Rnd_556x45_Stanag"],0.1], [["SCAR_H_CQC_CCO","20Rnd_762x51_B_SCAR"],0.2] ]; /* Oh noes I am lost here */ _weightedArray = [_weapons,_chance] call fnc_buildWeightedArray;
I've tried quite a few things, this was the strongest lead I had. I do need the split weapons and chance further in the script.
_listCount = (count _weaponsList) -1; _weapons = []; _chance = []; for "_x" from 0 to _listCount do { _weapons = ((_weaponsList select _x) select 0) + _weapons; _chance = ((_weaponsList select _x) select 1) + _chance; };
but, doesn't work... I'm hoping it is simple, and I am starting to wonder if it is treating my arrays as strings.
not a lot of examples of the weighted array out there. Can anyone throw me a bone?