Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.80 KB | None | 0 0
  1.    
  2. if myHero.charName ~= "Shaco" then return end
  3.  
  4. local version = 1.1
  5. local AUTOUPDATE = true
  6. local SCRIPT_NAME = "Shaco"
  7.  
  8. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  9. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  10. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  11.  
  12. local SOURCELIB_URL = "https://raw.github.com/TheRealSource/public/master/common/SourceLib.lua"
  13. local SOURCELIB_PATH = LIB_PATH.."SourceLib.lua"
  14.  
  15. if FileExist(SOURCELIB_PATH) then
  16.     require("SourceLib")
  17. else
  18.     DOWNLOADING_SOURCELIB = true
  19.     DownloadFile(SOURCELIB_URL, SOURCELIB_PATH, function() print("Required libraries downloaded successfully, please reload") end)
  20. end
  21.  
  22. if DOWNLOADING_SOURCELIB then print("Downloading required libraries, please wait...") return end
  23.  
  24. if AUTOUPDATE then
  25.      SourceUpdater(SCRIPT_NAME, version, "raw.github.com", "/Hellsing/BoL/master/"..SCRIPT_NAME..".lua", SCRIPT_PATH .. GetCurrentEnv().FILE_NAME, "/Hellsing/BoL/master/version/"..SCRIPT_NAME..".version"):CheckUpdate()
  26. end
  27.  
  28. local RequireI = Require("SourceLib")
  29. RequireI:Add("vPrediction", "https://raw.github.com/Hellsing/BoL/master/common/VPrediction.lua")
  30. RequireI:Add("SOW", "https://raw.github.com/Hellsing/BoL/master/common/SOW.lua")
  31. RequireI:Check()
  32.  
  33. if RequireI.downloadNeeded == true then return end
  34.  
  35. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  36. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  37. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  38.  
  39. local LastAttack = 0
  40. local Winduptime = 0
  41. local AnimationTime = 0
  42.  
  43. local CLastAttack = 0
  44. local CWinduptime = 0
  45. local CAnimationTime = 0
  46.  
  47. local clone
  48.  
  49. local Qrange = 400
  50. local Wrange = 425
  51. local Erange = 625
  52. local Rrange = 2400 --aprox
  53.  
  54. local wp
  55. local TargetsWaypoints = {}
  56.  
  57. local DeceiveTime = 0
  58. local isgrass = false
  59.  
  60. local HTarget  
  61. --23
  62.  
  63. local _HYDRA
  64. local _DFG
  65. local _IGNITE
  66. local _SHEEN
  67. local _LICH
  68. local _TF
  69.  
  70. local DamageToHeros = {}
  71. local lastrefresh = 0
  72.  
  73. local _RED --TODO
  74.  
  75. local Htime = 0
  76. function OnLoad()
  77.     Menu = scriptConfig("Shaco", "Shaco")
  78.    
  79.     Menu:addSubMenu("Orbwalker", "Orbwalker")
  80.         Menu.Orbwalker:addParam("Range", "Orwalk Range",  SCRIPT_PARAM_SLICE, 300, 0, 1000)
  81.         Menu.Orbwalker:addParam("DrawRange", "Draw Orbwalk range", SCRIPT_PARAM_ONOFF, true)
  82.         Menu.Orbwalker:addParam("Orbwalk", "Orbwalk!", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  83.    
  84.     Menu:addSubMenu("Jungle Farm", "JungleFarm")
  85.         Menu.JungleFarm:addParam("Orbwalk", "Orwalk the mobs",  SCRIPT_PARAM_ONOFF, true)
  86.         Menu.JungleFarm:addParam("Spells", "Use spells", SCRIPT_PARAM_ONOFF, true)
  87.         Menu.JungleFarm:addParam("Farm", "Farm!", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("V"))
  88.    
  89.     Menu:addSubMenu("Q (Deceive)", "Q")
  90.         Menu.Q:addParam("DrawTime", "Draw time", SCRIPT_PARAM_ONOFF, true)
  91.         Menu.Q:addParam("DrawRange", "Draw Q range", SCRIPT_PARAM_ONOFF, false)
  92.         Menu.Q:addParam("SR", "Use Q while recalling (stealth recall)", SCRIPT_PARAM_ONOFF, true)
  93.         Menu.Q:addParam("Landing", "Draw landing position", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("Q"))
  94.        
  95.     Menu:addSubMenu("W (Jack In The Box)", "W")
  96.         Menu.W:addParam("auto", "Auto W bushes if enemy chasing", SCRIPT_PARAM_ONOFF, true)
  97.         Menu.W:addParam("auto2", "Auto W if the enemy is stunned (Can cause fps drops!!)", SCRIPT_PARAM_ONOFF, false)
  98.         Menu.W:addParam("auto3", "Auto W in blitzcrank hook", SCRIPT_PARAM_ONOFF, false)
  99.         Menu.W:addParam("DrawRange", "Draw W range", SCRIPT_PARAM_ONOFF, false)
  100.    
  101.     Menu:addSubMenu("E (Two-Shiv Poison)", "E")
  102.         Menu.E:addParam("DrawRange", "Draw E range", SCRIPT_PARAM_ONOFF, false)
  103.         Menu.E:addParam("Packets", "Cast E using packets", SCRIPT_PARAM_ONOFF, true)
  104.         Menu.E:addParam("B", "Cast E from the back", SCRIPT_PARAM_ONOFF, false)
  105.         Menu.E:addParam("CastE2", "Cast E!", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("C"))
  106.         Menu.E:addParam("CastE", "Cast E!", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  107.    
  108.     Menu:addSubMenu("R (Hallucinate)", "R")
  109.         Menu.R:addSubMenu("Auto-movement", "movement")
  110.             Menu.R.movement:addParam("S", "Let the script decide the best option", SCRIPT_PARAM_ONOFF, true)
  111.             Menu.R.movement:addParam("Mouse", "Move to mouse", SCRIPT_PARAM_ONOFF, false)
  112.             Menu.R.movement:addParam("Random", "Run in random directions", SCRIPT_PARAM_ONOFF, false)
  113.             Menu.R.movement:addParam("Escape", "Run trying to escape from enemy team", SCRIPT_PARAM_ONOFF, false)
  114.             Menu.R.movement:addParam("Kamikaze", "Orbwalk the best target in a wide range", SCRIPT_PARAM_ONOFF, false)
  115.             Menu.R.movement:addParam("AlwaysOrbwalk", "Orbwalk the best target", SCRIPT_PARAM_ONOFF, false)
  116.             Menu.R.movement:addParam("CTarget", "Attack shaco's target", SCRIPT_PARAM_ONOFF, false)
  117.            
  118.     Menu.R:addParam("DrawRange", "Draw R range", SCRIPT_PARAM_ONOFF, false)
  119.     Menu.R:addParam("Orbwalk", "Force orbwalking", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  120.    
  121.     Menu:addSubMenu("Items", "Items")
  122.     Menu.Items:addParam("Hydra", "Use Hydra", SCRIPT_PARAM_ONOFF, true)
  123.     Menu.Items:addParam("DFG", "Use DFG", SCRIPT_PARAM_ONOFF, true)
  124.    
  125.     Menu:addSubMenu("Damage calculation", "DamageCalc")
  126.         Menu.DamageCalc:addSubMenu("Combo", "Combo")
  127.             Menu.DamageCalc.Combo:addParam("Q", "Q",  SCRIPT_PARAM_SLICE, 1, 0, 1)
  128.             Menu.DamageCalc.Combo:addParam("W", "W",  SCRIPT_PARAM_SLICE, 1, 0, 10)
  129.             Menu.DamageCalc.Combo:addParam("E", "E",  SCRIPT_PARAM_SLICE, 1, 0, 3)
  130.             Menu.DamageCalc.Combo:addParam("R", "R",  SCRIPT_PARAM_SLICE, 1, 0, 1)
  131.             Menu.DamageCalc.Combo:addParam("AA", "AA",  SCRIPT_PARAM_SLICE, 1, 0, 5)
  132.             Menu.DamageCalc.Combo:addParam("CAA", "CAA",  SCRIPT_PARAM_SLICE, 1, 0, 5)
  133.             Menu.DamageCalc.Combo:addParam("IGNITE", "IGNITE",  SCRIPT_PARAM_SLICE, 1, 0, 1)
  134.    
  135.     Menu.DamageCalc:addParam("Draw", "Draw health after combo in enemies", SCRIPT_PARAM_ONOFF, true)
  136.    
  137.     Menu:addParam("Version", "Version", SCRIPT_PARAM_INFO, version)
  138.    
  139.     if myHero:GetSpellData(SUMMONER_1).name:find("SummonerDot") then
  140.         _IGNITE = SUMMONER_1
  141.     elseif myHero:GetSpellData(SUMMONER_2).name:find("SummonerDot") then
  142.         _IGNITE = SUMMONER_2
  143.     else
  144.         _IGNITE = nil
  145.     end
  146.    
  147.     JungleMinions = minionManager(MINION_JUNGLE, Erange, myHero, MINION_SORT_MAXHEALTH_DEC)
  148.    
  149.     VP = VPrediction()
  150.     wp = WayPointManager()
  151. end
  152.  
  153.  
  154. function GetComboDamage(target)
  155.     local result = 0
  156.     local m = 1
  157.     local p = Facing(target) and 1 or 1.2
  158.     local Qcrit = {1, 1.4, 1.6, 1.8, 2, 2.2}
  159.    
  160.     local Wdamage = {35, 50, 65, 80, 95}
  161.     local Wscaling = 0.2
  162.    
  163.     local Edamage = {35, 50, 65, 80, 95}
  164.     local Escaling = 1
  165.    
  166.     local Rdamage= {300, 450, 600}
  167.     local Rscaling = 1
  168.    
  169.    
  170.     local Qlevel = myHero:GetSpellData(_Q).level
  171.     local Wlevel = myHero:GetSpellData(_W).level
  172.     local Elevel = myHero:GetSpellData(_E).level
  173.     local Rlevel = myHero:GetSpellData(_R).level
  174.    
  175.    
  176.     if _HYDRA and myHero:CanUseSpell(_HYDRA) == READY then
  177.         result = result + myHero:CalcDamage(target, myHero.totalDamage)
  178.     end
  179.    
  180.     if _DFG and myHero:CanUseSpell(_DFG) == READY then
  181.         result = result + myHero:CalcMagicDamage(target, target.maxHealth *0.15)
  182.         m = 1.2
  183.     end
  184.    
  185.     if Menu.DamageCalc.Combo.IGNITE and _IGNITE and myHero:CanUseSpell(_IGNITE) == READY then
  186.         result = result + 50 + 20 * myHero.level
  187.     end
  188.    
  189.     if Menu.DamageCalc.Combo.W > 0 and Wlevel > 0 then
  190.         for i =1, Menu.DamageCalc.Combo.W, 1 do
  191.             result = result + m * (myHero:CalcMagicDamage(target, Wdamage[Wlevel]) + myHero.ap * Wscaling)
  192.         end
  193.     end
  194.    
  195.     if Menu.DamageCalc.Combo.E > 0 and Elevel > 0 then
  196.         for i =1, Menu.DamageCalc.Combo.E, 1 do
  197.             result = result + p * m * (myHero:CalcMagicDamage(target, Edamage[Elevel]) + myHero.ap * Escaling + myHero.damage * Escaling)
  198.         end
  199.     end
  200.    
  201.     if Menu.DamageCalc.Combo.AA > 0 then
  202.         local sheendamage = _SHEEN and myHero.totalDamage - myHero.damage or 0
  203.         local lichdamage = _LICH and myHero.ap or 0
  204.         local tfdamage = _TF and 2 * (myHero.totalDamage - myHero.damage) or 0
  205.        
  206.         result = result + p * (myHero:CalcDamage(target, Qcrit[Qlevel+1] * myHero.totalDamage + sheendamage + tfdamage)) + p * m * (myHero:CalcMagicDamage(target, lichdamage))
  207.         for i =2, Menu.DamageCalc.Combo.AA, 1 do
  208.             result = result + p * (myHero:CalcDamage(target,  myHero.totalDamage))
  209.         end
  210.     end
  211.    
  212.     if Menu.DamageCalc.Combo.CAA > 0 and (clone or myHero:CanUseSpell(_R) == READY) then
  213.         for i =1, Menu.DamageCalc.Combo.CAA, 1 do
  214.             result = result +  (myHero:CalcDamage(target,  myHero.totalDamage * 0.75))
  215.         end
  216.     end
  217.    
  218.     if Menu.DamageCalc.Combo.R == 1 and (clone or myHero:CanUseSpell(_R) == READY) and Rlevel > 0 then
  219.         result = result + p * m * myHero:CalcMagicDamage(target, Rdamage[Rlevel])
  220.     end
  221.     return result
  222. end
  223.  
  224. function TrackWaypoints()
  225.     for i, enemy in ipairs(GetEnemyHeroes()) do
  226.         if ValidTarget(enemy) then
  227.             local Waypoints = wp:GetWayPoints(enemy)
  228.             if #Waypoints > 1 and GetDistance(Waypoints[1], Waypoints[2]) > 50 then
  229.                 TargetsWaypoints[enemy.charName] = Waypoints
  230.             end
  231.         end
  232.     end
  233.    
  234.     for i, mob in ipairs(JungleMinions.objects) do
  235.         if ValidTarget(mob) then
  236.             local Waypoints = wp:GetWayPoints(mob)
  237.             if #Waypoints > 1 and GetDistance(Waypoints[1], Waypoints[2]) > 50 then
  238.                 TargetsWaypoints[mob.networkID] = Waypoints
  239.             end
  240.         end
  241.     end
  242. end
  243.  
  244. function Facing(target)
  245.     local b = GetBack(target)
  246.    
  247.     if b.x == target.x and b.z == target.z then
  248.         return true
  249.     end
  250.    
  251.     --[[does not work if getdistance(target) < 30, too lazy to check the angle :)]]
  252.     if GetDistance(b) >= GetDistance(target) then
  253.         return true
  254.     else
  255.         return false
  256.     end
  257. end
  258.  
  259. function GetBack(target)
  260.     if target then
  261.         local CastPosition,  HitChance,  Position = VP:GetLineCastPosition(target, 0, 1, math.huge, myHero.ms, myHero)
  262.         if not TargetsWaypoints[target.networkID] then
  263.             return Vector(Position.x, 0, Position.z)
  264.         else
  265.             return Vector(Position.x, 0, Position.z) -  60 * Vector(TargetsWaypoints[target.networkID][2].x - Position.x, 0, TargetsWaypoints[target.networkID][2].y - Position.z):normalized()
  266.         end
  267.     end
  268. end
  269.  
  270. function GetTrueRange()
  271.     return 240
  272. end
  273.  
  274.  
  275. function OnSendPacket(p)
  276.      if p.header == Packet.headers.S_CAST then
  277.         p.pos = 1
  278.         local decodedPacket = Packet(p)
  279.         if decodedPacket:get('spellId') == RECALL and Menu.Q.SR and myHero:CanUseSpell(_Q) then
  280.             Packet('S_CAST', { spellId = _Q, toX = myHero.x, toY = myHero.z, fromX = myHero.x, fromY = myHero.z }):send()
  281.             Packet('S_CAST', { spellId = RECALL, toX = myHero.x, toY = myHero.z, fromX = myHero.x, fromY = myHero.z }):send()
  282.         end
  283.     end
  284. end
  285.  
  286. function OnTick()
  287.     _HYDRA = GetInventorySlotItem(3074) and GetInventorySlotItem(3074) or GetInventorySlotItem(3077)
  288.     _DFG    = GetInventorySlotItem(3074) and GetInventorySlotItem(3074) or nil
  289.     _SHEEN = GetInventorySlotItem(3057) and GetInventorySlotItem(3057) or nil
  290.     _LICH   = GetInventorySlotItem(3100) and GetInventorySlotItem(3100) or nil
  291.     _TF =  GetInventorySlotItem(3078) and GetInventorySlotItem(3078) or nil
  292.    
  293.     RefreshKillableTexts()
  294.     TrackWaypoints()
  295.     JungleMinions:update()
  296.     if Menu.JungleFarm.Farm then
  297.         if JungleMinions.objects[1] ~= nil then
  298.             local mob = JungleMinions.objects[1]
  299.            
  300.             if Menu.JungleFarm.Orbwalk then
  301.                 if os.clock() + GetLatency()/2000 > LastAttack + AnimationTime and GetDistance(mob) < GetTrueRange() then
  302.                         Packet('S_MOVE', {type = 3, targetNetworkId=mob.networkID}):send()
  303.                     elseif os.clock() + GetLatency()/2000 > LastAttack + Winduptime + 0.05 then
  304.                         local Point = GetBack(mob)
  305.                         if GetDistance(Point) > 30 then
  306.                             --myHero:MoveTo(Point.x, Point.z)
  307.                             Packet('S_MOVE', {type = 2, x = Point.x, y = Point.z}):send()
  308.                         end
  309.                 end
  310.             end
  311.            
  312.             if Menu.JungleFarm.Spells then
  313.                 if myHero:CanUseSpell(_E) == READY then
  314.                     CastSpell(_E, mob)
  315.                 end
  316.                 if myHero:CanUseSpell(_W) == READY then
  317.                     CastSpell(_W, mob.x, mob.z)
  318.                 end
  319.             end
  320.         end
  321.     end
  322.  
  323.     if Menu.Orbwalker.Orbwalk then
  324.         local target = GetBestTarget(myHero, Menu.Orbwalker.Range)
  325.        
  326.         if target and ValidTarget(target) then
  327.                 if os.clock() + GetLatency()/2000 > LastAttack + AnimationTime and GetDistance(target) < GetTrueRange() then
  328.                     Packet('S_MOVE', {type = 3, targetNetworkId=target.networkID}):send()
  329.                 elseif os.clock() + GetLatency()/2000 > LastAttack + Winduptime + 0.05 then
  330.                     local Point = GetBack(target)
  331.                     if GetDistance(Point) > 30 then
  332.                         Packet('S_MOVE', {type = 2, x = Point.x, y = Point.z}):send()
  333.                     end
  334.                 end
  335.         else
  336.             Packet('S_MOVE', {type = 2, x = mousePos.x, y = mousePos.z}):send()
  337.         end
  338.     end
  339.    
  340.     if Menu.W.auto and DeceiveTime == 0 and (false or CountEnemyHeroInRange(700, myHero)>0)  and (myHero:CanUseSpell(_W) == READY) then
  341.         if isgrass == false and IsWallOfGrass(D3DXVECTOR3(myHero.x, myHero.y, myHero.z)) then
  342.             CastSpell(_W, myHero.x, myHero.z)  
  343.         end
  344.         isgrass = IsWallOfGrass(D3DXVECTOR3(myHero.x, myHero.y, myHero.z))
  345.     end
  346.    
  347.     if Menu.W.auto2 and DeceiveTime == 0 and (myHero:CanUseSpell(_W) == READY) then
  348.         for i, enemy in ipairs(GetEnemyHeroes()) do
  349.             if ValidTarget(enemy) then
  350.                 local CastPosition,  HitChance,  Position = VP:GetCircularCastPosition(enemy, 0.5, 1, Wrange)
  351.                 if GetDistance(CastPosition) < Wrange and HitChance == 4 then--[[enemy immobile]]
  352.                     CastSpell(_W, CastPosition.x, CastPosition.z)
  353.                 end
  354.             end
  355.         end
  356.     end
  357.    
  358.     if Menu.E.CastE or Menu.E.CastE then
  359.         local target = GetBestTarget(myHero, Erange)
  360.         if target and ValidTarget(target) and (not Facing(target) or not Menu.E.B) then
  361.        
  362.             if Menu.Items.DFG and _DFG and myHero:CanUseSpell(_DFG) == READY then
  363.                 CastSpell(_DFG, target)
  364.             end
  365.            
  366.             if Menu.E.Packets then
  367.                 Packet("S_CAST", {spellId = _E, targetNetworkId = target.networkID}):send()
  368.             else
  369.                 CastSpell(_E, target)
  370.             end
  371.         end
  372.     end
  373.    
  374.     if myHero:CanUseSpell(_R) == COOLDOWN or myHero:GetSpellData(_R).name:lower():find("full") then
  375.         clone = nil
  376.     end
  377.        
  378.     if clone then
  379.         local ctarget = GetBestTarget(clone, Menu.Orbwalker.Range)
  380.        
  381.         if Menu.R.movement.S then
  382.             Menu.R.movement['AlwaysOrbwalk'] = false
  383.             Menu.R.movement['Mouse'] = false
  384.             Menu.R.movement['Random'] = false
  385.             Menu.R.movement['Escape'] = false
  386.             Menu.R.movement['Kamikaze'] = false
  387.             Menu.R.movement["CTarget"] = false
  388.            
  389.             if ValidTarget(HTarget) and (os.clock() - Htime < 5) then
  390.                 ctarget = HTarget
  391.                 Menu.R.movement["CTarget"] = true
  392.             elseif ctarget and ctarget.health < ctarget.maxHealth * 0.25 then
  393.                 Menu.R.movement['AlwaysOrbwalk'] = true
  394.             elseif myHero.health < myHero.maxHealth * 0.25 then
  395.                 Menu.R.movement['Escape']  = true
  396.             else
  397.                 Menu.R.movement['Kamikaze'] = true             
  398.             end
  399.         end
  400.        
  401.         if ValidTarget(HTarget) and Menu.R.movement.CTarget then
  402.             if os.clock() + GetLatency()/2000 > CLastAttack + CAnimationTime+0.05 then
  403.                 CastSpell(_R, HTarget.x, HTarget.z)
  404.             end
  405.         elseif Menu.R.Orbwalk or Menu.R.movement.Kamikaze or Menu.R.movement.AlwaysOrbwalk then
  406.             if Menu.R.movement.Kamikaze then
  407.                 ctarget = GetBestTarget(clone, 1000)
  408.                 if not ctarget then
  409.                     ctarget = GetBestTarget(clone, 2000)
  410.                 end
  411.             end
  412.             if ctarget and ValidTarget(ctarget) then
  413.                 if os.clock() + GetLatency()/2000 > CLastAttack + CAnimationTime and GetDistance(clone, ctarget) < GetTrueRange() then
  414.                     CastSpell(_R, ctarget.x, ctarget.z)
  415.                 elseif os.clock() + GetLatency()/2000 > CLastAttack + CWinduptime + 0.05 and GetDistance(clone, ctarget) < 30 then
  416.                     local Point = GetBack(ctarget)
  417.                     CastSpell(_R, ctarget.x, ctarget.z)
  418.                 elseif os.clock() + GetLatency()/2000 > CLastAttack + CWinduptime + 0.05 then
  419.                     local Point = Vector(GetBack(ctarget)) - 1000 * (Vector(clone) - Vector(GetBack(ctarget))):normalized()
  420.                     CastSpell(_R, Point.x, Point.z)
  421.                     --[[Casting CastSpell(_R, ctarget.x, ctarget.z) causes the clone to attack that unit instead of moving to that point]]
  422.                 end
  423.             else
  424.                     CastSpell(_R, mousePos.x, mousePos.z)
  425.             end
  426.            
  427.         elseif Menu.R.movement.Random then
  428.             local movepoint =  wp:GetWayPoints(myHero)
  429.             local line = Vector(clone) - Vector(myHero):perpendicular()
  430.             local Direction = (Vector(movepoint[#movepoint].x, 0, movepoint[#movepoint].z) - Vector(myHero)):mirrorOn(line):normalized()
  431.            
  432.             local movepos = Vector(clone) + 500 * Direction
  433.             CastSpell(_R, movepos.x, movepos.z)
  434.            
  435.         elseif Menu.R.movement.Mouse then
  436.             CastSpell(_R, mousePos.x, mousePos.z)
  437.            
  438.         elseif Menu.R.movement.Escape then
  439.             local Point = Vector(0, 0, 0)
  440.             local Count = 0
  441.             for i, hero in ipairs(GetAllyHeroes()) do
  442.                 Point = Vector(Point) + Vector(hero)
  443.                 Count = Count + 1
  444.             end
  445.             Count = Count or 1
  446.             Point = 1/Count * Vector(Point)
  447.             CastSpell(_R, Point.x, Point.z)
  448.         end
  449.     end
  450. end
  451.  
  452. function GetBestTarget(From, Range)
  453.     local MKillable = nil
  454.     local Min = 0
  455.     local Closest = 0
  456.     local D = 0
  457.  
  458.     for i, enemy in ipairs(GetEnemyHeroes()) do
  459.         if ValidTarget(enemy, Range) then
  460.             local Damage = myHero.ap < 100 and myHero:CalcDamage(enemy, 200) or myHero:CalcMagicDamage(enemy, 200)
  461.             local DMG = enemy.health / Damage
  462.  
  463.            
  464.             if (DMG <= Min or MKillable == nil) then
  465.                 MKillable = enemy
  466.                 Min = DMG
  467.             end
  468.         end
  469.     end
  470.  
  471.     return MKillable
  472. end
  473.  
  474. function OnCreateObj(object)
  475.     --[[TO-Check: Different obects names depending on skins?]]
  476.     if GetDistance(object) < 500 and object.name:lower():find("jester_copy.troy") then
  477.         clone = object
  478.     end
  479. end
  480.  
  481. function OnGainBuff(unit, buff)
  482.     --[[Q]]--
  483.     if unit.isMe and buff.name == "Deceive" then
  484.         DeceiveTime = os.clock()
  485.     end
  486. end
  487.  
  488. function OnLoseBuff(unit, buff)
  489.     --[[Q]]--
  490.     if unit.isMe and buff.name == "Deceive" then
  491.         DeceiveTime = 0
  492.     end
  493. end
  494.  
  495. function OnProcessSpell(unit, spell)
  496.     for i, enemy in ipairs(GetEnemyHeroes()) do
  497.         if ValidTarget(enemy) and enemy.networkID == unit.networkID and spell.target then
  498.             TargetsWaypoints[enemy.networkID] = {
  499.             [2] = {x =  spell.target.x, y = spell.target.z}
  500.             }
  501.         end
  502.     end
  503.     for i, mob in ipairs(JungleMinions.objects) do
  504.         if ValidTarget(mob) and unit.networkID == mob.networkID and spell.target then
  505.                         TargetsWaypoints[mob.networkID] = {
  506.             [2] = {x =  spell.target.x, y = spell.target.z}
  507.             }
  508.         end
  509.     end
  510.     --[[Clone auto-attack]]
  511.     if unit.team == myHero.team and unit.charName == myHero.charName and unit.networkID ~= myHero.networkID and  spell.name:lower():find("attack") then
  512.         CWinduptime = spell.windUpTime
  513.         CAnimationTime = spell.animationTime
  514.         CLastAttack = os.clock() - GetLatency()/2000
  515.     end
  516.    
  517.     if unit.networkID == myHero.networkID and spell.name:lower():find("attack") then
  518.         Winduptime = spell.windUpTime
  519.         AnimationTime = spell.animationTime
  520.         LastAttack = os.clock() - GetLatency()/2000
  521.        
  522.         if Menu.Items.Hydra and _HYDRA and myHero:CanUseSpell(_HYDRA) == READY and spell.target.type == myHero.type then
  523.             CastSpell(_HYDRA)
  524.         end
  525.            
  526.         if spell.target then
  527.             HTarget = spell.target
  528.             Htime = os.clock()
  529.         end
  530.     end
  531.    
  532.     if Menu.W.auto3 and ValidTarget(unit, 1000) and unit.charName == "Blitzcrank" and spell.name:lower():find("grab") and (myHero:CanUseSpell(_W) == READY) then
  533.         local spoint = Vector(unit)
  534.         local Direction = - (Vector(unit) - Vector(spell.endPos)):normalized()
  535.         local epoint = spoint + 1050 * Direction
  536.         local projection, line, isonsegment = VectorPointProjectionOnLineSegment(spoint, epoint, Vector(myHero) - 60 * Direction)
  537.         --[[Maybe better evade first and the put the box :)]]
  538.         if isonsegment and GetDistance(projection) < Wrange then
  539.             print("W casted in blitzcrank's grab, did it work? :o")
  540.             CastSpell(_W, projection.x, projection.z)
  541.         end
  542.     end
  543. end
  544.  
  545. function GetLandingPos(CastPoint)
  546.     local wall = IsWall(D3DXVECTOR3(CastPoint.x, CastPoint.y, CastPoint.z))
  547.     local Point = Vector(CastPoint)
  548.     local StartPoint = Vector(Point)
  549.     --[[Checks for 500 / 10 * pi/0.2 points]]
  550.     for i = 0, 500, 10--[[Decrease for better precision, increase for less fps drops:]] do
  551.         for theta = 0, 2 * math.pi + 0.2, 0.2 --[[Same :)]] do
  552.             local c = Vector(StartPoint.x + i * math.cos(theta), StartPoint.y, StartPoint.z + i * math.sin(theta))
  553.             if not IsWall(D3DXVECTOR3(c.x, c.y, c.z)) then
  554.                 return c
  555.             end
  556.         end
  557.     end
  558.     return Point
  559. end
  560.  
  561. function DLine(From, To, Color)
  562.     DrawLine3D(From.x, From.y, From.z, To.x, To.y, To.z, 2, Color)
  563. end
  564.  
  565. function DrawQ(To, Color)
  566.     local myPos = Vector(myHero.x, myHero.y, myHero.z)
  567.     local Direction = (Vector(To.x, To.y, To.z) - Vector(myPos)):perpendicular():normalized()
  568.     local Distance = GetDistance(To, myPos)
  569.     local Width = 75
  570.    
  571.     local P1r = Vector(myPos) + Width * Vector(Direction)
  572.     local P1l = Vector(myPos) - Width * Vector(Direction)
  573.     local P2r = Vector(myPos) + Width * Direction - Vector(Direction):perpendicular() * GetDistance(To)
  574.     local P2l = Vector(myPos) - Width * Direction - Vector(Direction):perpendicular() * GetDistance(To)
  575.    
  576.     DLine(P1r, P1l, Color)
  577.     DLine(P1r, P2r, Color)
  578.     DLine(P1l, P2l, Color)
  579.     DLine(P2r, P2l, Color)
  580. end
  581.  
  582. --[[Update the bar texts]]
  583. function RefreshKillableTexts()
  584.     if ((GetTickCount() - lastrefresh) > 1000) then
  585.         for i=1, heroManager.iCount do
  586.             local enemy = heroManager:GetHero(i)
  587.             if ValidTarget(enemy) then
  588.                 DamageToHeros[i] =  GetComboDamage(enemy)
  589.             end
  590.         end
  591.         lastrefresh = GetTickCount()
  592.     end
  593. end
  594.  
  595. --[[    Credits to zikkah   ]]
  596. function GetHPBarPos(enemy)
  597.     enemy.barData = GetEnemyBarData()
  598.     local barPos = GetUnitHPBarPos(enemy)
  599.     local barPosOffset = GetUnitHPBarOffset(enemy)
  600.     local barOffset = { x = enemy.barData.PercentageOffset.x, y = enemy.barData.PercentageOffset.y }
  601.     local barPosPercentageOffset = { x = enemy.barData.PercentageOffset.x, y = enemy.barData.PercentageOffset.y }
  602.     local BarPosOffsetX = 171
  603.     local BarPosOffsetY = 46
  604.     local CorrectionY =  0
  605.     local StartHpPos = 31
  606.     barPos.x = barPos.x + (barPosOffset.x - 0.5 + barPosPercentageOffset.x) * BarPosOffsetX + StartHpPos
  607.     barPos.y = barPos.y + (barPosOffset.y - 0.5 + barPosPercentageOffset.y) * BarPosOffsetY + CorrectionY
  608.                        
  609.     local StartPos = Vector(barPos.x , barPos.y, 0)
  610.     local EndPos =  Vector(barPos.x + 108 , barPos.y , 0)
  611.  
  612.     return Vector(StartPos.x, StartPos.y, 0), Vector(EndPos.x, EndPos.y, 0)
  613. end
  614.  
  615.  
  616. function DrawIndicator(unit, health)
  617.     local SPos, EPos = GetHPBarPos(unit)
  618.     local barlenght = EPos.x - SPos.x
  619.     local Position = SPos.x + (health / unit.maxHealth) * barlenght
  620.     if Position < SPos.x then
  621.         Position = SPos.x
  622.     end
  623.     DrawText("|", 13,  math.floor(Position),  math.floor(SPos.y+10), ARGB(255,0,255,0))
  624. end
  625.  
  626. function DrawOnHPBar(unit, health)
  627.     local Pos = GetHPBarPos(unit)
  628.     if health < 0 then
  629.         DrawCircle2(unit.x, unit.y, unit.z, 100, ARGB(255, 255, 0, 0)) 
  630.         DrawText("HP: "..health,13, math.floor(Pos.x), (Pos.y+5), ARGB(255,255,0,0))
  631.     else
  632.         DrawText("HP: "..health,13,  math.floor(Pos.x),  math.floor(Pos.y+5), ARGB(255,0,255,0))
  633.     end
  634. end
  635.  
  636. function OnDraw()
  637.     --[[
  638.     debug:
  639.     for i, enemy in ipairs(GetEnemyHeroes()) do
  640.          local P = GetBack(enemy)
  641.          DrawCircle2( P.x,  P.y,  P.z, 100, ARGB(255, 255, 0, 0))  
  642.     end
  643.     ]]--
  644.  
  645.     if Menu.DamageCalc.Draw then
  646.         for i=1, heroManager.iCount do
  647.             local enemy = heroManager:GetHero(i)
  648.             if ValidTarget(enemy) then
  649.                 local RemainingHealth = 0
  650.                 if DamageToHeros[i] ~= nil then
  651.                     RemainingHealth = enemy.health - DamageToHeros[i]
  652.                 end
  653.                     DrawOnHPBar(enemy, math.floor(RemainingHealth))
  654.                     DrawIndicator(enemy, math.floor(RemainingHealth))
  655.             end
  656.         end
  657.     end
  658.    
  659.     if Menu.Orbwalker.DrawRange then
  660.         DrawCircle2(myHero.x, myHero.y, myHero.z, Menu.Orbwalker.Range, ARGB(255, 255, 0, 0))  
  661.         if clone then
  662.             DrawCircle2(clone.x, clone.y, clone.z, Menu.Orbwalker.Range, ARGB(255, 0, 255, 0)) 
  663.         end
  664.     end
  665.    
  666.     if Menu.Q.DrawRange then
  667.         DrawCircle2(myHero.x, myHero.y, myHero.z, Qrange, ARGB(255, 255, 0, 0))
  668.     end
  669.    
  670.     if Menu.W.DrawRange then
  671.         DrawCircle2(myHero.x, myHero.y, myHero.z, Wrange, ARGB(255, 255, 0, 0))
  672.     end
  673.    
  674.     if Menu.E.DrawRange then
  675.         DrawCircle2(myHero.x, myHero.y, myHero.z, Erange, ARGB(255, 255, 0, 0))
  676.     end
  677.    
  678.     if Menu.R.DrawRange and clone then
  679.         DrawCircle(myHero.x, myHero.y, myHero.z, Rrange, ARGB(255, 0, 255, 0)) 
  680.     end
  681.    
  682.     if Menu.Q.Landing then
  683.         local CastPoint = GetDistance(mousePos) <= Qrange and Vector(mousePos) or Vector(myHero) + Qrange * (Vector(mousePos)-Vector(myHero)):normalized()
  684.         CastPoint = GetLandingPos(CastPoint)
  685.         local Color = myHero:CanUseSpell(_Q)==READY and  ARGB(255, 0, 255, 0) or ARGB(255, 255, 0, 0)
  686.         DrawQ(CastPoint, Color)
  687.     end
  688.    
  689.     if Menu.Q.DrawTime and DeceiveTime and DeceiveTime ~= 0 then
  690.         local myPos = WorldToScreen(D3DXVECTOR3(myHero.x, myHero.y, myHero.z))
  691.         DrawText(tostring(math.floor(35 - 10*(os.clock() - DeceiveTime))), 16, myPos.x, myPos.y, ARGB(255,255,0,0))
  692.     end
  693. end
  694.  
  695. function DrawCircle2(x, y, z, radius, color)
  696.     local vPos1 = Vector(x, y, z)
  697.     local vPos2 = Vector(cameraPos.x, cameraPos.y, cameraPos.z)
  698.     local tPos = vPos1 - (vPos1 - vPos2):normalized() * radius
  699.     local sPos = WorldToScreen(D3DXVECTOR3(tPos.x, tPos.y, tPos.z))
  700.  
  701.     if OnScreen({ x = sPos.x, y = sPos.y }, { x = sPos.x, y = sPos.y })  then
  702.         DrawCircleNextLvl(x, y, z, radius, 1, color, 75)   
  703.     end
  704. end
  705.  
  706. function DrawCircleNextLvl(x, y, z, radius, width, color, chordlength)
  707.     radius = radius or 300
  708.     quality = math.max(8,math.floor(180/math.deg((math.asin((chordlength/(2*radius)))))))
  709.     quality = 2 * math.pi / quality
  710.     radius = radius*.92
  711.     local points = {}
  712.     for theta = 0, 2 * math.pi + quality, quality do
  713.         local c = WorldToScreen(D3DXVECTOR3(x + radius * math.cos(theta), y, z - radius * math.sin(theta)))
  714.         points[#points + 1] = D3DXVECTOR2(c.x, c.y)
  715.     end
  716.     DrawLines2(points, width or 1, color or 4294967295)
  717. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement