Advertisement
Gorzoid

PsuedoBot.lua

Feb 25th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. local ply = Entities.me
  2.  
  3. local function regen(mode)
  4.     if type(mode) == "table" then
  5.         for k,v in ipairs(mode) do
  6.             if regen(v) then
  7.                 return mode,v
  8.             end
  9.         end
  10.     end
  11.  
  12.     if ply:InCombat() and mode != "POTION" then
  13.         return false
  14.     end
  15.    
  16.     if not mode or mode == "WAIT" then
  17.         while ply:Health() > ply:MaxHealth() do
  18.             sleep(5)
  19.            
  20.             if ply:InCombat() then
  21.                 return false
  22.             end
  23.         end
  24.         return true
  25.     elseif mode == "CLASS" then
  26.         local class = ply:GetClass()
  27.         ply:SetClass(class == "warrior" and "rougue" or "warrior")
  28.         ply:SetClass(class)
  29.        
  30.         return true
  31.     elseif mode == "POTION" then
  32.         local item = findItem(ply.InventoryController, Items.HEALTH_POTION)
  33.         if not item then return false end
  34.        
  35.         return ply:UseItem(item)
  36.     end
  37. end
  38.  
  39. local config_teleport = false
  40. local function moveTo(pos)
  41.     if config_teleport then
  42.         ply:SetPos(pos)
  43.     else
  44.         ply:MoveTo(pos)
  45.     end
  46. end
  47.  
  48. -- Keys to press
  49. local spells = {5,4,3,2}
  50. local function fight(ent)
  51.     ply:SetTarget(ent)
  52.     while ent and ent:IsValid() and ply:CanAttack(ent) do
  53.    
  54.         if (ply.position - ent.position).sqrMagnitude > combatRange^2 then
  55.             moveTo(ent.position)
  56.         end
  57.    
  58.         local gcd = ply:GetGlobalCD()
  59.         if gcd > 0 then sleep(gcd) end
  60.        
  61.         local flag = false
  62.         for i,v in ipairs(spells) do
  63.             if ply:CanAttackWithSpell(ent,spell) then
  64.                 ply:CastSpell(v)
  65.                 flag = true
  66.             end
  67.         end
  68.        
  69.         if not flag then
  70.             ply:AutoAttack(ent)
  71.         end
  72.        
  73.     end
  74. end
  75.  
  76. local function findNPCs(pred,comp)
  77.  
  78.     local ents = Entities.NPCMap
  79.    
  80.     local ent
  81.     for k,v in pairs(ents) do
  82.         if pred(v) then
  83.             if comp then
  84.                 ent = ent and comp(ent,v) and ent or v
  85.             else
  86.                 return v
  87.             end
  88.         end
  89.     end
  90.     return ent
  91. end
  92.  
  93. ply:JoinWorld("slabs")
  94.  
  95. --waypoints
  96. for i,v in ipairs{Vector(1.0,5.0,2.0),...} do
  97.     moveTo(v)
  98. end
  99.  
  100. while true do
  101.     local ent = findNPC("South Warsworn")
  102.    
  103.     if ent then
  104.         fight(ent)
  105.         regen("CLASS")
  106.     else
  107.         sleep(1)
  108.     end
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement