Signup Now
Results 1 to 2 of 2
  1. #1
    Free User
    Join Date
    Dec 2013
    Posts
    22
    Reputation
    18
    Rep Power
    0

    Visual Recent Loot

    Visual Recent Loot



    Code:
    Changelog:
    
    10-24-2016 - initial release [1.0.0]

    init start

    local HUD = {
    maxItemsShown = 6,
    maxEntriesShown = 6,


    showItemCount = true,
    showItemAnimations = false,
    showOutfitAnimations = false,


    -- items are ordered by NPC prices, adding an item here will overwrite that value with a custom one
    customItemValues = {
    ["silver raid token"] = 60000,
    },


    -- items that should not be shown in the HUD
    ignoredItems = {
    "amphora", "arrow", "axe", "banana skin", "banana", "battle axe", "battle hammer", "battle shield", "beetroot", "blank rune", "blue rose", "blue tapestry", "blueberry", "bolt", "bone club", "bone shield", "bone sword", "bone", "book", "bottle", "bow", "bowl of glooth soup", "bowl", "brass armor", "brass helmet", "brass legs", "brass shield", "bread", "broom", "brown bread", "brown flask", "brown mushroom", "bulb of garlic", "bunch of wheat", "burst arrow", "candlestick", "candy cane", "cape", "carrot", "chain armor", "chain helmet", "chain legs", "cheese", "cherry", "cleaver", "closed trap", "coat", "coconut", "coloured egg", "combat knife", "concentrated demonic blood", "cookie", "copper shield", "corncob", "crossbow", "crowbar", "crystalline arrow", "cucumber", "dagger", "deepling filet", "dirty fur", "double axe", "doublet", "dragon ham", "drill bolt", "earth arrow", "egg", "envenomed arrow", "fish tail", "fish", "fishing rod", "flaming arrow", "flash arrow", "fur bag", "glooth sandwich", "glooth spear", "glooth steak", "gold coin", "grapes", "grave flower", "great health potion", "great mana potion", "great spirit potion", "green tapestry", "green tunic", "halberd", "ham", "hand axe", "hatchet", "haunch of boar", "health potion", "hunting spear", "inkwell", "insectoid eggs", "jalapeño pepper", "katana", "knife", "lamp", "leather armor", "leather boots", "leather helmet", "leather legs", "longsword", "lute", "lyre", "mace", "machete", "mana potion", "mango", "meat", "melon", "mirror", "morning star", "mouldy cheese", "mushroom pie", "onyx arrow", "orange", "orichalcum pearl", "panpipes", "party hat", "party trumpet", "pear", "pick", "piece of iron", "piercing bolt", "pirate bag", "pitchfork", "plate armor", "plate shield", "plate", "plum", "poison arrow", "potato", "power bolt", "prismatic bolt", "pumpkin", "rapier", "raspberry", "rat cheese", "red apple", "red mushroom", "red rose", "roll", "rolling pin", "rope", "royal spear", "rum flask", "sabre", "sandals", "saw", "scale armor", "scarf", "scroll", "scythe", "shiver arrow", "short sword", "shovel", "sickle", "simple arrow", "simple dress", "simple fanfare", "skull candle", "skull", "small axe", "small blue pillow", "small pitchfork", "small stone", "small white pillow", "sniper arrow", "soft cheese", "soldier helmet", "spear", "spellbook", "staff", "steel shield", "strawberry", "strong health potion", "strong mana potion", "studded armor", "studded club", "studded helmet", "studded legs", "studded shield", "swampling club", "sword", "tarsal arrow", "tomato", "torch", "two handed sword", "ultimate health potion", "viking helmet", "viper star", "vortex bolt", "war drum", "watch", "waterskin", "white mushroom", "wooden flute", "wooden hammer", "wooden shield", "wooden spoon", "worm", "yellow pillow"
    }
    }


    -- DO NOT EDIT BELOW !!!


    HUD.colors = {}
    HUD.colors.fontColor = color(255, 255, 255, 0)
    HUD.colors.lootEntryBackground = {0.0, color(35, 35, 35, 20), 0.23, color(25, 25, 25, 20), 0.76, color(10, 10, 10, 20)}
    HUD.colors.itemIconBackground = {0.0, color(115, 115, 115, 20), 0.23, color(95, 95, 95, 20), 0.76, color(45, 45, 45, 20)}


    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 itemExceptions = {
    ["cookies"] = "cookie",
    ["mushroom pies" ] = "mushroom pie",
    ["gooey masses" ] = "gooey mass",
    }


    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 pluralEndings = {
    {"che", "ch"},
    {"she", "sh"},
    {"ie", "y"},
    {"ve", "fe"},
    {"oe", "o"},
    {"ze", "z"}
    }


    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


    setposition($clientwin.right - (275 + HUD.maxItemsShown * 41) + newOffset[1], $worldwin.top + newOffset[2])
    setfontstyle('Tahoma', 7, 75, HUD.colors.fontColor, 1, color(0, 0, 0, 20))


    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


    setfillstyle('gradient', 'linear', 2, 0, 0, 0, 81)
    addgradcolors(unpack(HUD.colors.lootEntryBackground))
    drawrect(0, (i - 1) * 87, 92 + (HUD.maxItemsShown * 41), 80)


    local creatureInfo = creatureinfo(name)
    local outfitSize = outfitinfo(creatureInfo.outfit).sizeinpixels


    setcompositionmode(0)
    drawoutfit(creatureInfo.outfit, 5 + math.max(64 - outfitSize, 9) * 0.65, 5 + (i - 1) * 87 + math.max(64 - outfitSize, 4) * 0.65, 100, 2, HUD.showOutfitAnimations and -1 or 0, creatureInfo.headcolor, creatureInfo.chestcolor, creatureInfo.legscolor, creatureInfo.feetcolor)
    setcompositionmode(3)


    setcompositionmode(0)
    drawtext(main, 86, 15 + (i - 1) * 87)
    setcompositionmode(3)


    for j = 1, #items do
    if j > HUD.maxItemsShown then
    break
    end


    local itemID = items[j].id
    local itemAmount = items[j].count


    setfillstyle('gradient', 'linear', 2, 0, 0, 0, 37)
    addgradcolors(unpack(HUD.colors.itemIconBackground))
    drawrect(85 + (j - 1) * 41, 32 + (i - 1) * 87, 36, 36)

    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
    Last edited by Rydan; 10-24-2016 at 07:53 PM. Reason: Updating Image

  2. #2
    Wind Tester
    Join Date
    Dec 2013
    Location
    Warsaw, Poland
    Posts
    2,578
    Reputation
    149
    Rep Power
    27
    good job

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •