318
edits
No edit summary |
No edit summary |
||
Line 763: | Line 763: | ||
-- Find drop chance of specified item from specified monster. | -- Find drop chance of specified item from specified monster. | ||
-- Usage: |Monster Name|Item Name | -- Usage: |Monster Name|Item Name | ||
function p.getItemDropChance(frame) | function p.getItemDropChance(frame) | ||
local | local MonsterName = frame.args ~= nil and frame.args[1] or frame[1] | ||
local ItemName = frame.args ~= nil and frame.args[2] or frame[2] | |||
local ItemName = args | |||
local monster = p.getMonster(MonsterName) | local monster = p.getMonster(MonsterName) | ||
Line 785: | Line 783: | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in pairs(monster.lootTable) do | |||
totalWt = totalWt + row[2] | |||
end | |||
mw.log(monster['id'], item['id']) | |||
for i, row in Shared.skpairs(monster.lootTable) do | |||
local thisItem = Items.getItemByID(row[1]) | |||
mw.log(thisItem['id']) | |||
if item['id'] == thisItem['id'] then | |||
local dropChance = (row[2] / totalWt * lootChance) | local dropChance = (row[2] / totalWt * lootChance) | ||
end | end | ||
end | end | ||
end | |||
mw.log(dropChance) | |||
return Shared.round(dropChance, 2, 2) | |||
end | end | ||
edits