Kain2030

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

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