Advertisement
martintokio

Untitled

Feb 2nd, 2024
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.91 KB | None | 0 0
  1. setDefaultTab("Tools")
  2. -- config
  3. local toFollow = ""
  4.  
  5. -- data
  6. local useId = {
  7.     [34847] = true,
  8.     [1764] = true,
  9.     [21051] = true,
  10.     [30823] = true,
  11.     [6264] = true,
  12.     [5282] = true,
  13.     [20453] = true,
  14.     [20454] = true,
  15.     [20474] = true,
  16.     [11708] = true,
  17.     [11705] = true,
  18.     [6257] = true,
  19.     [6256] = true,
  20.     [2772] = true,
  21.     [27260] = true,
  22.     [2773] = true,
  23.     [1632] = true,
  24.     [1633] = true,
  25.     [1948] = true,
  26.     [435] = true,
  27.     [6252] = true,
  28.     [6253] = true,
  29.     [5007] = true,
  30.     [4911] = true,
  31.     [1629] = true,
  32.     [1630] = true,
  33.     [5108] = true,
  34.     [5107] = true,
  35.     [5281] = true,
  36.     [1968] = true,
  37.     [435] = true,
  38.     [1948] = true,
  39.     [5542] = true,
  40.     [31116] = true,
  41.     [31120] = true,
  42.     [30742] = true,
  43.     [31115] = true,
  44.     [31118] = true,
  45.     [20474] = true,
  46.     [5737] = true,
  47.     [5736] = true,
  48.     [5734] = true,
  49.     [5733] = true,
  50.     [31202] = true,
  51.     [31228] = true,
  52.     [31199] = true,
  53.     [31200] = true,
  54.     [33262] = true,
  55.     [30824] = true,
  56.     [5125] = true,
  57.     [5126] = true,
  58.     [5116] = true,
  59.     [5117] = true,
  60.     [8257] = true,
  61.     [8258] = true,
  62.     [8255] = true,
  63.     [8256] = true,
  64.     [5120] = true,
  65.     [30777] = true,
  66.     [30776] = true,
  67.     [23873] = true,
  68.     [23877] = true,
  69.     [5736] = true,
  70.     [6264] = true,
  71.     [31262] = true,
  72.     [31130] = true,
  73.     [31129] = true,
  74.     [6250] = true,
  75.     [6249] = true,
  76.     [5122] = true,
  77.     [30049] = true,
  78.     [7131] = true,
  79.     [7132] = true,
  80.     [7727] = true
  81. }
  82. local shovelId = {
  83.     [606] = true,
  84.     [593] = true,
  85.     [867] = true,
  86.     [608] = true
  87. }
  88. local ropeId = {
  89.     [17238] = true,
  90.     [12202] = true,
  91.     [12935] = true,
  92.     [386] = true,
  93.     [421] = true,
  94.     [21966] = true,
  95.     [14238] = true
  96. }
  97. local macheteId = {
  98.     [2130] = true,
  99.     [3696] = true
  100. }
  101. local scytheId = {
  102.     [3653] = true
  103. }
  104. local tables = {useId, shovelId, ropeId, macheteId, scytheId}
  105. local settings = storage.extras
  106. local movementHistory = {}
  107. storage.vithraxFollow = storage.vithraxFollow or ''
  108.  
  109. -- functions
  110. local function useAll()
  111.     local tiles = getNearTiles(pos())
  112.     table.insert(tiles, g_map.getTile(pos()))
  113.  
  114.     for _, tile in ipairs(tiles) do
  115.         for __, item in ipairs(tile:getItems()) do
  116.             local id = item:getId()
  117.             for i, array in ipairs(tables) do
  118.                 if array[id] then
  119.                     if i == 1 then
  120.                         use(item)
  121.                     elseif i == 2 then
  122.                         useWith(settings.shovel, item)
  123.                     elseif i == 3 then
  124.                         useWith(settings.rope, item)
  125.                     elseif i == 4 then
  126.                         useWith(settings.machete, item)
  127.                     else
  128.                         useWith(settings.scythe, item)
  129.                     end
  130.                     return true
  131.                 end
  132.             end
  133.         end
  134.     end
  135.  
  136.     return false
  137. end
  138.  
  139. setDefaultTab("KT")
  140.  
  141. local getOutfit = player:getOutfit()
  142. local playerOutfit = {
  143.     type = getOutfit.type,
  144.     head = getOutfit.head,
  145.     body = getOutfit.body,
  146.     legs = getOutfit.legs,
  147.     feet = getOutfit.feet,
  148.     addons = getOutfit.addons,
  149.     --mount = getOutfit.mount
  150. }
  151.  
  152. local followIcon = addIcon("holdFollow",  {outfit=playerOutfit, movable=true, text = "Follow"},
  153. macro(75, "[Melee] Close Follow", function(macro)
  154.     local target = getCreatureByName(storage.vithraxFollow)
  155.     local tpos = target and target:getPosition()
  156.     if tpos and getDistanceBetween(tpos,pos()) < 2 then
  157.         movementHistory = {}
  158.         return
  159.     end
  160.     local dest = movementHistory[posz()]
  161.     if tpos and not dest then
  162.         local path = findPath(tpos, pos(), 20, { ignoreNonPathable = true, precision = 1 })
  163.         if path then
  164.             dest = tpos
  165.         end
  166.     end
  167.     if not dest then
  168.         if useAll() then
  169.             return
  170.         end
  171.         delay(100)
  172.     end
  173.     if dest and getDistanceBetween(dest, pos()) == 0 then
  174.         delay(100)
  175.         useAll()
  176.         return
  177.     end
  178.     local path = findPath(pos(), dest, 20, { ignoreNonPathable = true, precision = 1 })
  179.     if not path then
  180.         useAll()
  181.         delay(100)
  182.         return
  183.     end
  184.     CaveBot.walkTo(dest, 20, { ignoreNonPathable = true, precision = target and 1 or 0 })
  185. end))
  186.  
  187. UI.TextEdit(storage.vithraxFollow or 'Player Name', function(widget, newText)
  188.     storage.vithraxFollow = newText
  189. end)
  190.  
  191. onCreaturePositionChange(function(creature, oldPos, newPos)
  192.     if not newPos then return end
  193.     if creature:getName():lower() ~= storage.vithraxFollow:lower():trim() then return end
  194.  
  195.     -- register position on current floor
  196.     movementHistory[newPos.z] = newPos
  197. end)
  198. UI.Separator()
  199.  
  200. followIcon:setSize({height=55,width=50})
  201. followIcon.text:setFont('verdana-11px-rounded')
  202. followIcon.text:setTextOffset({x = 12, y = -8})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement