Kain2030

XT001-SummonerSpells - Auto Exhaust for DivineMethod.lua

Aug 17th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.20 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. --[[        Code        ]]
  100. function ExhaustOnLoad()
  101.     --[[            Conditional            ]]
  102.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerExhaust") ~= nil then
  103.         if player:GetSpellData(SUMMONER_1).name == "SummonerExhaust" then
  104.             autoSummonerExhaust.slot = SUMMONER_1
  105.         elseif player:GetSpellData(SUMMONER_2).name == "SummonerExhaust" then
  106.             autoSummonerExhaust.slot = SUMMONER_2
  107.         end
  108.         function autoSummonerExhaust.ready()
  109.             return autoSummonerExhaust.slot ~= nil and autoSummonerExhaust.exhaustCastDelay < GetTickCount() and player:CanUseSpell(autoSummonerExhaust.slot) == READY
  110.         end
  111.         function ExhaustOnWndMsg(msg,wParam)
  112.                 if msg == KEY_DOWN and wParam == autoSummonerExhaust.activeKey and autoSummonerExhaust.ready() then
  113.                     if autoSummonerExhaust.exhaustActive == false and autoSummonerExhaust.haveDisplay == false then PrintChat(" >> Auto exhaust forced") end
  114.                     autoSummonerExhaust.exhaustActive = true
  115.                     autoSummonerExhaust.exhaustActiveTick = GetTickCount() + 1000
  116.                 end
  117.             end
  118.         function ExhaustOnTick()
  119.             local exhaustTick = GetTickCount()
  120.             if autoSummonerExhaust.exhaustActive or autoSummonerExhaust.exhaustAuto then
  121.                 if autoSummonerExhaust.ready() then
  122.                     local exhsuatMaxDPShero = nil
  123.                     local maxDPS = 0
  124.                     for i = 1, heroManager.iCount, 1 do
  125.                         local exhaustHero = heroManager:getHero(i)
  126.                         if ValidTarget(exhaustHero,autoSummonerExhaust.exhaustRange + 100) then
  127.                             local exhaustDps = exhaustHero.totalDamage * exhaustHero.attackSpeed
  128.                             if exhsuatMaxDPShero == nil or maxDPS < exhaustDps then maxDPS, exhsuatMaxDPShero = exhaustDps, exhaustHero end
  129.                         end
  130.                     end
  131.                     if exhsuatMaxDPShero ~= nil then
  132.                         autoSummonerExhaust.exhaustActive = false
  133.                         autoSummonerExhaust.exhaustCastDelay = exhaustTick + 500
  134.                         CastSpell(autoSummonerExhaust.slot, exhsuatMaxDPShero)
  135.                     end
  136.                 end
  137.                 if autoSummonerExhaust.exhaustActiveTick < exhaustTick then autoSummonerExhaust.exhaustActive = false end
  138.             end
  139.         end
  140.     else
  141.         autoSummonerExhaust = nil
  142.     end
  143. end
  144.  
  145.  
  146. -- ############################################# EXHAUST ################################################
  147.  
  148. -- ############################################# IGNITE ################################################
  149.  
  150. --[[        Globals     ]]
  151.  
  152.     local autoSummonerDot = {
  153.         igniteRange = 600,
  154.         igniteBaseDamage = 50,
  155.         damagePerLevel = 20,
  156.         castDelay = 0,
  157.         haveDisplay = false,
  158.         activeKey = 249,            -- Press key to use autoSummonerDot mode (space by default)
  159.         toggleKey = 108,        -- Press key to toggle autoSummonerDot mode (F3/F4 by default -> slot)
  160.         forceIgniteKey = 84,    -- Press key to force ignite (tTt by default)
  161.         active = true,
  162.         toggled = true,
  163.         forced = true,
  164.         forcedTick = 0,
  165.     }
  166. --[[        Code        ]]
  167.     function IgniteOnLoad()
  168.         --[[            Conditional            ]]
  169.         if player == nil then player = GetMyHero() end
  170.         if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerDot") ~= nil then
  171.             if player:GetSpellData(SUMMONER_1).name == "SummonerDot" then
  172.                 autoSummonerDot.slot = SUMMONER_1
  173.             elseif player:GetSpellData(SUMMONER_2).name == "SummonerDot" then
  174.                 autoSummonerDot.slot = SUMMONER_2
  175.                 autoSummonerDot.toggleKey = autoSummonerDot.toggleKey + 1
  176.             end
  177.             function autoSummonerDot.ready()
  178.                 if autoSummonerDot.slot ~= nil and autoSummonerDot.castDelay < GetTickCount() and player:CanUseSpell(autoSummonerDot.slot) == READY then return true end
  179.                 return false
  180.             end
  181.             function autoSummonerDot.autoIgniteIfKill()
  182.                 if autoSummonerDot.ready() then
  183.                     local damage = autoSummonerDot.igniteBaseDamage + autoSummonerDot.damagePerLevel * player.level
  184.                     for i = 1, heroManager.iCount, 1 do
  185.                         local hero = heroManager:getHero(i)
  186.                         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
  187.                             return autoSummonerDot.igniteTarget( hero )
  188.                         end
  189.                     end
  190.                 end
  191.                 return nil
  192.             end
  193.             function autoSummonerDot.autoIgniteLowestHealth()
  194.                 if autoSummonerDot.ready() then
  195.                     local minLifeHero = nil
  196.                     for i = 1, heroManager.iCount, 1 do
  197.                         local hero = heroManager:getHero(i)
  198.                         if hero ~= nil and hero.team ~= player.team and not hero.dead and hero.visible and player:GetDistance(hero) <= autoSummonerDot.igniteRange then
  199.                             if minLifeHero == nil or hero.health < minLifeHero.health then
  200.                                 minLifeHero = hero
  201.                             end
  202.                         end
  203.                     end
  204.                     if minLifeHero ~= nil then
  205.                         return autoSummonerDot.igniteTarget( minLifeHero )
  206.                     end
  207.                 end
  208.                 return nil
  209.             end
  210.             function autoSummonerDot.igniteTarget(target)
  211.                 if autoSummonerDot.ready() then
  212.                     CastSpell(autoSummonerDot.slot, target)
  213.                     autoSummonerDot.castDelay = GetTickCount() + 500
  214.                     return target
  215.                 end
  216.                 return nil
  217.             end
  218.             function IgniteOnTick()
  219.                 local tick = GetTickCount()
  220.                 if autoSummonerDot.toggled == false then autoSummonerDot.active = IsKeyDown(autoSummonerDot.activeKey) end
  221.                 if autoSummonerDot.forced then
  222.                     if autoSummonerDot.forcedTick > tick then
  223.                         if autoSummonerDot.autoIgniteLowestHealth() ~= nil then autoSummonerDot.forced = false end
  224.                     else
  225.                         autoSummonerDot.forced = false
  226.                     end
  227.                 elseif autoSummonerDot.active then
  228.                     autoSummonerDot.autoIgniteIfKill()
  229.                 end
  230.             end
  231.         else
  232.             autoSummonerDot = nil
  233.         end
  234.     end
  235.  
  236. -- ############################################# IGNITE ################################################
  237.  
  238. -- XT001 --
  239. local hasIgnite, hasHeal, hasExhaust, hasBarrier, enabled = false, false, false, false, true
  240.  
  241. function OnLoad()
  242.    
  243.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerExhaust") ~= nil then hasExhaust = true end
  244.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerDot") ~= nil then hasIgnite = true end
  245.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerHeal") ~= nil then hasHeal = true end
  246.     if string.find(player:GetSpellData(SUMMONER_1).name..player:GetSpellData(SUMMONER_2).name, "SummonerBarrier") ~= nil then hasBarrier = true end
  247.  
  248.     if hasHeal or hasIgnite or hasExhaust or hasBarrier then KCConfig = scriptConfig("XT001-Summoner Spells", "xt001summonerspells") else enabled = false end
  249.     if hasIgnite then KCConfig:addParam("Ignite", "Enable Auto Ignite", SCRIPT_PARAM_ONOFF, true) end
  250.     if hasHeal then KCConfig:addParam("Heal", "Enable Auto Heal", SCRIPT_PARAM_ONOFF, true) end
  251.     if hasExhaust then KCConfig:addParam("Exhaust", "Enable Auto Exhaust", SCRIPT_PARAM_ONOFF, true) end
  252.     if hasBarrier then KCConfig:addParam("Barrier", "Enable Auto Barrier", SCRIPT_PARAM_ONOFF, true) end
  253.    
  254.    
  255.     if hasIgnite then IgniteOnLoad() end
  256.     if hasHeal then HealOnLoad() end
  257.     if hasExhaust then ExhaustOnLoad() end
  258.     if hasBarrier then BarrierOnLoad() end
  259. end
  260.  
  261. function OnTick()
  262.     if enabled then
  263.         if KCConfig.Ignite and hasIgnite then
  264.             IgniteOnTick()
  265.         end
  266.         if KCConfig.Heal and hasHeal then
  267.             HealOnTick()
  268.         end
  269.         if KCConfig.Exhaust and hasExhaust then
  270.             ExhaustOnTick()
  271.         end
  272.         if KCConfig.Barrier and hasBarrier then
  273.             BarrierOnTick()
  274.         end
  275.     end
  276. end
  277.  
  278. function OnDraw()
  279.     SC__OnDraw()
  280. end
  281.  
  282. function OnWndMsg(msg,key)
  283.     if enabled then
  284.         if hasExhaust and KCConfig.Exhaust then ExhaustOnWndMsg(msg, key) end
  285.         SC__OnWndMsg(msg,key)
  286.     end
  287. end
Advertisement
Add Comment
Please, Sign In to add comment