local function AddCleanVLS3017(theUnitobj) local arcT={'PB1','PB2','SB1','SB2','SMF1','SMF2','SMA1','SMA2','SS1','SS2','PS1','PS2','PMA1','PMA2','PMF1','PMF2'}; local arcD={'PB1','PB2','SB1','SB2','SMF1','SMF2','SMA1','SMA2','SS1','SS2','PS1','PS2','PMA1','PMA2','PMF1','PMF2'}; local arcM={'360'}; specialMountId = 3017 ScenEdit_UpdateUnit({guid=tostring(theUnitobj.guid),mode='add_mount',dbid=specialMountId,arc_detect=arcD, arc_track=arcT, arc_mount=arcM}); --ScenEdit_UpdateUnit({guid=tostring(theUnitobj.guid),mode='add_mount',dbid=specialMountId,arc_detect=arcD, arc_track=arcT, arc_mount=arcM}); local tcount = #theUnitobj.mounts local myList = {}; -- hold the items to remove. local bflag = false; for i = 1,tcount do if (theUnitobj.mounts[i]["mount_dbid"] == specialMountId) and (#theUnitobj.mounts[i]["mount_weapons"] > 0) then for wp=1,#theUnitobj.mounts[i]["mount_weapons"] do --if (theUnitobj.mounts[i]["mount_weapons"][wp]["wpn_dbid"] == dbid) then --dbid is weaponDBID. --remove all entries of this weapontype on this typemount. print('fnRemoveAllComponentsWithDBID(): adding entry scoped by mountid i: ' .. i .. ' wp:' .. wp .. ' ' .. theUnitobj.mounts[i]["mount_weapons"][wp]["wpn_guid"] .. ' name: ' .. theUnitobj.mounts[i]["mount_weapons"][wp]["wpn_name"]); table.insert(myList,{Wguid=theUnitobj.mounts[i]["mount_weapons"][wp]["wpn_guid"], Mguid=theUnitobj.mounts[i]["mount_guid"], wpn_dbid=theUnitobj.mounts[i]["mount_weapons"][wp]["wpn_dbid"]}); bflag=true; --end end end end if (bflag == true) then print('there are '.. #myList .. ' to remove') for k,v in pairs(myList) do ScenEdit_UpdateUnit({guid=theUnitobj.guid,mode='remove_weapon',dbid=v.wpn_dbid,mountid=v.Mguid,weaponid=v.Wguid}); --must give mountid end print('removed'); end end local function FindFirstMatchingMountIdByDBID(unit,matchdbid) if (unit ~=nil and dbid ~=nil) then for i =1,#unit.mounts do if(unit.mounts[i]["mount_dbid"] == matchdbid) then return unit.mounts[i]["mount_guid"] end end end end ---added additional here --