CCIP-subsim
Posts: 695
Joined: 11/10/2015 Status: offline
|
Here's an example I used, which just happened to be annotated:
math.randomseed(os.time())
--weapon allocations
--first clear mags
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=88, remove=true, w_max=10000, number=10000}) --AIM9B
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=412, remove=true, w_max=10000, number=10000}) --Hydra 70mm
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=413, remove=true, w_max=10000, number=10000}) --Zuni 127mm
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=1166, remove=true, w_max=10000, number=10000}) --Mk81
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=6, remove=true, w_max=10000, number=10000}) --Mk82
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=409, remove=true, w_max=10000, number=10000}) --Mk83
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=339, remove=true, w_max=10000, number=10000}) --M117
--then randomize weapon allocations
dn_aim9b = math.random(16,48)
dn_hydra = math.random(266,1330)
dn_zuni = math.random(0,32)
dn_mk81 = math.random (12,64)
dn_mk82 = math.random(84,204)
dn_mk83 = math.random(24,54)
dn_m117 = math.random(16,72)
--then fill mags
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=88, remove=false, w_max=10000, number=dn_aim9b}) --AIM9B
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=412, remove=false, w_max=10000, number=dn_hydra}) --Hydra 70mm
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=413, remove=false, w_max=10000, number=dn_zuni}) --Zuni 127mm
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=1166, remove=false, w_max=10000, number=dn_mk81}) --Mk81
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=6, remove=false, w_max=10000, number=dn_mk82}) --Mk82
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=409, remove=false, w_max=10000, number=dn_mk83}) --Mk83
ScenEdit_AddWeaponToUnitMagazine({unitname='Da Nang AB', wpn_dbid=339, remove=false, w_max=10000, number=dn_m117}) --M117
In that example I emptied the magazines and basically re-set the weapon allocations every night to prevent "hoarding" of weapons, but if you want stockpiles to build up, you can skip that first step and just add to the pool It's not a very sophisticated solution, but I found it simple enough for keeping the player at least thinking about aircraft loadouts.
|