318
edits
No edit summary |
No edit summary |
||
Line 782: | Line 782: | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in pairs(monster.lootTable) do | --for i, row in pairs(monster.lootTable) do | ||
totalWt = totalWt + row[2] | --totalWt = totalWt + row[2] | ||
end | --end | ||
local dropChance = 0 | |||
local dropWt = 0 | |||
for i, row in Shared.skpairs(monster.lootTable) do | for i, row in Shared.skpairs(monster.lootTable) do | ||
mw.log(row[2]) | |||
local thisItem = Items.getItemByID(row[1]) | local thisItem = Items.getItemByID(row[1]) | ||
totalWt = totalWt + row[2] | |||
if item['id'] == thisItem['id'] then | if item['id'] == thisItem['id'] then | ||
dropWt = row[2] | |||
end | end | ||
end | end | ||
dropChance = (dropWt / totalWt * lootChance) | |||
return Shared.round(dropChance, 2, 2) | return Shared.round(dropChance, 2, 2) | ||
end | end |
edits