Guns93RemoveItems = {
    "Base.FiberglassStock",
    "Base.Pistol",
    "Base.Pistol2",
    "Base.Pistol3",
    "Base.Revolver",
    "Base.Revolver_Short",
    "Base.Revolver_Long",
    "Base.TrapperCarbine",
    "Base.L94_Rifle",
    "Base.L92_Carbine",
    "Base.VarmintRifle",
    "Base.HuntingRifle",
    "Base.MSR7T_Rifle",
    "Base.JS14_Rifle",
    "Base.AssaultRifle",
    "Base.AssaultRifle2",
    "Base.Shotgun",
    "Base.ShotgunSawnoff",
    "Base.DoubleBarrelShotgun",
    "Base.DoubleBarrelShotgunSawnoff",
    "Base.JS3T_Shotgun",
    "Base.9mmClip",
    "Base.45Clip",
    "Base.44Clip",
    "Base.JS14_Clip",
    "Base.556Clip",
    "Base.308Clip",
    "Base.M14Clip"
}

local function RemoveVanillaLoot(itemsTable)
    if not itemsTable then return end
    for i = #itemsTable, 1, -2 do
        local itemType = itemsTable[i - 1]
        local weight = itemsTable[i]
        for _, badItem in ipairs(Guns93RemoveItems) do
            if itemType == badItem then
                table.remove(itemsTable, i)
                table.remove(itemsTable, i - 1)
                break
            end
        end
    end
end

local function ProcessLootTable(tbl)
    if not tbl then return end
    for _, zone in pairs(tbl) do
        if type(zone) == "table" then
            if zone.items then
                RemoveVanillaLoot(zone.items)
            end
            if zone.junk and zone.junk.items then
                RemoveVanillaLoot(zone.junk.items)
            end
            if not zone.procedural then
                ProcessLootTable(zone)
            end
        end
    end
end

local function ModifyAllLootTables()
    if not SandboxVars.Guns93.Guns93VanillaGuns then return end
    ProcessLootTable(SuburbsDistributions)
    ProcessLootTable(Distributions)
    ProcessLootTable(ProceduralDistributions)
    ProcessLootTable(ProceduralDistributions.list)
    ProcessLootTable(VehicleDistributions)
end

Events.OnPreDistributionMerge.Add(ModifyAllLootTables)