Advertisement
Fwaky

HultinHud v2 - PRE RELEASE - Tibia - Windbot

Mar 31st, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.54 KB | None | 0 0
  1. init start
  2. -- Hultin's Hud v2.0.0
  3. -- Major revision from old hud!
  4. -- Last update: 31/3/2014
  5.  
  6.     -- Script author - This is where you put your name.
  7.     -- The rest of the script info is entered into Useroptions.
  8.     local ScriptAuthor = "Hultin"
  9.  
  10.     -- Configuration for width/height
  11.     local FieldConfig = {
  12.         Height = 22, -- Optimized for 22px. Sizes lower than 20 looks weird and narrow, keep that in mind if you set the height lower.
  13.         Width  = 260, -- Total width of the HUD. Value/Field widths are automatically calculated.
  14.     }
  15.  
  16.  
  17.     -- You can add more color points to create a gradient. The current implementation is just a flat gradient.
  18.     -- First value is graident point, color(r, g, b, a)
  19.     -- Alpha is 0-100, 0 is non-transparent 100 is fully see through (no color!)
  20.     local Colors = {
  21.         HeaderColor =       {1, color(41, 79, 109, 10)},
  22.             HeaderInnerBorder   = color(58, 106, 140, 10),
  23.         FieldColor  =       {1, color(40, 40, 40, 10)},
  24.             FieldInnerBorder    = color(74, 74, 74, 10),
  25.         ValueNeutral =      {1, color(158, 104, 0, 10)},
  26.             NeutralInnerBorder  = color(166, 124, 44, 10),
  27.         ValuePositive =     {1, color(67, 99, 13, 10)},
  28.             PositiveInnerBorder = color(94, 119, 53, 10),
  29.         ValueNegative =     {1, color(139, 37, 13, 10)},
  30.             NegativeInnerBorder = color(150, 72, 54, 10),
  31.         Transparent  =      {1, color(0, 0, 0, 100)},
  32.             NoInnerBorder       = color(0, 0, 0, 100)
  33.     }
  34.  
  35.    
  36.     -- This value configures the width of the valuefield.
  37.     FieldConfig.ValueWidth = FieldConfig.Width/2.2
  38.     FieldConfig.TextOffset = FieldConfig.Height/2+5
  39.  
  40.     -- Added to make it easier to work with enginestates.
  41.     local Engines = {
  42.         {Name = 'Cavebot', Element = nil},
  43.         {Name = 'Looting', Element = nil},
  44.         {Name = 'Targeting', Element = nil},
  45.         {Name = 'Spell Healer', Element = nil},
  46.         {Name = 'Potion Healer', Element = nil},
  47.         {Name = 'Condition Healer', Element = nil},
  48.         {Name = 'Mana Trainer', Element = nil},
  49.     }
  50.     -- Temporary
  51.     local BotE = {'Cavebot', 'Looting', 'Targeting', 'Spell Healer', 'Potion Healer', 'Condition Healer', 'Mana Trainer'}
  52.    
  53.     -- Input events.
  54.     -- Keys, Mouseclicks, Mousemoves, Stealfocus
  55.     filterinput(false, true, false, false)
  56.     -- Allows interaction with hud, aswell as adds the ability to move the HUD.
  57.     function inputevents(e)
  58.         if e.type == IEVENT_LMOUSEUP then
  59.             for _, v in ipairs(Engines) do
  60.                 if e.elementid == v.Element then
  61.                     toggle(v.name:gsub(' ', '') .. '/Enabled')
  62.                     return
  63.                 end
  64.                
  65.             end
  66.         end
  67.     end
  68.  
  69.     local Elements = {}
  70. init end
  71. --[[ Functions ]]--
  72.  
  73. -- Returns a formated textstring for your vip and such.
  74. function viptext()
  75.     foreach vipentry v do
  76.         total = total +1
  77.         if(v.isonline) then
  78.             online = online + 1
  79.         end
  80.     end
  81.     return total..' ('..online..')'
  82. end
  83.  
  84. -- Works like PHPs ucfirst()
  85. -- http://www.php.net/manual/en/function.ucfirst.php
  86. function firstToUpper(str)
  87.     return (str:gsub("^%l", string.upper))
  88. end
  89.  
  90. -- Credit to SIRMATE
  91. function WeaponSkill()
  92.     local SkillTypes = {
  93.         ['axe'] = {type = 'axe', skill = $axe, skillpc = $axepc},
  94.         ['club'] = {type = 'club', skill = $club, skillpc = $clubpc},
  95.         ['sword'] = {type = 'sword', skill = $sword, skillpc = $swordpc},
  96.         ['bow'] = {type = 'distance', skill = $distance, skillpc = $distancepc},
  97.         ['distance weapon'] = {type = 'distance', skill = $distance, skillpc = $distancepc},
  98.         ['no weapon'] = {type = 'fist', skill = $fist, skillpc = $fistpc},
  99.         ['rod'] = {type = 'magic', skill = $mlevel, skillpc = $mlevelpc},
  100.         ['wand'] = {type = 'magic', skill = $mlevel, skillpc = $mlevelpc},
  101.     }
  102.  
  103.     return SkillTypes[findweapontype()]
  104. end
  105.  
  106. -- String used for Weaponskill/Magiclevel section of the HUD.
  107. local TypeSkill = WeaponSkill() or {type = 'magic', skill = $mlevel, skillpc = $mlevelpc}
  108.  
  109. -- Sections, you can add/remove elements as you please.
  110. local Sections = {
  111.         {
  112.             Name = getuseroption('scriptname'),
  113.             Display = true,
  114.             Items = {
  115.                 {"Created by", ScriptAuthor},  
  116.                 {"Version", getuseroption('scriptversion')}
  117.             }
  118.         },
  119.         {
  120.             Name = "Engine states",
  121.             Display = true,
  122.             Items = {
  123.                 {"Cavebot",         "ON"},
  124.                 {"Looting",         "ON"},
  125.                 {"Targeting",       "ON"},
  126.                 {"Spell Healer",    "OFF"},
  127.                 {"Potion Healer",   "ON"},
  128.                 {"Condition Healer","OFF"}
  129.             }
  130.         },
  131.         {
  132.             Name = "Character stats",
  133.             Display = true,
  134.             Items = {
  135.                 {"Experience", num($exp)..' exp'},
  136.                 {"Experience/hour", num($exphour)},
  137.                 {"Experience left", num(exptolevel())..' exp'},
  138.                 {"Experience gained", num($expgained)..' exp'},
  139.                 {"Time online", time(math.floor($timems / 1000))},
  140.                 {"Time to level", time(timetolevel())},
  141.                 {"Ping", $ping .. ' (avg: ' .. $pingaverage .. ')'},           
  142.             }
  143.         },
  144.         {
  145.             Name = "Botting stats",
  146.             Display = true,
  147.             Items = {
  148.                 {"Level", $level .. ' (' .. 100 - math.floor(($exp - expatlvl($level)) * 100 / (expatlvl($level + 1) - expatlvl($level))) .. '%)'},
  149.                 {firstToUpper(TypeSkill.type)..' level', TypeSkill.skill .. ' (' .. 100 - TypeSkill.skillpc .. '%)'},
  150.                 {"Balance", num($balance)},
  151.                 {"Stamina", time($stamina)},
  152.                 {"Softboots duration", 0},
  153.                 {"Vip (Online)", "7 (3)"}
  154.             }
  155.         },
  156.         {
  157.             Name = "Development toolkit",
  158.             Display = false,
  159.             Items = {
  160.                 {"Position", $posx..'/'..$posy..'/'..$posz},
  161.                 {"Mouseover item", $cursorinfo.id},
  162.                 {"Mouse position", $cursorinfo.x..'/'..$cursorinfo.y..'/'..$cursorinfo.z}
  163.             }
  164.         }
  165.     }
  166. --[[ Functions - Continued ]]--
  167. function y(v)
  168.     return v + (FieldConfig.Height + 5)
  169. end
  170. -- Creates a header
  171. function DrawHeader(posx, posy)
  172.     addgradcolors(table.unpack(Colors.Transparent))
  173.     setbordercolor(color(0, 0, 0, 10))
  174.     drawrect(posx, posy, FieldConfig.Width+2, FieldConfig.Height+2)
  175.  
  176.     addgradcolors(table.unpack(Colors.HeaderColor))
  177.     setbordercolor(Colors.HeaderInnerBorder)
  178.     drawrect(posx+1, posy+1, FieldConfig.Width, FieldConfig.Height)
  179. end
  180. -- Creates a field
  181.  
  182. function DrawField(posx, posy)
  183.     posx = posx
  184.     addgradcolors(table.unpack(Colors.Transparent))
  185.     setbordercolor(color(0, 0, 0, 10))
  186.     drawrect(posx, posy, (FieldConfig.Width-FieldConfig.ValueWidth)-1, FieldConfig.Height+2)
  187.  
  188.     addgradcolors(table.unpack(Colors.FieldColor))
  189.     setbordercolor(Colors.FieldInnerBorder)
  190.     drawrect(posx+1, posy+1, FieldConfig.Width-FieldConfig.ValueWidth-3, FieldConfig.Height)
  191. end
  192. -- Creates a value
  193. function DrawValue(posx, posy, valueType)
  194.     if(valueType == "positive") then
  195.         Border      = Colors.PositiveInnerBorder
  196.         Background  = Colors.ValuePositive
  197.     elseif(valueType == "negative") then
  198.         Border      = Colors.NegativeInnerBorder
  199.         Background  = Colors.ValueNegative
  200.     else
  201.         Border      = Colors.NeutralInnerBorder
  202.         Background  = Colors.ValueNeutral
  203.     end
  204.     addgradcolors(table.unpack(Colors.Transparent)) -- This will not show, anyways.
  205.     setbordercolor(color(0, 0, 0, 10))
  206.     drawrect(FieldConfig.Width-FieldConfig.ValueWidth+posx, posy, FieldConfig.ValueWidth+2, FieldConfig.Height+2)
  207.  
  208.     addgradcolors(table.unpack(Background))
  209.     setbordercolor(Border)
  210.     drawrect((FieldConfig.Width-FieldConfig.ValueWidth)+1+posx, posy+1, FieldConfig.ValueWidth, FieldConfig.Height)
  211. end
  212. -- Draws text
  213. function DrawText(text, x, y, fieldtype)
  214.     -- Field type is shorthand functionality to place it over the VALUE elements.
  215.     if(fieldtype == "value") then
  216.         x = ((FieldConfig.Width-FieldConfig.ValueWidth)+x)
  217.     end
  218.     addtext(text, x+6, y+6)
  219. end
  220. -- Hud definitions
  221. setposition($clientwin.left + 5, $worldwin.top+2)
  222. setfontstyle('Tahoma', 8, 75, 0xcfebfd, 1, 0x000000)
  223. setfillstyle('gradient', 'linear', 2, 0, 0, 0, 21)
  224. setantialiasing(true)
  225. --
  226. local yPos = 0
  227. local isEnabled = nil
  228.  
  229. -- Loop fields/values
  230. for k, v in ipairs(Sections) do
  231.     if(v.Display) then
  232.     DrawHeader(0, yPos)
  233.     DrawText(v.Name, 0, yPos)
  234.         for k, v in ipairs(v.Items) do
  235.             local Field, Value = v[1], v[2]
  236.             local fieldColor = nil
  237.             local xOffset = 0
  238.  
  239.             if(table.find(BotE, Field)) then
  240.                 isEnabled = get(Field:gsub(' ', '') .. '/Enabled') == 'yes'
  241.                 fieldColor = tern(isEnabled, "positive", "negative")
  242.                 Value = tern(isEnabled, "ON", "OFF")
  243.                 xOffset = tern(isEnabled, (FieldConfig.ValueWidth/2)-12, (FieldConfig.ValueWidth/2)-14)
  244.             elseif(Field == "Stamina") then
  245.                 if($stamina > 40*60) then
  246.                     fieldColor = "positive"
  247.                 end
  248.             end
  249.            
  250.             yPos = y(yPos) -- Increment yPos
  251.        
  252.             DrawField(0, yPos)
  253.             DrawValue(0, yPos, fieldColor) 
  254.             DrawText(Field, 0 ,yPos)
  255.             DrawText(Value, 0+xOffset, yPos, "value")
  256.         end
  257.    
  258.     yPos = y(yPos)
  259.     end
  260.  
  261. end
  262. -- Footer should NEVER be edited or changed. It's theft if you do so without permission!
  263. DrawHeader(0, yPos)
  264. DrawText("Hultin's HUD - Pre-release", 0, yPos)
  265. DrawText("v2.0.0", FieldConfig.Width-45, yPos)
  266. -- Thank you for using Hultin's Hud V2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement