Advertisement
Fwaky

HultinHud - Tibia - Windbot

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