Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
Show AP for chest drops and monster currency drops where applicable
(Better handling for abyss depths)
(Show AP for chest drops and monster currency drops where applicable)
Line 1,006: Line 1,006:
local lootChance = monster.lootChance ~= nil and monster.lootChance or 100
local lootChance = monster.lootChance ~= nil and monster.lootChance or 100
local lootValue = 0
local lootValue = 0
local currencyID = 'melvorD:GP'


result = result.."'''Loot:'''"
result = result.."'''Loot:'''"
local avgGp = 0
local avgGp = 0


if monster.gpDrops ~= nil then
if monster.currencyDrops ~= nil and not monster.currencyDrops[1] ~= nil then
avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2
local currencyDrop = monster.currencyDrops[1]
local gpTxt = Icons._Currency('GP', monster.gpDrops.min, monster.gpDrops.max)
currencyID = currencyDrop.currencyID or 'melvorD:GP'
avgGp = (currencyDrop.min + currencyDrop.max) / 2
local gpTxt = Icons._Currency(currencyID, currencyDrop.min, currencyDrop.max)
result = result.."\r\nIn addition to loot, the monster will also drop "..gpTxt..'.'
result = result.."\r\nIn addition to loot, the monster will also drop "..gpTxt..'.'
end
end
Line 1,041: Line 1,044:
for i, row in ipairs(lootTable) do
for i, row in ipairs(lootTable) do
local thisItem = Items.getItemByID(row.itemID)
local thisItem = Items.getItemByID(row.itemID)
currencyID = thisItem.sellsForCurrency or 'melvorD:GP'
if thisItem ~= nil then
if thisItem ~= nil then
Line 1,061: Line 1,065:
itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0
itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0
if itemPrice == 0 or row.maxQuantity == row.minQuantity then
if itemPrice == 0 or row.maxQuantity == row.minQuantity then
result = result..'||'.. Icons._Currency('GP', itemPrice * row.minQuantity)
result = result..'||'.. Icons._Currency(currencyID, itemPrice * row.minQuantity)
else
else
result = result..'||'.. Icons._Currency('GP', itemPrice * row.minQuantity, itemPrice * row.maxQuantity)
result = result..'||'.. Icons._Currency(currencyID, itemPrice * row.minQuantity, itemPrice * row.maxQuantity)
end
end
end
end
Line 1,094: Line 1,098:
end
end
result = result..'\r\n|}'
result = result..'\r\n|}'
result = result..'\r\nThe loot dropped by the average kill is worth '.. Icons._Currency('GP', Num.round(lootValue, 2, 0)).." if sold."
result = result..'\r\nThe loot dropped by the average kill is worth '.. Icons._Currency(currencyID, Num.round(lootValue, 2, 0)).." if sold."
if avgGp > 0 then
if avgGp > 0 then
result = result.."<br/>Including GP"
result = result.."<br/>Including "..(currencyID == 'melvorD:GP' and 'GP' or 'AP')
if boneVal > 0 then
if boneVal > 0 then
result = result..' and bones'
result = result..' and bones'
Line 1,103: Line 1,107:
result = result..' and barrier dust'
result = result..' and barrier dust'
end
end
result = result..', the average kill is worth '.. Icons._Currency('GP', Num.round(avgGp + lootValue + boneVal + dustVal, 2, 0))..'.'
result = result..', the average kill is worth '.. Icons._Currency(currencyID, Num.round(avgGp + lootValue + boneVal + dustVal, 2, 0))..'.'
end
end
end
end
Line 1,207: Line 1,211:
local chestName = frame.args ~= nil and frame.args[1] or frame
local chestName = frame.args ~= nil and frame.args[1] or frame
local chest = Items.getItem(chestName)
local chest = Items.getItem(chestName)
local currencyID = chest.sellsForCurrency or 'melvorD:GP'


if chest == nil then
if chest == nil then
Line 1,259: Line 1,264:
result = result..'||style="text-align:left" data-sort-value="'..thisItem.sellsFor..'"'
result = result..'||style="text-align:left" data-sort-value="'..thisItem.sellsFor..'"'
if thisItem.sellsFor == 0 or row.minQuantity == row.maxQuantity then
if thisItem.sellsFor == 0 or row.minQuantity == row.maxQuantity then
result = result..'|'.. Icons._Currency('GP', thisItem.sellsFor * row.minQuantity)
result = result..'|'.. Icons._Currency(currencyID, thisItem.sellsFor * row.minQuantity)
else
else
result = result..'|'.. Icons._Currency('GP', thisItem.sellsFor * row.minQuantity, thisItem.sellsFor * row.maxQuantity)
result = result..'|'.. Icons._Currency(currencyID, thisItem.sellsFor * row.minQuantity, thisItem.sellsFor * row.maxQuantity)
end
end
lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor * ((row.minQuantity + row.maxQuantity)/ 2))
lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor * ((row.minQuantity + row.maxQuantity)/ 2))
Line 1,277: Line 1,282:
end
end
result = result..'\r\n|}'
result = result..'\r\n|}'
result = result..'\r\nThe average value of the contents of one chest is '.. Icons._Currency('GP', Num.round(lootValue, 2, 0))..'.'
result = result..'\r\nThe average value of the contents of one chest is '.. Icons._Currency(currencyID, Num.round(lootValue, 2, 0))..'.'
if isAllFood then
if isAllFood then
result = result..'\r\n\r\nThe average healing of the contents of one chest is ' .. Icons.Icon({'Hitpoints', type='skill', notext=true, nolink=true}) .. ' ' .. Num.round(foodValue, 2, 0) .. '.'
result = result..'\r\n\r\nThe average healing of the contents of one chest is ' .. Icons.Icon({'Hitpoints', type='skill', notext=true, nolink=true}) .. ' ' .. Num.round(foodValue, 2, 0) .. '.'