16HeX16

Karma Combo

Apr 1st, 2013
6,238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.29 KB | None | 0 0
  1. if myHero.charName ~= "Karma" then return end
  2.  
  3. require 'Prodiction'
  4.  
  5. local empowered = false
  6.  
  7. class 'TickManager'
  8.  
  9. function TickManager:__init(ticksPerSecond)
  10.     self.TPS = ticksPerSecond
  11.     self.lastClock = 0
  12.     self.currentClock = 0
  13. end
  14.  
  15. function TickManager:__type()
  16.     return "TickManager"
  17. end
  18.  
  19. function TickManager:setTPS(ticksPerSecond)
  20.     self.TPS = ticksPerSecond
  21. end
  22.  
  23. function TickManager:getTPS(ticksPerSecond)
  24.     return self.TPS
  25. end
  26.  
  27. function TickManager:isReady()
  28.     self.currentClock = os.clock()
  29.     if self.currentClock < self.lastClock + (1 / self.TPS) then return false end
  30.     self.lastClock = self.currentClock
  31.     return true
  32. end
  33.  
  34. local tm = TickManager(20)
  35.  
  36. function OnLoad()
  37.     Load()
  38.     Menu()
  39. end
  40.  
  41. function OnTick()
  42.     ReadyCheck()
  43.     --[[    Combos  ]]--
  44.     if ts.target and not myHero.dead then
  45.         if KarmaConfig.Combo then
  46.             UseItems(ts.target)
  47.             autoCombo(ts.target)
  48.         end    
  49.         if KarmaConfig.Harass and QREADY then
  50.             castQ(ts.target, true)
  51.         end
  52.     end
  53.     --[[    Ignite  ]]--
  54.     if KarmaConfig.autoignite and IREADY then
  55.         AutoIgnite()
  56.     end
  57. end    
  58.  
  59. function OnDraw()
  60.     if KarmaConfig.circlesSelf and not myHero.dead then
  61.         DrawCircle(myHero.x, myHero.y, myHero.z, qRange, 0x19A712)
  62.     end
  63.     if KarmaConfig.circlesEnemies and ts.target then
  64.         for i=1, 5, 1 do
  65.             DrawCircle(ts.target.x, ts.target.y, ts.target.z, 50+3*i, 0xFF0000)
  66.         end
  67.     end
  68. end
  69.  
  70. --[[    Script Functions    ]]--
  71. function autoCombo(target)
  72.     if QREADY and target.health < getDmg("Q", target, myHero) then
  73.         castQ(target, false)
  74.     elseif QREADY and target.health < getDmg("Q", target, myHero, 2) and (RREADY or empowered) then
  75.         castQ(target, true)
  76.     elseif myHero.health <= myHero.maxHealth*0.70 and WREADY and GetDistance(target) <= wRange and (RREADY or empowered) then
  77.         WCombo(target)
  78.     elseif not QREADY and myHero.health <= myHero.maxHealth*0.65 and GetDistance(target) <= eRadius and EREADY and (RREADY or empowered) then
  79.         ECombo(target)
  80.     else
  81.         QCombo(target)
  82.     end
  83. end
  84.  
  85. function QCombo(target)
  86.     if WREADY and GetDistance(target) <= wRange then
  87.         CastSpell(_W, target)
  88.     end
  89.     if QREADY then castQ(target, true) end
  90.     if not KarmaConfig.supportMode and GetDistance(target) >= 600 and myHero.mana >= 200 then
  91.         CastSpell(_E, myHero)
  92.     end
  93. end
  94.  
  95. function WCombo(target)
  96.     if WREADY and GetDistance(target) <= wRange then
  97.         if RREADY or empowered then
  98.             CastSpell(_R)
  99.             CastSpell(_W, target)
  100.         else
  101.             CastSpell(_W, target)
  102.         end
  103.     end
  104.     if QREADY then castQ(target, false) end
  105.     if not KarmaConfig.supportMode and GetDistance(target) >= 600 and myHero.mana >= 200 then
  106.         CastSpell(_E, myHero)
  107.     end
  108. end
  109.  
  110. function ECombo(target)
  111.     if WREADY and GetDistance(target) <= wRange then
  112.         CastSpell(_W, target)
  113.     end
  114.     if EREADY and GetDistance(target) <= eRadius then
  115.         if RREADY or empowered then
  116.             CastSpell(_R)
  117.             CastSpell(_E, myHero)
  118.         end
  119.     end
  120.     if QREADY then castQ(target, false) end
  121. end
  122.  
  123. --[[    Base Functions  ]]--
  124. function Load()
  125.     --[[    Ranges  ]]--
  126.     qRange, wRange, eRange, eRadius = 950, 650, 800, 400
  127.     --[[    Ready   ]]--
  128.     ignite = nil
  129.     QREADY, WREADY, EREADY, RREADY = false, false, false, false
  130.     BRKSlot, DFGSlot, HXGSlot, BWCSlot, TMTSlot, RAHSlot, RNDSlot, YGBSlot = nil, nil, nil,
  131. nil, nil, nil, nil, nil
  132.     BRKREADY, DFGREADY, HXGREADY, BWCREADY, TMTREADY, RAHREADY, RNDREADY, YGBREADY, IREADY =
  133. false, false, false, false, false, false, false, false, false
  134. end
  135.  
  136. function Menu()
  137.     KarmaConfig = scriptConfig("Karma Helper", "KarmaHelper")
  138.     KarmaConfig:addParam("Combo", "Empowered Combo", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  139.     KarmaConfig:addParam("Harass", "Q Harass", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("T"))
  140.     KarmaConfig:addParam("empLogic", "Use Empowered Q Logic", SCRIPT_PARAM_ONOFF, false)
  141.     KarmaConfig:addParam("supportMode", "Support Mode", SCRIPT_PARAM_ONOFF, false)
  142.     KarmaConfig:addParam("autoignite", "Auto Ignite", SCRIPT_PARAM_ONOFF, true)
  143.     KarmaConfig:addParam("circlesSelf", "Draw Circles - Self", SCRIPT_PARAM_ONOFF, true)
  144.     KarmaConfig:addParam("circlesEnemies", "Draw Circles - Enemies", SCRIPT_PARAM_ONOFF, true)
  145.    
  146.     ts = TargetSelector(TARGET_LOW_HP, qRange, DAMAGE_MAGIC)
  147.     ts.name = "Karma"
  148.     KarmaConfig:addTS(ts)
  149.    
  150.     PrintChat("<font color='#CCCCCC'> >> Karma Combo loaded! <<</font>")
  151.    
  152.     if myHero:GetSpellData(SUMMONER_1).name:find("SummonerDot") then ignite = SUMMONER_1
  153.         elseif myHero:GetSpellData(SUMMONER_2).name:find("SummonerDot") then ignite =
  154. SUMMONER_2
  155.     end
  156. end
  157.  
  158. function castQ(target, castR)
  159.     local qPred, info = Prodiction.GetPrediction(target, 1050, 1700, 0.25, 90)
  160.     if qPred and GetDistance(qPred) <= qRange and info.hitchance > 1 and not info.mCollision() then
  161.         if VIP_USER then
  162.             if castR and (RREADY or empowered) then
  163.                 if KarmaConfig.empLogic and (info.hitchance > 2 or target.health < getDmg("Q", target, myHero, 2)) then
  164.                     CastSpell(_R)
  165.                     CastSpell(_Q, qPred.x, qPred.z)
  166.                 elseif not KarmaConfig.empLogic then
  167.                     CastSpell(_R)
  168.                     CastSpell(_Q, qPred.x, qPred.z)
  169.                 else
  170.                     CastSpell(_Q, qPred.x, qPred.z)
  171.                 end
  172.             else
  173.                 CastSpell(_Q, qPred.x, qPred.z)
  174.             end
  175.         end
  176.     end
  177. end
  178.  
  179. function ReadyCheck()
  180.     if not tm:isReady() then return end
  181.     ts:update()
  182.    
  183.     BRKSlot, DFGSlot, HXGSlot, BWCSlot, TMTSlot, RAHSlot, RNDSlot, YGBSlot =
  184. GetInventorySlotItem(3153), GetInventorySlotItem(3128), GetInventorySlotItem(3146),
  185. GetInventorySlotItem(3144), GetInventorySlotItem(3077), GetInventorySlotItem(3074),  
  186. GetInventorySlotItem(3143), GetInventorySlotItem(3142)
  187.    
  188.     QREADY = (myHero:CanUseSpell(_Q) == READY)
  189.     WREADY = (myHero:CanUseSpell(_W) == READY)
  190.     EREADY = (myHero:CanUseSpell(_E) == READY)
  191.     RREADY = (myHero:CanUseSpell(_R) == READY)
  192.    
  193.     DFGREADY = (DFGSlot ~= nil and myHero:CanUseSpell(DFGSlot) == READY)
  194.     HXGREADY = (HXGSlot ~= nil and myHero:CanUseSpell(HXGSlot) == READY)
  195.     BWCREADY = (BWCSlot ~= nil and myHero:CanUseSpell(BWCSlot) == READY)
  196.     BRKREADY = (BRKSlot ~= nil and myHero:CanUseSpell(BRKSlot) == READY)
  197.     TMTREADY = (TMTSlot ~= nil and myHero:CanUseSpell(TMTSlot) == READY)
  198.     RAHREADY = (RAHSlot ~= nil and myHero:CanUseSpell(RAHSlot) == READY)
  199.     RNDREADY = (RNDSlot ~= nil and myHero:CanUseSpell(RNDSlot) == READY)
  200.     YGBREADY = (YGBSlot ~= nil and myHero:CanUseSpell(YGBSlot) == READY)
  201.     IREADY = (ignite ~= nil and myHero:CanUseSpell(ignite) == READY)
  202. end
  203.  
  204. function UseItems(target)
  205.     if GetDistance(target) < 550 then
  206.         if DFGREADY then CastSpell(DFGSlot, target) end
  207.         if HXGREADY then CastSpell(HXGSlot, target) end
  208.         if BWCREADY then CastSpell(BWCSlot, target) end
  209.         if BRKREADY then CastSpell(BRKSlot, target) end
  210.         if YGBREADY then CastSpell(YGBSlot, target) end
  211.         if TMTREADY and GetDistance(target) < 275 then CastSpell(TMTSlot) end
  212.         if RAHREADY and GetDistance(target) < 275 then CastSpell(RAHSlot) end
  213.         if RNDREADY and GetDistance(target) < 275 then CastSpell(RNDSlot) end
  214.     end
  215. end
  216.  
  217. function AutoIgnite()
  218.     local ignitedmg = 0    
  219.     for i = 1, heroManager.iCount, 1 do
  220.         local enemyhero = heroManager:getHero(i)
  221.         if ValidTarget(enemyhero, 600) then
  222.             ignitedmg = 50 + 20 * myHero.level
  223.             if enemyhero.health <= ignitedmg then
  224.                 CastSpell(ignite, enemyhero)
  225.             end
  226.         end
  227.     end
  228. end
  229.  
  230. function OnGainBuff(unit, buff)
  231.     if unit.isMe and buff.name == "KarmaMantra" then empowered = true end
  232. end
  233.  
  234. function OnLoseBuff(unit, buff)
  235.     if unit.isMe and buff.name == "KarmaMantra" then empowered = false end
  236. end
Advertisement
Add Comment
Please, Sign In to add comment