Kain2030

XT001-SummonerSpells - Auto Exhaust for DivineMethod v2.lua

Aug 18th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.65 KB | None | 0 0
  1. -- ###################################################################################################### --
  2. -- #                                                                                                    # --
  3. -- #                                           XT001-Summoner Spells                                    # --
  4. -- #                                                by Sida                                             # --
  5. -- #                         Credit for original scripts 100% to the original authors!!                 # --
  6. -- #                                                                                                    # --
  7. -- ###################################################################################################### --
  8.  
  9. --[--------- Contains ---------]
  10.  
  11. -- Auto Ignite - Created by SurfaceS
  12. -- Auto Heal - Created by SurfaceS
  13. -- Auto Exhaust - Created by SurfaceS
  14. -- Auto Barrier - Created by SurfaceS
  15.  
  16. -- with Auto Exhaust added by Kain
  17.  
  18. -- ############################################# BARRIER ################################################
  19.  
  20. --[[        Globals     ]]
  21. local barrierCastDelay = 0
  22. local barrierActive = true
  23. local barrierHaveDisplay = true     -- don't display chat
  24. local minValue = 0.15       -- Minimum health ratio for using Barrier
  25. local barrierSlot
  26.  
  27. --[[        Code        ]]
  28. local function barrierReady()
  29.     if barrierSlot ~= nil and barrierCastDelay < GetTickCount() and player:CanUseSpell(barrierSlot) == READY then return true end
  30.     return false
  31. end
  32.  
  33. function BarrierOnLoad()
  34.     --[[            Conditional            ]]
  35.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerBarrier") ~= nil then
  36.         if player:GetSpellData(SUMMONER_1).name == "SummonerBarrier" then
  37.             barrierSlot = SUMMONER_1
  38.         elseif player:GetSpellData(SUMMONER_2).name == "SummonerBarrier" then
  39.             barrierSlot = SUMMONER_2
  40.         end
  41.         function BarrierOnTick()
  42.             local barrierTick = GetTickCount()
  43.             if barrierActive and barrierReady() and player.health / player.maxHealth < minValue then
  44.                 CastSpell(barrierSlot)
  45.                 barrierCastDelay = barrierTick + 300
  46.             end
  47.         end
  48.     end
  49. end
  50.  
  51. -- ############################################# BARRIER ################################################
  52.  
  53. -- ############################################# HEAL ################################################
  54.  
  55. --[[        Globals     ]]
  56. local healCastDelay = 0
  57. local healActive = true
  58. local minValue = 0.15       -- Minimum health ratio for using Barrier
  59. local slot
  60.  
  61. --[[        Code        ]]
  62. local function healReady()
  63.     if slot ~= nil and healCastDelay < GetTickCount() and player:CanUseSpell(slot) == READY then return true end
  64.     return false
  65. end
  66.  
  67. function HealOnLoad()
  68.     --[[            Conditional            ]]
  69.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerHeal") ~= nil then
  70.         if player:GetSpellData(SUMMONER_1).name == "SummonerHeal" then
  71.             slot = SUMMONER_1
  72.         elseif player:GetSpellData(SUMMONER_2).name == "SummonerHeal" then
  73.             slot = SUMMONER_2
  74.         end
  75.         function HealOnTick()
  76.             local healTick = GetTickCount()
  77.             if healActive and healReady() and player.health / player.maxHealth < minValue then
  78.                 CastSpell(slot)
  79.                 healCastDelay = healTick + 300
  80.             end
  81.         end
  82.     end
  83. end
  84.  
  85. -- ############################################# HEAL ################################################
  86.  
  87. -- ############################################# EXHAUST ################################################
  88.  
  89. --[[        Globals     ]]
  90. local autoSummonerExhaust = {
  91.     exhaustCastDelay = 0,
  92.     exhaustActive = false,
  93.     exhaustAuto = true,
  94.     exhaustActiveTick = 0,
  95.     exhaustRange = 550,
  96.     haveDisplay = false,        -- don't display chat
  97.     activeKey = 84,         -- Press key to use autoSummonerExhaust mode (tTt by default)
  98. }
  99.  
  100. local AD_Champion = {
  101.         "Ashe", "Caitlyn", "Corki", "Draven", "Ezreal", "Graves", "Jayce", "KogMaw", "MissFortune", "Pantheon", "Quinn", "Shaco", "Sivir",
  102.         "Talon", "Tristana", "Twitch", "Urgot", "Varus", "Vayne", "Zed", "MasterYi", "XinZhao", "Kayle"
  103.     }
  104.  
  105. --[[        Code        ]]
  106. function ExhaustOnLoad()
  107.     --[[            Conditional            ]]
  108.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerExhaust") ~= nil then
  109.         if player:GetSpellData(SUMMONER_1).name == "SummonerExhaust" then
  110.             autoSummonerExhaust.slot = SUMMONER_1
  111.         elseif player:GetSpellData(SUMMONER_2).name == "SummonerExhaust" then
  112.             autoSummonerExhaust.slot = SUMMONER_2
  113.         end
  114.         function autoSummonerExhaust.ready()
  115.             return autoSummonerExhaust.slot ~= nil and autoSummonerExhaust.exhaustCastDelay < GetTickCount() and player:CanUseSpell(autoSummonerExhaust.slot) == READY
  116.         end
  117.         function ExhaustOnWndMsg(msg,wParam)
  118.                 if msg == KEY_DOWN and wParam == autoSummonerExhaust.activeKey and autoSummonerExhaust.ready() then
  119.                     if autoSummonerExhaust.exhaustActive == false and autoSummonerExhaust.haveDisplay == false then PrintChat(" >> Auto exhaust forced") end
  120.                     autoSummonerExhaust.exhaustActive = true
  121.                     autoSummonerExhaust.exhaustActiveTick = GetTickCount() + 1000
  122.                 end
  123.             end
  124.         function ExhaustOnTick()
  125.             local exhaustTick = GetTickCount()
  126.            
  127.             if autoSummonerExhaust.exhaustActive or autoSummonerExhaust.exhaustAuto then
  128.                 if autoSummonerExhaust.ready() then
  129.                     local exhsuatMaxDPShero = nil
  130.                     local maxDPS = 0
  131.                     for i = 1, heroManager.iCount, 1 do
  132.                         local exhaustHero = heroManager:getHero(i)
  133.                        
  134.                         local isADC = false
  135.                         for i = 1, #AD_Champion, 1 do
  136.                             if AD_Champion[i] == exhaustHero.charName then
  137.                                 isADC = true
  138.                             end
  139.                         end
  140.  
  141.                         if ValidTarget(exhaustHero,autoSummonerExhaust.exhaustRange + 100) and isADC then
  142.                             local exhaustDps = exhaustHero.totalDamage * exhaustHero.attackSpeed
  143.                             if exhsuatMaxDPShero == nil or maxDPS < exhaustDps then maxDPS, exhsuatMaxDPShero = exhaustDps, exhaustHero end
  144.                         end
  145.                     end
  146.                     if exhsuatMaxDPShero ~= nil then
  147.                         autoSummonerExhaust.exhaustActive = false
  148.                         autoSummonerExhaust.exhaustCastDelay = exhaustTick + 500
  149.                         CastSpell(autoSummonerExhaust.slot, exhsuatMaxDPShero)
  150.                     end
  151.                 end
  152.                 if autoSummonerExhaust.exhaustActiveTick < exhaustTick then autoSummonerExhaust.exhaustActive = false end
  153.             end
  154.         end
  155.     else
  156.         autoSummonerExhaust = nil
  157.     end
  158. end
  159.  
  160.  
  161. -- ############################################# EXHAUST ################################################
  162.  
  163. -- ############################################# IGNITE ################################################
  164.  
  165. --[[        Globals     ]]
  166.  
  167.     local autoSummonerDot = {
  168.         igniteRange = 600,
  169.         igniteBaseDamage = 50,
  170.         damagePerLevel = 20,
  171.         castDelay = 0,
  172.         haveDisplay = false,
  173.         activeKey = 249,            -- Press key to use autoSummonerDot mode (space by default)
  174.         toggleKey = 108,        -- Press key to toggle autoSummonerDot mode (F3/F4 by default -> slot)
  175.         forceIgniteKey = 84,    -- Press key to force ignite (tTt by default)
  176.         active = true,
  177.         toggled = true,
  178.         forced = true,
  179.         forcedTick = 0,
  180.     }
  181. --[[        Code        ]]
  182.     function IgniteOnLoad()
  183.         --[[            Conditional            ]]
  184.         if player == nil then player = GetMyHero() end
  185.         if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerDot") ~= nil then
  186.             if player:GetSpellData(SUMMONER_1).name == "SummonerDot" then
  187.                 autoSummonerDot.slot = SUMMONER_1
  188.             elseif player:GetSpellData(SUMMONER_2).name == "SummonerDot" then
  189.                 autoSummonerDot.slot = SUMMONER_2
  190.                 autoSummonerDot.toggleKey = autoSummonerDot.toggleKey + 1
  191.             end
  192.             function autoSummonerDot.ready()
  193.                 if autoSummonerDot.slot ~= nil and autoSummonerDot.castDelay < GetTickCount() and player:CanUseSpell(autoSummonerDot.slot) == READY then return true end
  194.                 return false
  195.             end
  196.             function autoSummonerDot.autoIgniteIfKill()
  197.                 if autoSummonerDot.ready() then
  198.                     local damage = autoSummonerDot.igniteBaseDamage + autoSummonerDot.damagePerLevel * player.level
  199.                     for i = 1, heroManager.iCount, 1 do
  200.                         local hero = heroManager:getHero(i)
  201.                         if hero ~= nil and hero.team ~= player.team and not hero.dead and hero.visible and player:GetDistance(hero) < autoSummonerDot.igniteRange and hero.health <= damage then
  202.                             return autoSummonerDot.igniteTarget( hero )
  203.                         end
  204.                     end
  205.                 end
  206.                 return nil
  207.             end
  208.             function autoSummonerDot.autoIgniteLowestHealth()
  209.                 if autoSummonerDot.ready() then
  210.                     local minLifeHero = nil
  211.                     for i = 1, heroManager.iCount, 1 do
  212.                         local hero = heroManager:getHero(i)
  213.                         if hero ~= nil and hero.team ~= player.team and not hero.dead and hero.visible and player:GetDistance(hero) <= autoSummonerDot.igniteRange then
  214.                             if minLifeHero == nil or hero.health < minLifeHero.health then
  215.                                 minLifeHero = hero
  216.                             end
  217.                         end
  218.                     end
  219.                     if minLifeHero ~= nil then
  220.                         return autoSummonerDot.igniteTarget( minLifeHero )
  221.                     end
  222.                 end
  223.                 return nil
  224.             end
  225.             function autoSummonerDot.igniteTarget(target)
  226.                 if autoSummonerDot.ready() then
  227.                     CastSpell(autoSummonerDot.slot, target)
  228.                     autoSummonerDot.castDelay = GetTickCount() + 500
  229.                     return target
  230.                 end
  231.                 return nil
  232.             end
  233.             function IgniteOnTick()
  234.                 local tick = GetTickCount()
  235.                 if autoSummonerDot.toggled == false then autoSummonerDot.active = IsKeyDown(autoSummonerDot.activeKey) end
  236.                 if autoSummonerDot.forced then
  237.                     if autoSummonerDot.forcedTick > tick then
  238.                         if autoSummonerDot.autoIgniteLowestHealth() ~= nil then autoSummonerDot.forced = false end
  239.                     else
  240.                         autoSummonerDot.forced = false
  241.                     end
  242.                 elseif autoSummonerDot.active then
  243.                     autoSummonerDot.autoIgniteIfKill()
  244.                 end
  245.             end
  246.         else
  247.             autoSummonerDot = nil
  248.         end
  249.     end
  250.  
  251. -- ############################################# IGNITE ################################################
  252.  
  253. -- XT001 --
  254. local hasIgnite, hasHeal, hasExhaust, hasBarrier, enabled = false, false, false, false, true
  255.  
  256. function OnLoad()
  257.    
  258.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerExhaust") ~= nil then hasExhaust = true end
  259.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerDot") ~= nil then hasIgnite = true end
  260.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerHeal") ~= nil then hasHeal = true end
  261.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerBarrier") ~= nil then hasBarrier = true end
  262.  
  263.     if hasHeal or hasIgnite or hasExhaust or hasBarrier then KCConfig = scriptConfig("XT001-Summoner Spells", "xt001summonerspells") else enabled = false end
  264.     if hasIgnite then KCConfig:addParam("Ignite", "Enable Auto Ignite", SCRIPT_PARAM_ONOFF, true) end
  265.     if hasHeal then KCConfig:addParam("Heal", "Enable Auto Heal", SCRIPT_PARAM_ONOFF, true) end
  266.     if hasExhaust then KCConfig:addParam("Exhaust", "Enable Auto Exhaust", SCRIPT_PARAM_ONOFF, true) end
  267.     if hasBarrier then KCConfig:addParam("Barrier", "Enable Auto Barrier", SCRIPT_PARAM_ONOFF, true) end
  268.    
  269.    
  270.     if hasIgnite then IgniteOnLoad() end
  271.     if hasHeal then HealOnLoad() end
  272.     if hasExhaust then ExhaustOnLoad() end
  273.     if hasBarrier then BarrierOnLoad() end
  274. end
  275.  
  276. function OnTick()
  277.     if enabled then
  278.         if KCConfig.Ignite and hasIgnite then
  279.             IgniteOnTick()
  280.         end
  281.         if KCConfig.Heal and hasHeal then
  282.             HealOnTick()
  283.         end
  284.         if KCConfig.Exhaust and hasExhaust then
  285.             ExhaustOnTick()
  286.         end
  287.         if KCConfig.Barrier and hasBarrier then
  288.             BarrierOnTick()
  289.         end
  290.     end
  291. end
  292.  
  293. function OnDraw()
  294.     SC__OnDraw()
  295. end
  296.  
  297. function OnWndMsg(msg,key)
  298.     if enabled then
  299.         if hasExhaust and KCConfig.Exhaust then ExhaustOnWndMsg(msg, key) end
  300.         SC__OnWndMsg(msg,key)
  301.     end
  302. end
Advertisement
Add Comment
Please, Sign In to add comment