Kain2030

Auto Carry Plugin - Ziggs Edition - v1.2d

Aug 14th, 2013
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.58 KB | None | 0 0
  1. --[[
  2.  
  3.         Auto Carry Plugin - Ziggs Edition
  4.         Author: Kain
  5.         Version: 1.2d
  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.         Version History:
  16.             Version: 1.2d: http://pastebin.com/2J8F8XFt
  17.                 Added Wall check for Q.
  18.                 Added E toggle for Satchel Jump and Harass.
  19.                 Added line draw to currently selected target.
  20.                 Added auto disable for Killsteal when AFK.
  21.                 Cleaned up plugin menu.
  22.             Version: 1.1d: http://pastebin.com/T3rUd14Y
  23.             Version: 1.1c: http://pastebin.com/exXzdFD8
  24.                 Improved Satchel Jump to fire more accurately and also in the direction of the mouse position.
  25.                 Added low mana handling with the Mana Manager.
  26.                 Added Smart Q farming. Uses Q when it can kill multiple minions and mana is higher than the Mana Manager low limit.
  27.                 Improved prediction range logic for Q and R.
  28.                 Fixed Q to not hit minions as much.
  29.                 Added enemy low health logic.
  30.             Version: 1.08: http://pastebin.com/ebB89AnC
  31.             Version: 1.07: http://pastebin.com/Mj7i5k9X
  32.                 Added text on screen when Killsteal occurs to make it more noticeable.
  33.                 Added slider variable to set Killsteal hitchance/sensitivity.
  34.             Version: 1.06: http://pastebin.com/5j9W654G (7/23/2013)
  35.                 Fixed Karthus / Kog'maw, etc. bug where script would try to kill their 'ghost' after they were dead, but still present nearby.
  36.                 Added toggle for auto harass.
  37.                 Change range color indicators.
  38.             Version: 1.05: http://pastebin.com/CcgW9n27
  39.                 Added Satchel Jump.
  40.                 Improved "Ultimate Mega Killsteal" calculation. Now operates on a hitchance curve. The further away the target is, the higher the hitchance required to throw the Bomb. Should reduce the number of cross-map misses. Will experiment with the settings after more feedback.
  41.                 Removed Satchel from normal combo.
  42.                 Added a secondary Full Combo option.
  43.             Version: 1.04: http://pastebin.com/z4nTWmkr
  44.                 Fixed Bouncing Bomb for full range prediction. Requires SAC 4.9 or later.
  45.             Version: 1.03 Beta: http://pastebin.com/kZED9bqV
  46.             Version: 1.02 Beta: http://pastebin.com/5CzSRtdL
  47.             Version: 1.01 Beta: http://pastebin.com/hx2RYDaQ
  48.             Version: 1.0 Beta: http://pastebin.com/bGa23bFR
  49. --]]
  50.  
  51. if myHero.charName ~= "Ziggs" then return end
  52.  
  53. local Target
  54.  
  55. -- Prediction
  56. local QRange = 850
  57. local QMaxRange = 1400
  58. local WRange = 1000
  59. local ERange = 900
  60. local RRange = 5300
  61.  
  62. local QSpeed = 1.722 -- Old: 1.2
  63. local WSpeed = 1.727 -- Old: 1.5
  64. local ESpeed = 2.694 -- Old: 1.45
  65. local RSpeed = 1.856 -- Old: 1.5
  66.  
  67. local QDelay = 218
  68. local WDelay = 249
  69. local EDelay = 125
  70. local RDelay = 1014
  71.  
  72. local QWidth = 150
  73. local WWidth = 225
  74. local EWidth = 250
  75. local RWidth = 550
  76.  
  77.  
  78. local SkillQ = {spellKey = _Q, range = QMaxRange, speed = QSpeed, delay = QDelay, width = QWidth, configName = "bouncingbomb", displayName = "Q (Bouncing Bomb)", enabled = true, skillShot = true, minions = true, reset = false, reqTarget = true }
  79. local SkillW = {spellKey = _W, range = WRange, speed = WSpeed, delay = WDelay, width = WWidth, configName = "satchelcharge", displayName = "W (Satchel Charge)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = false }
  80. local SkillE = {spellKey = _E, range = ERange, speed = ESpeed, delay = EDelay, width = EWidth, configName = "hexplosiveminefield", displayName = "E (Hexplosive Minefield)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = false }
  81. local SkillR = {spellKey = _R, range = RRange, speed = RSpeed, delay = RDelay, width = RWidth, configName = "megainfernobomb", displayName = "R (Mega Inferno Bomb)", enabled = true, skillShot = true, minions = false, reset = false, reqTarget = true }
  82.  
  83. local KeyQ = string.byte("Q")
  84. local KeyW = string.byte("W")
  85. local KeyE = string.byte("E")
  86. local KeyR = string.byte("R")
  87.  
  88. local tick = nil
  89. local doUlt = false
  90.  
  91. -- Draw
  92. local waittxt = {}
  93. local calculationenemy = 1
  94. local floattext = {"Skills not available", "Able to fight", "Killable", "Murder him!"}
  95. local killable = {}
  96.  
  97. -- Items
  98. local ignite = nil
  99. local DFGSlot, HXGSlot, BWCSlot, SheenSlot, TrinitySlot, LichBaneSlot = nil, nil, nil, nil, nil, nil
  100. local QReady, WReady, EReady, RReady, DFGReady, HXGReady, BWCReady, IReady = false, false, false, false, false, false, false, false
  101.  
  102. -- Satchel Jump
  103. local satchelChargeExists = false
  104. local pendingSatchelChargeActivation = nil
  105.  
  106. -- AFK Vars
  107. local afkTick = nil
  108. local lastAFKStatus = false
  109. local myHeroLastPos = nil
  110.  
  111. -- Debug
  112. local debugMode = false
  113.  
  114. -- Main
  115.  
  116. function Menu()
  117.     AutoCarry.PluginMenu:addParam("ZiggsCombo", "Combo", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  118.     AutoCarry.PluginMenu:addParam("FullCombo", "Full Combo", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("Z"))
  119.     AutoCarry.PluginMenu:addParam("Harass", "Harass", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("A"))
  120.     AutoCarry.PluginMenu:addParam("SatchelJump", "Satchel Jump", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("T"))
  121.     AutoCarry.PluginMenu:addParam("AutoHarass", "Auto Harass (Mana Intensive)", SCRIPT_PARAM_ONOFF, false)
  122.     AutoCarry.PluginMenu:addParam("ManaManager", "Mana Manager %", SCRIPT_PARAM_SLICE, 40, 0, 100, 2)
  123.     AutoCarry.PluginMenu:addParam("Ultimate", "Use Ultimate with Combo", SCRIPT_PARAM_ONOFF, true)
  124.     AutoCarry.PluginMenu:addParam("Killsteal", "Ultimate Mega Killsteal", SCRIPT_PARAM_ONOFF, true)
  125.     AutoCarry.PluginMenu:addParam("SmartFarmWithQ", "Smart Farm With Q", SCRIPT_PARAM_ONOFF, true)
  126.     AutoCarry.PluginMenu:addParam("sep", "----- [ Draw ] -----", SCRIPT_PARAM_INFO, "")
  127.     AutoCarry.PluginMenu:addParam("DrawKillablEenemy", "Draw Killable Enemy", SCRIPT_PARAM_ONOFF, true)
  128.     AutoCarry.PluginMenu:addParam("DrawText", "Draw Text", SCRIPT_PARAM_ONOFF, true)
  129.     AutoCarry.PluginMenu:addParam("DrawPrediction", "Draw Prediction", SCRIPT_PARAM_ONOFF, true)
  130.     AutoCarry.PluginMenu:addParam("Draw", "Draw range circles", SCRIPT_PARAM_ONOFF, true)
  131.     AutoCarry.PluginMenu:addParam("DrawUlt", "Draw Ult range circle", SCRIPT_PARAM_ONOFF, true)
  132.     AutoCarry.PluginMenu:addParam("sep", "----- [ Advanced ] -----", SCRIPT_PARAM_INFO, "")
  133.     AutoCarry.PluginMenu:addParam("AvoidWallsWithQ", "Avoid Hitting Walls with Q (Beta)", SCRIPT_PARAM_ONOFF, false)
  134.     AutoCarry.PluginMenu:addParam("SatchelJumpWithE", "Satchel Jump with E", SCRIPT_PARAM_ONOFF, true)
  135.     AutoCarry.PluginMenu:addParam("HarassWithE", "Harass with E", SCRIPT_PARAM_ONOFF, false)
  136.     AutoCarry.PluginMenu:addParam("KillstealMinHitchance", "Killsteal Min. Req. Hitchance", SCRIPT_PARAM_SLICE, 60, 0, 90, 0)
  137.     AutoCarry.PluginMenu:addParam("AFKKillstealDisable", "AFK Killsteal Disable", SCRIPT_PARAM_ONOFF, true)
  138.     AutoCarry.PluginMenu:addParam("AFKKillstealDisableSeconds", "AFK Killsteal Disable Seconds", SCRIPT_PARAM_SLICE, 120, 10, 600, 0)
  139. end
  140.  
  141. function PluginOnLoad()
  142.     Menu()
  143.  
  144.     AutoCarry.SkillsCrosshair.range = QMaxRange
  145.  
  146.     if myHero:GetSpellData(SUMMONER_1).name:find("SummonerDot") then ignite = SUMMONER_1
  147.     elseif myHero:GetSpellData(SUMMONER_2).name:find("SummonerDot") then ignite = SUMMONER_2 end
  148.     for i=1, heroManager.iCount do waittxt[i] = i*3 end
  149. end
  150.  
  151. function IsSummonerAFK()
  152.     -- Mark as AFK
  153.     if not myHeroLastPos or not tick or not afkTick or myHero.x ~= myHeroLastPos.x or myHero.z ~= myHeroLastPos.z then
  154.         myHeroLastPos = {x=myHero.x, y=myHero.y, z=myHero.z}
  155.         afkTick = tick
  156.         SummonerAFKNotify(false)
  157.         return false
  158.     elseif tick > (afkTick + (AutoCarry.PluginMenu.AFKKillstealDisableSeconds * 1000)) and myHero.x == myHeroLastPos.x and myHero.z == myHeroLastPos.z then
  159.         SummonerAFKNotify(true)
  160.         return true
  161.     end
  162.  
  163.     SummonerAFKNotify(false)
  164.     return false
  165. end
  166.  
  167. function SummonerAFKNotify(afk)
  168.     if lastAFKStatus and not afk then
  169.         PrintChat("Welcome back! Killsteal Enabled.")
  170.         lastAFKStatus = false
  171.     elseif afk and not lastAFKStatus then
  172.         PrintChat("You are AFK. Killsteal temporarily Disabled.")
  173.         lastAFKStatus = true
  174.     end
  175. end
  176.  
  177. function PluginOnTick()
  178.     tick = GetTickCount()
  179.     Target = AutoCarry.GetAttackTarget(true)
  180.  
  181.     if IsTickReady(500) then IsSummonerAFK() end
  182.  
  183.     SpellCheck()
  184.  
  185.     if IsTickReady(200) then
  186.         CalculateDamage()
  187.     end
  188.  
  189.     if AutoCarry.PluginMenu.SatchelJump then
  190.         SatchelJump()
  191.     end
  192.  
  193.     if (AutoCarry.MainMenu.AutoCarry or AutoCarry.MainMenu.MixedMode) then
  194.         Combo()
  195.     end
  196.    
  197.     if AutoCarry.PluginMenu.FullCombo then
  198.         FullCombo()
  199.     end
  200.  
  201.     if AutoCarry.PluginMenu.Harass then
  202.         Harass()
  203.     end
  204.  
  205.     if AutoCarry.PluginMenu.Killsteal and IsTickReady(50) and not lastAFKStatus then
  206.         KillSteal()
  207.     end
  208.    
  209.     if (AutoCarry.MainMenu.LaneClear or AutoCarry.MainMenu.MixedMode) and IsTickReady(50) and AutoCarry.PluginMenu.SmartFarmWithQ and not IsMyManaLow() then
  210.         SmartFarmWithQ()
  211.     end
  212. end
  213.  
  214. function DrawArrowsToPos(pos1, pos2)
  215.     if pos1 and pos2 then
  216.         startVector = D3DXVECTOR3(pos1.x, pos1.y, pos1.z)
  217.         endVector = D3DXVECTOR3(pos2.x, pos2.y, pos2.z)
  218.         -- directionVector = (endVector-startVector):normalized()
  219.         DrawArrows(startVector, endVector, 60, 0xE97FA5, 100)
  220.     end
  221. end
  222.  
  223. function IsTickReady(tickFrequency)
  224.     -- Improves FPS
  225.     if tick ~= nil and math.fmod(tick, tickFrequency) then
  226.         return true
  227.     else
  228.         return false
  229.     end
  230. end
  231.  
  232. function PluginOnCreateObj(obj)
  233.     if obj.name == "ZiggsW_mis_ground.troy" then
  234.         satchelChargeExists = true
  235.         CastWActivate()
  236.     end
  237. end
  238.  
  239. function PluginOnDeleteObj(obj)
  240.     if obj.name == "ZiggsW_mis_ground.troy" then
  241.         satchelChargeExists = false
  242.         pendingSatchelChargeActivation = nil
  243.     end
  244. end
  245.  
  246. function OnAttacked()
  247.     -- Auto AA > Q > AA
  248.     if AutoCarry.PluginMenu.AutoHarass and not IsMyManaLow() then
  249.         CastQ()
  250.     end
  251. end
  252.  
  253. function SpellCheck()
  254.     DFGSlot, HXGSlot, BWCSlot, SheenSlot, TrinitySlot, LichBaneSlot = GetInventorySlotItem(3128),
  255.     GetInventorySlotItem(3146), GetInventorySlotItem(3144), GetInventorySlotItem(3057),
  256.     GetInventorySlotItem(3078), GetInventorySlotItem(3100)
  257.  
  258.     QReady = (myHero:CanUseSpell(SkillQ.spellKey) == READY)
  259.     WReady = (myHero:CanUseSpell(SkillW.spellKey) == READY)
  260.     EReady = (myHero:CanUseSpell(SkillE.spellKey) == READY)
  261.     RReady = (myHero:CanUseSpell(SkillR.spellKey) == READY)
  262.  
  263.     DFGReady = (DFGSlot ~= nil and myHero:CanUseSpell(DFGSlot) == READY)
  264.     HXGReady = (HXGSlot ~= nil and myHero:CanUseSpell(HXGSlot) == READY)
  265.     BWCReady = (BWCSlot ~= nil and myHero:CanUseSpell(BWCSlot) == READY)
  266.     IReady = (ignite ~= nil and myHero:CanUseSpell(ignite) == READY)
  267. end
  268.  
  269. -- Handle SBTW Skill Shots
  270.  
  271. function Combo()
  272.     CastSlots()
  273.  
  274.     if not IsMyManaLow() or IsTargetHealthLow() then
  275.         CastE()
  276.     end
  277.  
  278.     CastQ()
  279.     Ultimate()
  280. end
  281.  
  282. function Ultimate()
  283.     if Target ~= nil and AutoCarry.PluginMenu.Ultimate and (doUlt or ((Target.health + 30) < getDmg("R", Target, myHero) and IsValidHitChanceCustom(SkillR, Target))) then
  284.         CastR()
  285.     end
  286. end
  287.  
  288. function FullCombo()
  289.     CastSlots()
  290.     CastE()
  291.     CastQ()
  292.     CastW()
  293.     CastWActivate()
  294.     Ultimate()
  295. end
  296.  
  297. function CastSlots()
  298.     if Target ~= nil and not Target.dead then
  299.         if GetDistance(Target) <= QMaxRange then
  300.             if DFGReady then CastSpell(DFGSlot, Target) end
  301.             if HXGReady then CastSpell(HXGSlot, Target) end
  302.             if BWCReady then CastSpell(BWCSlot, Target) end
  303.         end
  304.     end
  305. end
  306.  
  307. function Harass()
  308.     CastQ()
  309.     if AutoCarry.PluginMenu.HarassWithE then CastE() end
  310. end
  311.  
  312. function CastQ()
  313.     if Target ~= nil and not Target.dead then
  314.         if QReady and ValidTarget(Target, QRange) and IsQWallCheckOK(Target) then
  315.             AutoCarry.CastSkillshot(SkillQ, Target)
  316.         elseif QReady and ValidTarget(Target, QMaxRange) then
  317.             -- Full Bouncing Bomb three bounce range
  318.             local PredictedPos = AutoCarry.GetPrediction(SkillQ, Target)
  319.  
  320.             if PredictedPos and AutoCarry.IsValidHitChance(SkillQ, Target) then
  321.                 local MyPos = Vector(myHero.x, myHero.y, myHero.z)
  322.                 local EnemyPos = Vector(PredictedPos.x, PredictedPos.y, PredictedPos.z)
  323.                 local CastPos = MyPos - (MyPos - EnemyPos):normalized() * QRange
  324.                 if CastPos and GetDistance(CastPos) < QMaxRange and IsQWallCheckOK(CastPos) and IsQWallCheckOK(EnemyPos) then
  325.                     -- CastSpell(SkillQ.spellKey, CastPos.x, CastPos.z)
  326.                     CastSkillshotBounce(SkillQ, CastPos)
  327.                 end
  328.             end
  329.         end
  330.     end
  331. end
  332.  
  333. function IsQWallCheckOK(position)
  334.     if position and not AutoCarry.PluginMenu.AvoidWallsWithQ or (AutoCarry.PluginMenu.AvoidWallsWithQ and not IsWall(D3DXVECTOR3(position.x, myHero.y, position.z))) then
  335.         return true
  336.     else
  337.         return false
  338.     end
  339. end
  340.  
  341. function CastSkillshotBounce(skill, castPos)
  342.     if castPos and GetDistance(castPos) <= skill.range then
  343.         if not skill.minions or not AutoCarry.GetCollision(skill, myHero, castPos) then
  344.             CastSpell(skill.spellKey, castPos.x, castPos.z)
  345.         end
  346.     end
  347. end
  348.  
  349. function CastW(noTarget)
  350.     if noTarget and WReady then
  351.         -- Find vector from mousePos -> myHero
  352.         local vectorX,y,vectorZ = (Vector(myHero) - Vector(mousePos)):normalized():unpack()
  353.  
  354.         -- Cast Satchel behind myHero by specified distance, where behind is determined relative to mousePos -> myHero vector.
  355.         -- if hasBuff("Speed Shrine") then satchelDistance should be less, like 50.
  356.         local satchelDistance = 125
  357.         local posX = myHero.x + (vectorX * satchelDistance)
  358.         local posZ = myHero.z + (vectorZ * satchelDistance)
  359.         CastSpell(SkillW.spellKey, posX, posZ)
  360.     elseif Target ~= nil and ValidTarget(Target, WRange) and not Target.dead then
  361.         if WReady and GetDistance(Target) <= WRange then
  362.             AutoCarry.CastSkillshot(SkillW, Target)
  363.         end
  364.     end
  365. end
  366.  
  367. function CastWActivate()
  368.     if satchelChargeExists and pendingSatchelChargeActivation ~= nil then
  369.         if pendingSatchelChargeActivation == "satcheljump" then
  370.             -- Old delay method
  371.             -- local delayTime = 100
  372.             -- local endClockTime = GetTickCount() + delayTime
  373.             -- while (GetTickCount() < endClockTime) do
  374.             --  -- Sleep
  375.             -- end
  376.  
  377.             CastSpell(SkillW.spellKey)
  378.             if AutoCarry.PluginMenu.SatchelJumpWithE then CastE() end
  379.             pendingSatchelChargeActivation = nil
  380.         end
  381.     end
  382. end
  383.  
  384. function CastE()
  385.     if Target ~= nil and ValidTarget(Target, ERange) and not Target.dead then
  386.         if EReady and GetDistance(Target) <= ERange then
  387.             AutoCarry.CastSkillshot(SkillE, Target)
  388.         end
  389.     end
  390. end
  391.  
  392. function CastR()
  393.     if Target ~= nil and ValidTarget(Target, RRange) and not Target.dead then
  394.         -- if RReady and GetDistance(Target) <= RRange then
  395.         enemyPos = AutoCarry.GetPrediction(SkillR, Target)
  396.         if RReady and enemyPos and ValidTarget(enemyPos, RRange) then
  397.             AutoCarry.CastSkillshot(SkillR, Target)
  398.         end
  399.     end
  400. end
  401.  
  402. function KillSteal()
  403.     for _, enemy in pairs(AutoCarry.EnemyTable) do
  404.         if ValidTarget(enemy, RRange) and not enemy.dead then
  405.             if (enemy.health + 30) < getDmg("R", enemy, myHero) and IsValidHitChanceCustom(SkillR, enemy) then
  406.                 enemyPos = AutoCarry.GetPrediction(SkillR, enemy)
  407.                 if RReady and enemyPos and GetDistance(enemyPos) < RRange then
  408.                     -- Message.AddMessage("Killsteal!", ColorARGB.Green, myHero)
  409.                     PrintFloatText(myHero, 10, "Ultimate Mega Killsteal!")
  410.                     if debugMode then PrintChat("Ultimate Mega Killsteal!") end
  411.                     AutoCarry.CastSkillshot(SkillR, enemy)
  412.                 end
  413.             end
  414.         end
  415.     end
  416. end
  417.  
  418. function SatchelJump()
  419.     -- E is cast before and after jump to insure that a target near either location can be hit.
  420.     pendingSatchelChargeActivation = "satcheljump"
  421.     CastW(true)
  422.     if AutoCarry.PluginMenu.SatchelJumpWithE then CastE() end
  423. end
  424.  
  425. function SmartFarmWithQOld()
  426.     local minions = {}
  427.     for _, minion in pairs(AutoCarry.EnemyMinions().objects) do
  428.         if ValidTarget(minion) and QReady and GetDistance(minion) <= QMaxRange then
  429.             if minion.health < getDmg("Q", minion, myHero) then
  430.                 table.insert(minions, minion)
  431.             end
  432.         end
  433.     end
  434.  
  435.     local pos1 = {x=0,z=0}
  436.     local pos1Count = 0
  437.     local pos2 = {x=0,z=0}
  438.     local pos2Count = 0
  439.  
  440.     local closeMinion = QWidth * 1.5
  441.  
  442.     for _, minion in pairs(minions) do
  443.         if pos1Count == 0 then
  444.             pos1.x = minion.x
  445.             pos1.z = minion.z
  446.             pos1Count = 1
  447.         elseif GetDistance(pos1, minion) < closeMinion then
  448.             pos1.x = ((pos1.x * pos1Count) + minion.x) / (pos1Count + 1)
  449.             pos1.z = ((pos1.z * pos1Count) + minion.z) / (pos1Count + 1)
  450.             pos1Count = pos1Count + 1
  451.         elseif pos2Count == 0 then
  452.             pos2.x = minion.x
  453.             pos2.z = minion.z
  454.             pos2Count = 1
  455.         elseif GetDistance(pos1, minion) < closeMinion then
  456.             pos2.x = ((pos2.x * pos2Count) + minion.x) / (pos2Count + 1)
  457.             pos2.z = ((pos2.z * pos2Count) + minion.z) / (pos2Count + 1)
  458.             pos2Count = pos2Count + 1
  459.         end
  460.     end
  461.  
  462.     if debugMode and (pos1Count > 1 or pos2Count > 1) then
  463.         PrintChat("pos1Count: "..pos1Count..", pos2Count: "..pos2Count)
  464.     end
  465.  
  466.     if pos1Count > pos2Count and pos1Count >= 2 then
  467.         CastSpell(SkillQ.spellKey, pos1.x, pos1.z)
  468.     elseif pos2Count >= 2 then
  469.         CastSpell(SkillQ.spellKey, pos2.x, pos2.z)
  470.     end
  471. end
  472.  
  473. function SmartFarmWithQ()
  474.     local minions = {}
  475.     for _, minion in pairs(AutoCarry.EnemyMinions().objects) do
  476.         if ValidTarget(minion) and QReady and GetDistance(minion) <= QMaxRange then
  477.             if minion.health < getDmg("Q", minion, myHero) then
  478.                 table.insert(minions, minion)
  479.             end
  480.         end
  481.     end
  482.  
  483.     local minionClusters = {}
  484.  
  485.     local closeMinion = QWidth * 1.5
  486.  
  487.     for _, minion in pairs(minions) do
  488.         local foundCluster = false
  489.         for i, mc in ipairs(minionClusters) do
  490.             if GetDistance(mc, minion) < closeMinion then
  491.                 mc.x = ((mc.x * mc.count) + minion.x) / (mc.count + 1)
  492.                 mc.z = ((mc.z * mc.count) + minion.z) / (mc.count + 1)
  493.                 mc.count = mc.count + 1
  494.                 foundCluster = true
  495.                 break
  496.             end
  497.         end
  498.  
  499.         if not foundCluster then
  500.             local mc = {x=0, z=0, count=0}
  501.             mc.x = minion.x
  502.             mc.z = minion.z
  503.             mc.count = 1
  504.             table.insert(minionClusters, mc)
  505.         end
  506.     end
  507.  
  508.     if #minionClusters < 1 then return end
  509.  
  510.     local largestCluster = 0
  511.     local largestClusterSize = 0
  512.     for i, mc in ipairs(minionClusters) do
  513.         if mc.count > largestClusterSize then
  514.             largestCluster = i
  515.             largestClusterSize = mc.count
  516.         end
  517.     end
  518.  
  519.     if debugMode and largestClusterSize >= 2 then
  520.         PrintChat("totalClusters: "..#minionClusters..", largestCluster: "..largestCluster..", largestClusterSize: "..largestClusterSize)
  521.     end
  522.  
  523.     if largestClusterSize >= 2 then
  524.         minionCluster = minionClusters[largestCluster]
  525.        
  526.         -- Needs to be in OnDraw to function.
  527.         -- local minionClusterPoint = {x=minionCluster.x, y=myHero.y, z=minionCluster.z}
  528.         -- DrawArrowsToPos(myHero, minionClusterPoint)
  529.  
  530.         CastSpell(SkillQ.spellKey, minionCluster.x, minionCluster.z)
  531.     end
  532.  
  533.     minions = nil
  534.     minionClusters = nil
  535. end
  536.  
  537. function IsMyManaLow()
  538.     if myHero.mana < (myHero.maxMana * ( AutoCarry.PluginMenu.ManaManager / 100)) then
  539.         return true
  540.     else
  541.         return false
  542.     end
  543. end
  544.  
  545. function IsTargetHealthLow()
  546.     local targetLowHealth = .40
  547.  
  548.     if Target ~= nil and Target.health < (Target.maxHealth * targetLowHealth) then
  549.         return true
  550.     else
  551.         return false
  552.     end
  553. end
  554.  
  555. function IsTargetManaLow()
  556.     local targetLowMana = .15
  557.  
  558.     if Target ~= nil and Target.mana < (Target.maxMana * targetLowMana) then
  559.         return true
  560.     else
  561.         return false
  562.     end
  563. end
  564.  
  565. -- Sliding scale hitchance based on target distance.
  566. function getScalingHitChanceFromDistance(SkillRange, Target)
  567.     local minHitChance = AutoCarry.PluginMenu.KillstealMinHitchance
  568.     local maxHitChance = 95
  569.  
  570.     hitChance = minHitChance + ((1 - (SkillRange - GetDistance(Target)) / (SkillRange - 0))) * (maxHitChance - minHitChance)
  571.     if debugMode then PrintChat("HitChance Info: skillrange="..SkillRange..", targetdistance="..GetDistance(Target)..", hitchance:"..hitChance) end
  572.     return hitChance
  573. end
  574.  
  575. function IsValidHitChanceCustom(skill, target)
  576.     if VIP_USER then
  577.         pred = TargetPredictionVIP(skill.range, skill.speed*1000, skill.delay/1000, skill.width)
  578.         return pred:GetHitChance(target) > getScalingHitChanceFromDistance(skill.range, target)/100 and true or false
  579.     elseif not VIP_USER then
  580.         local nonVIPMaxHitChance = 70
  581.         return getScalingHitChanceFromDistance(skill.range, target) < nonVIPMaxHitChance and true or false
  582.     end
  583. end
  584.  
  585. --[[
  586. function satchelChargeExistsDelete()
  587.     for i=1, objManager.maxObjects do
  588.         local obj = objManager:getObject(i)
  589.  
  590.         if obj ~= nil and obj.name:find("Satchel Charge") then
  591.             return true
  592.         end
  593.     end
  594.     return false
  595. end
  596. --]]
  597.  
  598. -- Handle Manual Skill Shots
  599.  
  600. function PluginOnWndMsg(msg,key)
  601.     Target = AutoCarry.GetAttackTarget()
  602.     if Target ~= nil then
  603.         if msg == KEY_DOWN and key == KeyQ then CastQ() end
  604.         if msg == KEY_DOWN and key == KeyW then CastW() end
  605.         if msg == KEY_DOWN and key == KeyE then CastE() end
  606.         if msg == KEY_DOWN and key == KeyR then CastR() end
  607.     end
  608. end
  609.  
  610. -- Drawing
  611.  
  612. function PluginOnDraw()
  613.     -- if Target ~= nil and not Target.dead and QReady and ValidTarget(Target, QMaxRange) then
  614.     if Target ~= nil and not Target.dead and (AutoCarry.MainMenu.AutoCarry or AutoCarry.MainMenu.MixedMode) then
  615.         DrawArrowsToPos(myHero, Target)
  616.     end
  617.  
  618.     if AutoCarry.PluginMenu.Draw then
  619.         DrawCircle(myHero.x, myHero.y, myHero.z, AutoCarry.SkillsCrosshair.range, 0x808080) -- Gray
  620.  
  621.         if myHero:CanUseSpell(SkillQ.spellKey) then
  622.             DrawCircle(myHero.x, myHero.y, myHero.z, QRange, 0x0099CC) -- Blue
  623.         end
  624.        
  625.         if myHero:CanUseSpell(SkillW.spellKey) then
  626.             DrawCircle(myHero.x, myHero.y, myHero.z, WRange, 0xFFFF00) -- Yellow
  627.         end
  628.        
  629.         if myHero:CanUseSpell(SkillE.spellKey) then
  630.             DrawCircle(myHero.x, myHero.y, myHero.z, ERange, 0x00FF00) -- Green
  631.         end
  632.  
  633.         if AutoCarry.PluginMenu.DrawUlt then
  634.             if myHero:CanUseSpell(SkillR.spellKey) then
  635.                 DrawCircle(myHero.x, myHero.y, myHero.z, RRange, 0xFF0000) -- Red
  636.             end
  637.         end
  638.  
  639.         Target = AutoCarry.GetAttackTarget()
  640.         if Target ~= nil then
  641.             for j=0, 10 do
  642.                 DrawCircle(Target.x, Target.y, Target.z, 40 + j*1.5, 0x00FF00) -- Green
  643.             end
  644.         end
  645.     end
  646.    
  647.     DrawKillable()
  648. end
  649.  
  650. function CalculateDamage()
  651.         if ValidTarget(Target) then
  652.                 local dfgdamage, hxgdamage, bwcdamage, ignitedamage, Sheendamage, Trinitydamage, LichBanedamage  = 0, 0, 0, 0, 0, 0, 0
  653.                 local pdamage = getDmg("P",Target,myHero)
  654.                 local qdamage = getDmg("Q",Target,myHero)
  655.                 local wdamage = getDmg("W",Target,myHero)
  656.                 local edamage = getDmg("E",Target,myHero)
  657.                 local rdamage = getDmg("R",Target,myHero)
  658.                 local hitdamage = getDmg("AD",Target,myHero)
  659.                 local dfgdamage = (DFGSlot and getDmg("DFG",Target,myHero) or 0)
  660.                 local hxgdamage = (HXGSlot and getDmg("HXG",Target,myHero) or 0)
  661.                 local bwcdamage = (BWCSlot and getDmg("BWC",Target,myHero) or 0)
  662.                 local ignitedamage = (ignite and getDmg("IGNITE",Target,myHero) or 0)
  663.                 local Sheendamage = (SheenSlot and getDmg("SHEEN",Target,myHero) or 0)
  664.                 local Trinitydamage = (TrinitySlot and getDmg("TRINITY",Target,myHero) or 0)
  665.                 local LichBanedamage = (LichBaneSlot and getDmg("LICHBANE",Target,myHero) or 0)
  666.                 local combo1 = hitdamage + qdamage + wdamage + edamage + rdamage + Sheendamage + Trinitydamage + LichBanedamage --0 cd
  667.                 local combo2 = hitdamage + Sheendamage + Trinitydamage + LichBanedamage
  668.                 local combo3 = hitdamage + Sheendamage + Trinitydamage + LichBanedamage
  669.                 local combo4 = 0
  670.                
  671.                 if QREADY then
  672.                         combo2 = combo2 + qdamage
  673.                         combo3 = combo3 + qdamage
  674.                         --combo4 = combo4 + qdamage
  675.                 end
  676.                 if WREADY then
  677.                         combo2 = combo2 + wdamage
  678.                         combo3 = combo3 + wdamage
  679.                 end
  680.                 if EREADY then
  681.                         combo2 = combo2 + edamage
  682.                         combo3 = combo3 + edamage
  683.                         --combo4 = combo4 + edamage
  684.                 end
  685.                 if RREADY then
  686.                         combo2 = combo2 + rdamage
  687.                         combo3 = combo3 + rdamage
  688.                         combo4 = combo4 + rdamage
  689.                 end
  690.                 if DFGREADY then        
  691.                         combo1 = combo1 + dfgdamage            
  692.                         combo2 = combo2 + dfgdamage
  693.                         combo3 = combo3 + dfgdamage
  694.                         --combo4 = combo4 + dfgdamage
  695.                 end
  696.                 if HXGREADY then              
  697.                         combo1 = combo1 + hxgdamage    
  698.                         combo2 = combo2 + hxgdamage
  699.                         combo3 = combo3 + hxgdamage
  700.                         --combo4 = combo4 + hxgdamage
  701.                 end
  702.                 if BWCREADY then
  703.                         combo1 = combo1 + bwcdamage
  704.                         combo2 = combo2 + bwcdamage
  705.                         combo3 = combo3 + bwcdamage
  706.                         combo4 = combo4 + bwcdamage
  707.                 end
  708.                 if IREADY then
  709.                         combo1 = combo1 + ignitedamage
  710.                         combo2 = combo2 + ignitedamage
  711.                         combo3 = combo3 + ignitedamage
  712.                 end
  713.                 if combo4 >= Target.health then killable[calculationenemy] = 4 doUlt = true
  714.                 elseif combo3 >= Target.health then killable[calculationenemy] = 3 doUlt = false
  715.                 elseif combo2 >= Target.health then killable[calculationenemy] = 2 doUlt = false
  716.                 elseif combo1 >= Target.health then killable[calculationenemy] = 1  doCombo = true doUlt = false
  717.                 else killable[calculationenemy] = 0 doCombo = false doUlt = false end
  718.         end
  719.         if calculationenemy == 1 then calculationenemy = heroManager.iCount
  720.         else calculationenemy = calculationenemy-1 end
  721. end
  722.  
  723. function DrawKillable()
  724.     if 1 == 2 and Target ~= nil and AutoCarry.PluginMenu.DrawPrediction then
  725.         if VIP_USER then
  726.             pred = TargetPredictionVIP(SkillQ.range, SkillQ.speed*1000, SkillQ.delay/1000, SkillQ.width)
  727.         elseif not VIP_USER then
  728.             pred = TargetPrediction(SkillQ.range, SkillQ.speed, SkillQ.delay, SkillQ.width)
  729.         end
  730.         predPos = pred:GetPrediction(Target)
  731.         DrawCircle(predPos.x, Target.y, predPos.z, 200, 0x0000FF)
  732.     end
  733.     for i=1, heroManager.iCount do
  734.         local enemydraw = heroManager:GetHero(i)
  735.         if ValidTarget(enemydraw) then
  736.             if AutoCarry.PluginMenu.DrawKillablEenemy then
  737.                 if killable[i] == 1 then
  738.                     for j=0, 20 do
  739.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 80 + j*1.5, 0x0000FF)
  740.                     end
  741.                 elseif killable[i] == 2 then
  742.                     for j=0, 10 do
  743.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 80 + j*1.5, 0xFF0000)
  744.                     end
  745.                 elseif killable[i] == 3 then
  746.                     for j=0, 10 do
  747.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 80 + j*1.5, 0xFF0000)
  748.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 110 + j*1.5, 0xFF0000)
  749.                     end
  750.                 elseif killable[i] == 4 then
  751.                     for j=0, 10 do
  752.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 80 + j*1.5, 0xFF0000)
  753.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 110 + j*1.5, 0xFF0000)
  754.                         DrawCircle(enemydraw.x, enemydraw.y, enemydraw.z, 140 + j*1.5, 0xFF0000)
  755.                     end
  756.                 end
  757.             end
  758.             if AutoCarry.PluginMenu.DrawText and waittxt ~= nil and waittxt[i] == 1 and killable ~= nil and killable[i] ~= 0 then
  759.                     PrintFloatText(enemydraw,0,floattext[killable[i]])
  760.             end
  761.         end
  762.         if waittxt ~= nil then
  763.             if waittxt[i] == 1 then waittxt[i] = 30
  764.             else waittxt[i] = waittxt[i]-1 end
  765.         end
  766.     end
  767. end
  768.  
  769. --[[
  770. class 'ColorARGB' -- {
  771.  
  772.     function ColorARGB:__init(red, green, blue, alpha)
  773.         self.R = red or 255
  774.         self.G = green or 255
  775.         self.B = blue or 255
  776.         self.A = alpha or 255
  777.     end
  778.  
  779.     function ColorARGB.FromArgb(red, green, blue, alpha)
  780.         return Color(red,green,blue, alpha)
  781.     end
  782.  
  783.     function ColorARGB:ToARGB()
  784.         return ARGB(self.A, self.R, self.G, self.B)
  785.     end
  786.  
  787.     ColorARGB.Red = ColorARGB(255, 0, 0, 255)
  788.     ColorARGB.Yellow = ColorARGB(255, 255, 0, 255)
  789.     ColorARGB.Green = ColorARGB(0, 255, 0, 255)
  790.     ColorARGB.Aqua = ColorARGB(0, 255, 255, 255)
  791.     ColorARGB.Blue = ColorARGB(0, 0, 255, 255)
  792.     ColorARGB.Fuchsia = ColorARGB(255, 0, 255, 255)
  793.     ColorARGB.Black = ColorARGB(0, 0, 0, 255)
  794.     ColorARGB.White = ColorARGB(255, 255, 255, 255)
  795. -- }
  796.  
  797. --Notification class
  798. class 'Message' -- {
  799.  
  800.     Message.instance = ""
  801.  
  802.     function Message:__init()
  803.         self.notifys = {}
  804.  
  805.         AddDrawCallback(function(obj) self:OnDraw() end)
  806.     end
  807.  
  808.     function Message.Instance()
  809.         if Message.instance == "" then Message.instance = Message() end return Message.instance
  810.     end
  811.  
  812.     function Message.AddMessage(text, color, target)
  813.         return Message.Instance():PAddMessage(text, color, target)
  814.     end
  815.  
  816.     function Message:PAddMessage(text, color, target)
  817.         local x = 0
  818.         local y = 200
  819.         local tempName = "Screen"
  820.         local tempcolor = color or ColorARGB.Red
  821.  
  822.         if target then  
  823.             tempName = target.networkID
  824.         end
  825.  
  826.         self.notifys[tempName] = { text = text, color = tempcolor, duration = GetGameTimer() + 2, object = target}
  827.     end
  828.  
  829.     function Message:OnDraw()
  830.         for i, notify in pairs(self.notifys) do
  831.             if notify.duration < GetGameTimer() then notify = nil
  832.             else
  833.                 notify.color.A = math.floor((255/2)*(notify.duration - GetGameTimer()))
  834.  
  835.                 if i == "Screen" then  
  836.                     local x = 0
  837.                     local y = 200
  838.                     local gameSettings = GetGameSettings()
  839.                     if gameSettings and gameSettings.General then
  840.                         if gameSettings.General.Width then x = gameSettings.General.Width/2 end
  841.                         if gameSettings.General.Height then y = gameSettings.General.Height/4 - 100 end
  842.                     end  
  843.                     --PrintChat(tostring(notify.color))
  844.                     local p = GetTextArea(notify.text, 40).x
  845.                     self:DrawTextWithBorder(notify.text, 40, x - p/2, y, notify.color:ToARGB(), ARGB(notify.color.A, 0, 0, 0))
  846.                 else    
  847.                     local pos = WorldToScreen(D3DXVECTOR3(notify.object.x, notify.object.y, notify.object.z))
  848.                     local x = pos.x
  849.                     local y = pos.y - 25
  850.                     local p = GetTextArea(notify.text, 40).x
  851.  
  852.                     self:DrawTextWithBorder(notify.text, 30, x- p/2, y, notify.color:ToARGB(), ARGB(notify.color.A, 0, 0, 0))
  853.                 end
  854.             end
  855.         end
  856.     end
  857.  
  858.     function Message:DrawTextWithBorder(textToDraw, textSize, x, y, textColor, backgroundColor)
  859.         DrawText(textToDraw, textSize, x + 1, y, backgroundColor)
  860.         DrawText(textToDraw, textSize, x - 1, y, backgroundColor)
  861.         DrawText(textToDraw, textSize, x, y - 1, backgroundColor)
  862.         DrawText(textToDraw, textSize, x, y + 1, backgroundColor)
  863.         DrawText(textToDraw, textSize, x , y, textColor)
  864.     end
  865. -- }
  866. --]]
Advertisement
Add Comment
Please, Sign In to add comment