Advertisement
Guest User

iBot Loot Counter HUD v1.1

a guest
Jan 24th, 2014
6,246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.51 KB | None | 0 0
  1. --[[
  2.     Name: iBot Loot Counter HUD
  3.     Version: v1.1
  4.     Last Updated: 23 Jan 2014
  5. ]]--
  6.  
  7.  
  8. HUD = {
  9.  
  10.     TITLE = "iBot Loot Counter",
  11.  
  12.     CONFIG = {
  13.         ORIENTATION = "right",
  14.         START_POSITION = {35, 25},
  15.         MAX_TEXT_LENGTH = 15,
  16.         TEXT_DISTANCE = 115,
  17.         LINE_DISTANCE = 12,
  18.     },
  19.  
  20.     ITEMS =
  21.     {
  22.         LOOT = getlootitems(),
  23.  
  24.         SUPPLY =
  25.     {
  26.             {NAME = "mana potion", VALUE = 50},
  27.             {NAME = "strong mana potion", VALUE = 80},
  28.             {NAME = "great mana potion", VALUE = 120},
  29.             {NAME = "health potion", VALUE = 45},
  30.             {NAME = "strong health potion", VALUE = 100},
  31.             {NAME = "great health potion", VALUE = 190},
  32.             {NAME = "ultimate health potion", VALUE = 310},
  33.             {NAME = "Assassin Star", VALUE = 100},
  34.             {NAME = "prismatic bolt", VALUE = 20},
  35.             {NAME = "crystalline arrow", VALUE = 20},
  36.             {NAME = "great fireball rune", VALUE = 45},
  37.             {NAME = "sudden death rune", VALUE = 108},
  38.             {NAME = "avalanche rune", VALUE = 45},
  39.             {NAME = "icicle rune", VALUE = 30},
  40.             {NAME = "fireball rune", VALUE = 30},
  41.             {NAME = "thunderstorm rune", VALUE = 37},
  42.             {NAME = "Soft Boots", VALUE = 10000},
  43.             {NAME = "Rust Remover", VALUE = 50}
  44.         }
  45.     },
  46.  
  47.     --[[ Just edit below if you know what you're doing --]]
  48.  
  49.     COLORS = {
  50.     SHADOW = rgbcolor(10, 10, 10),
  51.     TITLE = rgbcolor(255, 165, 0),
  52.     TEXT1 = rgbcolor(205, 200, 177),
  53.     TEXT2 = rgbcolor(255, 255, 255),
  54.     SUBTITLE = rgbcolor(30, 144, 255),
  55.     PROFIT = rgbcolor(107, 142, 35),
  56.     WASTE = rgbcolor(178, 34, 34),
  57.     },
  58.  
  59.     VERSION = "1.0"
  60. }
  61.  
  62. --[[ DONT EDIT NOTHING BELOW THIS LINE --]]
  63.  
  64. AMMO_COUNT, AMMO_COUNT_BP = AMMO_COUNT or 0, AMMO_COUNT_BP or 0
  65. local DISTANCE_WEAPONS, AMMUNITION, AMMO_NAME, AMMO_TYPE_COUNT, ADD_TO_HUD = {"assassin star", "enchanted spear", "hunting spear", "mean paladin spear", "royal spear", "small stone", "snowball", "spear", "throwing knife", "throwing star", "viper star"}, {"arrow", "burst arrow", "crystalline arrow", "earth arrow", "envenomed arrow", "flaming arrow", "flash arrow", "onyx arrow", "poison arrow", "shiver arrow", "sniper arrow", "tarsal arrow", "infernal bolt", "drill bolt", "power bolt", "prismatic bolt", "vortex bolt", "piercing bolt", "bolt"}, nil, 0, 0
  66.  
  67. if (weapon ~= 0) and (table.find(DISTANCE_WEAPONS, itemname(weapon):lower())) then
  68.     AMMO_NAME, AMMO_TYPE_COUNT = itemname(weapon) or nil, weaponamount or 0
  69. elseif (ammo ~= 0) and (table.find(AMMUNITION, itemname(ammo):lower())) then
  70.     AMMO_NAME, AMMO_TYPE_COUNT = itemname(ammo) or nil, ammoamount or 0
  71. end
  72.  
  73. if (AMMO_NAME ~= nil) then
  74.     local CURRENT_AMMO_COUNT = itemcount(AMMO_NAME)
  75.    
  76.     if (AMMO_TYPE_COUNT < AMMO_COUNT) then
  77.         ADD_TO_HUD = math.max(0, AMMO_COUNT-AMMO_TYPE_COUNT)
  78.     elseif (AMMO_TYPE_COUNT > AMMO_COUNT) and (CURRENT_AMMO_COUNT < AMMO_COUNT_BP) then
  79.         ADD_TO_HUD = math.max(0, (AMMO_COUNT+(AMMO_COUNT_BP-CURRENT_AMMO_COUNT))-100)
  80.     end
  81.    
  82.     addhudsupplie(AMMO_NAME, ADD_TO_HUD)
  83.     AMMO_COUNT, AMMO_COUNT_BP = AMMO_TYPE_COUNT, CURRENT_AMMO_COUNT
  84. end
  85.  
  86. function formatnumber(n, s)
  87.     local result, sign, before, after = '', string.match(tostring(n), '^([%+%-]?)(%d*)(%.?.*)$')
  88.  
  89.     while #before > 3 do
  90.         result = (s or '.') .. string.sub(before, -3, -1) .. result
  91.         before = string.sub(before, 1, -4)
  92.     end
  93.  
  94.     return sign .. before .. result .. after
  95. end
  96.  
  97. local X, Y, INDEX, TOTAL, TOTAL_LOOTED, TOTAL_WASTED = (HUD.CONFIG.ORIENTATION:lower() == "right" and worldwin.right + 10 or clientwin.left + 10) + HUD.CONFIG.START_POSITION[1], worldwin.top + 10 + HUD.CONFIG.START_POSITION[2], 1, 0, 0, 0
  98.  
  99. setfontcolor(HUD.COLORS.TITLE)
  100. addtextstroke(HUD.TITLE, X, Y)
  101.  
  102. Y = Y + 20
  103.  
  104. setfontcolor(HUD.COLORS.SUBTITLE)
  105. addtextstroke("ITEMS LOOTED:", X, Y)
  106.  
  107. Y = Y + 5
  108.  
  109. local lootqtd = HUD.ITEMS.LOOT.count-1
  110.  
  111. for it = 0, lootqtd do
  112.     local ITEM = HUD.ITEMS.LOOT[it]
  113.     if ITEM.lootmessage > 0 then
  114.         Y = Y + HUD.CONFIG.LINE_DISTANCE
  115.  
  116.     local itemvalue = ITEM.npcsell
  117.     if ITEM.custom ~= 0 then
  118.         itemvalue = ITEM.custom
  119.     end
  120.  
  121.     setfontcolor(HUD.COLORS.TEXT1)
  122.         addtextstroke((#ITEM.NAME < HUD.CONFIG.MAX_TEXT_LENGTH and ITEM.NAME or ITEM.NAME:sub(1, HUD.CONFIG.MAX_TEXT_LENGTH) .. "..."):gsub("(%a)([%w_']*)", function(s1, s2) return s1:upper() .. s2:lower() end), X, Y)
  123.  
  124.     setfontcolor(HUD.COLORS.TEXT2)
  125.     addtextstroke(string.format("%s (%s k)", formatnumber(ITEM.lootmessage), math.floor(ITEM.lootmessage * itemvalue / 100) / 10), X + HUD.CONFIG.TEXT_DISTANCE, Y)
  126.  
  127.         TOTAL, TOTAL_LOOTED = TOTAL + ITEM.lootmessage * itemvalue, TOTAL_LOOTED + (ITEM.lootmessage * itemvalue)
  128.     end
  129. end
  130.  
  131. Y = Y + HUD.CONFIG.LINE_DISTANCE + 2
  132.  
  133. setfontcolor(HUD.COLORS.TEXT2)
  134. addtextstroke("Total: ", X, Y)
  135.  
  136. setfontcolor(HUD.COLORS.TITLE)
  137. addtextstroke(formatnumber(TOTAL_LOOTED) .. " GPs", X+35, Y)
  138.  
  139. Y = Y + 25
  140.  
  141. setfontcolor(HUD.COLORS.SUBTITLE)
  142. addtextstroke("SUPPLIES USED:", X, Y)
  143.  
  144. Y = Y + 5
  145.  
  146. for _, ITEM in ipairs(HUD.ITEMS.SUPPLY) do
  147.     local ITEM_USED = itemproperty(ITEM.NAME)
  148.     if ITEM_USED.usagemessage > 0 then
  149.         Y = Y + HUD.CONFIG.LINE_DISTANCE
  150.  
  151.     setfontcolor(HUD.COLORS.TEXT1)
  152.         addtextstroke((#ITEM.NAME < HUD.CONFIG.MAX_TEXT_LENGTH and ITEM.NAME or ITEM.NAME:sub(1, HUD.CONFIG.MAX_TEXT_LENGTH) .. "..."):gsub("(%a)([%w_']*)", function(s1, s2) return s1:upper() .. s2:lower() end), X, Y)
  153.  
  154.     setfontcolor(HUD.COLORS.TEXT2)
  155.     addtextstroke(string.format("%s (%sk)", formatnumber(ITEM_USED.usagemessage), math.floor(ITEM_USED.usagemessage * (ITEM.VALUE or itemvalue(ITEM.NAME)) / 100) / 10), X + HUD.CONFIG.TEXT_DISTANCE, Y)
  156.  
  157.         TOTAL, TOTAL_WASTED = TOTAL - ITEM_USED.usagemessage * (ITEM.VALUE or itemvalue(ITEM.NAME)), TOTAL_WASTED + (ITEM_USED.usagemessage * (ITEM.VALUE or itemvalue(ITEM.NAME)))
  158.     end
  159. end
  160.  
  161. Y = Y + HUD.CONFIG.LINE_DISTANCE + 2
  162.  
  163. setfontcolor(HUD.COLORS.TEXT2)
  164. addtextstroke("Total: ", X, Y)
  165.  
  166. setfontcolor(HUD.COLORS.TITLE)
  167. addtextstroke("-" .. formatnumber(TOTAL_WASTED) .. " GPs", X + 35, Y)
  168.  
  169. Y = Y + 25
  170.  
  171. setfontcolor(TOTAL_LOOTED - TOTAL_WASTED >= 0 and HUD.COLORS.PROFIT or HUD.COLORS.WASTE)
  172. addtextstroke(string.format("%s %s GPs (%s k/h)", TOTAL_LOOTED - TOTAL_WASTED >= 0 and "PROFIT:" or "WASTE:", formatnumber(TOTAL_LOOTED - TOTAL_WASTED), math.floor(((TOTAL_LOOTED - TOTAL_WASTED) / (tosec(timehunt) / 3600)) / 100) / 10), X, Y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement