Advertisement
Guest User

Jayce-Helper-bring-the-law-xkjtx.lua

a guest
Apr 2nd, 2013
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.54 KB | None | 0 0
  1. if myHero.charName ~= "Jayce" then return end
  2. PrintChat(" >> Jayce Helper loaded!")
  3. --[[
  4.     » Jayce Helper [BoL Studio]
  5.         by Manciuszz.
  6.         modded/edited/made to work by xkjtx
  7.     Press and hold "hot-key" key to do:
  8.      » Auto Q > E combo(Mercury Cannon stance)
  9.      » Auto Q (Hammer stance)
  10.      » Will attempt to auto kill steal or "Last Hit" enemy champion with E
  11.  
  12.          ---- Run key (when hot-key is pressed R(if not in CONNON stance)-E-R in Hammer Stance
  13.             --Added by xkjtx
  14.  
  15. ]]
  16.  
  17. --SETTINGS
  18. local showRanges = true --Displays Q range and Q > E max range when in Mercury Cannon stance(will show range only of the available spells(not on cooldown))
  19. local showGateRange = true --E(Acceleration Gate) range.
  20. local focusedTarget = true
  21.  
  22. local AutoKnockBack = true -- Automatically knock backs incoming threats, for example: Malphite Ultimate charge, Xin Zhao E, Shen E(taunt).
  23. local EnableAutoE = true
  24. local QEHowFarAway = 100 --Cast Acceleration gate this far away when firing QE at your target. From 0 to 500 I prefer 200 cause it drops it near me, getting the buff with the improved blast almost instantly.
  25. local EDistance = 100 --Cast Acceleration gate this far away when firing QE at your cursor (great for clearing mobs). From 0 to 500 I prefer 200 cause it drops it near me, getting the buff with the improved blast almost instantly.
  26.  
  27. local RefreshRate = 150 --function OnTick() refresh rate(How fast will it work) | Good Value is from 50 to 500
  28.  
  29. local hotkey = 32 -- GetKey("S")
  30. local BurstKey = GetKey("S")
  31.  
  32. local RunKey = string.byte("X")
  33.  
  34. local targetCircle = 100 --Purple Circle of an enemy that is in Target Selectors scan range.
  35.  
  36. --Globals
  37. local Delay = 0
  38. local scriptActive = false
  39. local BurstActive = false
  40.  
  41. local RunActive = false
  42.  
  43. --local delayFinished = GetTickCount()
  44. --local lastAA = GetTickCount()
  45. --local baseAS = 1/0.658
  46. --local attackSpeed = myHero.attackSpeed / baseAS
  47.  
  48. -- Target Prediction
  49. local range = 1575
  50.  
  51. local castRrange = 650
  52.  
  53. local wrange = 600
  54. local proj_speed = 2.1
  55. local delay = 230
  56. local smoothness = 50
  57.  
  58. --[[ Code ]]
  59.  
  60. local ts = TargetSelector(TARGET_LOW_HP, range, true)
  61. local tp = TargetPrediction(range, proj_speed, delay, smoothness)
  62. --PrintChat(tostring(myHero:GetSpellData(_R).name))
  63.  
  64. function OnLoad()
  65.     velocityTimer = {}
  66.     oldPos = {}
  67.     Velocity = {}
  68.     oldTick = {}
  69.  
  70.     velocity = 0
  71.     velocityTimeOut = 5
  72.  
  73.     erange = 300
  74.  
  75.     conversionFactor = 975 --estimate. Converts coordinate velocity to game movement speed.
  76.     msVarianceTrigger = 100 --will knock back when velocity > hero.ms + variance
  77.     minMovementSpeed = 300 --minimum hero.ms to condemn. Sometimes hero.ms bugs and shows lesser values.
  78.  
  79.     for i = 1, heroManager.iCount, 1 do
  80.         local hero = heroManager:getHero(i)
  81.         if hero.team == TEAM_ENEMY then
  82.             oldPos[hero.name] = {}
  83.             oldTick[hero.name] = {}
  84.             Velocity[hero.name] = 0
  85.             velocityTimer[hero.name] = 0
  86.         end
  87.     end
  88. end
  89.  
  90. function findmyHeroVelocity(target, oldPos, oldTick)
  91.     if oldPos.x and oldPos.z and target.x and target.z then
  92.         dis = math.sqrt((oldPos.x - target.x) ^ 2 + (oldPos.z - target.z) ^ 2)
  93.         Velocity[target.name] = (dis / (GetTickCount() - oldTick)) * conversionFactor
  94.     end
  95. end
  96.  
  97. function OnTick()
  98.     if myHero.dead then return end --If dead. Do nothing.
  99.  
  100.     if Delay > GetTickCount() then return end
  101.     Delay = GetTickCount() + RefreshRate
  102.  
  103.     ts:update()
  104.  
  105.     if scriptActive and ts.target ~= nil and GetDistance(ts.target) <= range and myHero:GetSpellData(_R).name == "jaycestancegth" then
  106.         local predictedPos = tp:GetPrediction(ts.target)
  107.                 if (myHero:CanUseSpell(_Q) == READY and myHero:CanUseSpell(_E) == READY) then
  108.                         if predictedPos ~= nil then
  109.                                 EnemyPos = Vector(predictedPos.x, predictedPos.y, predictedPos.z)
  110.                                 HeroPos = Vector(myHero.x, myHero.y, myHero.z)
  111.                                 GatePos = HeroPos + ( HeroPos - EnemyPos )*(-QEHowFarAway/GetDistance(predictedPos))
  112.                                 if (myHero:CanUseSpell(_Q) == READY and myHero:CanUseSpell(_E) == READY) then
  113.                                         CastSpell(_Q, predictedPos.x, predictedPos.z) -- _Q has a ~0.5s channel time and casting E doesn't cancel it, making pretty comfty combo
  114.                                         CastSpell(_E, GatePos.x, GatePos.z) -- Drops it near yourself.This way YOU GET THE SPEED BOOST almost IMMEDIATELY + You get almost instant powered Q.
  115.                                        
  116.                                 end
  117.  
  118.                         end
  119.                        
  120.                 end
  121.                
  122.                 if ts.target ~= nil and myHero:CanUseSpell(_W) == READY and GetDistance(ts.target) <= wrange then
  123.  
  124.                     CastSpell(_W)
  125.  
  126.                 end
  127.  
  128.                 if ts.target ~= nil and GetDistance(ts.target) <= range then
  129.  
  130.                     myHero:Attack(ts.target)
  131.  
  132.                 end
  133.  
  134.                 if ts.target ~= nil and myHero:CanUseSpell(_R) == READY and myHero:CanUseSpell(_Q) == COOLDOWN and myHero:CanUseSpell(_W) == COOLDOWN and myHero:CanUseSpell(_E) == COOLDOWN and GetDistance(ts.target) >= castRrange then
  135.  
  136.                     CastSpell(_R)
  137.                 end
  138.     end
  139.  
  140.     if BurstActive then
  141.         if myHero:GetSpellData(_R).name == "jaycestancegth" then
  142.             EnemyPos = Vector(mousePos.x, mousePos.y, mousePos.z)
  143.             HeroPos = Vector(myHero.x, myHero.y, myHero.z)
  144.             GatePos = HeroPos + ( HeroPos - EnemyPos )*(-EDistance/GetDistance(mousePos))
  145.             if (myHero:CanUseSpell(_Q) == READY and myHero:CanUseSpell(_E) == READY) then
  146.                 CastSpell(_Q, mousePos.x,mousePos.z)
  147.                 CastSpell(_E, GatePos.x, GatePos.z)
  148.             end
  149.         end
  150.             if ts.target ~= nil and myHero:CanUseSpell(_W) == READY and GetDistance(ts.target) <= wrange then
  151.  
  152.                 CastSpell(_W)
  153.             end
  154.  
  155.             if ts.target ~= nil and GetDistance(ts.target) <= range then
  156.  
  157.                 myHero:Attack(ts.target)
  158.  
  159.             end
  160.     end
  161.  
  162. --    local function attack()
  163. --        ts:update()
  164. --
  165. --        if myHero:GetSpellData(_R).name == "JayceStanceHtG" then
  166. --            lrange = 250
  167. --        elseif myHero:GetSpellData(_R).name == "jaycestancegth" then
  168. --            lrange = 600
  169. --        end
  170. --
  171. --        if ts.target ~= nil and GetDistance(myHero,ts.target) <= lrange and GetTickCount() - lastAA > 1000/attackSpeed then
  172. --            myHero:Attack(ts.target)
  173. --            delayFinished = nil
  174. --            lastAA = GetTickCount()
  175. --        elseif delayFinished ~= nil then
  176. --            if GetTickCount() - delayFinished > 100 then
  177. --                myHero:MoveTo(mousePos.x, mousePos.z)
  178. --            end
  179. --        end
  180. --    end
  181.  
  182.     if myHero:GetSpellData(_R).name == "JayceStanceHtG" and scriptActive then -- When in Hammer form go dunk that enemy and attack-kite him.
  183.         if ValidTarget(ts.target, 600) then
  184.             if (myHero:CanUseSpell(_Q) == READY and myHero:CanUseSpell(_W) == READY) then
  185.                 CastSpell(_Q, ts.target)
  186.                 CastSpell(_W)
  187.             end
  188.  
  189.             if ts.target ~= nil and GetDistance(ts.target) <= range then
  190.                 myHero:Attack(ts.target)
  191.             end
  192.         end
  193.     end
  194.  
  195.     if EnableAutoE then --Auto Last Hit
  196.         if myHero:GetSpellData(_R).name == "JayceStanceHtG" then
  197.             if ValidTarget(ts.target) then
  198.                 local jayceEhammerdmg = myHero.addDamage +((3 * myHero:GetSpellData(_E).level + 5)*ts.target.maxHealth/100)
  199.                 if ts.target.health < jayceEhammerdmg and ValidTarget(ts.target, 350) then
  200.                     if myHero:CanUseSpell(_E) == READY and ValidTarget(ts.target, 350) then
  201.                         CastSpell(_E, ts.target)
  202.                     end
  203.                 end
  204.             end
  205.         end
  206.     end
  207.  
  208.     if RunActive then
  209.  
  210.         if myHero:GetSpellData(_R).name == "jaycestancegth" then
  211.  
  212.             EnemyPos = Vector(mousePos.x, mousePos.y, mousePos.z)
  213.  
  214.             HeroPos = Vector(myHero.x, myHero.y, myHero.z)
  215.  
  216.             GatePos = HeroPos + ( HeroPos - EnemyPos )*(-EDistance/GetDistance(mousePos))
  217.  
  218.             if myHero:CanUseSpell(_E) == READY then
  219.  
  220.                 CastSpell(_E, GatePos.x, GatePos.z)
  221.  
  222.             end
  223.  
  224.            
  225.  
  226.             CastSpell(_R)
  227.  
  228.         end
  229.  
  230.        
  231.  
  232.         if myHero:GetSpellData(_R).name == "JayceStanceHtG" then
  233.  
  234.            
  235.  
  236.             CastSpell(_R)
  237.  
  238.            
  239.  
  240.         end
  241.  
  242.     end
  243.  
  244. --    if delayFinished == nil and lastAA - 300 > GetTickCount() then
  245. --        delayFinished = GetTickCount()
  246. --    end
  247.  
  248.     if AutoKnockBack then
  249.         for i = 1, heroManager.iCount, 1 do
  250.             local hero = heroManager:getHero(i)
  251.  
  252.             if ValidTarget(hero, nil, true) then
  253.                 if velocityTimer[hero.name] <= GetTickCount() and hero and hero.x and hero.z then
  254.                     velocityTimer[hero.name] = GetTickCount() + velocityTimeOut
  255.                     findmyHeroVelocity(hero, oldPos[hero.name], oldTick[hero.name])
  256.                     oldPos[hero.name].x = hero.x
  257.                     oldPos[hero.name].z = hero.z
  258.                     oldTick[hero.name] = GetTickCount()
  259.                 end
  260.                 if Velocity[hero.name] > (hero.ms + msVarianceTrigger) and hero.ms > minMovementSpeed and GetDistance(myHero, hero) < erange then
  261.                     if myHero:GetSpellData(_R).name == "jaycestancegth" and myHero:GetSpellData(_E).level > 0 then
  262.                         CastSpell(_R)
  263.                         CastSpell(_E,hero)
  264.                     elseif myHero:GetSpellData(_R).name == "JayceStanceHtG" and myHero:CanUseSpell(_E) == READY then
  265.                         CastSpell(_E,hero)
  266.                         PrintChat("" .. Velocity[hero.name])
  267.                     end
  268.                 end
  269.             end
  270.         end
  271.     end
  272. end
  273.  
  274. function OnDraw()
  275.     if myHero.dead then return end
  276.  
  277.     if focusedTarget then
  278.         if ts.target ~= nil then
  279.             DrawCircle(ts.target.x, ts.target.y, ts.target.z, targetCircle, 0x990099)
  280.         end
  281.     end
  282.  
  283.     if showRanges then
  284.         if myHero:GetSpellData(_R).name == "jaycestancegth" then --if in Mercury Cannon stance
  285.             if myHero:CanUseSpell(_Q) == READY and myHero:CanUseSpell(_E) == READY then
  286.                 DrawCircle(myHero.x, myHero.y, myHero.z, range, 0xFF00FF00) --40% increased range cause of Acceleration Gate.
  287.             elseif myHero:CanUseSpell(_Q) == READY and myHero:CanUseSpell(_E) ~= READY then
  288.                 DrawCircle(myHero.x, myHero.y, myHero.z, 1050, 0xFF00FF00)
  289.             end
  290.             if showGateRange then
  291.                 DrawCircle(myHero.x, myHero.y, myHero.z, 675, 0xFF00FF00)
  292.             end
  293.         elseif myHero:GetSpellData(_R).name == "JayceStanceHtG" then
  294.             if myHero:CanUseSpell(_Q) == READY and myHero:CanUseSpell(_E) ~= READY then
  295.                 DrawCircle(myHero.x, myHero.y, myHero.z, 600, 0xFF00FF00)
  296.             elseif myHero:CanUseSpell(_Q) == READY then
  297.                 DrawCircle(myHero.x, myHero.y, myHero.z, 600, 0xFF00FF00)
  298.             elseif myHero:CanUseSpell(_E) == READY then
  299.                 DrawCircle(myHero.x, myHero.y, myHero.z, 305, 0xFF00FF00)
  300.             end
  301.         end
  302.     end
  303. end
  304.  
  305. function OnWndMsg(msg,key)
  306.     if key == hotkey then
  307.         if msg == KEY_DOWN then
  308.             --if ts.target == nil then myHero:MoveTo(mousePos.x, mousePos.z) end
  309.             scriptActive = true
  310.         else
  311.             scriptActive = false
  312.         end
  313.     end
  314.  
  315.     if key == BurstKey then
  316.         if msg == KEY_DOWN then
  317.             if ts.target == nil then myHero:MoveTo(mousePos.x, mousePos.z) end
  318.             BurstActive = true
  319.         else
  320.             BurstActive = false
  321.         end
  322.     end
  323.  
  324.     if key == RunKey then
  325.  
  326.         if msg == KEY_DOWN then
  327.  
  328.             if ts.target == nil then myHero:MoveTo(mousePos.x, mousePos.z) end
  329.  
  330.             RunActive = true
  331.  
  332.         else
  333.  
  334.             RunActive = false
  335.  
  336.         end
  337.  
  338.     end
  339.  
  340. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement