-- items are ordered by NPC prices, adding an item here will overwrite that value with a custom one
customItemValues = {
["silver raid token"] = 60000,
},
HUD.lootEntries = {}
HUD.maxItemsShown = HUD.maxItemsShown < 5 and 5 or HUD.maxItemsShown
HUD.hiddenItems = {}
for i = 1, #HUD.ignoredItems do
local name = HUD.ignoredItems[i]:lower()
if not HUD.hiddenItems[name] then
HUD.hiddenItems[name] = true
end
end
local pluralExceptions = {
{"knives", "knife"},
{"pieces of *", "piece of "},
{"*pieces of", "piece of "},
{"bunches of *", "bunch of "},
{"haunches of *", "haunch of "},
{"flasks of *", "flask of "},
{"veins of *", "vein of "},
{"bowls of *", "bowl of "},
{"sandwiches", "sandwich"}
}
local function pairsByKeys(t)
local temp = {}
for n in pairs(t) do
temp[#temp+1] = n
end
table.sort(temp, function(a, b) return a > b end)
local i = 0
local function iter()
i = i + 1
if temp[i] then
return temp[i], t[temp[i]]
else
return nil
end
end
return iter
end
setitemwarnings(false)
local function lootedItems(msg)
local items = {}
local temp = {}
local itemsDropped = msg:explode(",")
for i = 1, #itemsDropped do
local name = itemsDropped[i]
local count = tonumber(name:match("^(%d+)"))
if count then
name = name:gsub("^%d+ ", "")
if itemExceptions[name] then
name = name:gsub(name, itemExceptions[name])
else
for j = 1, #pluralExceptions do
local pluralException = pluralExceptions[j]
if name:find(pluralException[1]) then
name = name:gsub(pluralException[1], pluralException[2])
break
end
end
if name:find("s$") then
name = name:sub(1, -2)
for j = 1, #pluralEndings do
local pluralEnding = pluralEndings[j]
if name:find(pluralEnding[1].."$") then
name = name:gsub(pluralEnding[1].."$", pluralEnding[2])
break
end
end
end
end
end
count = count or 1
name = name:gsub("^a ", "")
name = name:gsub("^an ", "")
local value = (HUD.customItemValues[name] and HUD.customItemValues[name] or itemvalue(name)) * count
while temp[value] do value = value + 1 end
temp[value] = {name = name:lower(), count = count}
end
for value, data in pairsByKeys(temp) do
if not HUD.hiddenItems[data.name] and itemid(data.name) > 0 then
items[#items+1] = {id = itemid(data.name), count = data.count}
end
end
return items
end
filterinput(false, true, false, false)
local isMoving, tempOffset, newOffset = false, {0, 0}, {0, 0}
function inputevents(e)
if (e.type == IEVENT_MMOUSEDOWN) then
isMoving, tempOffset = true, {$cursor.x - newOffset[1], $cursor.y - newOffset[2]}
end
if (e.type == IEVENT_MMOUSEUP) then
isMoving = false
end
end
init end
if isMoving then
auto(10)
newOffset = {$cursor.x - tempOffset[1], $cursor.y - tempOffset[2]}
end
foreach newmessage m do
if m.type == MSG_INFO then
local main = m.content:match("Loot of .+:")
local creature, loot = m.content:match('Loot of (.+): (.+)')
if creature then
creature = creature:gsub("^a ", ""):gsub("^an ", "")
if loot and loot ~= "nothing" then
loot = loot:lower()
local items = lootedItems(loot)
if #items > 0 then
if #HUD.lootEntries >= HUD.maxEntriesShown then
table.remove(HUD.lootEntries, 1)
end
HUD.lootEntries[#HUD.lootEntries+1] = {main = main, name = creature, items = items}
end
end
end
end
end
for i = 1, #HUD.lootEntries do
local main, name, items = HUD.lootEntries[i].main, HUD.lootEntries[i].name, HUD.lootEntries[i].items
setcompositionmode(0)
drawitem(itemID, 88 + (j - 1) * 41, 35 + (i - 1) * 87, 100, math.min(itemAmount, 100), HUD.showItemAnimations and -1 or 0)
setcompositionmode(3)
if HUD.showItemCount and itemAmount > 1 then
setcompositionmode(0)
drawtext(itemAmount, 120 - measurestring(itemAmount) + (j - 1) * 41, 58 + (i - 1) * 87)
setcompositionmode(3)
end
end
end