Advertisement
Guest User

Untitled

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