Advertisement
mwow

Twitch Helper

Nov 11th, 2012
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.86 KB | None | 0 0
  1. if GetMyHero().charName ~= "Twitch" then return end
  2.  
  3. require "AllClass"
  4. require "spellDmg"
  5.  
  6. local targetFindRange = 80
  7. local poisonTimeOut = 6000
  8. local maxPoisonStacks = 6
  9.  
  10. local ts = nil
  11. local player = GetMyHero()
  12. local lastTick = GetTickCount()
  13. local wPrediction
  14. local wp
  15.  
  16. local enemyTable = {}
  17. local poisonTable = {
  18.     [1] = "twitch_poison_counter_01.troy",
  19.     [2] = "twitch_poison_counter_02.troy",
  20.     [3] = "twitch_poison_counter_03.troy",
  21.     [4] = "twitch_poison_counter_04.troy",
  22.     [5] = "twitch_poison_counter_05.troy",
  23.     [6] = "twitch_poison_counter_06.troy",
  24. }
  25.        
  26. for i=0, heroManager.iCount, 1 do
  27.     local playerObj = heroManager:GetHero(i)
  28.     if playerObj and playerObj.team ~= player.team then
  29.         playerObj.poison = { tick = 0, count = 0, }
  30.         table.insert(enemyTable,playerObj)
  31.     end
  32. end
  33.  
  34. function OnLoad()
  35.     ts = TargetSelector(TARGET_LOW_HP, 1200, DAMAGE_PHYSICAL)
  36.     wPrediction = TargetPrediction(950, 1.38, 100, 50)
  37.     config = scriptConfig("Twitch", "TwitchExpunge")
  38.     config:addParam("eActive", "Harass", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("C"))
  39.     config:addParam("drawcircles", "Draw Circles", SCRIPT_PARAM_ONOFF, true)
  40.     config:addParam("drawFullVenomCircles", "6 Venom Stacks cicle", SCRIPT_PARAM_ONOFF, true)
  41.     config:addParam("vsFloatText", "Venom stacks FloatText", SCRIPT_PARAM_ONOFF, true)
  42.     config:permaShow("eActive")
  43.     ts.name = "Twitch"
  44.     config:addTS(ts)
  45. end
  46.  
  47. function PoisonTimer()
  48.     for i, enemy in pairs(enemyTable) do
  49.         if enemy.poison.count > 0 and enemy.poison.tick+poisonTimeOut < GetTickCount() then
  50.             enemy.poison.count = 0
  51.         end
  52.     end
  53. end
  54.  
  55. function GetPoisonStacks(target)
  56.     for i, enemy in pairs(enemyTable) do
  57.         if enemy.networkID == target.networkID then
  58.             return enemy.poison.count
  59.         end
  60.     end
  61. end
  62.        
  63. function OnTick()
  64.     if GetTickCount()-lastTick < 100 then return end
  65.     lastTick = GetTickCount()
  66.     ts:update()
  67.     TargetPrediction__OnTick()
  68.     PoisonTimer()
  69.     wp = {x=0,z=0}
  70.     if ts.target ~= nil and ts.target.type == "obj_AI_Hero" then
  71.         poisonStacks = GetPoisonStacks(ts.target)
  72.         if ValidTarget(ts.target) then
  73.             wp = wPrediction:GetPrediction(ts.target)
  74.             if config.eActive and wp and GetDistance(wp) < 950 and poisonStacks < 6 and player:CanUseSpell(_W) == READY then   
  75.                 CastSpell(_W,wp.x,wp.z)
  76.             end
  77.            
  78.             local eDmgStack = getDmg("E",ts.target,player,1)*poisonStacks
  79.             local eDmgBase = getDmg("E",ts.target,player,2)
  80.             local totalDmg = eDmgStack + eDmgBase
  81.             if (ts.target.health < totalDmg or poisonStacks == maxPoisonStacks) and player:CanUseSpell(_E) == READY then
  82.                 CastSpell(_E,ts.target)
  83.             end
  84.         end
  85.     end
  86. end    
  87.                        
  88. function OnCreateObj( object )
  89.     if object and string.find(string.lower(object.name),"twitch_poison_counter") then
  90.         for i, enemy in pairs(enemyTable) do
  91.             if enemy and not enemy.dead and enemy.visible and GetDistance2D(enemy,object) <= targetFindRange then
  92.                 for k, poison in pairs(poisonTable) do
  93.                     if object.name == poison then
  94.                         enemy.poison.tick = GetTickCount()+poisonTimeOut
  95.                         enemy.poison.count = k
  96.                         if config.vsFloatText then
  97.                             PrintFloatText(enemy,21,enemy.poison.count .. " poison")
  98.                         end
  99.                     end
  100.                 end
  101.             end
  102.         end
  103.     end
  104. end
  105.  
  106. function OnDraw()
  107.     if config.drawcircles and not myHero.dead then
  108.         DrawCircle(player.x, player.y, player.z, 1200, 0xFF0000) --_E range
  109.     end
  110.     if config.drawFullVenomCircles and not myHero.dead then
  111.         for i, enemy in pairs(enemyTable) do
  112.             if enemy.poison.count == 6 and not enemy.dead then
  113.                     DrawCircle(enemy.x, enemy.y, enemy.z, 100, 0x00FF00)
  114.                     DrawCircle(enemy.x, enemy.y, enemy.z, 101, 0x00FF00)
  115.                     DrawCircle(enemy.x, enemy.y, enemy.z, 102, 0x00FF00)
  116.             end
  117.         end
  118.     end
  119.     SC__OnDraw()
  120. end
  121.  
  122. function OnWndMsg(msg, key)
  123.     SC__OnWndMsg(msg,key)
  124.    
  125. end
  126.  
  127. function OnSendChat(msg)
  128.     TargetSelector__OnSendChat(msg)
  129.     ts:OnSendChat(msg, "pri")
  130. end
  131.  
  132. PrintChat(" >> TwitchHelper Loaded!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement