Greets, Homefry,
Feasable. You could generate a random number based on the number of elements in an array, round it off, and then select whatever number results from the array.
You would need two arrays: one for Primary weapon, and one for secondary. Maybe a third for Handgun?
Here's some scripting ideas
The user inputs unit to exec for, and the two (or three) arrays.
;******************************
; RandomWeapons.sqs
;******************************
; PsyWarrior@spiers.tv
;******************************
_unit = _this select 0
_primaryArray = _this select 1
_secondaryArray = _this select 2
;Weapons are removed:
removeAllWeapons _unit
;Generate random number based on no of elements in array.
_n = 0
_n = count _primaryArray
_random1 = random _n
;Add the weapon
_primaryWeap = _primaryArray select _n
_unit addWeapon _primaryWeap
;STOP
At this point you would have to add the ammo for the weapon. One way to do this is to create another array, with the ammo names in the same place as the weapon in the weapons array (
)
EG: primaryArray [m16, weap1,..., weapn]
primaryAmmoArray [m16, weap1Mag,..., weapnMag]
We'll assume that's _this select 3
;Start
_primaryAmmoArray = _this select 3
_ammo = _primaryAmmoArray select _n
_unit addmagazine _ammo
;repeat for 4 times
;Just remembered that this has to be
before the weapon is added. Sorry.
;exactly the same applies for the secondary weapons, if you want them.
exit
;STOP
Yes, it's a mess. But it's also a starting point...
I may refine this a bit when I've had some sleep. As you can see, it is entirely possible.
The only disadvantage is that the mission editor would have to pass 4 great arrays of all the weapons and magazines with the script. Alternatively, you could set the arrays up elsewhere, (init.sqs?), and then simply use
_unit = _this select 0
with primaryArray, secondaryArray etc. all defined elsewhere, and used as global variables.
Of course, due to some glaring error that I have not yet noticed, the above may not work at all
-Supr. Cmdr. PsyWarrior
-Psychic Productions