318
edits
No edit summary |
No edit summary |
||
Line 761: | Line 761: | ||
return result | return result | ||
end | end | ||
function p.getItemDropChance(frame) | |||
local MonsterName = frame.args ~= nil and frame.args[1] or frame | |||
local ItemName = frame.args ~= nil and frame.args[2] or frame | |||
local monster = p.getMonster(MonsterName) | |||
local item = p.getItem(ItemName) | |||
if monster == nil then | |||
return "ERROR: No monster with that name found[[Category:Pages with script errors]]" | |||
end | |||
if item == nil then | |||
return "ERROR: No item with that name found[[Category:Pages with script errors]]" | |||
end | |||
if not p._isDungeonOnlyMonster(monster) then | |||
local lootChance = monster.lootChance ~= nil and monster.lootChance or 100 | |||
local totalWt = 0 | |||
for i, row in pairs(monster.lootTable) do | |||
totalWt = totalWt + row[2] | |||
end | |||
for i, row in Shared.skpairs(monster.lootTable) do | |||
local thisItem = Items.getItemByID(row[1]) | |||
if item == thisItem then | |||
local dropChance = (row[2] / totalWt * lootChance) | |||
end | |||
end | |||
end | |||
return dropChance | |||
end | |||
function p.getChestDrops(frame) | function p.getChestDrops(frame) |
edits