function Enemies:BuildDropTable(enemy, difficulty)
local dropTable = {}
local IsBoss = Enemies:IsBoss(enemy)
local IsElite = Enemies:IsElite(enemy)
local dropChance = 10
if (IsElite) then
dropChance = Enemies:GetEliteEnemyDropChance(enemy, difficulty)
end
if (IsBoss) then
dropChance = 100
end
if (not RollPercentage(dropChance)) then
return dropTable
end
local itemsPerDrop = 1
local dropChanceFactor = Enemies.dropChanceFactor
local itemsTable = {}
local commonItems = Inventory:GetItemsByRarity(Inventory.rarity.common)
if(GetTableSize(commonItems) > 0) then
table.insert(itemsTable, Inventory.rarity.common, { items = Inventory:GetItemsByRarity(Inventory.rarity.common), chance = 100, itemsDifficulty = 1 })
end
for _ = 1, itemsPerDrop do
for rarity = #itemsTable, Inventory.rarity.common do
if (GetTableSize(dropTable) >= itemsPerDrop) then
break
end
if (itemsTable[rarity] and RollPercentage(itemsTable[rarity].chance)) then
table.insert(dropTable, { item = itemsTable[rarity].items[math.random(1, #itemsTable[rarity].items)], difficulty = itemsTable[rarity].itemsDifficulty})
end
end
end
return dropTable
end