require "Items/Distributions";
require "Items/ProceduralDistributions";

if SandboxVars.WT.SpawnAmmoIntheWorld then
    local magazines_items = {"Base.792Bullets", 3, "Base.792Box", 2, "Base.APFSDSAmmo", 2, "Base.HEATAmmo", 2,
                             "Base.APAmmo", 2, "Base.HEAmmo", 2, "Base.30mmAP", 2, "Base.30mmHE", 2, "Base.Rocket10", 1,
                             "Base.AnTiTankMissile10", 1, "Base.MachineGun10", 1, "Base.RocketNest10", 1,
                             "Base.HeliGun10", 2};

    local function insertItemListsInProcDistribution(location, itemDistList)

        local table = ProceduralDistributions["list"][location].items
        if (table == nil) then
            print("ERROR: ProceduralDistributions[\"list\"][\"" .. location .. "\"].items is nil")
            return
        end
        local n = #table + 1
        for idx, itemDist in ipairs(itemDistList) do
            for i = 1, #itemDist, 2 do
                table[n] = itemDist[i]
                table[n + 1] = itemDist[i + 1] * SandboxVars.WT.SpawnAmmoIntheWorldPercent
                n = n + 2
            end
        end
    end

    local ArmyLocation = {"GunStoreShelf", "PlankStashGun", "FirearmWeapons", "ArmyStorageGuns", "GunStoreCounter",
                          "PoliceStorageGuns", "PawnShopGunsSpecial", "GunStoreDisplayCase", "GarageFirearms",
                          "DrugLabGuns", "GunStoreAmmunition", "ArmyStorageAmmunition"}

    for i, location in ipairs(ArmyLocation) do
        insertItemListsInProcDistribution(location, {magazines_items});

    end
end
