Kain2030

Auto Carry Plugin - Lucian Edition - v1.07e

Aug 23rd, 2013
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 26.57 KB | None | 0 0
  1. --[[
  2.  
  3.         Auto Carry Plugin - Lucian Edition
  4.         Author: Kain
  5.         Version: 1.07d
  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: 1.07e: http://pastebin.com/kgFKdwuS
  17.                 Sword of the Divine supported.
  18.                 Improved dynamic draw ranges.
  19.                 Harass fixed. Fires Q.
  20.                 Hack fixed killsteal until BoL finally gets updated properly.
  21.                 Killsteal fix resolved firing spells without key pressed.
  22.             Version: 1.07c: http://pastebin.com/tK2WNXsy
  23.                 Relentless Pursuit Out of Enemy slows.
  24.                 Tweaked prediction variables.
  25.                 Killsteal enabled.
  26.             Version: 1.06c: http://pastebin.com/sdvmmNyR
  27.                 Spell weaving.
  28.                 Draw range logic improvement.
  29.                 Menu updates.
  30.             Version: 1.05d Beta: http://pastebin.com/rE5X8puE
  31.                 Improvements to mechanics of Culling Lockon. (Still more to do here.)
  32.                 Fix issue with Ultimate ending early.
  33.                 Miscellaneous bug fixes.
  34.             Version: 1.04 Beta Pre-Release: http://pastebin.com/ayEX5Bfq
  35.                 Culling Lockon added. Considered experimental, but seems to be working pretty well.
  36.             Version: 1.02 Beta Pre-Release: http://pastebin.com/tXxr95g9
  37.             Version: 1.0 Alpha: http://pastebin.com/xWbRz89K
  38. --]]
  39.  
  40. if myHero.charName ~= "Lucian" then return end
  41.  
  42. function PluginOnLoad()
  43.     Vars()
  44.     Menu()
  45.  
  46.     AutoCarry.SkillsCrosshair.range = QMaxRange
  47. end
  48.  
  49. function Vars()
  50.     tick = nil
  51.     Target = nil
  52.  
  53.     -- Confirm ranges on release.
  54.     QRange = 550
  55.     QMaxRange = 1100
  56.     WRange = 1000
  57.     ERange = 425
  58.     RRange = 1400
  59.  
  60.     QSpeed = 19.346
  61.     WSpeed = 1.47 -- Old: 1.009
  62.     ESpeed = 3.867
  63.     RSpeed = 2.9 -- Old: 1.3
  64.  
  65.     QWidth = 250
  66.     WWidth = 250
  67.     EWidth = 250
  68.     RWidth = 250
  69.  
  70.     QDelay = 405
  71.     WDelay = 288 -- Old: 256
  72.     EDelay = 1070
  73.     RDelay = 200
  74.  
  75.     RRefresh = 0.1
  76.     RDuration = 3.2 -- Old: 3.0 2.871 - 3.167
  77.  
  78.     ParticleRProjectileName = "Lucian_R_mis.troy"
  79.     ParticleRProjectileNameOld = "bowMaster_volley_mis.troy"
  80.     ParticleR = "Lucian_R_tar.troy"
  81.     ParticleRFiring = "Lucian_R_self.troy"
  82.  
  83.     -- Start New
  84.     BuffPassive = "lucianpassivebuff" -- Old: "Lightslinger"
  85.     BuffW = "lucianwcastingbuff"
  86.     BuffR = "LucianR"
  87.  
  88.     -- End New
  89. --[[
  90.     Raw data dump:
  91.  
  92.     spellName = LucianBasicAttack
  93.     projectileName = ???
  94.     castDelay = 4001.50 (827.00-7176.00)
  95.     projectileSpeed = 6321.08 (724.19-11917.96)
  96.     range = 2594.85 (541.70-4648.01)
  97.  
  98.     spellName = LucianW
  99.     projectileName = Lucian_W_mis.troy
  100.     castDelay = 288.67 (265.00-297.00)
  101.     projectileSpeed = 1484.95 (1391.22-1640.62)
  102.     range = 661.85 (304.68-1000.83)
  103.  
  104.     spellName = LucianE
  105.     projectileName = Lucian_W_mis.troy
  106.     castDelay = 8189.75 (0.00-32245.00)
  107.     projectileSpeed = 25590.51 (703.58-79656.61)
  108.     range = 3772.70 (372.90-8054.26)
  109.  
  110.     spellName = LucianR
  111.     projectileName = Lucian_R_mis.troy
  112.     castDelay = 210.50 (187.00-234.00)
  113.     projectileSpeed = 2850.25 (2342.64-3357.86)
  114.     range = 405.05 (261.91-548.18)
  115.  
  116.     Raw data dump #2:
  117.  
  118.     spellName = LucianW
  119.     projectileName = Lucian_W_mis.troy
  120.     castDelay = 313.81 (265.00-453.00)
  121.     projectileSpeed = 1459.60 (558.14-1797.76)
  122.     range = 648.24 (17.30-1007.14)
  123.  
  124.     spellName = LucianE
  125.     projectileName = Lucian_W_mis.troy
  126.     castDelay = 2147.83 (0.00-10530.00)
  127.     projectileSpeed = 4680.15 (632.65-14746.30)
  128.     range = 3349.24 (809.79-8272.67)
  129.  
  130.     spellName = LucianR
  131.     projectileName = Lucian_R_mis.troy
  132.     castDelay = 199.80 (172.00-218.00)
  133.     projectileSpeed = 3023.31 (2816.79-3321.66)
  134.     range = 757.80 (205.94-1063.38)
  135.  
  136. --]]
  137.  
  138.     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 }
  139.     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 }
  140.     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 }
  141.     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 }
  142.  
  143.     KeyQ = string.byte("Q")
  144.     KeyW = string.byte("W")
  145.     KeyE = string.byte("E")
  146.     KeyR = string.byte("R")
  147.  
  148.     KeyTest = string.byte("U")
  149.  
  150.     DFGSlot, HXGSlot, BWCSlot, STDSlot, SheenSlot, TrinitySlot, LichBaneSlot = nil, nil, nil, nil, nil, nil, nil
  151.     QReady, WReady, EReady, RReady, DFGReady, HXGReady, BWCReady, STDReady, IReady = false, false, false, false, false, false, false, false
  152.  
  153.     ultCastTick = 0
  154.     ultCastTarget = nil
  155.     ultVectorX = nil
  156.     ultVectorZ = nil
  157.  
  158.     isSlowed = false
  159.  
  160.     healthLastTick = 0
  161.     healthLastHealth = 0
  162.  
  163.     isUltFiring = false
  164.     lastUltMessage = 0
  165.  
  166.     comboActive = false
  167.     nextAttack = 0
  168.  
  169.     debugMode = false
  170.     debugModeDisableNonR = false
  171. end
  172.  
  173. function Menu()
  174.     AutoCarry.PluginMenu:addParam("sep", "----- [ Combo ] -----", SCRIPT_PARAM_INFO, "")
  175.     AutoCarry.PluginMenu:addParam("Combo", "Combo - Default Spacebar", SCRIPT_PARAM_INFO, "")
  176.     AutoCarry.PluginMenu:addParam("FullCombo", "Insta Blast Combo (No AA)", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("Z"))
  177.     AutoCarry.PluginMenu:addParam("ComboQ", "Use Piercing Light", SCRIPT_PARAM_ONOFF, true)
  178.     AutoCarry.PluginMenu:addParam("ComboW", "Use Ardent Blaze", SCRIPT_PARAM_ONOFF, true)
  179.     AutoCarry.PluginMenu:addParam("ComboE", "Use Relentless Pursuit", SCRIPT_PARAM_ONOFF, true)
  180.     AutoCarry.PluginMenu:addParam("ComboR", "Use The Culling", SCRIPT_PARAM_ONOFF, true)
  181.     AutoCarry.PluginMenu:addParam("SmartE", "Smart Relentless Pursuit", SCRIPT_PARAM_ONOFF, true)
  182.     AutoCarry.PluginMenu:addParam("UltLockOn", "Use Ultimate Lock On (Beta)", SCRIPT_PARAM_ONOFF, true)
  183.     AutoCarry.PluginMenu:addParam("sep", "----- [ Misc ] -----", SCRIPT_PARAM_INFO, "")
  184.     AutoCarry.PluginMenu:addParam("PursuitSlow", "Pursuit Out of Slows", SCRIPT_PARAM_ONOFF, true)
  185.     AutoCarry.PluginMenu:addParam("AutoHarass", "Auto Harass", SCRIPT_PARAM_ONOFF, false)
  186.     AutoCarry.PluginMenu:addParam("sep", "----- [ Killsteal ] -----", SCRIPT_PARAM_INFO, "")
  187.     AutoCarry.PluginMenu:addParam("Killsteal", "Killsteal", SCRIPT_PARAM_ONOFF, true)
  188.     AutoCarry.PluginMenu:addParam("KillstealUlt", "Killsteal with Ult", SCRIPT_PARAM_ONOFF, false)
  189.     AutoCarry.PluginMenu:addParam("sep", "----- [ Advanced ] -----", SCRIPT_PARAM_INFO, "")
  190.     AutoCarry.PluginMenu:addParam("EMinMouseDiff", "Pursuit Min. Mouse Diff.", SCRIPT_PARAM_SLICE, 600, 100, 1000, 0)
  191.     AutoCarry.PluginMenu:addParam("ProMode", "Use Auto QWER Keys", SCRIPT_PARAM_ONOFF, true)
  192. --  AutoCarry.PluginMenu:addParam("HealthPercentage", "Health Drop %",SCRIPT_PARAM_SLICE, 0, 0, 100, 0)
  193. --  AutoCarry.PluginMenu:addParam("HealthTime", "Health Tracking Time",SCRIPT_PARAM_SLICE, 0, 2, 5, 0)
  194.     AutoCarry.PluginMenu:addParam("sep", "----- [ Draw ] -----", SCRIPT_PARAM_INFO, "")
  195.     AutoCarry.PluginMenu:addParam("DisableDraw", "Disable Draw", SCRIPT_PARAM_ONOFF, false)
  196.     AutoCarry.PluginMenu:addParam("DrawFurthest", "Draw Furthest Spell Available", SCRIPT_PARAM_ONOFF, true)
  197.     AutoCarry.PluginMenu:addParam("DrawQ", "Draw Piercing Light", SCRIPT_PARAM_ONOFF, true)
  198.     AutoCarry.PluginMenu:addParam("DrawW", "Draw Ardent Blaze", SCRIPT_PARAM_ONOFF, true)
  199.     AutoCarry.PluginMenu:addParam("DrawE", "Draw Relentless Pursuit", SCRIPT_PARAM_ONOFF, true)
  200.     AutoCarry.PluginMenu:addParam("DrawR", "Draw The Culling", SCRIPT_PARAM_ONOFF, true)
  201. end
  202.  
  203. function PluginOnTick()
  204.     tick = GetTickCount()
  205.     Target = AutoCarry.GetAttackTarget(true)
  206.  
  207.     SpellCheck()
  208.  
  209.     -- GetTickCount() % 5 == 0) and
  210.     if IsTickReady(25) and IsFiringUlt() then
  211.         CheckRPosition()
  212.     else
  213.         if AutoCarry.MainMenu.AutoCarry then
  214.             comboActive = true
  215.             Combo()
  216.         else
  217.             comboActive = false
  218.         end
  219.  
  220.         if AutoCarry.PluginMenu.FullCombo then
  221.             FullCombo()
  222.         end
  223.  
  224.         if AutoCarry.MainMenu.MixedMode or AutoCarry.PluginMenu.AutoHarass then
  225.             Harass()
  226.         end
  227.  
  228.         if AutoCarry.PluginMenu.Killsteal then
  229.             KillSteal()
  230.         end
  231.     end
  232. end
  233.  
  234. function PluginOnCreateObj(obj)
  235.     -- Nothing to do here.
  236.     if obj.name == ParticleRFiring then
  237.         if debugMode then PrintChat("Ult Particle Started") end
  238.         isUltFiring = true
  239.         if debugMode then PrintChat("start: "..(GetTickCount() / 1000)) end
  240.     end
  241. end
  242.  
  243. function PluginOnDeleteObj(obj)
  244.     if obj.name == ParticleRFiring then
  245.         if debugMode then PrintChat("Ult Particle Stopped") end
  246.         isUltFiring = false
  247.         UltFireStop()
  248.         if debugMode then PrintChat("stop: "..(GetTickCount() / 1000)) end
  249.     end
  250. end
  251.  
  252. function OnAttacked()
  253.     -- AA > Q > AA
  254.     if AutoCarry.MainMenu.MixedMode or AutoCarry.PluginMenu.AutoHarass then CastQ() end
  255.  
  256.     if AutoCarry.MainMenu.AutoCarry and comboActive and GetTickCount() > nextAttack then
  257.         nextAttack = AutoCarry.GetNextAttackTime()
  258.  
  259.         if AutoCarry.PluginMenu.ComboW then CastW() end
  260.         if AutoCarry.PluginMenu.ComboE then CastE() end
  261.         if AutoCarry.PluginMenu.ComboQ then CastQ() end
  262.  
  263.         comboActive = false
  264.     end
  265. end
  266.  
  267. --[[
  268. function CustomAttackEnemy(enemy)
  269.         if enemy.dead or not enemy.valid then return end
  270.         -- myHero:Attack(enemy)
  271.         -- AutoCarry.shotFired = true
  272. end
  273. --]]
  274.  
  275. function OnGainBuff(unit, buff)
  276.     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
  277.         -- BUFF_STUN = 5 BUFF_SLOW = 10 BUFF_ROOT = 11
  278.         if AutoCarry.PluginMenu.PursuitSlow then
  279.             isSlowed = true
  280.             CastE()
  281.         end
  282.     end
  283. end
  284.  
  285. function SpellCheck()
  286.     DFGSlot, HXGSlot, BWCSlot, BRKSlot, STDSlot, SheenSlot, TrinitySlot, LichBaneSlot = GetInventorySlotItem(3128),
  287.     GetInventorySlotItem(3146), GetInventorySlotItem(3144), GetInventorySlotItem(3153), GetInventorySlotItem(3131),
  288.     GetInventorySlotItem(3057), GetInventorySlotItem(3078), GetInventorySlotItem(3100)
  289.  
  290.     QReady = (myHero:CanUseSpell(SkillQ.spellKey) == READY)
  291.     WReady = (myHero:CanUseSpell(SkillW.spellKey) == READY)
  292.     EReady = (myHero:CanUseSpell(SkillE.spellKey) == READY)
  293.     RReady = (myHero:CanUseSpell(SkillR.spellKey) == READY)
  294.  
  295.     DFGReady = (DFGSlot ~= nil and myHero:CanUseSpell(DFGSlot) == READY)
  296.     HXGReady = (HXGSlot ~= nil and myHero:CanUseSpell(HXGSlot) == READY)
  297.     BWCReady = (BWCSlot ~= nil and myHero:CanUseSpell(BWCSlot) == READY)
  298.     BRKReady = (BRKSlot ~= nil and myHero:CanUseSpell(BRKSlot) == READY)
  299.     STDReady = (STDSlot ~= nil and myHero:CanUseSpell(BRKSlot) == READY)
  300.  
  301.     IReady = (ignite ~= nil and myHero:CanUseSpell(ignite) == READY)
  302. end
  303.  
  304. -- Handle SBTW Skill Shots
  305.  
  306. function Combo()
  307.     if not debugModeDisableNonR then
  308.         CastSlots()
  309.     end
  310.  
  311.     if AutoCarry.PluginMenu.ComboR then CastR() end
  312. end
  313.  
  314. function FullCombo()
  315.     CastSlots()
  316.     CastW()
  317.     CastE()
  318.     CastQ()
  319.     CastR()
  320. end
  321.  
  322. function CastSlots()
  323.     if Target ~= nil then
  324.         if GetDistance(Target) <= QRange then
  325.             if DFGReady then CastSpell(DFGSlot, Target) end
  326.             if HXGReady then CastSpell(HXGSlot, Target) end
  327.             if BWCReady then CastSpell(BWCSlot, Target) end
  328.             if BRKReady then CastSpell(BRKSlot, Target) end
  329.             if STDReady then CastSpell(STDSlot, Target) end
  330.         end
  331.     end
  332. end
  333.  
  334. function Harass()
  335.     CastQ()
  336. end
  337.  
  338. function IsTickReady(tickFrequency)
  339.     -- Improves FPS
  340.     -- Disabled for now.
  341.     if 1 == 1 then return true end
  342.  
  343.     if tick ~= nil and math.fmod(tick, tickFrequency) == 0 then
  344.         return true
  345.     else
  346.         return false
  347.     end
  348. end
  349.  
  350. function CastQ(enemy)
  351.     -- Q (Piercing Light)
  352.     if not enemy then enemy = Target end
  353.  
  354.     if enemy ~= nil and QReady and ValidTarget(enemy, QRange) then
  355.         if debugMode then PrintChat("Cast Q") end
  356.  
  357.         CastSpell(SkillQ.spellKey, enemy)
  358.         return true
  359.     end
  360. end
  361.  
  362. function CastW(enemy)
  363.     -- W (Ardent Blaze)
  364.     if not enemy then enemy = Target end
  365.  
  366.     if enemy ~= nil and WReady and ValidTarget(enemy, WRange) then
  367.         if debugMode then PrintChat("Cast W") end
  368.         AutoCarry.CastSkillshot(SkillW, enemy)
  369.         return true
  370.     end
  371. end
  372.  
  373. --[[
  374. function CastEOld()
  375.     -- E (Relentless Pursuit)
  376.     if debugMode then
  377.         -- PrintChat("Mouse Distance: "..GetDistance(mousePos))
  378.     end
  379.  
  380.     if EReady then
  381.         -- if ( math.abs(mousePos.x - myHero.x) > PursuitMinMouseDiff or math.abs(mousePos.z - myHero.z) > PursuitMinMouseDiff) then
  382.         if ((GetDistance(mousePos) > PursuitMinMouseDiff) and isEnemyInRange(SkillE.range + SkillR.range)) then
  383.             if debugMode then PrintChat("Cast E") end
  384.             CastSpell(SkillE.spellKey, mousePos.x, mousePos.z)
  385.         end
  386.     end
  387. end
  388. --]]
  389.  
  390. function CastE()
  391.     if AutoCarry.PluginMenu.SmartE then
  392.         if ((GetDistance(mousePos) > AutoCarry.PluginMenu.EMinMouseDiff or isSlowed) and isEnemyInRange(SkillE.range + SkillR.range)) then
  393.             local dashSqr = math.sqrt((mousePos.x - myHero.x)^2+(mousePos.z - myHero.z)^2)
  394.             local dashX = myHero.x + ERange*((mousePos.x - myHero.x)/dashSqr)
  395.             local dashZ = myHero.z + ERange*((mousePos.z - myHero.z)/dashSqr)
  396.             CastSpell(SkillE.spellKey, dashX, dashZ)
  397.             isSlowed = false
  398.             return true
  399.         end
  400.     else
  401.         CastSpell(SkillE.spellKey, mousePos.x, mousePos.z)
  402.         isSlowed = false
  403.         return true
  404.     end
  405. end
  406.  
  407. function CastR(enemy)
  408.     if not enemy then enemy = Target end
  409.     -- R (The Culling)
  410.     if enemy ~= nil and RReady and ValidTarget(enemy, RRange) then
  411.         if not IsFiringUlt() then
  412.             if debugMode then PrintChat("Cast R") end
  413.             if not isUltFiring then
  414.                 AutoCarry.CastSkillshot(SkillR, enemy)
  415.                 if AutoCarry.PluginMenu.UltLockOn and GetTickCount() > (lastUltMessage + 2000) then
  416.                     lastUltMessage = GetTickCount()
  417.                     PrintFloatText(myHero, 10, "Ultimate Locked On!")
  418.                 end
  419.             end
  420.  
  421.             ultCastTarget = enemy
  422.             ultCastTick = GetTickCount()
  423.  
  424.             -- Vector from target -> myHero
  425.             if ultVectorX == nil and ultVectorZ == nil then
  426.                 if debugMode and false then PrintChat("update x,z") end
  427.                 ultVectorX,y,ultVectorZ = (Vector(myHero) - Vector(ultCastTarget)):normalized():unpack()
  428.             end
  429.         end
  430.  
  431.         CheckRPosition()
  432.     end
  433. end
  434.  
  435. function CheckRPosition()
  436.     if (ultCastTick > 0) then
  437.         if debugMode and IsFiringUlt() then burp = "true" else burp = "false" end
  438.         if debugMode and false then PrintChat("Tick: "..GetTickCount()..", ultCastTick: "..ultCastTick..", RDuration: "..(ultCastTick + (RDuration * 1000))..", IsFiringUlt: "..burp) end
  439.     end
  440.  
  441.     if AutoCarry.PluginMenu.UltLockOn and IsFiringUlt() then
  442.         MoveMyHeroToRPosition()
  443.     end
  444. end
  445.  
  446. function MoveMyHeroToRPosition()
  447.     -- Please don't steal this function!
  448.     local tpR = VIP_USER and TargetPredictionVIP(RRange, RSpeed*1000, RRefresh, RWidth) or TargetPrediction(RRange, RSpeed, RRefresh*1000, RWidth)
  449.  
  450.     local target = nil
  451.     if ultCastTarget ~= nil then
  452.         target = ultCastTarget
  453.     else
  454.         target = Target
  455.     end
  456.  
  457.     local predR = tpR:GetPrediction(target)
  458.  
  459.     if not predR then return end
  460.  
  461.     local RRangeBuffered = RRange * .98 -- Allow a bit of slippage for targets running away.
  462.     local posX = predR.x + (ultVectorX * RRangeBuffered)
  463.     local posZ = predR.z + (ultVectorZ * RRangeBuffered)
  464.  
  465.     -- Thank you, Pythagoras
  466.     -- local distanceBetweenPoints = math.sqrt((predR.x - posX)^2 + (predR.z - posZ)^2)
  467.     -- local distanceBetweenPoints = GetDistance(Point(posX, posZ), predR)
  468.     -- local posXRanged = (posX + (posX - predR.x)) / distanceBetweenPoints * RRangeBuffered
  469.     -- local posZRanged = (posZ + (posZ - predR.z)) / distanceBetweenPoints * RRangeBuffered
  470.  
  471.     local predRPath = LineSegment(Point(predR.x, predR.z), Point(posX, posZ))
  472.  
  473.     local closePoint = nil
  474.     if predRPath ~= nil then
  475.         closePoint = Point(myHero.x, myHero.z):closestPoint(predRPath)
  476.     else
  477.         if debugMode then PrintChat("predRPath is nil") end
  478.     end
  479.  
  480.     if debugMode and closePoint ~= nil then
  481.         --  PrintChat("moveto: "..posX..", "..posZ.."... targetat: "..ultCastTarget.x..", "..ultCastTarget.z..", ultVectorX: "..ultVectorX..", ultVectorZ: "..ultVectorZ..", RDuration: "..RDuration)
  482.         --  PrintChat("posXRanged: "..posXRanged..", posZRanged: "..posZRanged..", closePoint: "..closePoint.x..", "..closePoint.y)
  483.         PrintChat("moveto: "..closePoint.x..", "..closePoint.y.."; targetat: "..predR.x..", "..predR.z..", ultVectorX: "..ultVectorX..", ultVectorZ: "..ultVectorZ)
  484.     end
  485.  
  486.     if debugMode then
  487.         PrintChat("distance: method 1: "..GetDistance(closePoint, predR)..", method 2: "..GetDistance(Point(posX, posZ), predR))
  488.     end
  489.  
  490.     if predRPath ~= nil and closePoint ~= nil and not IsWall(D3DXVECTOR3(closePoint.x, myHero.y, closePoint.y)) and GetDistance(closePoint, predR) > ERange then
  491.         -- Closest Point Method
  492.         if debugMode then PrintChat("Move: Method 1") end
  493.         myHero:MoveTo(closePoint.x, closePoint.y)
  494.     elseif predR ~= nil and posX ~= nil and posZ ~= nil and not IsWall(D3DXVECTOR3(posX, myHero.y, posZ))
  495.         -- and GetDistance(Point(posX, posZ), predR) > 500
  496.         and GetDistance(Point(posX, posZ), predR) < RRange and GetDistance(Point(posX, posZ), predR) > 100 then
  497.         -- Full Vector Method
  498.         if debugMode then PrintChat("Move: Method 2") end
  499.         if (GetTickCount() > (lastUltMessage + 2000)) then
  500.             -- lastUltMessage = GetTickCount()
  501.             -- PrintFloatText(myHero, 10, "Ultimate Manual Mode!")
  502.         end
  503.         myHero:MoveTo(posX, posZ)
  504. --  elseif not IsWall(D3DXVECTOR3(posXRanged, myHero.y, posZRanged)) then
  505. --      -- Last Ditch Method
  506. --      if debugMode then PrintChat("Move: Method 3") end
  507. --      myHero:MoveTo(posXRanged, posZRanged)
  508.     else
  509.         -- Fallback to User Aiming
  510.         if debugMode then PrintChat("Move: Wall") end
  511.         myHero:MoveTo(mousePos.x, mousePos.z)
  512.     end
  513.     -- myHero:MoveTo(posXRanged, posZRanged)
  514. end
  515.  
  516. function getDistanceBetweenPoints(pointA, pointB)
  517.     -- Thank you, Pythagoras
  518.     local distanceBetweenPoints = math.sqrt((predR.x - posX)^2 + (predR.z - posZ)^2)
  519. end
  520.  
  521. function IsFiringUlt()
  522.     local tickCount = GetTickCount()
  523.  
  524.     -- if (ultCastTick > 0) and (tickCount >= ultCastTick) and (tickCount <= (ultCastTick + (RDuration * 1000))) and not RReady and ultCastTarget ~= nil and not ultCastTarget.dead then
  525.     if (ultCastTick > 0) and (tickCount >= ultCastTick) and isUltFiring and ultCastTarget ~= nil and not ultCastTarget.dead then
  526.         AutoCarry.CanMove = false
  527.         return true
  528.     else
  529.         UltFireStop()
  530.         return false
  531.     end
  532. end
  533.  
  534. function UltFireStop()
  535.     ultCastTick = 0
  536.     ultVectorX = nil
  537.     ultVectorZ = nil
  538.     AutoCarry.CanMove = true
  539. end
  540.  
  541. function isEnemyInRange(range)
  542.     for _, enemy in pairs(AutoCarry.EnemyTable) do
  543.         if ValidTarget(enemy, range) and not enemy.dead then
  544.             return true
  545.         end
  546.     end
  547.  
  548.     return false
  549. end
  550.  
  551. --[[
  552. function TakingRapidDamage()
  553.     if GetTickCount() - healthLastTick > (AutoCarry.PluginMenu.HealthTime * 1000) then
  554.         --> Check amount of health lost
  555.         if myHero.health - healthLastHealth > myHero.maxHealth * (AutoCarry.PluginMenu.HealthPercentage / 100) then
  556.             return true
  557.         else
  558.             --> Reset counters
  559.             healthLastTick = GetTickCount()
  560.             healthLastHealth = myHero.health
  561.         end
  562.     end
  563. end
  564. --]]
  565.  
  566. function KillSteal()
  567.     -- Will try to perform a killsteam using any spell.
  568.     if not AutoCarry.PluginMenu.Killsteal then return end
  569.  
  570.     -- Killsteal disabled until Bol update for Lucian
  571.  
  572.     for _, enemy in pairs(AutoCarry.EnemyTable) do
  573.         if enemy and not enemy.dead then
  574.             -- getDmg broken in BoL for Lucian right now.
  575.             local qDmg = 80 -- getDmg("Q", enemy, myHero)
  576.             local wDmg = 60 -- getDmg("W", enemy, myHero)
  577.             local rDmg = 50 -- getDmg("R", enemy, myHero)
  578.  
  579.             if QReady and ValidTarget(enemy, QRange) and (enemy.health + 20) < qDmg then
  580.                 if debugMode then PrintChat("Cast Q KS") end
  581.                 CastQ(enemy)
  582.             elseif WReady and ValidTarget(enemy, WRange) and (enemy.health + 20) < wDmg then
  583.                 if debugMode then PrintChat("Cast W KS") end
  584.                 CastW(enemy)
  585.             elseif AutoCarry.PluginMenu.KillstealUlt and RReady and ValidTarget(enemy, RRange) and (enemy.health + 20) < rDmg then
  586.                 if debugMode then PrintChat("Cast R KS") end
  587.                 CastR(enemy)
  588.             end
  589.  
  590.         end
  591.     end
  592. end
  593.  
  594. function PluginOnWndMsg(msg,key)
  595.     Target = AutoCarry.GetAttackTarget()
  596.     if Target ~= nil and AutoCarry.PluginMenu.ProMode then
  597.         -- if msg == KEY_DOWN and key == KeyQ then CastQ() end
  598.         if msg == KEY_DOWN and key == KeyW then CastW() end
  599.         if msg == KEY_DOWN and key == KeyE then CastE() end
  600.         if msg == KEY_DOWN and key == KeyR then CastR() end
  601.         if msg == KEY_DOWN and key == KeyTest and debugMode then
  602.             if ultVectorX == nil and ultVectorZ == nil then
  603.                 ultCastTarget = Target
  604.                 ultVectorX,y,ultVectorZ = (Vector(myHero) - Vector(ultCastTarget)):normalized():unpack()
  605.             end
  606.             MoveMyHeroToRPosition()
  607.         end
  608.        
  609.         if msg == KEY_UP and key == KeyTest and debugMode then
  610.             ultVectorX = nil
  611.             ultVectorZ = nil
  612.         end
  613.     end
  614. end
  615.  
  616. -- Draw
  617. function PluginOnDraw()
  618.     -- if Target ~= nil and not Target.dead and QReady and ValidTarget(Target, QMaxRange) then
  619.     if Target ~= nil and not Target.dead and (AutoCarry.MainMenu.AutoCarry or AutoCarry.MainMenu.MixedMode) then
  620.         DrawArrowsToPos(myHero, Target)
  621.     end
  622.  
  623.     if not AutoCarry.PluginMenu.DisableDraw and not myHero.dead then
  624.         local farSpell = FindFurthestReadySpell()
  625.         -- if debugMode and farSpell then PrintChat("far: "..farSpell.configName) end
  626.  
  627.         -- Not needed as SAC has the same range draw.
  628.         -- DrawCircle(myHero.x, myHero.y, myHero.z, getTrueRange(), 0x808080) -- Gray
  629.  
  630.         if AutoCarry.PluginMenu.DrawQ and QReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillQ) or not AutoCarry.PluginMenu.DrawFurthest) then
  631.             DrawCircle(myHero.x, myHero.y, myHero.z, QRange, 0x0099CC) -- Blue
  632.         end
  633.  
  634.         if AutoCarry.PluginMenu.DrawW and WReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillW) or not AutoCarry.PluginMenu.DrawFurthest) then
  635.             DrawCircle(myHero.x, myHero.y, myHero.z, WRange, 0xFFFF00) -- Yellow
  636.         end
  637.        
  638.         if AutoCarry.PluginMenu.DrawE and EReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillE) or not AutoCarry.PluginMenu.DrawFurthest) then
  639.             DrawCircle(myHero.x, myHero.y, myHero.z, ERange, 0x00FF00) -- Green
  640.         end
  641.  
  642.         if AutoCarry.PluginMenu.DrawR and RReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillR) or not AutoCarry.PluginMenu.DrawFurthest) then
  643.             DrawCircle(myHero.x, myHero.y, myHero.z, RRange, 0xFF0000) -- Red
  644.         end
  645.  
  646.         Target = AutoCarry.GetAttackTarget()
  647.         if Target ~= nil then
  648.             for j=0, 10 do
  649.                 DrawCircle(Target.x, Target.y, Target.z, 40 + j*1.5, 0x00FF00) -- Green
  650.             end
  651.         end
  652.  
  653.     end
  654. end
  655.  
  656. function FindFurthestReadySpell()
  657.     local farSpell = nil
  658.  
  659.     if AutoCarry.PluginMenu.DrawQ and QReady then farSpell = SkillQ end
  660.     if AutoCarry.PluginMenu.DrawW and WReady and (not farSpell or WRange > farSpell.range) then farSpell = SkillW end
  661.     if AutoCarry.PluginMenu.DrawE and EReady and (not farSpell or ERange > farSpell.range) then farSpell = SkillE end
  662.     if AutoCarry.PluginMenu.DrawR and RReady and (not farSpell or RRange > farSpell.range) then farSpell = SkillR end
  663.  
  664.     return farSpell
  665. end
  666.  
  667. function getTrueRange()
  668.     return myHero.range + GetDistance(myHero.minBBox)
  669. end
  670.  
  671. function DrawArrowsToPos(pos1, pos2)
  672.     if pos1 and pos2 then
  673.         startVector = D3DXVECTOR3(pos1.x, pos1.y, pos1.z)
  674.         endVector = D3DXVECTOR3(pos2.x, pos2.y, pos2.z)
  675.         -- directionVector = (endVector-startVector):normalized()
  676.         DrawArrows(startVector, endVector, 60, 0xE97FA5, 100)
  677.     end
  678. end
  679.  
  680. --[[
  681. class 'ColorARGB' -- {
  682.  
  683.     function ColorARGB:__init(red, green, blue, alpha)
  684.         self.R = red or 255
  685.         self.G = green or 255
  686.         self.B = blue or 255
  687.         self.A = alpha or 255
  688.     end
  689.  
  690.     function ColorARGB.FromArgb(red, green, blue, alpha)
  691.         return Color(red,green,blue, alpha)
  692.     end
  693.  
  694.     function ColorARGB:ToARGB()
  695.         return ARGB(self.A, self.R, self.G, self.B)
  696.     end
  697.  
  698.     ColorARGB.Red = ColorARGB(255, 0, 0, 255)
  699.     ColorARGB.Yellow = ColorARGB(255, 255, 0, 255)
  700.     ColorARGB.Green = ColorARGB(0, 255, 0, 255)
  701.     ColorARGB.Aqua = ColorARGB(0, 255, 255, 255)
  702.     ColorARGB.Blue = ColorARGB(0, 0, 255, 255)
  703.     ColorARGB.Fuchsia = ColorARGB(255, 0, 255, 255)
  704.     ColorARGB.Black = ColorARGB(0, 0, 0, 255)
  705.     ColorARGB.White = ColorARGB(255, 255, 255, 255)
  706. -- }
  707.  
  708. --Notification class
  709. class 'Message' -- {
  710.  
  711.     Message.instance = ""
  712.  
  713.     function Message:__init()
  714.         self.notifys = {}
  715.  
  716.         AddDrawCallback(function(obj) self:OnDraw() end)
  717.     end
  718.  
  719.     function Message.Instance()
  720.         if Message.instance == "" then Message.instance = Message() end return Message.instance
  721.     end
  722.  
  723.     function Message.AddMessage(text, color, target)
  724.         return Message.Instance():PAddMessage(text, color, target)
  725.     end
  726.  
  727.     function Message:PAddMessage(text, color, target)
  728.         local x = 0
  729.         local y = 200
  730.         local tempName = "Screen"
  731.         local tempcolor = color or ColorARGB.Red
  732.  
  733.         if target then  
  734.             tempName = target.networkID
  735.         end
  736.  
  737.         self.notifys[tempName] = { text = text, color = tempcolor, duration = GetGameTimer() + 2, object = target}
  738.     end
  739.  
  740.     function Message:OnDraw()
  741.         for i, notify in pairs(self.notifys) do
  742.             if notify.duration < GetGameTimer() then notify = nil
  743.             else
  744.                 notify.color.A = math.floor((255/2)*(notify.duration - GetGameTimer()))
  745.  
  746.                 if i == "Screen" then  
  747.                     local x = 0
  748.                     local y = 200
  749.                     local gameSettings = GetGameSettings()
  750.                     if gameSettings and gameSettings.General then
  751.                         if gameSettings.General.Width then x = gameSettings.General.Width/2 end
  752.                         if gameSettings.General.Height then y = gameSettings.General.Height/4 - 100 end
  753.                     end  
  754.                     --PrintChat(tostring(notify.color))
  755.                     local p = GetTextArea(notify.text, 40).x
  756.                     self:DrawTextWithBorder(notify.text, 40, x - p/2, y, notify.color:ToARGB(), ARGB(notify.color.A, 0, 0, 0))
  757.                 else    
  758.                     local pos = WorldToScreen(D3DXVECTOR3(notify.object.x, notify.object.y, notify.object.z))
  759.                     local x = pos.x
  760.                     local y = pos.y - 25
  761.                     local p = GetTextArea(notify.text, 40).x
  762.  
  763.                     self:DrawTextWithBorder(notify.text, 30, x- p/2, y, notify.color:ToARGB(), ARGB(notify.color.A, 0, 0, 0))
  764.                 end
  765.             end
  766.         end
  767.     end
  768.  
  769.     function Message:DrawTextWithBorder(textToDraw, textSize, x, y, textColor, backgroundColor)
  770.         DrawText(textToDraw, textSize, x + 1, y, backgroundColor)
  771.         DrawText(textToDraw, textSize, x - 1, y, backgroundColor)
  772.         DrawText(textToDraw, textSize, x, y - 1, backgroundColor)
  773.         DrawText(textToDraw, textSize, x, y + 1, backgroundColor)
  774.         DrawText(textToDraw, textSize, x , y, textColor)
  775.     end
  776. -- }
  777. --]]
Advertisement
Add Comment
Please, Sign In to add comment