Kain2030

Auto Carry Plugin - Ziggs Edition - v1.06

Jul 23rd, 2013
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.25 KB | None | 0 0
  1. --[[
  2.  
  3.         Auto Carry Plugin - Ziggs Edition
  4.         Author: Kain
  5.         Version: 1.06
  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 - Ziggs.lua" without the quotes.
  13.             Place the plugin in BoL/Scripts/Common folder.
  14. --]]
  15.  
  16. if myHero.charName ~= "Ziggs" then return end
  17.  
  18. local Target
  19.  
  20. -- Prediction
  21. local QRange = 850
  22. local QMaxRange = 1400
  23. local WRange = 1000
  24. local ERange = 900
  25. local RRange = 5300
  26.  
  27. local QSpeed = 1.2
  28. local WSpeed = 1.5
  29. local ESpeed = 1.45
  30. local RSpeed = 1.5
  31.  
  32. local QWidth = 150
  33. local WWidth = 225
  34. local EWidth = 250
  35. local RWidth = 550
  36.  
  37. local SkillQ = {spellKey = _Q, range = QMaxRange, speed = QSpeed, delay = 0, width = QWidth, configName = "bouncingbomb", displayName = "Q (Bouncing Bomb)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = true }
  38. local SkillW = {spellKey = _W, range = WRange, speed = WSpeed, delay = 0, width = WWidth, configName = "satchelcharge", displayName = "W (Satchel Charge)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = false }
  39. local SkillE = {spellKey = _E, range = ERange, speed = ESpeed, delay = 0, width = EWidth, configName = "hexplosiveminefield", displayName = "E (Hexplosive Minefield)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = false }
  40. local SkillR = {spellKey = _R, range = RRange, speed = RSpeed, delay = 0, width = RWidth, configName = "megainfernobomb", displayName = "R (Mega Inferno Bomb)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = true }
  41.  
  42. local KeyQ = string.byte("Q")
  43. local KeyW = string.byte("W")
  44. local KeyE = string.byte("E")
  45. local KeyR = string.byte("R")
  46.  
  47. local tick = nil
  48. local doUlt = false
  49.  
  50. -- Draw
  51. local waittxt = {}
  52. local calculationenemy = 1
  53. local floattext = {"Skills not available", "Able to fight", "Killable", "Murder him!"}
  54. local killable = {}
  55.  
  56. local ignite = nil
  57. local DFGSlot, HXGSlot, BWCSlot, SheenSlot, TrinitySlot, LichBaneSlot = nil, nil, nil, nil, nil, nil
  58. local QReady, WReady, EReady, RReady, DFGReady, HXGReady, BWCReady, IReady = false, false, false, false, false, false, false, false
  59.  
  60. local satchelChargeExists = false
  61. local pendingSatchelChargeActivation = nil
  62. local debugMode = false
  63.  
  64. -- Main
  65.  
  66. function Menu()
  67.     AutoCarry.PluginMenu:addParam("ZiggsCombo", "Combo", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  68.     AutoCarry.PluginMenu:addParam("FullCombo", "Full Combo", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("Z"))
  69.     AutoCarry.PluginMenu:addParam("Harass", "Harass", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("A"))
  70.     AutoCarry.PluginMenu:addParam("SatchelJump", "Satchel Jump", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("T"))
  71.     AutoCarry.PluginMenu:addParam("AutoHarass", "Auto Harass (Mana Intensive)", SCRIPT_PARAM_ONOFF, false)
  72.     AutoCarry.PluginMenu:addParam("Ultimate", "Use Ultimate with Combo", SCRIPT_PARAM_ONOFF, true)
  73.     AutoCarry.PluginMenu:addParam("Killsteal", "Ultimate Mega Killsteal", SCRIPT_PARAM_ONOFF, true)
  74.     AutoCarry.PluginMenu:addParam("DrawKillablEenemy", "Draw Killable Enemy", SCRIPT_PARAM_ONOFF, true)
  75.     AutoCarry.PluginMenu:addParam("DrawText", "Draw Text", SCRIPT_PARAM_ONOFF, true)
  76.     AutoCarry.PluginMenu:addParam("DrawPrediction", "Draw Prediction", SCRIPT_PARAM_ONOFF, true)
  77.     AutoCarry.PluginMenu:addParam("Draw", "Draw range circles", SCRIPT_PARAM_ONOFF, true)
  78.     AutoCarry.PluginMenu:addParam("DrawUlt", "Draw Ult range circle", SCRIPT_PARAM_ONOFF, true)
  79. end
  80.  
  81. function PluginOnLoad()
  82.     Menu()
  83.  
  84.     AutoCarry.SkillsCrosshair.range = QMaxRange
  85.  
  86.     if myHero:GetSpellData(SUMMONER_1).name:find("SummonerDot") then ignite = SUMMONER_1
  87.     elseif myHero:GetSpellData(SUMMONER_2).name:find("SummonerDot") then ignite = SUMMONER_2 end
  88.     for i=1, heroManager.iCount do waittxt[i] = i*3 end
  89. end
  90.  
  91. function PluginOnTick()
  92.     Target = AutoCarry.GetAttackTarget(true)
  93.  
  94.     SpellCheck()
  95.  
  96.     if tick == nil or GetTickCount()-tick >= 200 then
  97.         tick = GetTickCount()
  98.         CalculateDamage()
  99.     end
  100.  
  101.     if AutoCarry.PluginMenu.SatchelJump then
  102.         SatchelJump()
  103.     end
  104.  
  105.     if (AutoCarry.MainMenu.AutoCarry or AutoCarry.MainMenu.MixedMode) then
  106.         Combo()
  107.     end
  108.    
  109.     if AutoCarry.PluginMenu.FullCombo then
  110.         FullCombo()
  111.     end
  112.  
  113.     if AutoCarry.PluginMenu.Harass then
  114.         Harass()
  115.     end
  116.  
  117.     if AutoCarry.PluginMenu.Killsteal then
  118.         KillSteal()
  119.     end
  120. end
  121.  
  122. function PluginOnCreateObj(obj)
  123.     if obj.name == "ZiggsW_mis_ground.troy" then
  124.         satchelChargeExists = true
  125.         CastWActivate()
  126.     end
  127. end
  128.  
  129. function PluginOnDeleteObj(obj)
  130.     if obj.name == "ZiggsW_mis_ground.troy" then
  131.         satchelChargeExists = false
  132.         pendingSatchelChargeActivation = nil
  133.     end
  134. end
  135.  
  136. function OnAttacked()
  137.     -- AA > Q > AA
  138.     if AutoCarry.PluginMenu.AutoHarass then
  139.         CastQ()
  140.     end
  141. end
  142.  
  143. function SpellCheck()
  144.     DFGSlot, HXGSlot, BWCSlot, SheenSlot, TrinitySlot, LichBaneSlot = GetInventorySlotItem(3128),
  145.     GetInventorySlotItem(3146), GetInventorySlotItem(3144), GetInventorySlotItem(3057),
  146.     GetInventorySlotItem(3078), GetInventorySlotItem(3100)
  147.  
  148.     QReady = (myHero:CanUseSpell(SkillQ.spellKey) == READY)
  149.     WReady = (myHero:CanUseSpell(SkillW.spellKey) == READY)
  150.     EReady = (myHero:CanUseSpell(SkillE.spellKey) == READY)
  151.     RReady = (myHero:CanUseSpell(SkillR.spellKey) == READY)
  152.  
  153.     DFGReady = (DFGSlot ~= nil and myHero:CanUseSpell(DFGSlot) == READY)
  154.     HXGReady = (HXGSlot ~= nil and myHero:CanUseSpell(HXGSlot) == READY)
  155.     BWCReady = (BWCSlot ~= nil and myHero:CanUseSpell(BWCSlot) == READY)
  156.     IReady = (ignite ~= nil and myHero:CanUseSpell(ignite) == READY)
  157. end
  158.  
  159. -- Handle SBTW Skill Shots
  160.  
  161. function Combo()
  162.     CastSlots()
  163.     CastE()
  164.     CastQ()
  165.     if AutoCarry.PluginMenu.Ultimate and doUlt then
  166.         CastR()
  167.     end
  168. end
  169.  
  170. function FullCombo()
  171.     CastSlots()
  172.     CastE()
  173.     CastQ()
  174.     CastW()
  175.     CastWActivate()
  176.     if AutoCarry.PluginMenu.Ultimate and doUlt then
  177.         CastR()
  178.     end
  179. end
  180.  
  181. function CastSlots()
  182.     if Target ~= nil and not Target.dead then
  183.         if GetDistance(Target) <= QMaxRange then
  184.             if DFGReady then CastSpell(DFGSlot, Target) end
  185.             if HXGReady then CastSpell(HXGSlot, Target) end
  186.             if BWCReady then CastSpell(BWCSlot, Target) end
  187.         end
  188.     end
  189. end
  190.  
  191. function Harass()
  192.     CastQ()
  193. end
  194.  
  195. function CastQ()
  196.     if Target ~= nil and not Target.dead then
  197.         if QReady and ValidTarget(Target, QRange) then
  198.             AutoCarry.CastSkillshot(SkillQ, Target)
  199.         elseif QReady and ValidTarget(Target, QMaxRange) then
  200.             -- Full Bouncing Bomb three bounce range
  201.             local PredictedPos = AutoCarry.GetPrediction(SkillQ, Target)
  202.  
  203.             if PredictedPos and AutoCarry.IsValidHitChance(SkillQ, Target) then
  204.                 local MyPos = Vector(myHero.x, myHero.y, myHero.z)
  205.                 local EnemyPos = Vector(PredictedPos.x, PredictedPos.y, PredictedPos.z)
  206.                 local CastPos = MyPos - (MyPos - EnemyPos):normalized() * QRange
  207.                 if CastPos then CastSpell(SkillQ.spellKey, CastPos.x, CastPos.z) end
  208.             end
  209.         end
  210.     end
  211. end
  212.  
  213. function CastW(noTarget)
  214.     if noTarget and WReady then
  215.         AutoCarry.CastSkillshot(SkillW, myHero)
  216.     elseif Target ~= nil and ValidTarget(Target, WRange) and not Target.dead then
  217.         if WReady and GetDistance(Target) <= WRange then
  218.             AutoCarry.CastSkillshot(SkillW, Target)
  219.         end
  220.     end
  221. end
  222.  
  223. function CastWActivate()
  224.     if satchelChargeExists and pendingSatchelChargeActivation ~= nil then
  225.         if pendingSatchelChargeActivation == "satcheljump" then
  226.             CastSpell(SkillW.spellKey)
  227.             CastE()
  228.             pendingSatchelChargeActivation = nil
  229.         end
  230.     end
  231. end
  232.  
  233. function CastE()
  234.     if Target ~= nil and ValidTarget(Target, ERange) and not Target.dead then
  235.         if EReady and GetDistance(Target) <= ERange then
  236.             AutoCarry.CastSkillshot(SkillE, Target)
  237.         end
  238.     end
  239. end
  240.  
  241. function CastR()
  242.     if Target ~= nil and ValidTarget(Target, RRange) and not Target.dead then
  243.         if RReady and GetDistance(Target) <= RRange then
  244.             AutoCarry.CastSkillshot(SkillR, Target)
  245.         end
  246.     end
  247. end
  248.  
  249. function KillSteal()
  250.     for _, enemy in pairs(AutoCarry.EnemyTable) do
  251.         if ValidTarget(enemy, RRange) and not enemy.dead then
  252.             if enemy.health < getDmg("R", enemy, myHero) and IsValidHitChanceCustom(SkillR, enemy) then
  253.                 AutoCarry.CastSkillshot(SkillR, enemy)
  254.             end
  255.         end
  256.     end
  257. end
  258.  
  259. function SatchelJump()
  260.     -- E is cast before and after jump to insure that a target near either location can be hit.
  261.     pendingSatchelChargeActivation = "satcheljump"
  262.     CastW(true)
  263.     CastE()
  264. end
  265.  
  266. -- Sliding scale hitchance based on target distance.
  267. function getScalingHitChanceFromDistance(SkillRange, Target)
  268.     local minHitChance = 60
  269.     local maxHitChance = 95
  270.  
  271.     hitChance = minHitChance + ((1 - (SkillRange - GetDistance(Target)) / (SkillRange - 0))) * (maxHitChance - minHitChance)
  272.     if debugMode then PrintChat("HitChance Info: skillrange="..SkillRange..", targetdistance="..GetDistance(Target)..", hitchance:"..hitChance) end
  273.     return hitChance
  274. end
  275.  
  276. function IsValidHitChanceCustom(skill, target)
  277.     if VIP_USER then
  278.         pred = TargetPredictionVIP(skill.range, skill.speed*1000, skill.delay/1000, skill.width)
  279.         return pred:GetHitChance(target) > getScalingHitChanceFromDistance(skill.range, target)/100 and true or false
  280.     elseif not VIP_USER then
  281.         local nonVIPMaxHitChance = 70
  282.         return getScalingHitChanceFromDistance(skill.range, target) < nonVIPMaxHitChance and true or false
  283.     end
  284. end
  285.  
  286. --[[
  287. function satchelChargeExistsDelete()
  288.     for i=1, objManager.maxObjects do
  289.         local obj = objManager:getObject(i)
  290.  
  291.         if obj ~= nil and obj.name:find("Satchel Charge") then
  292.             return true
  293.         end
  294.     end
  295.     return false
  296. end
  297. --]]
  298.  
  299. -- Handle Manual Skill Shots
  300.  
  301. function PluginOnWndMsg(msg,key)
  302.     Target = AutoCarry.GetAttackTarget()
  303.     if Target ~= nil then
  304.         if msg == KEY_DOWN and key == KeyQ then CastQ() end
  305.         if msg == KEY_DOWN and key == KeyW then CastW() end
  306.         if msg == KEY_DOWN and key == KeyE then CastE() end
  307.         if msg == KEY_DOWN and key == KeyR then CastR() end
  308.     end
  309. end
  310.  
  311. -- Drawing
  312.  
  313. function PluginOnDraw()
  314.     if AutoCarry.PluginMenu.Draw then
  315.         DrawCircle(myHero.x, myHero.y, myHero.z, AutoCarry.SkillsCrosshair.range, 0x808080) -- Gray
  316.  
  317.         if myHero:CanUseSpell(SkillQ.spellKey) then
  318.             DrawCircle(myHero.x, myHero.y, myHero.z, QRange, 0x0099CC) -- Blue
  319.         end
  320.        
  321.         if myHero:CanUseSpell(SkillW.spellKey) then
  322.             DrawCircle(myHero.x, myHero.y, myHero.z, WRange, 0xFFFF00) -- Yellow
  323.         end
  324.        
  325.         if myHero:CanUseSpell(SkillE.spellKey) then
  326.             DrawCircle(myHero.x, myHero.y, myHero.z, ERange, 0x00FF00) -- Green
  327.         end
  328.  
  329.         if AutoCarry.PluginMenu.DrawUlt then
  330.             if myHero:CanUseSpell(SkillR.spellKey) then
  331.                 DrawCircle(myHero.x, myHero.y, myHero.z, RRange, 0xFF0000) -- Red
  332.             end
  333.         end
  334.  
  335.         Target = AutoCarry.GetAttackTarget()
  336.         if Target ~= nil then
  337.             for j=0, 10 do
  338.                 DrawCircle(Target.x, Target.y, Target.z, 40 + j*1.5, 0x00FF00) -- Green
  339.             end
  340.         end
  341.     end
  342.    
  343.     DrawKillable()
  344. end
  345.  
  346. function CalculateDamage()
  347.         if ValidTarget(Target) then
  348.                 local dfgdamage, hxgdamage, bwcdamage, ignitedamage, Sheendamage, Trinitydamage, LichBanedamage  = 0, 0, 0, 0, 0, 0, 0
  349.                 local pdamage = getDmg("P",Target,myHero)
  350.                 local qdamage = getDmg("Q",Target,myHero)
  351.                 local wdamage = getDmg("W",Target,myHero)
  352.                 local edamage = getDmg("E",Target,myHero)
  353.                 local rdamage = getDmg("R",Target,myHero)
  354.                 local hitdamage = getDmg("AD",Target,myHero)
  355.                 local dfgdamage = (DFGSlot and getDmg("DFG",Target,myHero) or 0)
  356.                 local hxgdamage = (HXGSlot and getDmg("HXG",Target,myHero) or 0)
  357.                 local bwcdamage = (BWCSlot and getDmg("BWC",Target,myHero) or 0)
  358.                 local ignitedamage = (ignite and getDmg("IGNITE",Target,myHero) or 0)
  359.                 local Sheendamage = (SheenSlot and getDmg("SHEEN",Target,myHero) or 0)
  360.                 local Trinitydamage = (TrinitySlot and getDmg("TRINITY",Target,myHero) or 0)
  361.                 local LichBanedamage = (LichBaneSlot and getDmg("LICHBANE",Target,myHero) or 0)
  362.                 local combo1 = hitdamage + qdamage + wdamage + edamage + rdamage + Sheendamage + Trinitydamage + LichBanedamage --0 cd
  363.                 local combo2 = hitdamage + Sheendamage + Trinitydamage + LichBanedamage
  364.                 local combo3 = hitdamage + Sheendamage + Trinitydamage + LichBanedamage
  365.                 local combo4 = 0
  366.                
  367.                 if QREADY then
  368.                         combo2 = combo2 + qdamage
  369.                         combo3 = combo3 + qdamage
  370.                         --combo4 = combo4 + qdamage
  371.                 end
  372.                 if WREADY then
  373.                         combo2 = combo2 + wdamage
  374.                         combo3 = combo3 + wdamage
  375.                 end
  376.                 if EREADY then
  377.                         combo2 = combo2 + edamage
  378.                         combo3 = combo3 + edamage
  379.                         --combo4 = combo4 + edamage
  380.                 end
  381.                 if RREADY then
  382.                         combo2 = combo2 + rdamage
  383.                         combo3 = combo3 + rdamage
  384.                         combo4 = combo4 + rdamage
  385.                 end
  386.                 if DFGREADY then        
  387.                         combo1 = combo1 + dfgdamage            
  388.                         combo2 = combo2 + dfgdamage
  389.                         combo3 = combo3 + dfgdamage
  390.                         --combo4 = combo4 + dfgdamage
  391.                 end
  392.                 if HXGREADY then              
  393.                         combo1 = combo1 + hxgdamage    
  394.                         combo2 = combo2 + hxgdamage
  395.                         combo3 = combo3 + hxgdamage
  396.                         --combo4 = combo4 + hxgdamage
  397.                 end
  398.                 if BWCREADY then
  399.                         combo1 = combo1 + bwcdamage
  400.                         combo2 = combo2 + bwcdamage
  401.                         combo3 = combo3 + bwcdamage
  402.                         combo4 = combo4 + bwcdamage
  403.                 end
  404.                 if IREADY then
  405.                         combo1 = combo1 + ignitedamage
  406.                         combo2 = combo2 + ignitedamage
  407.                         combo3 = combo3 + ignitedamage
  408.                 end
  409.                 if combo4 >= Target.health then killable[calculationenemy] = 4 doUlt = true
  410.                 elseif combo3 >= Target.health then killable[calculationenemy] = 3 doUlt = false
  411.                 elseif combo2 >= Target.health then killable[calculationenemy] = 2 doUlt = false
  412.                 elseif combo1 >= Target.health then killable[calculationenemy] = 1  doCombo = true doUlt = false
  413.                 else killable[calculationenemy] = 0 doCombo = false doUlt = false end
  414.         end
  415.         if calculationenemy == 1 then calculationenemy = heroManager.iCount
  416.         else calculationenemy = calculationenemy-1 end
  417. end
  418.  
  419. function DrawKillable()
  420.     if 1 == 2 and Target ~= nil and AutoCarry.PluginMenu.DrawPrediction then
  421.         if VIP_USER then
  422.             pred = TargetPredictionVIP(SkillQ.range, SkillQ.speed*1000, SkillQ.delay/1000, SkillQ.width)
  423.         elseif not VIP_USER then
  424.             pred = TargetPrediction(SkillQ.range, SkillQ.speed, SkillQ.delay, SkillQ.width)
  425.         end
  426.         predPos = pred:GetPrediction(Target)
  427.         DrawCircle(predPos.x, Target.y, predPos.z, 200, 0x0000FF)
  428.     end
  429.     for i=1, heroManager.iCount do
  430.         local enemydraw = heroManager:GetHero(i)
  431.         if ValidTarget(enemydraw) then
  432.             if AutoCarry.PluginMenu.DrawKillablEenemy then
  433.                 if killable[i] == 1 then
  434.                     for j=0, 20 do
  435.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 80 + j*1.5, 0x0000FF)
  436.                     end
  437.                 elseif killable[i] == 2 then
  438.                     for j=0, 10 do
  439.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 80 + j*1.5, 0xFF0000)
  440.                     end
  441.                 elseif killable[i] == 3 then
  442.                     for j=0, 10 do
  443.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 80 + j*1.5, 0xFF0000)
  444.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 110 + j*1.5, 0xFF0000)
  445.                     end
  446.                 elseif killable[i] == 4 then
  447.                     for j=0, 10 do
  448.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 80 + j*1.5, 0xFF0000)
  449.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 110 + j*1.5, 0xFF0000)
  450.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 140 + j*1.5, 0xFF0000)
  451.                     end
  452.                 end
  453.             end
  454.             if AutoCarry.PluginMenu.DrawText and waittxt[i] == 1 and killable[i] ~= 0 then
  455.                     PrintFloatText(enemydraw,0,floattext[killable[i]])
  456.             end
  457.         end
  458.         if waittxt[i] == 1 then waittxt[i] = 30
  459.         else waittxt[i] = waittxt[i]-1 end
  460.     end
  461. end
Advertisement
Add Comment
Please, Sign In to add comment