Kain2030

Auto Carry Plugin - Lucian Edition - v1.08c

Aug 26th, 2013
2,227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 33.24 KB | None | 0 0
  1. --[[
  2.  
  3.         Auto Carry Plugin - Lucian Edition
  4.         Author: Kain
  5.         Version: 1.08c
  6.         Copyright 2013
  7.  
  8.         Dependency: Sida's Auto Carry: Revamped
  9.  
  10.         How to install:
  11.             Make sure you already have AutoCarry installed.
  12.             Name the script EXACTLY "SidasAutoCarryPlugin - Lucian.lua" without the quotes.
  13.             Place the plugin in BoL/Scripts/Common folder.
  14.        
  15.         Version History:
  16.             Version: Version: 1.08c: http://pastebin.com/D5NwQUae
  17.                 Fixed Combo weaving.
  18.                 Added spell initiation if AA unavailable.
  19.                 Fixed auto attack before Q.
  20.                 Fixed Killsteal.
  21.                 Added Smart Cast angles to Q. Won't fire if probability of missing is too high.
  22.                 Added minimum range to shoot Ultimate to avoid complete misses.
  23.                 Fixed stand still and shoot range.
  24.                 Fixed a bug with R.
  25.                 Using SAC with "Enabled Jungle Clearing" enabled doesn't use R now.
  26.             Version: 1.07e: http://pastebin.com/kgFKdwuS
  27.                 Sword of the Divine supported.
  28.                 Improved dynamic draw ranges.
  29.                 Harass fixed. Fires Q.
  30.                 Hack fixed killsteal until BoL finally gets updated properly.
  31.                 Killsteal fix resolved firing spells without key pressed.
  32.             Version: 1.07c: http://pastebin.com/tK2WNXsy
  33.                 Relentless Pursuit Out of Enemy slows.
  34.                 Tweaked prediction variables.
  35.                 Killsteal enabled.
  36.             Version: 1.06c: http://pastebin.com/sdvmmNyR
  37.                 Spell weaving.
  38.                 Draw range logic improvement.
  39.                 Menu updates.
  40.             Version: 1.05d Beta: http://pastebin.com/rE5X8puE
  41.                 Improvements to mechanics of Culling Lockon. (Still more to do here.)
  42.                 Fix issue with Ultimate ending early.
  43.                 Miscellaneous bug fixes.
  44.             Version: 1.04 Beta Pre-Release: http://pastebin.com/ayEX5Bfq
  45.                 Culling Lockon added. Considered experimental, but seems to be working pretty well.
  46.             Version: 1.02 Beta Pre-Release: http://pastebin.com/tXxr95g9
  47.             Version: 1.0 Alpha: http://pastebin.com/xWbRz89K
  48. --]]
  49.  
  50. if myHero.charName ~= "Lucian" then return end
  51.  
  52. function PluginOnLoad()
  53.     Vars()
  54.     Menu()
  55.  
  56.     AutoCarry.SkillsCrosshair.range = QMaxRange
  57. end
  58.  
  59. function Vars()
  60.     tick = nil
  61.     Target = nil
  62.  
  63.     -- Confirm ranges on release.
  64.     QRange = 550
  65.     QMaxRange = 1100
  66.     WRange = 1000
  67.     ERange = 425
  68.     RRange = 1400
  69.  
  70.     QSpeed = 19.346
  71.     WSpeed = 1.47 -- Old: 1.009
  72.     ESpeed = 3.867
  73.     RSpeed = 2.9 -- Old: 1.3
  74.  
  75.     QWidth = 250
  76.     WWidth = 250
  77.     EWidth = 250
  78.     RWidth = 250
  79.  
  80.     QDelay = 405
  81.     WDelay = 288 -- Old: 256
  82.     EDelay = 1070
  83.     RDelay = 200
  84.  
  85.     RRefresh = 0.1
  86.     RDuration = 3.2 -- Old: 3.0 2.871 - 3.167
  87.  
  88.     ParticleRProjectileName = "Lucian_R_mis.troy"
  89.     ParticleRProjectileNameOld = "bowMaster_volley_mis.troy"
  90.     ParticleR = "Lucian_R_tar.troy"
  91.     ParticleRFiring = "Lucian_R_self.troy"
  92.  
  93.     -- Start New
  94.     BuffPassive = "lucianpassivebuff" -- Old: "Lightslinger"
  95.     BuffW = "lucianwcastingbuff"
  96.     BuffR = "LucianR"
  97.  
  98.     -- End New
  99. --[[
  100.     Raw data dump:
  101.  
  102.     spellName = LucianBasicAttack
  103.     projectileName = ???
  104.     castDelay = 4001.50 (827.00-7176.00)
  105.     projectileSpeed = 6321.08 (724.19-11917.96)
  106.     range = 2594.85 (541.70-4648.01)
  107.  
  108.     spellName = LucianW
  109.     projectileName = Lucian_W_mis.troy
  110.     castDelay = 288.67 (265.00-297.00)
  111.     projectileSpeed = 1484.95 (1391.22-1640.62)
  112.     range = 661.85 (304.68-1000.83)
  113.  
  114.     spellName = LucianE
  115.     projectileName = Lucian_W_mis.troy
  116.     castDelay = 8189.75 (0.00-32245.00)
  117.     projectileSpeed = 25590.51 (703.58-79656.61)
  118.     range = 3772.70 (372.90-8054.26)
  119.  
  120.     spellName = LucianR
  121.     projectileName = Lucian_R_mis.troy
  122.     castDelay = 210.50 (187.00-234.00)
  123.     projectileSpeed = 2850.25 (2342.64-3357.86)
  124.     range = 405.05 (261.91-548.18)
  125.  
  126.     Raw data dump #2:
  127.  
  128.     spellName = LucianW
  129.     projectileName = Lucian_W_mis.troy
  130.     castDelay = 313.81 (265.00-453.00)
  131.     projectileSpeed = 1459.60 (558.14-1797.76)
  132.     range = 648.24 (17.30-1007.14)
  133.  
  134.     spellName = LucianE
  135.     projectileName = Lucian_W_mis.troy
  136.     castDelay = 2147.83 (0.00-10530.00)
  137.     projectileSpeed = 4680.15 (632.65-14746.30)
  138.     range = 3349.24 (809.79-8272.67)
  139.  
  140.     spellName = LucianR
  141.     projectileName = Lucian_R_mis.troy
  142.     castDelay = 199.80 (172.00-218.00)
  143.     projectileSpeed = 3023.31 (2816.79-3321.66)
  144.     range = 757.80 (205.94-1063.38)
  145.  
  146. --]]
  147.  
  148.     SkillQ = {spellKey = _Q, range = QRange, speed = QSpeed, delay = QDelay, width = QWidth, configName = "piercinglight", displayName = "Q (Piercing Light)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = true }
  149.     SkillW = {spellKey = _W, range = WRange, speed = WSpeed, delay = WDelay, width = WWidth, configName = "ardentblaze", displayName = "W (Ardent Blaze)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = false }
  150.     SkillE = {spellKey = _E, range = ERange, speed = ESpeed, delay = EDelay, width = EWidth, configName = "relentlesspursuit", displayName = "E (Relentless Pursuit)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = false }
  151.     SkillR = {spellKey = _R, range = RRange, speed = RSpeed, delay = RDelay, width = RWidth, configName = "theculling", displayName = "R (The Culling)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = true }
  152.  
  153.     KeyQ = string.byte("Q")
  154.     KeyW = string.byte("W")
  155.     KeyE = string.byte("E")
  156.     KeyR = string.byte("R")
  157.  
  158.     KeyTest = string.byte("U")
  159.  
  160.     DFGSlot, HXGSlot, BWCSlot, STDSlot, SheenSlot, TrinitySlot, LichBaneSlot = nil, nil, nil, nil, nil, nil, nil
  161.     QReady, WReady, EReady, RReady, DFGReady, HXGReady, BWCReady, STDReady, IReady = false, false, false, false, false, false, false, false
  162.  
  163.     ultCastTick = 0
  164.     ultCastTarget = nil
  165.     ultVectorX = nil
  166.     ultVectorZ = nil
  167.  
  168.     isSlowed = false
  169.  
  170.     healthLastTick = 0
  171.     healthLastHealth = 0
  172.  
  173.     isUltFiring = false
  174.     lastUltMessage = 0
  175.  
  176.     comboActive = false
  177.     nextAttack = 0
  178.     lastSpell = 0
  179.  
  180.     -- Angles
  181.     angle_towards = 180
  182.     angle_away = 0
  183.     angle_parallel_towards = 90
  184.     angle_parallel_away = 270
  185.     angle_unknown = -1
  186.  
  187.     debugMode = false
  188.     debugModeDisableNonR = false
  189. end
  190.  
  191. function Menu()
  192.     AutoCarry.PluginMenu:addParam("sep", "----- [ Combo ] -----", SCRIPT_PARAM_INFO, "")
  193.     AutoCarry.PluginMenu:addParam("Combo", "Combo - Default Spacebar", SCRIPT_PARAM_INFO, "")
  194.     AutoCarry.PluginMenu:addParam("FullCombo", "Insta Blast Combo (No AA)", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("Z"))
  195.     AutoCarry.PluginMenu:addParam("ComboQ", "Use Piercing Light", SCRIPT_PARAM_ONOFF, true)
  196.     AutoCarry.PluginMenu:addParam("ComboW", "Use Ardent Blaze", SCRIPT_PARAM_ONOFF, true)
  197.     AutoCarry.PluginMenu:addParam("ComboE", "Use Relentless Pursuit", SCRIPT_PARAM_ONOFF, true)
  198.     AutoCarry.PluginMenu:addParam("ComboR", "Use The Culling", SCRIPT_PARAM_ONOFF, true)
  199.     AutoCarry.PluginMenu:addParam("SmartE", "Smart Relentless Pursuit", SCRIPT_PARAM_ONOFF, true)
  200.     AutoCarry.PluginMenu:addParam("UltLockOn", "Use Ultimate Lock On (Beta)", SCRIPT_PARAM_ONOFF, true)
  201.     AutoCarry.PluginMenu:addParam("sep", "----- [ Misc ] -----", SCRIPT_PARAM_INFO, "")
  202.     AutoCarry.PluginMenu:addParam("PursuitSlow", "Pursuit Out of Slows", SCRIPT_PARAM_ONOFF, true)
  203.     AutoCarry.PluginMenu:addParam("AutoHarass", "Auto Harass", SCRIPT_PARAM_ONOFF, false)
  204.     AutoCarry.PluginMenu:addParam("sep", "----- [ Killsteal ] -----", SCRIPT_PARAM_INFO, "")
  205.     AutoCarry.PluginMenu:addParam("Killsteal", "Killsteal", SCRIPT_PARAM_ONOFF, true)
  206. --  AutoCarry.PluginMenu:addParam("KillstealUlt", "Killsteal with Ult", SCRIPT_PARAM_ONOFF, false)
  207.     AutoCarry.PluginMenu:addParam("sep", "----- [ Advanced ] -----", SCRIPT_PARAM_INFO, "")
  208.     AutoCarry.PluginMenu:addParam("EMinMouseDiff", "Pursuit Min. Mouse Diff.", SCRIPT_PARAM_SLICE, 600, 100, 1000, 0)
  209.     AutoCarry.PluginMenu:addParam("ProMode", "Use Auto QWER Keys", SCRIPT_PARAM_ONOFF, true)
  210.     AutoCarry.PluginMenu:addParam("MaxSpellAngle", "Max Spell Angle", SCRIPT_PARAM_SLICE, 35, 5, 90, 0)
  211.     AutoCarry.PluginMenu:addParam("UltClose", "Don't Ult Closer Than", SCRIPT_PARAM_SLICE, 150, 50, 800, 0)
  212. --  AutoCarry.PluginMenu:addParam("HealthPercentage", "Health Drop %", SCRIPT_PARAM_SLICE, 0, 0, 100, 0)
  213. --  AutoCarry.PluginMenu:addParam("HealthTime", "Health Tracking Time", SCRIPT_PARAM_SLICE, 0, 2, 5, 0)
  214.     AutoCarry.PluginMenu:addParam("sep", "----- [ Draw ] -----", SCRIPT_PARAM_INFO, "")
  215.     AutoCarry.PluginMenu:addParam("DisableDraw", "Disable Draw", SCRIPT_PARAM_ONOFF, false)
  216.     AutoCarry.PluginMenu:addParam("DrawFurthest", "Draw Furthest Spell Available", SCRIPT_PARAM_ONOFF, true)
  217.     AutoCarry.PluginMenu:addParam("DrawQ", "Draw Piercing Light", SCRIPT_PARAM_ONOFF, true)
  218.     AutoCarry.PluginMenu:addParam("DrawW", "Draw Ardent Blaze", SCRIPT_PARAM_ONOFF, true)
  219.     AutoCarry.PluginMenu:addParam("DrawE", "Draw Relentless Pursuit", SCRIPT_PARAM_ONOFF, true)
  220.     AutoCarry.PluginMenu:addParam("DrawR", "Draw The Culling", SCRIPT_PARAM_ONOFF, true)
  221. end
  222.  
  223. function PluginOnTick()
  224.     tick = GetTickCount()
  225.     Target = AutoCarry.GetAttackTarget(true)
  226.  
  227.     SpellCheck()
  228.  
  229.     -- GetTickCount() % 5 == 0) and
  230.     if IsTickReady(25) and IsFiringUlt() then
  231.         CheckRPosition()
  232.     else
  233.         if AutoCarry.MainMenu.AutoCarry then
  234.             comboActive = true
  235.             Combo()
  236.         else
  237.             comboActive = false
  238.         end
  239.  
  240.         if AutoCarry.PluginMenu.FullCombo then
  241.             FullCombo()
  242.         end
  243.  
  244.         if AutoCarry.MainMenu.MixedMode or AutoCarry.PluginMenu.AutoHarass then
  245.             Harass()
  246.         end
  247.  
  248.         if AutoCarry.PluginMenu.Killsteal then
  249.             KillSteal()
  250.         end
  251.     end
  252. end
  253.  
  254. function PluginOnCreateObj(obj)
  255.     -- Nothing to do here.
  256.     if obj.name == ParticleRFiring then
  257.         if debugMode then PrintChat("Ult Particle Started") end
  258.         isUltFiring = true
  259.         if debugMode then PrintChat("start: "..(GetTickCount() / 1000)) end
  260.     end
  261. end
  262.  
  263. function PluginOnDeleteObj(obj)
  264.     if obj.name == ParticleRFiring then
  265.         if debugMode then PrintChat("Ult Particle Stopped") end
  266.         isUltFiring = false
  267.         UltFireStop()
  268.         if debugMode then PrintChat("stop: "..(GetTickCount() / 1000)) end
  269.     end
  270. end
  271.  
  272. function OnAttacked()
  273.     -- AA > Q > AA
  274.     ComboWeave(true)
  275. end
  276.  
  277. --[[
  278. function CustomAttackEnemy(enemy)
  279.         if enemy.dead or not enemy.valid then return end
  280.         -- myHero:Attack(enemy)
  281.         -- AutoCarry.shotFired = true
  282. end
  283. --]]
  284.  
  285. function OnGainBuff(unit, buff)
  286.     if buff and buff.type ~= nil and unit.name == myHero.name and unit.team == myHero.team and (buff.type == 5 or buff.type == 10 or buff.type == 11) then
  287.         -- BUFF_STUN = 5 BUFF_SLOW = 10 BUFF_ROOT = 11
  288.         if AutoCarry.PluginMenu.PursuitSlow then
  289.             isSlowed = true
  290.             CastE()
  291.         end
  292.     end
  293. end
  294.  
  295. function SpellCheck()
  296.     DFGSlot, HXGSlot, BWCSlot, BRKSlot, STDSlot, SheenSlot, TrinitySlot, LichBaneSlot = GetInventorySlotItem(3128),
  297.     GetInventorySlotItem(3146), GetInventorySlotItem(3144), GetInventorySlotItem(3153), GetInventorySlotItem(3131),
  298.     GetInventorySlotItem(3057), GetInventorySlotItem(3078), GetInventorySlotItem(3100)
  299.  
  300.     QReady = (myHero:CanUseSpell(SkillQ.spellKey) == READY)
  301.     WReady = (myHero:CanUseSpell(SkillW.spellKey) == READY)
  302.     EReady = (myHero:CanUseSpell(SkillE.spellKey) == READY)
  303.     RReady = (myHero:CanUseSpell(SkillR.spellKey) == READY)
  304.  
  305.     DFGReady = (DFGSlot ~= nil and myHero:CanUseSpell(DFGSlot) == READY)
  306.     HXGReady = (HXGSlot ~= nil and myHero:CanUseSpell(HXGSlot) == READY)
  307.     BWCReady = (BWCSlot ~= nil and myHero:CanUseSpell(BWCSlot) == READY)
  308.     BRKReady = (BRKSlot ~= nil and myHero:CanUseSpell(BRKSlot) == READY)
  309.     STDReady = (STDSlot ~= nil and myHero:CanUseSpell(BRKSlot) == READY)
  310.  
  311.     IReady = (ignite ~= nil and myHero:CanUseSpell(ignite) == READY)
  312. end
  313.  
  314. -- Handle SBTW Skill Shots
  315.  
  316. function Combo()
  317.     if not Target then return end
  318.     ComboWeave()
  319. end
  320.  
  321. function ComboWeave(attacked)
  322.     if AutoCarry.MainMenu.MixedMode or AutoCarry.PluginMenu.AutoHarass then CastQ() end
  323.  
  324.     if AutoCarry.MainMenu.AutoCarry then
  325.         CastSlots()
  326.  
  327.         if not attacked and tick > (lastSpell + 3000) then
  328.             if not AutoCarry.PluginMenu.ComboW or (AutoCarry.PluginMenu.ComboW and not CastW()) then
  329.                 if AutoCarry.PluginMenu.ComboQ then CastQ() end
  330.             end
  331.         elseif comboActive then -- and GetTickCount() > nextAttack then
  332.             nextAttack = AutoCarry.GetNextAttackTime()
  333.  
  334.             if AutoCarry.PluginMenu.ComboW then
  335.                 if CastW() then return end
  336.             end
  337.  
  338.             if AutoCarry.PluginMenu.ComboE then
  339.                 if CastE() then return end
  340.             end
  341.  
  342.             if AutoCarry.PluginMenu.ComboQ then
  343.                 if CastQ() then return end
  344.             end
  345.  
  346.             if AutoCarry.PluginMenu.ComboR then
  347.                 if CastR() then return end
  348.             end
  349.  
  350.             comboActive = false
  351.         end
  352.     end
  353. end
  354.  
  355. function FullCombo()
  356.     CastSlots()
  357.     CastW()
  358.     CastE()
  359.     CastQ()
  360.     CastR()
  361. end
  362.  
  363. function CastSlots()
  364.     if Target ~= nil then
  365.         if GetDistance(Target) <= QRange then
  366.             if DFGReady then CastSpell(DFGSlot, Target) end
  367.             if HXGReady then CastSpell(HXGSlot, Target) end
  368.             if BWCReady then CastSpell(BWCSlot, Target) end
  369.             if BRKReady then CastSpell(BRKSlot, Target) end
  370.             if STDReady then CastSpell(STDSlot, Target) end
  371.         end
  372.     end
  373. end
  374.  
  375. function Harass()
  376.     CastQ()
  377. end
  378.  
  379. function IsTickReady(tickFrequency)
  380.     -- Improves FPS
  381.     -- Disabled for now.
  382.     if 1 == 1 then return true end
  383.  
  384.     if tick ~= nil and math.fmod(tick, tickFrequency) == 0 then
  385.         return true
  386.     else
  387.         return false
  388.     end
  389. end
  390.  
  391. function UpdateLastSpellTime()
  392.     lastSpell = tick
  393. end
  394.  
  395. function CastQ(enemy)
  396.     -- Q (Piercing Light)
  397.     if not enemy then enemy = Target end
  398.  
  399.     if enemy and not enemy.dead and QReady and ValidTarget(enemy, QRange) then
  400.         if debugMode then PrintChat("Cast Q") end
  401.  
  402.         local tpQ = VIP_USER and TargetPredictionVIP(SkillQ.range, SkillQ.speed*1000, 0, SkillR.width) or TargetPrediction(SkillQ.range, SkillQ.speed, 0, SkillQ.width)
  403.  
  404.         local angleDiff = nil
  405.         if tpQ then
  406.             local predPos = tpQ:GetPrediction(enemy)
  407.             if predPos then
  408.                 angleDiff = GetAngle(enemy, predPos)
  409.             end
  410.         end
  411.    
  412.         if not angleDiff or (IsGoodAngle(angleDiff, AutoCarry.PluginMenu.MaxSpellAngle)) then
  413.             CastSpell(SkillQ.spellKey, enemy)
  414.             UpdateLastSpellTime()
  415.             return true
  416.         end
  417.     end
  418.  
  419.     return false
  420. end
  421.  
  422. function CastW(enemy)
  423.     -- W (Ardent Blaze)
  424.     if not enemy then enemy = Target end
  425.  
  426.     if enemy and not enemy.dead and WReady and ValidTarget(enemy, WRange) then
  427.         if debugMode then PrintChat("Cast W") end
  428.         AutoCarry.CastSkillshot(SkillW, enemy)
  429.         UpdateLastSpellTime()
  430.         return true
  431.     end
  432.  
  433.     return false
  434. end
  435.  
  436. --[[
  437. function CastEOld()
  438.     -- E (Relentless Pursuit)
  439.     if debugMode then
  440.         -- PrintChat("Mouse Distance: "..GetDistance(mousePos))
  441.     end
  442.  
  443.     if EReady then
  444.         -- if ( math.abs(mousePos.x - myHero.x) > PursuitMinMouseDiff or math.abs(mousePos.z - myHero.z) > PursuitMinMouseDiff) then
  445.         if ((GetDistance(mousePos) > PursuitMinMouseDiff) and isEnemyInRange(SkillE.range + SkillR.range)) then
  446.             if debugMode then PrintChat("Cast E") end
  447.             CastSpell(SkillE.spellKey, mousePos.x, mousePos.z)
  448.         end
  449.     end
  450. end
  451. --]]
  452.  
  453. function CastE()
  454.     if EReady then
  455.         if AutoCarry.PluginMenu.SmartE then
  456.             if ((GetDistance(mousePos) > AutoCarry.PluginMenu.EMinMouseDiff or isSlowed) and isEnemyInRange(SkillE.range + SkillR.range)) then
  457.                 local dashSqr = math.sqrt((mousePos.x - myHero.x)^2+(mousePos.z - myHero.z)^2)
  458.                 local dashX = myHero.x + ERange*((mousePos.x - myHero.x)/dashSqr)
  459.                 local dashZ = myHero.z + ERange*((mousePos.z - myHero.z)/dashSqr)
  460.                 CastSpell(SkillE.spellKey, dashX, dashZ)
  461.                 UpdateLastSpellTime()
  462.                 isSlowed = false
  463.                 return true
  464.             end
  465.         else
  466.             CastSpell(SkillE.spellKey, mousePos.x, mousePos.z)
  467.             UpdateLastSpellTime()
  468.             isSlowed = false
  469.             return true
  470.         end
  471.     end
  472.  
  473.     return false
  474. end
  475.  
  476. function CastR(enemy)
  477.     if not enemy then enemy = Target end
  478.  
  479.     -- R (The Culling)
  480.     if enemy and not enemy.dead and RReady and ValidTarget(enemy, RRange) and enemy.type == myHero.type then
  481.         if GetDistance(enemy) < AutoCarry.PluginMenu.UltClose then return false end
  482.  
  483.         if not IsFiringUlt() then
  484.             if debugMode then PrintChat("Cast R") end
  485.             if not isUltFiring then
  486.                 AutoCarry.CastSkillshot(SkillR, enemy)
  487.                 UpdateLastSpellTime()
  488.                 if AutoCarry.PluginMenu.UltLockOn and GetTickCount() > (lastUltMessage + 2000) then
  489.                     lastUltMessage = GetTickCount()
  490.                     PrintFloatText(myHero, 10, "Ultimate Locked On!")
  491.                 end
  492.             end
  493.  
  494.             ultCastTarget = enemy
  495.             ultCastTick = GetTickCount()
  496.  
  497.             -- Vector from target -> myHero
  498.             if ultVectorX == nil and ultVectorZ == nil then
  499.                 if debugMode and false then PrintChat("update x,z") end
  500.                 ultVectorX,y,ultVectorZ = (Vector(myHero) - Vector(ultCastTarget)):normalized():unpack()
  501.             end
  502.         end
  503.  
  504.         CheckRPosition()
  505.     end
  506. end
  507.  
  508. function CheckRPosition()
  509.     if (ultCastTick > 0) then
  510.         if debugMode and IsFiringUlt() then burp = "true" else burp = "false" end
  511.         if debugMode and false then PrintChat("Tick: "..GetTickCount()..", ultCastTick: "..ultCastTick..", RDuration: "..(ultCastTick + (RDuration * 1000))..", IsFiringUlt: "..burp) end
  512.     end
  513.  
  514.     if AutoCarry.PluginMenu.UltLockOn and IsFiringUlt() then
  515.         MoveMyHeroToRPosition()
  516.     end
  517. end
  518.  
  519. function MoveMyHeroToRPosition()
  520.     -- Please don't steal this function!
  521.     local tpR = VIP_USER and TargetPredictionVIP(SkillR.range, SkillR.speed*1000, RRefresh, SkillR.width) or TargetPrediction(SkillR.range, SkillR.speed, RRefresh*1000, SkillR.width)
  522.  
  523.     local target = nil
  524.     if ultCastTarget ~= nil then
  525.         target = ultCastTarget
  526.     else
  527.         target = Target
  528.     end
  529.  
  530.     local predR = tpR:GetPrediction(target)
  531.  
  532.     if not predR then return end
  533.  
  534.     local RRangeBuffered = RRange * .98 -- Allow a bit of slippage for targets running away.
  535.     local posX = predR.x + (ultVectorX * RRangeBuffered)
  536.     local posZ = predR.z + (ultVectorZ * RRangeBuffered)
  537.  
  538.     -- Thank you, Pythagoras
  539.     -- local distanceBetweenPoints = math.sqrt((predR.x - posX)^2 + (predR.z - posZ)^2)
  540.     -- local distanceBetweenPoints = GetDistance(Point(posX, posZ), predR)
  541.     -- local posXRanged = (posX + (posX - predR.x)) / distanceBetweenPoints * RRangeBuffered
  542.     -- local posZRanged = (posZ + (posZ - predR.z)) / distanceBetweenPoints * RRangeBuffered
  543.  
  544.     local predRPath = LineSegment(Point(predR.x, predR.z), Point(posX, posZ))
  545.  
  546.     local closePoint = nil
  547.     if predRPath ~= nil then
  548.         closePoint = Point(myHero.x, myHero.z):closestPoint(predRPath)
  549.     else
  550.         if debugMode then PrintChat("predRPath is nil") end
  551.     end
  552.  
  553.     if debugMode and closePoint ~= nil then
  554.         --  PrintChat("moveto: "..posX..", "..posZ.."... targetat: "..ultCastTarget.x..", "..ultCastTarget.z..", ultVectorX: "..ultVectorX..", ultVectorZ: "..ultVectorZ..", RDuration: "..RDuration)
  555.         --  PrintChat("posXRanged: "..posXRanged..", posZRanged: "..posZRanged..", closePoint: "..closePoint.x..", "..closePoint.y)
  556.         PrintChat("moveto: "..closePoint.x..", "..closePoint.y.."; targetat: "..predR.x..", "..predR.z..", ultVectorX: "..ultVectorX..", ultVectorZ: "..ultVectorZ)
  557.     end
  558.  
  559.     if debugMode then
  560.         PrintChat("distance: method 1: "..GetDistance(closePoint, predR)..", method 2: "..GetDistance(Point(posX, posZ), predR))
  561.     end
  562.  
  563.     if predRPath ~= nil and closePoint ~= nil and not IsWall(D3DXVECTOR3(closePoint.x, myHero.y, closePoint.y)) and GetDistance(closePoint, predR) > ERange then
  564.         -- Closest Point Method
  565.         if debugMode then PrintChat("Move: Method 1") end
  566.         myHero:MoveTo(closePoint.x, closePoint.y)
  567.     elseif predR ~= nil and posX ~= nil and posZ ~= nil and not IsWall(D3DXVECTOR3(posX, myHero.y, posZ))
  568.         -- and GetDistance(Point(posX, posZ), predR) > 500
  569.         and GetDistance(Point(posX, posZ), predR) < RRange and GetDistance(Point(posX, posZ), predR) > 100 then
  570.         -- Full Vector Method
  571.         if debugMode then PrintChat("Move: Method 2") end
  572.         if (GetTickCount() > (lastUltMessage + 2000)) then
  573.             -- lastUltMessage = GetTickCount()
  574.             -- PrintFloatText(myHero, 10, "Ultimate Manual Mode!")
  575.         end
  576.         myHero:MoveTo(posX, posZ)
  577. --  elseif not IsWall(D3DXVECTOR3(posXRanged, myHero.y, posZRanged)) then
  578. --      -- Last Ditch Method
  579. --      if debugMode then PrintChat("Move: Method 3") end
  580. --      myHero:MoveTo(posXRanged, posZRanged)
  581.     else
  582.         -- Fallback to User Aiming
  583.         if debugMode then PrintChat("Move: Wall") end
  584.         myHero:MoveTo(mousePos.x, mousePos.z)
  585.     end
  586.     -- myHero:MoveTo(posXRanged, posZRanged)
  587. end
  588.  
  589. function getDistanceBetweenPoints(pointA, pointB)
  590.     -- Thank you, Pythagoras
  591.     local distanceBetweenPoints = math.sqrt((predR.x - posX)^2 + (predR.z - posZ)^2)
  592. end
  593.  
  594. function IsFiringUlt()
  595.     local tickCount = GetTickCount()
  596.  
  597.     -- if (ultCastTick > 0) and (tickCount >= ultCastTick) and (tickCount <= (ultCastTick + (RDuration * 1000))) and not RReady and ultCastTarget ~= nil and not ultCastTarget.dead then
  598.     if (ultCastTick > 0) and (tickCount >= ultCastTick) and isUltFiring and ultCastTarget ~= nil and not ultCastTarget.dead then
  599.         AutoCarry.CanMove = false
  600.         return true
  601.     else
  602.         -- UltFireStop()
  603.         return false
  604.     end
  605. end
  606.  
  607. function UltFireStop()
  608.     ultCastTick = 0
  609.     ultVectorX = nil
  610.     ultVectorZ = nil
  611.     AutoCarry.CanMove = true
  612. end
  613.  
  614. function isEnemyInRange(range)
  615.     for _, enemy in pairs(AutoCarry.EnemyTable) do
  616.         if ValidTarget(enemy, range) and not enemy.dead then
  617.             return true
  618.         end
  619.     end
  620.  
  621.     return false
  622. end
  623.  
  624. --[[
  625. function TakingRapidDamage()
  626.     if GetTickCount() - healthLastTick > (AutoCarry.PluginMenu.HealthTime * 1000) then
  627.         --> Check amount of health lost
  628.         if myHero.health - healthLastHealth > myHero.maxHealth * (AutoCarry.PluginMenu.HealthPercentage / 100) then
  629.             return true
  630.         else
  631.             --> Reset counters
  632.             healthLastTick = GetTickCount()
  633.             healthLastHealth = myHero.health
  634.         end
  635.     end
  636. end
  637. --]]
  638.  
  639. function KillSteal()
  640.     -- Will try to perform a killsteam using any spell.
  641.     if not AutoCarry.PluginMenu.Killsteal then return end
  642.  
  643.     -- Killsteal disabled until Bol update for Lucian
  644.  
  645.     for _, enemy in pairs(AutoCarry.EnemyTable) do
  646.         if enemy and not enemy.dead then
  647.             -- getDmg broken in BoL for Lucian right now.
  648.             local qDmg = GetDamage(enemy, _Q) -- getDmg("Q", enemy, myHero)
  649.             local wDmg = GetDamage(enemy, _W) -- getDmg("W", enemy, myHero)
  650.             -- local rDmg = 50 -- getDmg("R", enemy, myHero)
  651.  
  652.             if QReady and ValidTarget(enemy, QRange) and enemy.health < qDmg then
  653.                 if debugMode then PrintChat("Cast Q KS") end
  654.                 CastQ(enemy)
  655.             elseif WReady and ValidTarget(enemy, WRange) and enemy.health < wDmg then
  656.                 if debugMode then PrintChat("Cast W KS") end
  657.                 CastW(enemy)
  658.             elseif QReady and WReady and ValidTarget(enemy, QRange) and ValidTarget(enemy, WRange) and enemy.health < (qDmg + wDmg) then
  659.                 if debugMode then PrintChat("Cast Q + W KS") end
  660.                 CastW(enemy)
  661.                 if not enemy.dead then
  662.                     CastQ(enemy)
  663.                 end
  664.             -- Ultimate is not a viable killsteal since the number of individual shots to hit can not be pre-determined.
  665.             -- elseif AutoCarry.PluginMenu.KillstealUlt and RReady and ValidTarget(enemy, RRange) and (enemy.health + 20) < rDmg then
  666.             --  if debugMode then PrintChat("Cast R KS") end
  667.             --  CastR(enemy)
  668.             end
  669.  
  670.         end
  671.     end
  672. end
  673.  
  674. function GetDamage(enemy, spell)
  675.     if spell == _Q then
  676.         return myHero:CalcDamage(enemy, ((40*(myHero:GetSpellData(_Q).level-1) + 80) + (((.15 * (myHero:GetSpellData(_Q).level-1)) + .60) * myHero.addDamage)))
  677.     elseif spell == _W then
  678.         return myHero:CalcMagicDamage(enemy, ((40*(myHero:GetSpellData(_Q).level-1) + 60) + (.90 * myHero.ap) + (.60 * myHero.addDamage)))
  679.     end
  680. end
  681.  
  682. function PluginOnWndMsg(msg,key)
  683.     Target = AutoCarry.GetAttackTarget()
  684.     if Target ~= nil and AutoCarry.PluginMenu.ProMode then
  685.         -- if msg == KEY_DOWN and key == KeyQ then CastQ() end
  686.         if msg == KEY_DOWN and key == KeyW then CastW() end
  687.         if msg == KEY_DOWN and key == KeyE then CastE() end
  688.         if msg == KEY_DOWN and key == KeyR then CastR() end
  689.         if msg == KEY_DOWN and key == KeyTest and debugMode then
  690.             if ultVectorX == nil and ultVectorZ == nil then
  691.                 ultCastTarget = Target
  692.                 ultVectorX,y,ultVectorZ = (Vector(myHero) - Vector(ultCastTarget)):normalized():unpack()
  693.             end
  694.             MoveMyHeroToRPosition()
  695.         end
  696.        
  697.         if msg == KEY_UP and key == KeyTest and debugMode then
  698.             ultVectorX = nil
  699.             ultVectorZ = nil
  700.         end
  701.     end
  702. end
  703.  
  704. -- Draw
  705. function PluginOnDraw()
  706.     -- if Target ~= nil and not Target.dead and QReady and ValidTarget(Target, QMaxRange) then
  707.     if Target ~= nil and not Target.dead and (AutoCarry.MainMenu.AutoCarry or AutoCarry.MainMenu.MixedMode) then
  708.         DrawArrowsToPos(myHero, Target)
  709.     end
  710.  
  711.     if not AutoCarry.PluginMenu.DisableDraw and not myHero.dead then
  712.         local farSpell = FindFurthestReadySpell()
  713.         -- if debugMode and farSpell then PrintChat("far: "..farSpell.configName) end
  714.  
  715.         -- Not needed as SAC has the same range draw.
  716.         -- DrawCircle(myHero.x, myHero.y, myHero.z, getTrueRange(), 0x808080) -- Gray
  717.  
  718.         if AutoCarry.PluginMenu.DrawQ and QReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillQ) or not AutoCarry.PluginMenu.DrawFurthest) then
  719.             DrawCircle(myHero.x, myHero.y, myHero.z, QRange, 0x0099CC) -- Blue
  720.         end
  721.  
  722.         if AutoCarry.PluginMenu.DrawW and WReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillW) or not AutoCarry.PluginMenu.DrawFurthest) then
  723.             DrawCircle(myHero.x, myHero.y, myHero.z, WRange, 0xFFFF00) -- Yellow
  724.         end
  725.        
  726.         if AutoCarry.PluginMenu.DrawE and EReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillE) or not AutoCarry.PluginMenu.DrawFurthest) then
  727.             DrawCircle(myHero.x, myHero.y, myHero.z, ERange, 0x00FF00) -- Green
  728.         end
  729.  
  730.         if AutoCarry.PluginMenu.DrawR and RReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillR) or not AutoCarry.PluginMenu.DrawFurthest) then
  731.             DrawCircle(myHero.x, myHero.y, myHero.z, RRange, 0xFF0000) -- Red
  732.         end
  733.  
  734.         Target = AutoCarry.GetAttackTarget()
  735.         if Target ~= nil then
  736.             for j=0, 10 do
  737.                 DrawCircle(Target.x, Target.y, Target.z, 40 + j*1.5, 0x00FF00) -- Green
  738.             end
  739.         end
  740.  
  741.     end
  742. end
  743.  
  744. function FindFurthestReadySpell()
  745.     local farSpell = nil
  746.  
  747.     if AutoCarry.PluginMenu.DrawQ and QReady then farSpell = SkillQ end
  748.     if AutoCarry.PluginMenu.DrawW and WReady and (not farSpell or WRange > farSpell.range) then farSpell = SkillW end
  749.     if AutoCarry.PluginMenu.DrawE and EReady and (not farSpell or ERange > farSpell.range) then farSpell = SkillE end
  750.     if AutoCarry.PluginMenu.DrawR and RReady and (not farSpell or RRange > farSpell.range) then farSpell = SkillR end
  751.  
  752.     return farSpell
  753. end
  754.  
  755. function getTrueRange()
  756.     return myHero.range + GetDistance(myHero.minBBox)
  757. end
  758.  
  759. function DrawArrowsToPos(pos1, pos2)
  760.     if pos1 and pos2 then
  761.         startVector = D3DXVECTOR3(pos1.x, pos1.y, pos1.z)
  762.         endVector = D3DXVECTOR3(pos2.x, pos2.y, pos2.z)
  763.         -- directionVector = (endVector-startVector):normalized()
  764.         DrawArrows(startVector, endVector, 60, 0xE97FA5, 100)
  765.     end
  766. end
  767.  
  768. --[[
  769. function test1(skill, enemy)
  770.     local tp = VIP_USER and TargetPredictionVIP(8000, skill.speed*1000, 0, SkillR.width) or TargetPrediction(skill.range, skill.speed, 0, skill.width)
  771.     -- local tp = TargetPredictionVIP(8000, math.huge, skill.delay, SkillR.width)
  772.     --local tp = TargetPredictionVIP(8000, math.huge, 0.535, 75)
  773.     GetEnemyPrediction(enemy, tp)
  774. end
  775. --]]
  776.  
  777. function GetEnemyPrediction(enemy, tp)
  778.     -- local tpQ = VIP_USER and TargetPredictionVIP(SkillQ.range, SkillQ.speed*1000, SkillQ.delay, SkillR.width) or TargetPrediction(SkillQ.range, SkillQ.speed, SkillQ.delay*1000, SkillQ.width)
  779.  
  780.     if not enemy or enemy.dead or not tp or not QReady then return nil end
  781.  
  782.     -- local predPos, p2, p3 = tp:GetPrediction(enemy)
  783.     local predPos = tp:GetPrediction(enemy)
  784.    
  785.     if not predPos then return nil end
  786.  
  787.     GetAngle(enemy, predPos)
  788. end
  789.  
  790. -- Angle Functions
  791. function IsGoodAngle(angleDiff, variance)
  792.     local direction = Directionality(angleDiff, variance)
  793.    
  794.     if direction == angle_towards or direction == angle_away then
  795.         return true
  796.     else
  797.         return false
  798.     end
  799. end
  800.  
  801. function GetAngle(enemy, predPos)
  802.     -- ultVectorX,y,ultVectorZ = (Vector(myHero) - Vector(ultCastTarget)):normalized():unpack()
  803.  
  804.         -- v1 = Vector(predPos.x - myHero.x, predPos.z - myHero.z):normalized()
  805.     -- v2 = Vector((Vector(predPos) - Vector(enemy)):normalized())
  806.         -- v2 = Vector(predPos.x - enemy.x, predPos.z - enemy.z):normalized()
  807.     -- v2 = Vector(coneTargetsTable[j].x-player.x , coneTargetsTable[j].z-player.z)
  808.  
  809.     v1 = (Vector(predPos) - Vector(myHero)):normalized()
  810.  
  811.     if predPos.x == enemy.x and predPos.z == enemy.z then
  812.         -- Enemy is standing still.
  813.         return false
  814.     end
  815.    
  816.  
  817.     v2 = (Vector(predPos) - Vector(enemy)):normalized()
  818. -- PrintChat("a"..predPos.x.."!"..enemy.x.."!"..v2.x.."!"..v2.z)
  819. --  if not v2 or v2 == -1 then
  820. --      return false
  821. --  end
  822.     -- shootTheta = sign(v1.z)*90-math.deg(math.atan2(v1.z, v1.x))
  823.     -- enemyTheta = sign(v2.z)*90-math.deg(math.atan2(v2.z, v2.x))
  824.     -- angle = enemyTheta-shootTheta
  825.  
  826.     shootTheta = math.deg(math.atan2(v1.z, v1.x))
  827.     enemyTheta = math.deg(math.atan2(v2.z, v2.x))
  828.  
  829.     if shootTheta < 0 then
  830.         shootTheta = shootTheta + 360  
  831.     end
  832.  
  833.     if enemyTheta < 0 then
  834.         enemyTheta = enemyTheta + 360
  835.     end
  836.  
  837.     angleDiff = math.abs(enemyTheta - shootTheta)
  838.  
  839.     local angleView = ""
  840.     local angleVariance = 30
  841.  
  842.     angleView = Directionality(angleDiff, AutoCarry.PluginMenu.MaxSpellAngle)
  843.    
  844.     if angleView ~= nil then
  845.         -- PrintChat("v1: "..shootTheta..", v2: "..enemyTheta..", angle: "..angle..", angleView: "..angleView..", predx: "..predPos.x..", predz: "..predPos.z..", hittime: "..p2..", posx: "..p3.x..", posz: "..p3.z)
  846.         -- PrintChat("v1: "..shootTheta..", v2: "..enemyTheta..", angleDiff: "..angleDiff..", angleView: "..angleView..", predx: "..predPos.x..", predz: "..predPos.z)
  847.     end
  848.  
  849.     return angleDiff
  850. end
  851.  
  852. function Directionality(angleDiff, variance)
  853.     if betweenRounded(angleDiff, variance, angle_away) then
  854.         return angle_away
  855.     elseif betweenRounded(angleDiff, variance, angle_towards) then
  856.         return angle_towards
  857.     elseif betweenRounded(angleDiff, variance, angle_parallel_towards) then
  858.         return angle_parallel_towards
  859.     elseif betweenRounded(angleDiff, variance, angle_parallel_away) then
  860.         return angle_parallel_away
  861.     else
  862.         return angle_unknown
  863.     end
  864. end
  865.  
  866. function betweenRounded(angleDiff, variance, angle) -- diff = known angle between two people, variance is allowed slippage, angle = goal you want if true
  867.     low = angle - variance
  868.     high = angle + variance
  869.  
  870.     if low <= 0 then
  871.         return (low + 360 <= angleDiff or angleDiff <= high)
  872.     else
  873.         return (low <= angleDiff and angleDiff <= high)
  874.     end
  875. end
  876.  
  877. function sign(x)
  878.     if x > 0 then return 1
  879.     elseif x < 0 then return -1
  880.     end
  881. end
  882.  
  883. --[[
  884. class 'ColorARGB' -- {
  885.  
  886.     function ColorARGB:__init(red, green, blue, alpha)
  887.         self.R = red or 255
  888.         self.G = green or 255
  889.         self.B = blue or 255
  890.         self.A = alpha or 255
  891.     end
  892.  
  893.     function ColorARGB.FromArgb(red, green, blue, alpha)
  894.         return Color(red,green,blue, alpha)
  895.     end
  896.  
  897.     function ColorARGB:ToARGB()
  898.         return ARGB(self.A, self.R, self.G, self.B)
  899.     end
  900.  
  901.     ColorARGB.Red = ColorARGB(255, 0, 0, 255)
  902.     ColorARGB.Yellow = ColorARGB(255, 255, 0, 255)
  903.     ColorARGB.Green = ColorARGB(0, 255, 0, 255)
  904.     ColorARGB.Aqua = ColorARGB(0, 255, 255, 255)
  905.     ColorARGB.Blue = ColorARGB(0, 0, 255, 255)
  906.     ColorARGB.Fuchsia = ColorARGB(255, 0, 255, 255)
  907.     ColorARGB.Black = ColorARGB(0, 0, 0, 255)
  908.     ColorARGB.White = ColorARGB(255, 255, 255, 255)
  909. -- }
  910.  
  911. --Notification class
  912. class 'Message' -- {
  913.  
  914.     Message.instance = ""
  915.  
  916.     function Message:__init()
  917.         self.notifys = {}
  918.  
  919.         AddDrawCallback(function(obj) self:OnDraw() end)
  920.     end
  921.  
  922.     function Message.Instance()
  923.         if Message.instance == "" then Message.instance = Message() end return Message.instance
  924.     end
  925.  
  926.     function Message.AddMessage(text, color, target)
  927.         return Message.Instance():PAddMessage(text, color, target)
  928.     end
  929.  
  930.     function Message:PAddMessage(text, color, target)
  931.         local x = 0
  932.         local y = 200
  933.         local tempName = "Screen"
  934.         local tempcolor = color or ColorARGB.Red
  935.  
  936.         if target then  
  937.             tempName = target.networkID
  938.         end
  939.  
  940.         self.notifys[tempName] = { text = text, color = tempcolor, duration = GetGameTimer() + 2, object = target}
  941.     end
  942.  
  943.     function Message:OnDraw()
  944.         for i, notify in pairs(self.notifys) do
  945.             if notify.duration < GetGameTimer() then notify = nil
  946.             else
  947.                 notify.color.A = math.floor((255/2)*(notify.duration - GetGameTimer()))
  948.  
  949.                 if i == "Screen" then  
  950.                     local x = 0
  951.                     local y = 200
  952.                     local gameSettings = GetGameSettings()
  953.                     if gameSettings and gameSettings.General then
  954.                         if gameSettings.General.Width then x = gameSettings.General.Width/2 end
  955.                         if gameSettings.General.Height then y = gameSettings.General.Height/4 - 100 end
  956.                     end  
  957.                     --PrintChat(tostring(notify.color))
  958.                     local p = GetTextArea(notify.text, 40).x
  959.                     self:DrawTextWithBorder(notify.text, 40, x - p/2, y, notify.color:ToARGB(), ARGB(notify.color.A, 0, 0, 0))
  960.                 else    
  961.                     local pos = WorldToScreen(D3DXVECTOR3(notify.object.x, notify.object.y, notify.object.z))
  962.                     local x = pos.x
  963.                     local y = pos.y - 25
  964.                     local p = GetTextArea(notify.text, 40).x
  965.  
  966.                     self:DrawTextWithBorder(notify.text, 30, x- p/2, y, notify.color:ToARGB(), ARGB(notify.color.A, 0, 0, 0))
  967.                 end
  968.             end
  969.         end
  970.     end
  971.  
  972.     function Message:DrawTextWithBorder(textToDraw, textSize, x, y, textColor, backgroundColor)
  973.         DrawText(textToDraw, textSize, x + 1, y, backgroundColor)
  974.         DrawText(textToDraw, textSize, x - 1, y, backgroundColor)
  975.         DrawText(textToDraw, textSize, x, y - 1, backgroundColor)
  976.         DrawText(textToDraw, textSize, x, y + 1, backgroundColor)
  977.         DrawText(textToDraw, textSize, x , y, textColor)
  978.     end
  979. -- }
  980. --]]
Advertisement
Add Comment
Please, Sign In to add comment