Kain2030

Auto Carry Plugin - Graves Edition - True Grit - v1.0

Aug 21st, 2013
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.48 KB | None | 0 0
  1. --[[
  2.  
  3.         Auto Carry Plugin - Graves Edition
  4.         Author: Kain
  5.         Copyright 2013
  6.  
  7.         Dependency: Sida's Auto Carry: Revamped
  8.  
  9.         How to install:
  10.             Make sure you already have AutoCarry installed.
  11.             Name the script EXACTLY "SidasAutoCarryPlugin - Graves.lua" without the quotes.
  12.             Place the plugin in BoL/Scripts/Common folder.
  13.  
  14.         Version History:
  15.             Version: 1.0:
  16.                 Combo
  17.                 Smart Quickdraw
  18.                 True Grit keep alive
  19.                 Killsteal combos
  20.                 Pro Mode spell buttons
  21. --]]
  22.  
  23. if myHero.charName ~= "Graves" then return end
  24.  
  25. function PluginOnLoad()
  26.     Vars()
  27.     Menu()
  28. end
  29.  
  30. function Vars()
  31.     tick = nil
  32.     Target = nil
  33.  
  34.     KeyQ = string.byte("Q")
  35.     KeyW = string.byte("W")
  36.     KeyE = string.byte("E")
  37.     KeyR = string.byte("R")
  38.  
  39.     QRange, WRange, ERange, RRange = 950, 950, 425, 1000
  40.     QSpeed, WSpeed, ESpeed, RSpeed = 1.95, 1.65, 1.45, 2.10
  41.     QDelay, WDelay, EDelay, RDelay = 265, 300, 250, 219
  42.     QWidth, WWidth, EWidth = 70, 500, 200
  43.    
  44.     SkillQ = { spellKey = _Q, range = QRange, speed = QSpeed, delay = QDelay, width = QWidth, configName = "buckShot", displayName = "Q (Buck Shot)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = true }
  45.     SkillW = { spellKey = _W, range = WRange, speed = WSpeed, delay = WDelay, width = 500, configName = "smokeScreen", displayName = "W (Smoke Screen)", enabled = false, skillShot = true, minions = false, reset = false, reqTarget = true }
  46.     SkillE = { spellKey = _E, range = ERange, speed = ESpeed, delay = EDelay, width = 200, configName = "quickDraw", displayName = "E (Quick Draw)", enabled = true, skillShot = false, minions = false, reset = true, reqTarget = false, atMouse = true }
  47.     SkillR = { spellKey = _R, range = RRange, speed = RSpeed, delay = RDelay, configName = "collateralDamage"}
  48.  
  49.     -- Buffs
  50.     BuffPassive = "gravespassivegrit"
  51.     BuffQuickdraw = "gravesmovesteroid"
  52.  
  53.     -- True Grit Passive
  54.     PassiveTimer = 0
  55.     BuffPassivePresent = false
  56.     BuffQuickdrawPresent = false
  57.     PassiveTimeout = 3 -- Seconds
  58.     isPassiveAttack = false
  59.  
  60.     debugMode = false
  61. end
  62.  
  63. function Menu()
  64.     AutoCarry.PluginMenu:addParam("sep", "----- [ Combo ] -----", SCRIPT_PARAM_INFO, "")
  65.     AutoCarry.PluginMenu:addParam("ComboQ", "Use Buckshot", SCRIPT_PARAM_ONOFF, true)
  66.     AutoCarry.PluginMenu:addParam("ComboW", "Use Smoke Screen", SCRIPT_PARAM_ONOFF, true)
  67.     AutoCarry.PluginMenu:addParam("ComboE", "Use Quickdraw", SCRIPT_PARAM_ONOFF, true)
  68.     AutoCarry.PluginMenu:addParam("ComboR", "Use Collateral Damage", SCRIPT_PARAM_ONOFF, true)
  69.     AutoCarry.PluginMenu:addParam("SmartE", "Smart Quickdraw", SCRIPT_PARAM_ONOFF, true)
  70.     AutoCarry.PluginMenu:addParam("sep", "----- [ Advanced ] -----", SCRIPT_PARAM_INFO, "")
  71.     AutoCarry.PluginMenu:addParam("AutoHarass", "Auto Harass", SCRIPT_PARAM_ONOFF, false)
  72.     AutoCarry.PluginMenu:addParam("KeepPassiveActive", "Keep True Grit Active (Beta)", SCRIPT_PARAM_ONOFF, true)
  73.     AutoCarry.PluginMenu:addParam("RegainPassive", "Regain True Grit If Lost", SCRIPT_PARAM_ONOFF, false)
  74.     AutoCarry.PluginMenu:addParam("ProMode", "Use Auto QWER Keys", SCRIPT_PARAM_ONOFF, true)
  75.     AutoCarry.PluginMenu:addParam("EMinMouseDiff", "Quickdraw Min. Mouse Diff.", SCRIPT_PARAM_SLICE, 600, 100, 1000, 0)
  76.     AutoCarry.PluginMenu:addParam("sep", "----- [ Killsteal ] -----", SCRIPT_PARAM_INFO, "")
  77.     AutoCarry.PluginMenu:addParam("Killsteal", "Killsteal", SCRIPT_PARAM_ONOFF, true)
  78.     AutoCarry.PluginMenu:addParam("KillstealQ", "Use Buckshot", SCRIPT_PARAM_ONOFF, true)
  79.     AutoCarry.PluginMenu:addParam("KillstealW", "Use Smoke Screen", SCRIPT_PARAM_ONOFF, true)
  80.     AutoCarry.PluginMenu:addParam("KillstealR", "Use Collateral Damage", SCRIPT_PARAM_ONOFF, true)
  81.     AutoCarry.PluginMenu:addParam("sep", "----- [ Draw ] -----", SCRIPT_PARAM_INFO, "")
  82.     AutoCarry.PluginMenu:addParam("DisableDraw", "Disable Draw", SCRIPT_PARAM_ONOFF, false)
  83.     AutoCarry.PluginMenu:addParam("DrawFurthest", "Draw Furthest Spell Available", SCRIPT_PARAM_ONOFF, true)
  84.     AutoCarry.PluginMenu:addParam("DrawQ", "Draw Buckshot", SCRIPT_PARAM_ONOFF, true)
  85.     AutoCarry.PluginMenu:addParam("DrawW", "Draw Smoke Screen", SCRIPT_PARAM_ONOFF, true)
  86.     AutoCarry.PluginMenu:addParam("DrawE", "Draw Quickdraw", SCRIPT_PARAM_ONOFF, true)
  87.     AutoCarry.PluginMenu:addParam("DrawR", "Draw Collateral Damage", SCRIPT_PARAM_ONOFF, true)
  88. end
  89.  
  90. function SpellChecks()
  91.     QReady = (myHero:CanUseSpell(SkillQ.spellKey) == READY)
  92.     WReady = (myHero:CanUseSpell(SkillW.spellKey) == READY)
  93.     EReady = (myHero:CanUseSpell(SkillE.spellKey) == READY)
  94.     RReady = (myHero:CanUseSpell(SkillR.spellKey) == READY)
  95. end
  96.  
  97. function PluginOnTick()
  98.     tick = GetTickCount()
  99.     Target = AutoCarry.GetAttackTarget(true)
  100.  
  101.     SpellChecks()
  102.  
  103.     if (AutoCarry.MainMenu.AutoCarry or AutoCarry.MainMenu.MixedMode) then
  104.         Combo()
  105.     end
  106.  
  107.     if AutoCarry.PluginMenu.Killsteal then
  108.         -- Killsteal()
  109.     end
  110.  
  111.     if AutoCarry.PluginMenu.KeepPassiveActive then
  112.         PassiveKeepAlive()
  113.     end
  114. end
  115.  
  116. function OnGainBuff(unit, buff)
  117.     if unit.name == myHero.name then
  118.         if buff and buff.name ~= nil then
  119.             -- PrintChat("gain buff: "..buff.name)
  120.             if buff.name == BuffPassive then
  121.                 BuffPassivePresent = true
  122.                 PassiveTimer = GetTickCount()
  123.             elseif buff.name == BuffQuickdraw then
  124.                 BuffQuickdrawPresent = true
  125.             end
  126.         end
  127.     end
  128. end
  129.  
  130. function OnLoseBuff(unit, buff)
  131.     if unit.name == myHero.name then
  132.         if buff and buff.name ~= nil then
  133.             -- PrintChat("lose buff: "..buff.name)
  134.             if buff.name == BuffPassive then
  135.                 BuffPassivePresent = false
  136.                 PassiveTimer = 0
  137.             elseif buff.name == BuffQuickdraw then
  138.                 BuffQuickdrawPresent = false
  139.             end
  140.         end
  141.     end
  142. end
  143.  
  144. function OnAttacked()
  145.     -- Auto AA > Q > AA
  146.  
  147.     ResetPassiveTimer()
  148.  
  149.     if isPassiveAttack then
  150.         isPassiveAttack = false
  151.         PrintFloatText(myHero, 20, "True Grit!")
  152.         if AutoCarry.PluginMenu.KeepPassiveActive and not AutoCarry.MainMenu.AutoCarry and not AutoCarry.MainMenu.MixedMode and not AutoCarry.MainMenu.LaneClear then
  153.             if myHero then myHero:HoldPosition() end
  154.         end
  155.     end
  156.  
  157.     if AutoCarry.MainMenu.AutoCarry or AutoCarry.MainMenu.MixedMode or (AutoCarry.PluginMenu.AutoHarass and not IsMyManaLow()) then
  158.         CastQ()
  159.     end
  160. end
  161.  
  162. function Combo()
  163.     if Target then
  164.         if AutoCarry.PluginMenu.ComboE then CastE() end
  165.         if AutoCarry.PluginMenu.ComboW then CastW() end
  166.         if AutoCarry.PluginMenu.ComboQ then CastQ() end
  167.         if AutoCarry.PluginMenu.ComboR then CastR() end
  168.     end
  169. end
  170.  
  171. function IsTickReady(tickFrequency)
  172.     -- Improves FPS
  173.     if tick ~= nil and math.fmod(tick, tickFrequency) == 0 then
  174.         return true
  175.     else
  176.         return false
  177.     end
  178. end
  179.  
  180. function PassiveKeepAlive()
  181.     if not AutoCarry.PluginMenu.KeepPassiveActive then return end
  182.  
  183.     local timeSincePassive = GetTickCount() - PassiveTimer
  184.     local timeLeftOnPassive = ((PassiveTimeout * 1000) - timeSincePassive)
  185.  
  186.     if AutoCarry.PluginMenu.RegainPassive and IsTickReady(25) and (not BuffPassivePresent or timeSincePassive > (PassiveTimeout * 1000)) then
  187.         -- Already expired.
  188.         if AutoCarry.PluginMenu.RegainPassive then
  189.             if PassiveFire() then
  190.                 if debugMode then PrintChat("true grit2: "..(timeSincePassive/1000)..", left on passive: "..(timeLeftOnPassive/1000)) end
  191.             end
  192.         end
  193.     elseif PassiveTimer > 0 and timeLeftOnPassive > 0 and timeLeftOnPassive < 750 then
  194.         -- Passive about to expire. Do something!
  195.         if debugMode then PrintChat("true grit1: "..(timeSincePassive/1000)..", left on passive: "..(timeLeftOnPassive/1000)) end
  196.         PassiveFire()
  197.     end
  198. end
  199.  
  200. function ResetPassiveTimer()
  201.     PassiveTimer = GetTickCount()
  202. end
  203.  
  204. function PassiveFire()
  205.     local passiveTarget
  206.  
  207.     if Target and GetDistance(Target) < myHero.range then
  208.         passiveTarget = Target
  209.     else
  210.         -- Find enemy player
  211.         local playerTarget = nil
  212.         for _, enemy in pairs(AutoCarry.EnemyTable) do
  213.             if enemy and not enemy.dead and ValidTarget(enemy) and GetDistance(enemy) <= myHero.range then
  214.                 if enemy.health < getDmg("AD", enemy, myHero) then
  215.                     -- Enemy is killable
  216.                     playerTarget = enemy
  217.                     break
  218.                 elseif playerTarget == nil or enemy.health < playerTarget.health then
  219.                     -- Find lowest target health
  220.                     playerTarget = enemy
  221.                 end
  222.             end
  223.         end
  224.  
  225.         if playerTarget then
  226.             passiveTarget = playerTarget
  227.         end
  228.    
  229.         local minionTarget = nil
  230.         for _, minion in pairs(AutoCarry.EnemyMinions().objects) do
  231.             if ValidTarget(minion) and GetDistance(minion) <= myHero.range then
  232.                 if minion.health < getDmg("AD", minion, myHero) then
  233.                     minionTarget = minion
  234.                     break
  235.                 elseif minionTarget == nil then
  236.                     minionTarget = minion
  237.                 end
  238.             end
  239.         end
  240.  
  241.         if minionTarget then
  242.             passiveTarget = minionTarget
  243.         end
  244.     end
  245.  
  246.     if passiveTarget and not isPassiveAttack then
  247.         if debugMode then PrintChat("true grit: fired") end
  248.         myHero:HoldPosition()
  249.         myHero:Attack(passiveTarget)
  250.         isPassiveAttack = true
  251.         return true
  252.     end
  253.  
  254.     return false
  255. end
  256.  
  257. -- Draw
  258. function PluginOnDraw()
  259.     -- if Target ~= nil and not Target.dead and QReady and ValidTarget(Target, QMaxRange) then
  260.     if Target ~= nil and not Target.dead and (AutoCarry.MainMenu.AutoCarry or AutoCarry.MainMenu.MixedMode) then
  261.         DrawArrowsToPos(myHero, Target)
  262.     end
  263.  
  264.     if not AutoCarry.PluginMenu.DisableDraw and not myHero.dead then
  265.         local farSpell = FindFurthestReadySpell()
  266.         -- if debugMode and farSpell then PrintChat("far: "..farSpell.configName) end
  267.  
  268.         DrawCircle(myHero.x, myHero.y, myHero.z, AutoCarry.SkillsCrosshair.range, 0x808080) -- Gray
  269.  
  270.         if AutoCarry.PluginMenu.DrawQ and QReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillQ) or not AutoCarry.PluginMenu.DrawFurthest) then
  271.             DrawCircle(myHero.x, myHero.y, myHero.z, QRange, 0x0099CC) -- Blue
  272.         end
  273.  
  274.         if AutoCarry.PluginMenu.DrawW and WReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillW) or not AutoCarry.PluginMenu.DrawFurthest) then
  275.             DrawCircle(myHero.x, myHero.y, myHero.z, WRange, 0xFFFF00) -- Yellow
  276.         end
  277.        
  278.         if AutoCarry.PluginMenu.DrawE and EReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillE) or not AutoCarry.PluginMenu.DrawFurthest) then
  279.             DrawCircle(myHero.x, myHero.y, myHero.z, ERange, 0x00FF00) -- Green
  280.         end
  281.  
  282.         if AutoCarry.PluginMenu.DrawR and RReady and ((AutoCarry.PluginMenu.DrawFurthest and farSpell and farSpell == SkillR) or not AutoCarry.PluginMenu.DrawFurthest) then
  283.             DrawCircle(myHero.x, myHero.y, myHero.z, RRange, 0xFF0000) -- Red
  284.         end
  285.  
  286.         Target = AutoCarry.GetAttackTarget()
  287.         if Target ~= nil then
  288.             for j=0, 10 do
  289.                 DrawCircle(Target.x, Target.y, Target.z, 40 + j*1.5, 0x00FF00) -- Green
  290.             end
  291.         end
  292.  
  293.     end
  294. end
  295.  
  296. function FindFurthestReadySpell()
  297.     local farSpell = nil
  298.  
  299.     if AutoCarry.PluginMenu.DrawQ and QReady then farSpell = SkillQ end
  300.     if AutoCarry.PluginMenu.DrawW and WReady and (not farSpell or WRange > farSpell.range) then farSpell = SkillW end
  301.     if AutoCarry.PluginMenu.DrawE and EReady and (not farSpell or ERange > farSpell.range) then farSpell = SkillE end
  302.     if AutoCarry.PluginMenu.DrawR and RReady and (not farSpell or RRange > farSpell.range) then farSpell = SkillR end
  303.  
  304.     return farSpell
  305. end
  306.  
  307. function DrawArrowsToPos(pos1, pos2)
  308.     if pos1 and pos2 then
  309.         startVector = D3DXVECTOR3(pos1.x, pos1.y, pos1.z)
  310.         endVector = D3DXVECTOR3(pos2.x, pos2.y, pos2.z)
  311.         -- directionVector = (endVector-startVector):normalized()
  312.         DrawArrows(startVector, endVector, 60, 0xE97FA5, 100)
  313.     end
  314. end
  315.  
  316. -- Buckshot
  317. function CastQ(enemy)
  318.     if not enemy then enemy = Target end
  319.     if enemy and QReady and GetDistance(enemy) < QRange then
  320.         AutoCarry.CastSkillshot(SkillQ, enemy)
  321.         ResetPassiveTimer()
  322.     end
  323. end
  324.  
  325. -- Smoke Screen
  326. function CastW(enemy)
  327.     if not enemy then enemy = Target end
  328.     if enemy and WReady and GetDistance(enemy) < WRange then
  329.         AutoCarry.CastSkillshot(SkillW, enemy)
  330.         ResetPassiveTimer()
  331.     end
  332. end
  333.  
  334. -- Quickdraw
  335. function CastE()
  336.     if not AutoCarry.PluginMenu.ComboE then return end
  337.  
  338.     if AutoCarry.PluginMenu.SmartE then
  339.         if ((GetDistance(mousePos) > AutoCarry.PluginMenu.EMinMouseDiff) and isEnemyInRange(ERange + RRange)) then
  340.             local dashSqr = math.sqrt((mousePos.x - myHero.x)^2+(mousePos.z - myHero.z)^2)
  341.             local dashX = myHero.x + ERange*((mousePos.x - myHero.x)/dashSqr)
  342.             local dashZ = myHero.z + ERange*((mousePos.z - myHero.z)/dashSqr)
  343.  
  344.             CastSpell(SkillE.spellKey, dashX, dashZ)
  345.             ResetPassiveTimer()
  346.         end
  347.     else
  348.         CastSpell(SkillE.spellKey, mousePos.x, mousePos.z)
  349.     end
  350. end
  351.  
  352. -- Collateral Damage
  353. function CastR(enemy)
  354.     if not enemy then enemy = Target end
  355.     if enemy and RReady and GetDistance(enemy) < RRange then
  356.         AutoCarry.CastSkillshot(SkillR, enemy)
  357.         ResetPassiveTimer()
  358.     end
  359. end
  360.  
  361. function isEnemyInRange(range)
  362.     for _, enemy in pairs(AutoCarry.EnemyTable) do
  363.         if ValidTarget(enemy, range) and not enemy.dead then
  364.             return true
  365.         end
  366.     end
  367.  
  368.     return false
  369. end
  370.  
  371. function Killsteal()
  372.     for _, enemy in pairs(AutoCarry.EnemyTable) do
  373.         if enemy and not enemy.dead then
  374.             local qDmg = getDmg("Q", enemy, myHero)
  375.             local wDmg = getDmg("W", enemy, myHero)
  376.             local rDmg = getDmg("R", enemy, myHero)
  377.  
  378.             if QReady and AutoCarry.PluginMenu.KillstealQ and ValidTarget(enemy, QRange) and enemy.health < qDmg then
  379.                 CastQ(enemy)
  380.             elseif QReady and WReady and AutoCarry.PluginMenu.KillstealQ and AutoCarry.PluginMenu.KillstealW and ValidTarget(enemy, QRange) and ValidTarget(enemy, WRange) and enemy.health < (qDmg + wDmg) then
  381.                 CastW(enemy)
  382.                 CastQ(enemy)
  383.             elseif RReady and AutoCarry.PluginMenu.KillstealR and ValidTarget(enemy, RRange) and enemy.health < rDmg then
  384.                 CastR(enemy)
  385.             elseif QReady and RReady and AutoCarry.PluginMenu.KillstealQ and AutoCarry.PluginMenu.KillstealR
  386.                 and ValidTarget(enemy, QRange) and ValidTarget(enemy, RRange) and enemy.health < (qDmg + rDmg) then
  387.                 CastQ(enemy)
  388.                 CastR(enemy)
  389.             end
  390.         end
  391.     end
  392. end
  393.  
  394. function IsMyManaLow()
  395.     local lowManaPercent = 40
  396.     if myHero.mana < (myHero.maxMana * ( lowManaPercent / 100)) then
  397.         return true
  398.     else
  399.         return false
  400.     end
  401. end
  402.  
  403. function IsTargetHealthLow()
  404.     local targetLowHealth = .40
  405.  
  406.     if Target ~= nil and Target.health < (Target.maxHealth * targetLowHealth) then
  407.         return true
  408.     else
  409.         return false
  410.     end
  411. end
  412.  
  413. function IsTargetManaLow()
  414.     local targetLowMana = .15
  415.  
  416.     if Target ~= nil and Target.mana < (Target.maxMana * targetLowMana) then
  417.         return true
  418.     else
  419.         return false
  420.     end
  421. end
  422.  
  423. function PluginOnWndMsg(msg,key)
  424.     Target = AutoCarry.GetAttackTarget(true)
  425.     if Target ~= nil and AutoCarry.PluginMenu.ProMode then
  426.         if msg == KEY_DOWN and key == KeyQ then CastQ() end
  427.         if msg == KEY_DOWN and key == KeyW then CastW() end
  428.         if msg == KEY_DOWN and key == KeyE then CastE() end
  429.         if msg == KEY_DOWN and key == KeyR then CastR() end
  430.     end
  431. end
Advertisement
Add Comment
Please, Sign In to add comment