Advertisement
Guest User

Untitled

a guest
Jan 30th, 2014
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.42 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. -- ADDED PART
  105.  
  106.     Y2 = Y-20
  107.     local X2 = (HUD.CONFIG.ORIENTATION:lower() == "left" and worldwin.right + 10 or clientwin.left + 10) + HUD.CONFIG.START_POSITION[1]
  108.    
  109.     setfontcolor(HUD.COLORS.SUBTITLE)
  110.     addtextstroke("CHARACTER STATS:", X2, Y2)
  111.    
  112.     Y2 = Y2+20
  113.    
  114.     local STATNAME = {"Level", "Exp/h (Ibot info)", "Exp/h (Tibia info)", "Exp Gained", "Exp to level", "Time to level", "Time Played", "Bank Balance", "Cursor ID", "Stamina"}
  115.     local STATVALUE = {level, formatnumber(exphour), formatnumber(tibiaexphour), formatnumber(expgained), formatnumber(exptolevel()), timetolevel, timehunt, formatnumber(balance), cursorinfo().id, (math.floor(stamina/60)..":"..string.format("%02s", (stamina-60*math.floor(stamina/60)))) }
  116.    
  117.     for i=1, #STATNAME do
  118.         setfontcolor(HUD.COLORS.TEXT1)
  119.         addtextstroke(STATNAME[i], X2, Y2)
  120.         setfontcolor(HUD.COLORS.TEXT2)
  121.         if i > 9 then
  122.             if stamina > 2400 then
  123.             setfontcolor(HUD.COLORS.PROFIT)
  124.             elseif stamina < 840 then
  125.             setfontcolor(HUD.COLORS.WASTE)
  126.             else setfontcolor(HUD.COLORS.TITLE)
  127.             end
  128.         end
  129.     addtextstroke(STATVALUE[i], X2+HUD.CONFIG.TEXT_DISTANCE, Y2)
  130.      Y2 = Y2 + HUD.CONFIG.LINE_DISTANCE
  131.     end
  132.  
  133.     local ENGINE = {"Caveboting", "Looting", "Targeting"}
  134.     local ENGINEVALUE = {cavebot, looting, targeting}
  135.     for i=1, #ENGINE do
  136.         setfontcolor(HUD.COLORS.TEXT1)
  137.         addtextstroke(ENGINE[i], X2, Y2)
  138.         setfontcolor(HUD.COLORS.TEXT2)
  139.             if ENGINEVALUE[i] then
  140.             setfontcolor(HUD.COLORS.PROFIT)
  141.             addtextstroke("ON", X2+HUD.CONFIG.TEXT_DISTANCE, Y2)
  142.             else
  143.             setfontcolor(HUD.COLORS.WASTE)
  144.             addtextstroke("OFF", X2+HUD.CONFIG.TEXT_DISTANCE, Y2)
  145.             end
  146.         Y2 = Y2 + HUD.CONFIG.LINE_DISTANCE
  147.     end
  148.    
  149.     Y2 = Y2 + 20
  150. --- END OF ADDED PART
  151.  
  152. setfontcolor(HUD.COLORS.SUBTITLE)
  153. addtextstroke("ITEMS LOOTED:", X, Y)
  154.  
  155. Y = Y + 5
  156.  
  157. local lootqtd = HUD.ITEMS.LOOT.count-1
  158.  
  159. for it = 0, lootqtd do
  160.     local ITEM = HUD.ITEMS.LOOT[it]
  161.     if ITEM.lootmessage > 0 then
  162.         Y = Y + HUD.CONFIG.LINE_DISTANCE
  163.  
  164.     local itemvalue = ITEM.npcsell
  165.     if ITEM.custom ~= 0 then
  166.         itemvalue = ITEM.custom
  167.     end
  168.  
  169.     setfontcolor(HUD.COLORS.TEXT1)
  170.         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)
  171.  
  172.     setfontcolor(HUD.COLORS.TEXT2)
  173.     addtextstroke(string.format("%s (%s k)", formatnumber(ITEM.lootmessage), math.floor(ITEM.lootmessage * itemvalue / 100) / 10), X + HUD.CONFIG.TEXT_DISTANCE, Y)
  174.  
  175.         TOTAL, TOTAL_LOOTED = TOTAL + ITEM.lootmessage * itemvalue, TOTAL_LOOTED + (ITEM.lootmessage * itemvalue)
  176.     end
  177. end
  178.  
  179. Y = Y + HUD.CONFIG.LINE_DISTANCE + 2
  180.  
  181. setfontcolor(HUD.COLORS.TEXT2)
  182. addtextstroke("Total: ", X, Y)
  183.  
  184. setfontcolor(HUD.COLORS.TITLE)
  185. addtextstroke(formatnumber(TOTAL_LOOTED) .. " GPs", X+35, Y)
  186.  
  187. Y = Y + 25
  188.  
  189. setfontcolor(HUD.COLORS.SUBTITLE)
  190. addtextstroke("SUPPLIES USED:", X, Y)
  191.  
  192. Y = Y + 5
  193.  
  194. for _, ITEM in ipairs(HUD.ITEMS.SUPPLY) do
  195.     local ITEM_USED = itemproperty(ITEM.NAME)
  196.     if ITEM_USED.usagemessage > 0 then
  197.         Y = Y + HUD.CONFIG.LINE_DISTANCE
  198.  
  199.     setfontcolor(HUD.COLORS.TEXT1)
  200.         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)
  201.  
  202.     setfontcolor(HUD.COLORS.TEXT2)
  203.     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)
  204.  
  205.         TOTAL, TOTAL_WASTED = TOTAL - ITEM_USED.usagemessage * (ITEM.VALUE or itemvalue(ITEM.NAME)), TOTAL_WASTED + (ITEM_USED.usagemessage * (ITEM.VALUE or itemvalue(ITEM.NAME)))
  206.     end
  207. end
  208.  
  209. Y = Y + HUD.CONFIG.LINE_DISTANCE + 2
  210.  
  211. setfontcolor(HUD.COLORS.TEXT2)
  212. addtextstroke("Total: ", X, Y)
  213.  
  214. setfontcolor(HUD.COLORS.TITLE)
  215. addtextstroke("-" .. formatnumber(TOTAL_WASTED) .. " GPs", X + 35, Y)
  216.  
  217. Y = Y + 25
  218.  
  219. setfontcolor(TOTAL_LOOTED - TOTAL_WASTED >= 0 and HUD.COLORS.PROFIT or HUD.COLORS.WASTE)
  220. 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