Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2015
1,499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.04 KB | None | 0 0
  1. require "VPrediction"
  2. require "Collision"
  3. local farmingMode
  4. local wRange = 1535
  5. local eRange = 900
  6. local rRange = 50000
  7. local castR = string.byte("R")
  8. local PredictionW = nil
  9. function PluginOnLoad()
  10.     AutoCarry.SkillsCrosshair.range = 1600
  11.     PredictionW = VPrediction()
  12.     Menu = AutoCarry.PluginMenu
  13.     ts = TargetSelector(TARGET_LOW_HP,4000,DAMAGE_PHYSICAL, false)
  14.     --Menu:addParam("ultR","ultR", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  15.     Menu:addParam("autoQ","Auto use Q ", SCRIPT_PARAM_ONOFF, true)
  16.     Menu:addParam("autoW","Auto use W ", SCRIPT_PARAM_ONOFF, true) 
  17.     Menu:addParam("autoE","Auto use E ", SCRIPT_PARAM_ONOFF, true) 
  18.     Menu:addParam("autoR","Auto use R ", SCRIPT_PARAM_ONOFF, true) 
  19.     Menu:addParam("ultR","Semi-manual cast R", SCRIPT_PARAM_ONKEYDOWN, false, 32)  -- space
  20.     Menu:addParam("drawW","Draw helper W ", SCRIPT_PARAM_ONOFF, true)
  21.     Menu:addParam("drawE","Draw helper E ", SCRIPT_PARAM_ONOFF, true)
  22.     Menu:addParam("drawR","Draw helper R ", SCRIPT_PARAM_ONOFF, true)
  23.     Menu:addParam("manaMenager","Mana menager", SCRIPT_PARAM_ONOFF, true)
  24. end
  25.  
  26. function PluginOnTick()
  27.     Target = AutoCarry.Crosshair:GetTarget()
  28.     manaMenager()
  29.     QREADY = (myHero:CanUseSpell(_Q) == READY)
  30.     WREADY = (myHero:CanUseSpell(_W) == READY)
  31.     EREADY = (myHero:CanUseSpell(_E) == READY)
  32.     RREADY = (myHero:CanUseSpell(_R) == READY)
  33.     if ( AutoCarry.Keys.MixedMode or AutoCarry.Keys.LaneClear or AutoCarry.Keys.LastHit) then
  34.         farmingMode = true
  35.     else
  36.         farmingMode = false
  37.     end
  38.     bonusRange = 525 + 120 + 25 * myHero:GetSpellData(_Q).level
  39.     if Target ~= nil then
  40.         if QREADY then
  41.             if (GetDistance(Target) > 630 or CountEnemies(Target, 130) > 1 ) and
  42.             (myHero.mana > WMANA + RMANA or myHero.totalDamage * 3 >  Target.health) then
  43.                 if AutoCarry.Keys.AutoCarry then
  44.                     minigunOn()
  45.                 elseif farmingMode and myHero.mana > WMANA + RMANA + EMANA and GetDistance(Target) < bonusRange + 150  then
  46.                     minigunOn()
  47.                 else
  48.                     minigunOff()
  49.                 end
  50.             else
  51.                 minigunOff()
  52.             end
  53.         end
  54.        
  55.         if Menu.autoW and WREADY then
  56.             wDmg = getDmg("W", Target, myHero)
  57.             local CastPosition,  HitChance,  Position = PredictionW:GetLineCastPosition(Target, 0.6, 75, wRange, 1600, myHero, true)
  58.             if not AutoCarry.Orbwalker:IsShooting() and GetDistance(Target) > 525 and wDmg > Target.health and HitChance >= 1 and GetDistance(CastPosition) < wRange then
  59.                 CastSpell(_W, CastPosition.x, CastPosition.z)
  60.             elseif not AutoCarry.Orbwalker:IsShooting()  and AutoCarry.Keys.AutoCarry and myHero.mana > WMANA + RMANA and HitChance >= 2 and CountEnemies(myHero, bonusRange) == 0 and GetDistance(CastPosition) < wRange then
  61.                 CastSpell(_W, CastPosition.x, CastPosition.z)
  62.             elseif not AutoCarry.Orbwalker:IsShooting()  and farmingMode and (myHero.mana > 2 * (WMANA + RMANA + EMANA) or HitChance >= 3) and HitChance >= 2 and CountEnemies(myHero, bonusRange) == 0 and GetDistance(CastPosition) < wRange-200 then
  63.                 CastSpell(_W, CastPosition.x, CastPosition.z)
  64.             end
  65.         end
  66.        
  67.         if Menu.autoE and EREADY then
  68.             local CastPosition,  HitChance,  Position = PredictionW:GetCircularCastPosition(Target, 2, 30, eRange)
  69.             local ePos = GetAoESpellPosition(350, Target, 1900)
  70.             if (Target.canMove ~= true or HitChance >= 3) and GetDistance(Target) < 900 and myHero.mana > RMANA + EMANA then
  71.                 CastSpell(_E, CastPosition.x, CastPosition.z)
  72.             end
  73.         end
  74.     else
  75.         if AutoCarry.Keys.LaneClear and myHero.mana > myHero.maxMana * 0.9 then
  76.             minigunOn()
  77.         elseif myHero.mana > WMANA + RMANA and AutoCarry.Keys.AutoCarry then
  78.             minigunOn()
  79.         else
  80.             minigunOff()
  81.         end
  82.     end
  83.    
  84.     if RREADY then
  85.         ts:update()
  86.         if ts.target ~= nil then
  87.             local CastPosition,  HitChance,  Position = PredictionW:GetLineCastPosition(ts.target, 0.58, 150, rRange, 2165, myHero, false)
  88.             rPredistion = CastPosition
  89.             rDmg = getDmg("R", ts.target, myHero)
  90.             if Menu.ultR and HitChance >= 2 then
  91.                 CastSpell(_R, CastPosition.x, CastPosition.z)
  92.             end
  93.             if Menu.autoR and rDmg > ts.target.health and GetDistance(ts.target, myHero) < 3000 then
  94.                 Collision:__init(rRange, 2150, 0.58, 250)
  95.                 PrintFloatText(player,0,ts.target.charName)
  96.                 PrintFloatText(ts.target,0,"KILL R")
  97.                 if  HitChance >= 2 and GetDistance(ts.target) > bonusRange + 150 and CountAlly(ts.target, 600) == 0 and not Collision:GetHeroCollision(myHero, ts.target, HERO_ENEMY) then
  98.                     CastSpell(_R, CastPosition.x, CastPosition.z)
  99.                 end
  100.                 if  HitChance >= 2  and CountEnemies(ts.target, 350) > 1  and rDmg * 0.9 > ts.target.health then
  101.                     CastSpell(_R, CastPosition.x, CastPosition.z)
  102.                 end
  103.                 if  HitChance >= 1  and myHero.health < myHero.maxHealth * 0.5 and 2.6 * rDmg > ts.target.health then
  104.                     CastSpell(_R, CastPosition.x, CastPosition.z)
  105.                 end
  106.                 if  HitChance >= 2  and ts.target.canMove ~= true  and 2.6 * rDmg > ts.target.health then
  107.                     CastSpell(_R, CastPosition.x, CastPosition.z)
  108.                 end
  109.             end
  110.         end
  111.     end
  112. end
  113.  
  114. function PluginOnDraw()
  115.     if Menu.drawW and Target ~= nil then
  116.         wDmg = getDmg("W", Target, myHero)
  117.         if wDmg > Target.health then
  118.             PrintFloatText(player,0,Target.charName)
  119.             PrintFloatText(Target,0,"KILL W")
  120.             DrawCircleNextLvl(myHero.x, myHero.y, myHero.z, wRange)
  121.             DrawLineNextLvl(myHero,Target)
  122.         end
  123.         if WREADY then
  124.             DrawCircleNextLvl(myHero.x, myHero.y, myHero.z, wRange)
  125.         end
  126.     end
  127.     if Menu.drawE and Target ~= nil then
  128.         if Target.canMove ~= true and EREADY then
  129.             PrintFloatText(player,0,Target.charName)
  130.             PrintFloatText(Target,0,"STUNE E")
  131.             DrawCircleNextLvl(myHero.x, myHero.y, myHero.z, eRange)
  132.         end
  133.     end
  134.     if Menu.drawR and ts.target ~= nil and RREADY then
  135.         rDmg = getDmg("R", ts.target, myHero)
  136.         if rDmg > ts.target.health or  Menu.ultR then
  137.             DrawLineNextLvl(myHero,rPredistion)
  138.         end
  139.         DrawCircleNextLvl(rPredistion.x, rPredistion.y, rPredistion.z, 100)
  140.     end
  141. end
  142. function manaMenager()
  143.     if Menu.manaMenager then
  144.         WMANA = 40 + 10 * myHero:GetSpellData(_W).level
  145.         EMANA = 50
  146.         if not RREADY then
  147.             RMANA = WMANA-10
  148.         else
  149.             RMANA = 100
  150.         end
  151.     else
  152.         WMANA = 0
  153.         RMANA = 0
  154.         EMANA = 0
  155.         RMANA = 0
  156.     end
  157. end
  158.  
  159. function DrawLineNextLvl(point1, point2)
  160.   local points = {}
  161.   local c = WorldToScreen(D3DXVECTOR3(point1.x, point1.y, point1.z ))
  162.   local c2 = WorldToScreen(D3DXVECTOR3(point2.x, point2.y, point2.z ))
  163.   points[1] = D3DXVECTOR2(c.x, c.y)
  164.   points[2] = D3DXVECTOR2(c2.x, c2.y)
  165.   DrawLines2(points, 1,  4294967295)
  166. end
  167.  
  168. function DrawCircleNextLvl(x, y, z, radius, width, color, chordlength)
  169.   radius = radius or 300
  170.   quality = math.max(8,math.floor(180/math.deg((math.asin((70/(2*radius)))))))
  171.   quality = 2 * math.pi / quality
  172.   radius = radius*.92
  173.   local points = {}
  174.   for theta = 0, 2 * math.pi + quality, quality do
  175.     local c = WorldToScreen(D3DXVECTOR3(x + radius * math.cos(theta), y, z - radius * math.sin(theta)))
  176.     points[#points + 1] = D3DXVECTOR2(c.x, c.y)
  177.   end
  178.   DrawLines2(points, width or 1, color or 6294967295)
  179. end
  180.  
  181. function CountEnemies(point, range)
  182.     local ChampCount = 0
  183.     for j = 1, heroManager.iCount, 1 do
  184.         local enemyhero = heroManager:getHero(j)
  185.         if myHero.team ~= enemyhero.team and enemyhero.dead ~= true then
  186.             if GetDistance(enemyhero, point) <= range then
  187.                 ChampCount = ChampCount + 1
  188.             end
  189.         end
  190.     end            
  191.     return ChampCount
  192. end
  193.  
  194. function CountAlly(point, range)
  195.     local ChampCount = 0
  196.     for j = 1, heroManager.iCount, 1 do
  197.         local allyhero = heroManager:getHero(j)
  198.         if myHero.team == allyhero.team and allyhero.dead ~= true then
  199.             if GetDistance(allyhero, point) <= range then
  200.                 ChampCount = ChampCount + 1
  201.             end
  202.         end
  203.     end            
  204.     return ChampCount
  205. end
  206. function minigunOff()
  207.     if (farmingMode or AutoCarry.Keys.AutoCarry) and Menu.autoQ and myHero.range > 530 and not AutoCarry.Orbwalker:IsShooting() then
  208.         CastSpell(_Q)
  209.     end
  210. end
  211.  
  212. function minigunOn()
  213.     if (farmingMode or AutoCarry.Keys.AutoCarry) and Menu.autoQ and myHero.range < 530 and not AutoCarry.Orbwalker:IsShooting() then
  214.         CastSpell(_Q)
  215.     end
  216. end
  217.  
  218. --[[
  219.         AoE_Skillshot_Position 2.0 by monogato
  220.        
  221.         GetAoESpellPosition(radius, main_target, [delay]) returns best position in order to catch as many enemies as possible with your AoE skillshot, making sure you get the main target.
  222.         Note: You can optionally add delay in ms for prediction (VIP if avaliable, normal else).
  223. ]]
  224.  
  225. function GetCenter(points)
  226.         local sum_x = 0
  227.         local sum_z = 0
  228.        
  229.         for i = 1, #points do
  230.                 sum_x = sum_x + points[i].x
  231.                 sum_z = sum_z + points[i].z
  232.         end
  233.        
  234.         local center = {x = sum_x / #points, y = 0, z = sum_z / #points}
  235.        
  236.         return center
  237. end
  238.  
  239. function ContainsThemAll(circle, points)
  240.         local radius_sqr = circle.radius*circle.radius
  241.         local contains_them_all = true
  242.         local i = 1
  243.        
  244.         while contains_them_all and i <= #points do
  245.                 contains_them_all = GetDistanceSqr(points[i], circle.center) <= radius_sqr
  246.                 i = i + 1
  247.         end
  248.        
  249.         return contains_them_all
  250. end
  251.  
  252. -- The first element (which is gonna be main_target) is untouchable.
  253. function FarthestFromPositionIndex(points, position)
  254.         local index = 2
  255.         local actual_dist_sqr
  256.         local max_dist_sqr = GetDistanceSqr(points[index], position)
  257.        
  258.         for i = 3, #points do
  259.                 actual_dist_sqr = GetDistanceSqr(points[i], position)
  260.                 if actual_dist_sqr > max_dist_sqr then
  261.                         index = i
  262.                         max_dist_sqr = actual_dist_sqr
  263.                 end
  264.         end
  265.        
  266.         return index
  267. end
  268.  
  269. function RemoveWorst(targets, position)
  270.         local worst_target = FarthestFromPositionIndex(targets, position)
  271.        
  272.         table.remove(targets, worst_target)
  273.        
  274.         return targets
  275. end
  276.  
  277. function GetInitialTargets(radius, main_target)
  278.         local targets = {main_target}
  279.         local diameter_sqr = 4 * radius * radius
  280.        
  281.         for i=1, heroManager.iCount do
  282.                 target = heroManager:GetHero(i)
  283.                 if target.networkID ~= main_target.networkID and ValidTarget(target) and GetDistanceSqr(main_target, target) < diameter_sqr then table.insert(targets, target) end
  284.         end
  285.        
  286.         return targets
  287. end
  288.  
  289. function GetPredictedInitialTargets(radius, main_target, delay)
  290.         if VIP_USER and not vip_target_predictor then vip_target_predictor = TargetPredictionVIP(nil, nil, delay/1000) end
  291.         local predicted_main_target = VIP_USER and vip_target_predictor:GetPrediction(main_target) or GetPredictionPos(main_target, delay)
  292.         local predicted_targets = {predicted_main_target}
  293.         local diameter_sqr = 4 * radius * radius
  294.        
  295.         for i=1, heroManager.iCount do
  296.                 target = heroManager:GetHero(i)
  297.                 if ValidTarget(target) then
  298.                         predicted_target = VIP_USER and vip_target_predictor:GetPrediction(target) or GetPredictionPos(target, delay)
  299.                         if target.networkID ~= main_target.networkID and GetDistanceSqr(predicted_main_target, predicted_target) < diameter_sqr then table.insert(predicted_targets, predicted_target) end
  300.                 end
  301.         end
  302.        
  303.         return predicted_targets
  304. end
  305.  
  306. -- I don't need range since main_target is gonna be close enough. You can add it if you do.
  307. function GetAoESpellPosition(radius, main_target, delay)
  308.         local targets = delay and GetPredictedInitialTargets(radius, main_target, delay) or GetInitialTargets(radius, main_target)
  309.         local position = GetCenter(targets)
  310.         local best_pos_found = true
  311.         local circle = Circle(position, radius)
  312.         circle.center = position
  313.        
  314.         if #targets > 2 then best_pos_found = ContainsThemAll(circle, targets) end
  315.        
  316.         while not best_pos_found do
  317.                 targets = RemoveWorst(targets, position)
  318.                 position = GetCenter(targets)
  319.                 circle.center = position
  320.                 best_pos_found = ContainsThemAll(circle, targets)
  321.         end
  322.        
  323.         return position, #targets
  324. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement