Advertisement
Kevinkev

Merry Go Round 1.0.lua

Dec 30th, 2012
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.27 KB | None | 0 0
  1. --[[
  2.  
  3.     MerryGoRound 1.0
  4.  
  5.     By Kevinkev
  6.  
  7.     <Because you should be happy running around turret opposite your enemy>
  8.  
  9.     Description:
  10.  
  11.     Basically we've all known about juking under turret. Especially at top lane when (s)he wants to dive you.
  12.     Because sometimes juking under turret is what will help you win the fight and ultimately kill him.
  13.     We've probably all succeeded at this sometimes and sometimes we misclick and walk right in to the enemy.
  14.     But what if, there was a way to do it without fail. Provided you turn it on when needed. :P
  15.  
  16.     Tips:
  17.     -Turn it on when you feel like they will dive you at turret and you want to juke them.
  18.     -Be smart, if they have a gap closer like xin zhao this probably won't work. But then it might to some degree help. (He dashes you flash to other side and proceed to juke)
  19.  
  20.     HOTKEYS (for different users)
  21.     T-Stay on or off
  22.     V-Hold down to turn on, let go to turn off
  23.  
  24.     I recommend V. :P
  25.  
  26.     Notes:
  27.  
  28.     -Currently supports single targets. Might update later on for 2 targets to determine best position but more than that and I'm pretty sure you should just leave that turret.
  29.     -No dead turret check because you can still juke around the remains of a turret although it'd only buy time..
  30. ]]--
  31.  
  32. function OnLoad()
  33.     --HOTKEYS
  34.     switchHK = string.byte("T") --Press once to turn on/off
  35.     toggleHK = string.byte("V") --Hold to turn on/off
  36.  
  37.     --RANGES
  38.     rangeFromEnemy      = 600 --Range it detects enemies and proceeds to go to the furthest side of the turret
  39.     rangeAroundTurret   = 180 --Range it will move around turret.(Whether or not you delay while moving around depends on auto pathing)
  40.     TurretDistance      = 1000 --Range it will detect the turret from
  41.     TargetCircleRadius  = 100  --Size of destination point circles
  42.  
  43.     --COLOURS
  44.     SafeColor    = 0x00FF00 --Color of safe position if juking
  45.     NeutralColor = 0xF0F8FF --Color of enemy circle on opposite side.
  46.    
  47.     --TURRETS
  48.     GetIds()
  49.    
  50.     --MENU
  51.     TJukeConfig = scriptConfig("Merry-Go-Round 1.0", "TJ")
  52.     TJukeConfig:addParam("JukeT", "Juking (toggle)", SCRIPT_PARAM_ONKEYDOWN, false, toggleHK)
  53.     TJukeConfig:addParam("JukeS", "Juking (switch)", SCRIPT_PARAM_ONKEYTOGGLE, false, switchHK)
  54.     TJukeConfig:addParam("DrawCircle", "Draw circles", SCRIPT_PARAM_ONOFF, true)
  55.     TJukeConfig:permaShow("JukeT")
  56.     TJukeConfig:permaShow("JukeS")
  57. end
  58.  
  59.  
  60.  
  61. function getClosestTurretXZ()
  62.     x = myHero.x
  63.     z = myHero.z
  64.     for i,Turret in pairs(Turret) do
  65.         if TurretDistance > math.round(math.sqrt((x - Turret.x)^2 + (z - Turret.z)^2)) then
  66.             return Turret.x, Turret.z
  67.         end
  68.     end
  69.    
  70.     return nil --If nothing is there
  71. end
  72.  
  73.  
  74. function moveToPredicted(x,y,z)
  75.     myHero:MoveTo(x,z)
  76. end
  77.  
  78.  
  79. function getPredictionPosition(x,y,z)
  80.     x1,z1 = getClosestTurretXZ()
  81.     gradient = (z - z1)/( x - x1)
  82.     if x1 > x then
  83.         return   ((math.cos(math.atan(gradient))) * rangeAroundTurret) + x1,y,((math.sin(math.atan(gradient))) * rangeAroundTurret) + z1
  84.     else
  85.         return  -((math.cos(math.atan(gradient))) * rangeAroundTurret) + x1,y,-((math.sin(math.atan(gradient))) * rangeAroundTurret) + z1
  86.     end
  87. end
  88.  
  89.  
  90. function getPositionOfEnemyOnTurret(x,y,z)
  91.     x1,z1 = getClosestTurretXZ()
  92.     gradient = (z - z1)/( x - x1)
  93.     if x1 > x then
  94.         return   -((math.cos(math.atan(gradient))) * rangeAroundTurret) + x1,y,-((math.sin(math.atan(gradient))) * rangeAroundTurret) + z1
  95.     else
  96.         return  ((math.cos(math.atan(gradient))) * rangeAroundTurret) + x1,y,((math.sin(math.atan(gradient))) * rangeAroundTurret) + z1
  97.     end
  98. end
  99.  
  100. function OnDraw()
  101.    
  102.    
  103.     --If turret is in range
  104.     if getClosestTurretXZ() ~= nil then
  105.         xTurret,zTurret = getClosestTurretXZ()
  106.         DrawCircle(xTurret, myHero.y, zTurret, TurretDistance, SafeColor) --Change color to something you want. (safecolor)
  107.  
  108.         for j = 1, heroManager.iCount, 1 do
  109.             local enemyhero = heroManager:getHero(j)
  110.                
  111.                 if TJukeConfig.DrawCircle and ValidTarget(enemyhero) and myHero:GetDistance(enemyhero) <= rangeFromEnemy then
  112.  
  113.                 --Enemy Position
  114.                 x,y,z  = getPositionOfEnemyOnTurret(enemyhero.x,enemyhero.y,enemyhero.z)
  115.                
  116.                 DrawCircle(x,y,z, TargetCircleRadius*0.5 +1 , NeutralColor)
  117.                 DrawCircle(x,y,z, TargetCircleRadius*0.5    , NeutralColor)
  118.                 DrawCircle(x,y,z, TargetCircleRadius*0.5 -1 , NeutralColor)
  119.                 DrawCircle(x,y,z, TargetCircleRadius*0.5 -2 , NeutralColor)
  120.                 DrawCircle(x,y,z, TargetCircleRadius*0.5 -3 , NeutralColor)
  121.                
  122.                 --Predicted Position
  123.                 x,y,z  = getPredictionPosition(enemyhero.x,enemyhero.y,enemyhero.z)
  124.                
  125.                 DrawCircle(x,y,z, TargetCircleRadius*0.5 +1 , SafeColor)
  126.                 DrawCircle(x,y,z, TargetCircleRadius*0.5    , SafeColor)
  127.                 DrawCircle(x,y,z, TargetCircleRadius*0.5 -1 , SafeColor)
  128.                 DrawCircle(x,y,z, TargetCircleRadius*0.5 -2 , SafeColor)
  129.                 DrawCircle(x,y,z, TargetCircleRadius*0.5 -3 , SafeColor)
  130.                
  131.                 end
  132.                
  133.                 if ValidTarget(enemyhero) and myHero:GetDistance(enemyhero) <= rangeFromEnemy then
  134.                     --ACTION
  135.                     if TJukeConfig.JukeT or TJukeConfig.JukeS then
  136.                     moveToPredicted(getPredictionPosition(enemyhero.x,enemyhero.y,enemyhero.z))
  137.                     end
  138.                
  139.                 end
  140.                
  141.            
  142.        end
  143.      
  144.     end
  145.    
  146.     SC__OnDraw()
  147. end
  148.  
  149.  
  150. function OnWndMsg(msg,key)
  151.     SC__OnWndMsg(msg,key)
  152. end
  153.  
  154. function GetIds()
  155.     if myHero.team == TEAM_BLUE then
  156.         --Bottom side
  157.         Turret = {
  158.         {name = "Turret_T1_L_03_A", x = 574.65502929688, y = 26.813898086548, z = 10220.470703125},
  159.         {name = "Turret_T1_C_05_A", x = 5439.4682617188, y = 44.099128723145, z = 6175.7666015625},
  160.         {name = "Turret_T1_R_03_A", x = 10097.618164063, y = 41.339515686035, z = 808.73291015625},
  161.         {name = "Turret_T1_L_02_A", x = 1106.2634277344, y = 42.06392288208, z = 6478.5864257813},
  162.         {name = "Turret_T1_C_04_A", x = 4641.4418945313, y = 43.518402099609, z = 4591.9091796875},
  163.         {name = "Turret_T1_R_02_A", x = 6512.52734375,   y = 43.320083618164, z = 1262.6145019531},
  164.         {name = "Turret_T1_C_06_A", x = 802.81036376953, y = 96.739608764648, z = 4052.3605957031},
  165.         {name = "Turret_T1_C_03_A", x = 3233.994140625,  y = 96.034530639648, z = 3447.2421875},
  166.         {name = "Turret_T1_C_07_A", x = 3747.2548828125, y = 96.264854431152, z = 1041.0439453125},
  167.         {name = "Turret_T1_C_01_A", x = 1341.6325683594, y = 98.230155944824, z = 2029.984375},
  168.         {name = "Turret_T1_C_02_A", x = 1768.1916503906, y = 96.472526550293, z = 1589.4655761719},
  169.         }
  170.     else
  171.         --Top side
  172.         Turret = {
  173.         {name = "Turret_T2_L_03_A", x = 3911.6752929688, y = 13.130361557007, z = 13654.815429688},
  174.         {name = "Turret_T2_C_05_A", x = 8548.8046875,    y = 44.313140869141, z = 8289.49609375},
  175.         {name = "Turret_T2_R_03_A", x = 13459.614257813, y = 40.973766326904, z = 4284.2392578125},
  176.         {name = "Turret_T2_L_02_A", x = 7536.5234375,    y = 39.184650421143, z = 13190.815429688},
  177.         {name = "Turret_T2_C_04_A", x = 9361.072265625,  y = 41.252155303955, z = 9892.6240234375},
  178.         {name = "Turret_T2_R_02_A", x = 12920.7890625,   y = 37.775768280029, z = 8005.2919921875},
  179.         {name = "Turret_T2_L_01_A", x = 10261.900390625, y = 95.404235839844, z = 13465.911132813},
  180.         {name = "Turret_T2_C_03_A", x = 10743.580078125, y = 96.524940490723, z = 11010.0625},
  181.         {name = "Turret_T2_R_01_A", x = 13205.825195313, y = 95.759963989258, z = 10474.619140625},
  182.         {name = "Turret_T2_C_02_A", x = 12118.146484375, y = 93.899185180664, z = 12876.62890625},
  183.         {name = "Turret_T2_C_01_A", x = 12662.48828125,  y = 93.969276428223, z = 12442.701171875},
  184.         }
  185.     end
  186. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement