Advertisement
mwow

Twitch Helper 30-01-2013

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