Advertisement
Fwaky

HultinHud - Tibia - Windbot (Beta version)

Feb 20th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.31 KB | None | 0 0
  1. init start
  2. -- Created by Hultin
  3. -- 2014-02-19 - Updated 2014-02-21
  4. -- Thanks to:
  5. --      Rafael (Borrowed code)
  6. --      Sirmate (Colors and inspiration)
  7. --      Lucas Terra (Making Tibia worth playing again "playing")
  8. --      Dworak (Suggestions)
  9.     local scriptinfo = {
  10.         name = "Earth elementals - Kazordoon",
  11.         items = {
  12.             {"Author", "Harvey Scripts"},  
  13.             {"Version", "1.0.1"},
  14.         },
  15.         development = false,  -- Set to true if you wish to see coordinates and such.
  16.     }
  17.     -- Taken from Sirmate's MMH
  18.     local gradient = {
  19.         blue    = {0.0, color(36, 68, 105, 20), 0.23, color(39, 73, 114, 20), 0.76, color(21, 39, 60, 20)},
  20.         black   = {0.0, color(75, 75, 75, 20), 0.23, color(45, 45, 45, 20), 0.76, color(19, 19, 19, 20)},
  21.         red     = {0.0, color(136, 35, 12, 20), 0.23, color(139, 37, 13, 20), 0.76, color(92, 6, 6, 20)},
  22.         green   = {0.0, color(65, 96, 12, 20), 0.23, color(67, 99, 13, 20), 0.76, color(36, 52, 6, 20)},
  23.         yellow  = {0.0, color(145, 95, 0, 20), 0.23, color(158, 104, 0, 20), 0.76, color(84, 55, 0, 20)},
  24.     }
  25.    
  26.     -- Engines taken from Raphael "Engine states"
  27.     local engines = {'Cavebot', 'Looting', 'Targeting', 'Spell Healer', 'Potion Healer', 'Condition Healer', 'Mana Trainer'}
  28.    
  29.    
  30.     -- keys, mouseclicks, mousemoves, stealfocus
  31.     filterinput(false, true, false, false)
  32.    
  33.     function firstToUpper(str)
  34.         return (str:gsub("^%l", string.upper))
  35.     end
  36.     local Moving, Temp, Moved = false, {0, 0}, {0, 0}
  37.     function inputevents(e)
  38.         if e.type == IEVENT_LMOUSEUP then
  39.             for _, v in ipairs(engines) do
  40.                 if e.elementid == v.shape then
  41.                     toggle(v.name:gsub(' ', '') .. '/Enabled')
  42.                     return
  43.                 end
  44.                
  45.             end-- Cogwheel click
  46.                 print(e.elementid)
  47.                 if e.elementid == config then
  48.                     if (scriptinfo.development) then
  49.                         scriptinfo.development = false
  50.                     else
  51.                         scriptinfo.development = true
  52.                     end
  53.                 end
  54.         end
  55.         if (e.type == IEVENT_MMOUSEDOWN) then
  56.             Moving, Temp = true, {$cursor.x - Moved[1], $cursor.y - Moved[2]}
  57.         end
  58.         if (e.type == IEVENT_MMOUSEUP) then
  59.             Moving = false
  60.         end
  61.     end
  62.  
  63.     -- Credit to Raphael
  64.     for k, v in ipairs(engines) do
  65.         engines[k] = {
  66.             name  = v,
  67.             shape = nil
  68.         }
  69.     end
  70.  
  71.     -- Do not edit
  72.     local hud = {
  73.         author = "Hultin",
  74.         version = "1.1.2",
  75.     }
  76.  
  77.     -- Credit to SIRMATE
  78.     function WeaponSkill()
  79.         local SkillTypes = {
  80.             ['axe'] = {type = 'axe', skill = $axe, skillpc = $axepc},
  81.             ['club'] = {type = 'club', skill = $club, skillpc = $clubpc},
  82.             ['sword'] = {type = 'sword', skill = $sword, skillpc = $swordpc},
  83.             ['bow'] = {type = 'distance', skill = $distance, skillpc = $distancepc},
  84.             ['distance weapon'] = {type = 'distance', skill = $distance, skillpc = $distancepc},
  85.             ['no weapon'] = {type = 'fist', skill = $fist, skillpc = $fistpc},
  86.             ['rod'] = {type = 'magic', skill = $mlevel, skillpc = $mlevelpc},
  87.             ['wand'] = {type = 'magic', skill = $mlevel, skillpc = $mlevelpc},
  88.         }
  89.  
  90.         return SkillTypes[findweapontype()]
  91.     end
  92.     -- Function by Donatello
  93.     function getsecs(msg)
  94.         local times = {
  95.              a = '+',
  96.              h = '* 3600',
  97.              m = '* 60',
  98.              s = '* 1'
  99.         }
  100.         local time = msg:gsub(' (%l)(%l+)', ' %1'):gsub('(%l)', function( t ) return times[t] end)
  101.         return loadstring('return ' .. time)()
  102.     end
  103. init end
  104.  
  105. if (Moving) then
  106.     auto(10)
  107.     Moved = {$cursor.x - Temp[1], $cursor.y - Temp[2]}
  108. end
  109. setposition($clientwin.left + 5 + Moved[1], $worldwin.top + Moved[2])
  110. setfontstyle('Tahoma', 8, 75, 0xFFFFFF, 1, 0x000000)
  111. setfillstyle('gradient', 'linear', 2, 0, 0, 0, 21)
  112. setbordercolor(color(0, 0, 0, 50))
  113. setantialiasing(true)
  114.  
  115. function minuteorhour()
  116.     local t = $timetonextlevel
  117.     if(t > 60 and t < 120)  then
  118.         v = "hour"
  119.     elseif(t > 120) then
  120.         v = "hours"
  121.     else
  122.         v = "min"
  123.     end
  124.     return v
  125. end
  126. local total, online = 0,0
  127. function viptext()
  128.     foreach vipentry v do
  129.         total = total +1
  130.         if(v.isonline) then
  131.             online = online + 1
  132.         end
  133.     end
  134.     return total..' ('..online..')'
  135. end
  136. local softDuration = time(softTime) or 0;
  137. local bottingstats = {
  138.     {"Experience", num($exp)..' exp'},
  139.     {"Experience/hour", num($exphour)},
  140.     {"Experience gained", num($expgained)..' exp'},
  141.     {"Experience left", num(exptolevel())..' exp'},
  142.     {"Time online", time(math.floor($timems / 1000))},
  143.     {"Time to level", time(timetolevel())..minuteorhour()..'~'}, -- Minutes work, hours don't. Need fix.
  144.     {"Ping", $ping .. ' (avg: ' .. $pingaverage .. ')'},
  145. }
  146. local offskill = WeaponSkill() or {type = 'magic', skill = $mlevel, skillpc = $mlevelpc}
  147. local characterstats = {
  148.     {"Level", $level .. ' (' .. 100 - math.floor(($exp - expatlvl($level)) * 100 / (expatlvl($level + 1) - expatlvl($level))) .. '%)'},
  149.     {firstToUpper(offskill.type)..' level', offskill.skill .. ' (' .. 100 - offskill.skillpc .. '%)'},
  150.     {"Balance", num($balance)},
  151.     {"Stamina", time($stamina)},
  152.     {"Softboots duration", softDuration},
  153.     {"Vip (Online)", viptext()}
  154. }
  155.  
  156. local lastypos = 0
  157. -- Script info
  158. addgradcolors(table.unpack(gradient.blue))
  159. header3 = addshape('rect', 0, lastypos, 250, 20, 3, 3)
  160. addtext(scriptinfo.name, 8, lastypos+3)
  161. -- Devbutton start
  162. if(scriptinfo.development) then
  163.     addgradcolors(table.unpack(gradient.red))
  164.     config = addshape('rect', 230, lastypos, 20, 20, 3, 3)
  165.     addtext("-", 238, lastypos+3)
  166. else
  167.     addgradcolors(table.unpack(gradient.green))
  168.     config = addshape('rect', 230, lastypos, 20, 20, 3, 3)
  169.     addtext("+", 236, lastypos+3)
  170. end
  171. -- Devbutton end
  172.  
  173. for k, v in ipairs(scriptinfo.items) do
  174.     lastypos = lastypos + 23
  175.     addgradcolors(table.unpack(gradient.black))
  176.     addshape('rect', 0, lastypos, 140, 20, 3, 3)
  177.     addtext(v[1], 8, lastypos + 3)
  178.     addgradcolors(table.unpack(gradient.yellow))
  179.     addshape('rect', 140, lastypos, 110, 20, 3, 3)
  180.     addtext(v[2], 150, lastypos + 3)
  181. end
  182.  
  183. lastypos = lastypos + 23
  184. -- Engine states
  185. addgradcolors(table.unpack(gradient.blue))
  186. header = addshape('rect', 0, lastypos, 250, 20, 3, 3)
  187. addtext('Engine states', 8, lastypos + 3)
  188.  
  189. local isEnabled
  190. for k, v in ipairs(engines) do
  191.     addgradcolors(table.unpack(gradient.black))
  192.     addshape('rect', 0, lastypos + 23, 200, 20, 3, 3)
  193.     addtext(v.name, 6, lastypos + 26)
  194.  
  195.     isEnabled = get(v.name:gsub(' ', '') .. '/Enabled') == 'yes'
  196.     addgradcolors(table.unpack(tern(isEnabled, gradient.green, gradient.red)))
  197.     engines[k].shape = addshape('rect', 198, lastypos + 23, 52, 20, 3, 3)
  198.     addtext(tern(isEnabled, 'ON', 'OFF'), 213 + tern(isEnabled, 2, 0),  lastypos + 26)
  199.     lastypos = lastypos + 23
  200. end
  201. -- Botting stats
  202. addgradcolors(table.unpack(gradient.blue))
  203. header = addshape('rect', 0, lastypos+23, 250, 20, 3, 3)
  204. addtext('Botting stats', 8, lastypos+26)
  205. lastypos = lastypos+23
  206. local botstartypos = lastypos+63
  207. for k, v in ipairs(bottingstats) do
  208.     local name = v[1]
  209.     local value = v[2]
  210.     -- Fieldname
  211.     addgradcolors(table.unpack(gradient.black))
  212.     addshape('rect', 0, lastypos + 23, 140, 20, 3, 3)
  213.     addtext(name, 6, lastypos+23 + 3)
  214.     lastypos = lastypos + 23
  215.     -- Field value
  216.     if($expgained < 0 and name == "Experience") then
  217.         addgradcolors(table.unpack(gradient.red))
  218.     elseif(name == "Experience" and $expgained > 0) then
  219.         addgradcolors(table.unpack(gradient.green))
  220.     else
  221.         addgradcolors(table.unpack(gradient.yellow))
  222.     end
  223.     addshape('rect', 140, lastypos, 110, 20, 3, 3)
  224.     addtext(value, 150, lastypos+3)
  225. end
  226. -- Character stats
  227. addgradcolors(table.unpack(gradient.blue))
  228. header2 = addshape('rect', 0, lastypos+23, 250, 20, 3, 3)
  229. addtext('Character stats', 8, lastypos+26)
  230. lastypos = lastypos+23
  231. local botstartypos = lastypos+63
  232. for k, v in ipairs(characterstats) do
  233.     lastypos = lastypos + 23
  234.     local name = v[1]
  235.     local value = v[2]
  236.     -- Fieldname
  237.     addgradcolors(table.unpack(gradient.black))
  238.     addshape('rect', 0, lastypos, 140, 20, 3, 3)
  239.     addtext(name, 6, lastypos + 3)
  240.    
  241.     -- Field value
  242.     if(name == "Stamina") then
  243.         if($stamina >= (40*60)+1) then -- Green
  244.             addgradcolors(table.unpack(gradient.green))
  245.         elseif($stamina >= 14*60 and $stamina <= 40*60) then -- Yellow
  246.             addgradcolors(table.unpack(gradient.yellow))
  247.         else -- Red
  248.             addgradcolors(table.unpack(gradient.red))
  249.         end
  250.     else
  251.         addgradcolors(table.unpack(gradient.yellow))
  252.     end
  253.     addshape('rect', 140, lastypos, 110, 20, 3, 3)
  254.     addtext(value, 150, lastypos+3)
  255. end
  256.  
  257. -- Hud info
  258. lastypos = lastypos + 23
  259. addgradcolors(table.unpack(gradient.blue))
  260.  
  261. header2 = addshape('rect', 0, lastypos, 250, 20, 3, 3)
  262. addtext('Hultins HUD', 8, lastypos +3)
  263. addtext('Version '..hud.version, 170, lastypos + 3)
  264. lastypos = lastypos + 23
  265. -----
  266. -- Development tools
  267. -----
  268.  
  269. if(scriptinfo.development) then
  270.     lastypos = lastypos + 20 -- We want some spacing from the main HUD
  271.     -- Header
  272.     addgradcolors(table.unpack(gradient.blue))
  273.     addshape('rect', 0, lastypos, 250, 20, 3, 3)
  274.     addtext('Development toolkit', 8, lastypos +3)
  275.     lastypos = lastypos + 23
  276.     -- Coords
  277.     addgradcolors(table.unpack(gradient.black))
  278.     addshape('rect', 0, lastypos, 140, 20, 3, 3)
  279.     addtext('Coords (x/y/z)', 8, lastypos + 3)
  280.     addgradcolors(table.unpack(gradient.yellow))
  281.     addshape('rect', 140, lastypos, 110, 20, 3, 3)
  282.     addtext($posx..'/'..$posy..'/'..$posz, 148, lastypos + 3)
  283.     lastypos = lastypos + 23
  284.     -- Mouseover itemid
  285.         addgradcolors(table.unpack(gradient.black))
  286.     addshape('rect', 0, lastypos, 140, 20, 3, 3)
  287.     addtext('Mouse itemid', 8, lastypos + 3)
  288.     addgradcolors(table.unpack(gradient.yellow))
  289.     addshape('rect', 140, lastypos, 110, 20, 3, 3)
  290.     addtext($cursorinfo.id, 148, lastypos + 3)
  291.     lastypos = lastypos + 23
  292. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement