Module:Monsters: Difference between revisions

no edit summary
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
mw.log(monster['id'], item['id'])
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
    local dropChance = (row[2] / totalWt * lootChance)
    dropWt = row[2]
    mw.log(dropChance)
    end
    end
end
end
dropChance = (dropWt / totalWt * lootChance)
return Shared.round(dropChance, 2, 2)
return Shared.round(dropChance, 2, 2)
   end
   end
318

edits