nengo

Warlock.lua

Jan 16th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.09 KB | None | 0 0
  1. function round(num, numDecimalPlaces)
  2.   return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
  3. end
  4.  
  5. function Cast(spellName)
  6.     if (HasSpell(spellName) == 1) then
  7.         if (IsSpellInRange(targetObj, spellName) == 1) then
  8.             if (IsSpellOnCD(spellName) == 0) then
  9.                 if (IsAutoCasting(spellName) == 0) then
  10.                     --Face Target
  11.                     FaceTarget(targetObj);
  12.                
  13.                     --Cast Spell
  14.                     CastSpellByName(spellName);
  15.                
  16.                     return true;
  17.                 end
  18.             end        
  19.         end
  20.     end
  21.     return false;
  22. end
  23.  
  24. function Buff(spellName, player)
  25.     if (HasSpell(spellName) == 1) then
  26.         if (HasBuff(player, spellName) == 0) then
  27.             TargetEnemy(localObj);
  28.             CastSpellByName(spellName);
  29.             TargetEnemy(player);
  30.             return true;
  31.         end
  32.     end
  33.     return false;
  34. end
  35.  
  36. function DeBugInfo()
  37.     y = 150;
  38.     x = 25;
  39. --[[
  40.     --Spell Info
  41.     castingTime, maxRange, minRange, powerType, Cost, spellID, spellObj = GetSpellInfoX('Fire Blast');
  42.     text =  'castingTime =' .. castingTime ..
  43.             ', minRange=' .. minRange ..
  44.             ', maxRange=' .. maxRange ..
  45.             ', powerType=' .. powerType ..
  46.             ', Cost=' .. Cost ..
  47.             ', spellID=' .. spellID
  48.     DrawText(text, x, y, 66, 255, 244);
  49.     y += 25;
  50. --]]
  51.  
  52.     local_ = GetLocalPlayer();
  53.     DrawText('Health:' .. GetHealth(localObj) .. ' ' .. round(GetHealthPercentage(localObj),2) .. '%', x, y, 66, 255, 244); y = y + 15;
  54.     DrawText('Mana:' .. GetMana(localObj) .. ' ' .. round(GetManaPercentage(localObj),2) .. '%', x, y, 66, 255, 244); y = y + 25;
  55. end
  56.  
  57. debug_ = false;
  58.  
  59. if (debug_) then
  60.     DeBugInfo();
  61. end
  62.  
  63. --Get Enemy
  64. targetObj = GetTarget();--GetNearestEnemy();
  65. localObj = GetLocalPlayer();
  66.        
  67. --
  68. if (IsDead(localObj) == 1) then
  69.     return;
  70. end
  71.  
  72. -- Pre Check
  73. if (IsChanneling() == 1) then
  74.     return;
  75. end
  76. if (IsCasting() == 1) then
  77.     return;
  78. end
  79. if (IsStanding() == 0) then
  80.     return;
  81. end
  82.    
  83. -- Do Buff
  84. --If we don't have the demon skin we probably wont neither have a summon, so we cast it 1st.
  85. --Note this is just a workaround until I figure out how to check for the demon or the function UnitExists is implemented,
  86. --if we enter combat just after reviving it's probably not gonna work as intended(just hope to get the 10sec cast interrupted before you die again).
  87. if (HasBuff(localObj, 'Demon Skin') == 0) then
  88.     if (IsInCombat() == 0) then
  89.         CastSpellByName('Summon Imp');
  90.     end
  91. end
  92.  
  93. if (Buff('Demon Skin', localObj)) then
  94.     return;
  95. end
  96.    
  97.  
  98.  
  99. --Valid Enemy
  100. if (targetObj ~= 0) then
  101.    
  102.     -- Cant Attack dead targets
  103.     if (IsDead(targetObj) == 1) then
  104.         return;
  105.     end
  106.    
  107.     if (CanAttack(targetObj) == 0) then
  108.         return;
  109.     end
  110.    
  111.     -- Dismount
  112.     Dismount();
  113.    
  114.     -- Auto Attack
  115.     AutoAttack(targetObj);
  116.    
  117.     --Health/Mana values
  118.     targetHealth = GetHealthPercentage(targetObj);
  119.     localHealth = GetHealthPercentage(localObj);
  120.     localMana = GetManaPercentage(localObj);
  121.     localManaVal = GetMana(localObj);
  122.    
  123.     -- Opener
  124.     if (IsInCombat() == 0 and localMana >= 40 and localHealth >= 60) then
  125.    
  126.         --Cast Opener Depending on Movement
  127.         if (IsMoving() == 1) then
  128.             Cast('Curse of Weakness');
  129.             return;
  130.         else
  131.             Cast('Corruption');
  132.             return;
  133.         end
  134.    
  135.     -- Combat
  136.     else
  137.         --Buff/Debuff checking
  138.         local hasCorruption = HasDebuff(targetObj, 'Corruption')
  139.         local hasWeakness = HasDebuff(targetObj, 'Curse of Weakness')
  140.         local hasImmolate = HasDebuff(targetObj, 'Immolate')
  141.         if (debug_) then
  142.             ToConsole('- Has Debuff= ' .. tostring(hasCorruption))
  143.         end
  144.        
  145.         --Life Tap
  146.         if localMana < 20 and localHealth > 60 then
  147.             CastSpellByName('Life Tap');
  148.             return;
  149.         end
  150.        
  151.         --Offensive Spells
  152.         if (hasWeakness == 0) then
  153.             Cast('Curse of Weakness');
  154.             return;
  155.         end
  156.        
  157.         if (IsMoving() == 0 and hasImmolate == 0) then
  158.             Cast('Immolate');
  159.             return;
  160.         end
  161.        
  162.         if (IsMoving() == 0 and hasCorruption == 0) then
  163.             Cast('Corruption');
  164.             return;
  165.         end
  166.        
  167.         if (IsMoving() == 0 and Cast('Shadow Bolt')) then
  168.             return;
  169.         end
  170.        
  171.     end
  172. else
  173.    
  174.     --if (Loot() == 1) then
  175.     --  return;
  176.     --end
  177.    
  178.     --if (Navigate() == 1) then
  179.     --  return;
  180.     --end  
  181. end
  182.  
  183. --Some interesting functions:
  184. --UnitExists("unit") as seen in the WoW Api, to get info about having or not a pet for example
Advertisement
Add Comment
Please, Sign In to add comment