fbragequit

SidasAutoCarryPlugin - Lucian.lua

Dec 7th, 2013
3,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.94 KB | None | 0 0
  1. --[[
  2.     Sida's Auto Carry - Reborn
  3.     Lucian plugin by fbragequit
  4.     v1.1.1
  5. ]]
  6.  
  7. function PluginOnLoad()
  8.     qCastRange, qMaxRange, qWidth, qDelay = 680, 1100, 65, 350
  9.     wRange, wSpeed, wWidth, wDelay = 1000, 1.6, 80, 300
  10.     AARange = 680 -- 550
  11.    
  12.     Menu = AutoCarry.PluginMenu
  13.     Menu:addParam("info", "                      — Q options —", SCRIPT_PARAM_INFO, "")
  14.     Menu:addParam("qCarry", "Use in Auto Carry Mode", SCRIPT_PARAM_ONOFF, true)
  15.     Menu:addParam("qHarass", "Use in Mixed Mode", SCRIPT_PARAM_ONOFF, true)
  16.     Menu:addParam("qPassiveWeave", "Don't cast with passive", SCRIPT_PARAM_ONOFF, true)
  17.     Menu:addParam("qSheenWeave", "Wait for Sheen/Trinity", SCRIPT_PARAM_ONOFF, true)
  18.     Menu:addParam("qHarassMana", "Mana manager (Mixed Mode)", SCRIPT_PARAM_SLICE, 20, 0, 100, 0)
  19.     Menu:addParam("qAfterAttack", "Cast only after AA (RELOAD)", SCRIPT_PARAM_ONOFF, false)
  20.     Menu:addParam("info", "Custom Q logic (OFF = simple direct casts)", SCRIPT_PARAM_INFO, "")
  21.     Menu:addParam("qLogicCarry", "    » in AutoCarry mode", SCRIPT_PARAM_ONOFF, true)
  22.     Menu:addParam("qLogicHarass", "    » in Mixed Mode", SCRIPT_PARAM_ONOFF, true)
  23.     Menu:addParam("qPrioAoE", "AoE if can multishot >=", SCRIPT_PARAM_SLICE, 3, 3, 5, 0)
  24.     Menu:addParam("info", "                      — W options —", SCRIPT_PARAM_INFO, "")
  25.     Menu:addParam("wCarry", "Use in Auto Carry Mode", SCRIPT_PARAM_ONOFF, true)
  26.     Menu:addParam("wChase", "Only when chasing (>AA range)", SCRIPT_PARAM_ONOFF, false)
  27.     Menu:addParam("wPassiveWeave", "Don't cast with passive (<AA range)", SCRIPT_PARAM_ONOFF, true)
  28.     Menu:addParam("wSheenWeave", "Wait for Sheen/Trinity (<AA range)", SCRIPT_PARAM_ONOFF, true)
  29.     Menu:addParam("info", "                      — Drawing —", SCRIPT_PARAM_INFO, "")
  30.     Menu:addParam("qDraw", "Draw Q helpers", SCRIPT_PARAM_ONOFF, true)
  31.     Menu:addParam("qDrawRange", "Draw Q range", SCRIPT_PARAM_ONOFF, false)
  32.     Menu:addParam("wDrawRange", "Draw W range", SCRIPT_PARAM_ONOFF, false)
  33.    
  34.     AutoCarry.Crosshair:SetSkillCrosshairRange(1000)
  35.     SkillQ = AutoCarry.Skills:NewSkill(false, _Q, qCastRange, "Piercing Light", AutoCarry.SPELL_TARGETED, 0, Menu.qAfterAttack, false, math.huge, qDelay, qWidth, false)
  36.     SkillW = AutoCarry.Skills:NewSkill(false, _W, wRange, "Ardent Blaze", AutoCarry.SPELL_LINEAR_COL, 0, false, false, wSpeed, wDelay, wWidth, true)
  37.    
  38.     Prod = ProdictManager.GetInstance()
  39.     qProd = Prod:AddProdictionObject(_Q, qMaxRange, math.huge, qDelay/1000, qWidth)
  40.    
  41.     AdvancedCallback:bind('OnLoseBuff', OnLoseBuff)
  42.    
  43.     Timer = 0
  44. end
  45.  
  46. function PluginOnTick()
  47.     qReady = myHero:CanUseSpell(_Q) == READY
  48.     wReady = myHero:CanUseSpell(_W) == READY
  49.     eReady = myHero:CanUseSpell(_E) == READY
  50.     Target = AutoCarry.Crosshair:GetTarget(true)
  51.    
  52.     if Timer ~= 0 then
  53.         if GetGameTimer() - Timer >= 2 then
  54.             sFlag = false
  55.             Timer = 0
  56.         end
  57.     end
  58.    
  59.     if Target then
  60.        
  61.         if AutoCarry.Keys.AutoCarry then
  62.             if Menu.qCarry and qReady then
  63.                 qCast()
  64.             end
  65.             if Menu.wCarry and wReady then
  66.                 wCast()
  67.             end
  68.         end
  69.        
  70.         if AutoCarry.Keys.MixedMode then
  71.             if qReady and Menu.qHarass and myHero.mana >= (myHero.maxMana * (Menu.qHarassMana / 100)) then
  72.                 qCast()
  73.             end
  74.         end
  75.        
  76.     end
  77.    
  78. end
  79.  
  80. function qCast()
  81.     if not Menu.qLogicCarry then SkillQ:Cast(Target) return end
  82.     if (Menu.qPassiveWeave and pFlag) or (Menu.qSheenWeave and sFlag) then return end
  83.    
  84.     local Units = {}
  85.     local Champs = {}
  86.    
  87.     local i = 1
  88.     for h, hero in pairs(AutoCarry.EnemyTable) do
  89.         if GetDistance(hero) < qCastRange then
  90.             table.insert(Units, hero)
  91.         end
  92.         if GetDistance(hero) < qMaxRange then
  93.             table.insert(Champs, hero)
  94.             Champs[i].prod = qProd:GetPrediction(hero)
  95.             i = i + 1
  96.         end
  97.     end
  98.     if Champs == {} then return end
  99.    
  100.     for m, minion in pairs(AutoCarry.EnemyMinions().objects) do
  101.         table.insert(Units, minion)
  102.     end
  103.    
  104.     local bestshot, bestshotHits, bestshotHitsTarget = nil, 0, 0
  105.     for u, unit in pairs(Units) do
  106.         local V = Vector(unit) - Vector(myHero)
  107.        
  108.         local Vn = V:normalized()
  109.         local Vp = V:perpendicular():normalized()
  110.         local a, b, c = Vn:unpack()
  111.         local x, y, z = Vp:unpack()
  112.        
  113.         local startLeftX = myHero.x + (x * qWidth)
  114.         local startLeftY = myHero.y + (y * qWidth)
  115.         local startLeftZ = myHero.z + (z * qWidth)
  116.         local startRightX = myHero.x - (x * qWidth)
  117.         local startRightY = myHero.y - (y * qWidth)
  118.         local startRightZ = myHero.z - (z * qWidth)
  119.        
  120.         local endLeftX = myHero.x + (x * qWidth) + (a * qMaxRange)
  121.         local endLeftY = myHero.y + (y * qWidth) + (b * qMaxRange)
  122.         local endLeftZ = myHero.z + (z * qWidth) + (c * qMaxRange)
  123.         local endRightX = myHero.x - (x * qWidth) + (a * qMaxRange)
  124.         local endRightY = myHero.y - (y * qWidth) + (b * qMaxRange)
  125.         local endRightZ = myHero.z - (z * qWidth) + (c * qMaxRange)
  126.        
  127.         local startLeft = WorldToScreen(D3DXVECTOR3(startLeftX, startLeftY, startLeftZ))
  128.         local startRight = WorldToScreen(D3DXVECTOR3(startRightX, startRightY, startRightZ))
  129.         local endLeft = WorldToScreen(D3DXVECTOR3(endLeftX, endLeftY, endLeftZ))
  130.         local endRight = WorldToScreen(D3DXVECTOR3(endRightX, endRightY, endRightZ))
  131.        
  132.         local Poly = Polygon(Point(startLeft.x, startLeft.y), Point(endLeft.x, endLeft.y), Point(endRight.x, endRight.y), Point(startRight.x, startRight.y))
  133.        
  134.         local hits, hitsTarget = 0, 0
  135.         for c, champ in pairs(Champs) do
  136.             local Pos = champ.prod
  137.             if Pos == nil then Pos = champ end
  138.            
  139.             local toScreen = WorldToScreen(D3DXVECTOR3(Pos.x, Pos.y, Pos.z))
  140.             local toPoint = Point(toScreen.x, toScreen.y)
  141.            
  142.             if Poly:contains(toPoint) then
  143.                 bestshot = unit
  144.                 hits = hits + 1
  145.                 if champ == Target then hitsTarget = 1 end
  146.             end
  147.         end
  148.        
  149.         if (hits > bestshotHits and hitsTarget >= bestshotHitsTarget) or hits >= Menu.qPrioAoE then
  150.             bestshot, bestshotHits, bestshotHitsTarget = unit, hits, hitsTarget
  151.         end
  152.     end
  153.    
  154.     if bestshot ~= nil then
  155.         SkillQ:Cast(bestshot)
  156.     end
  157.    
  158.     if Menu.qDraw and Target then
  159.         local V = Vector(Target) - Vector(myHero)
  160.        
  161.         local Vn = V:normalized()
  162.         local Distance = GetDistance(Target)
  163.         local tx, ty, tz = Vn:unpack()
  164.         local TopX = Target.x - (tx * Distance)
  165.         local TopY = Target.y - (ty * Distance)
  166.         local TopZ = Target.z - (tz * Distance)
  167.        
  168.         local Vr = V:perpendicular():normalized()
  169.         local Radius = GetDistance(Target, Target.minBBox)
  170.         local tx, ty, tz = Vr:unpack()
  171.        
  172.         local LeftX = Target.x + (tx * Radius)
  173.         local LeftY = Target.y + (ty * Radius)
  174.         local LeftZ = Target.z + (tz * Radius)
  175.         local RightX = Target.x - (tx * Radius)
  176.         local RightY = Target.y - (ty * Radius)
  177.         local RightZ = Target.z - (tz * Radius)
  178.        
  179.         Left = WorldToScreen(D3DXVECTOR3(LeftX, LeftY, LeftZ))
  180.         Right = WorldToScreen(D3DXVECTOR3(RightX, RightY, RightZ))
  181.         Top = WorldToScreen(D3DXVECTOR3(TopX, TopY, TopZ))
  182.     end
  183.    
  184. end
  185.  
  186. function wCast()
  187.     if GetDistance(Target) < AARange then
  188.         if Menu.wChase then return end
  189.         if (Menu.qPassiveWeave and pFlag) or (Menu.qSheenWeave and sFlag) then return end
  190.     end
  191.     SkillW:Cast(Target)
  192. end
  193.  
  194. function OnLoseBuff(unit, buff)
  195.     if unit.isMe then
  196.         if buff.name == "sheen" then
  197.             Timer = GetGameTimer()
  198.             sFlag = true
  199.         end
  200.         if buff.name == "lucianpassivebuff" and pFlag then
  201.             pFlag = false
  202.         end
  203.     end
  204. end
  205.  
  206. function PluginOnProcessSpell(unit, spell)
  207.     if unit.isMe then
  208.         if spell.name == "LucianPassiveAttack" and pFlag then
  209.             pFlag = false
  210.         elseif spell.name == "LucianQ" or spell.name == "LucianW" or spell.name == "LucianE" or spell.name == "LucianR" and not pFlag then
  211.             pFlag = true
  212.         end
  213.     end
  214. end
  215.  
  216. function PluginOnDraw()
  217.     if Menu.qDraw and Left and Right and Top then
  218.         DrawLine(Left.x, Left.y, Right.x, Right.y, 1, 0xFF0000)
  219.         DrawLine(Left.x, Left.y, Top.x, Top.y, 1, 0xFF0000)
  220.         DrawLine(Right.x, Right.y, Top.x, Top.y, 1, 0xFF0000)
  221.         Left, Right, Top = nil, nil, nil
  222.     end
  223.    
  224.     if not myHero.dead then
  225.         if qReady and Menu.qDrawRange then
  226.             DrawCircle(myHero.x, myHero.y, myHero.z, qCastRange, 0x008080)
  227.         end
  228.         if wReady and Menu.wDrawRange then
  229.             DrawCircle(myHero.x, myHero.y, myHero.z, wRange, 0x32B2B2)
  230.         end
  231.     end
  232. end
Advertisement
Add Comment
Please, Sign In to add comment