Guest User

Untitled

a guest
Feb 8th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.12 KB | None | 0 0
  1. --[[
  2.  
  3.     Darius Dunk v0.35 by Lux - Modified by Mwow
  4.  
  5.  
  6.  
  7.     Changelog:
  8.  
  9.     v0.35  Added Toggles for Ult and Q Harrass, added config menu, speed up ult usage
  10.  
  11.     v0.34  different approach to avoid ultimate usage when enemy is immune
  12.  
  13.            initial support to shield calculation
  14.  
  15.         v0.33: added some stuff to smooth the ultimate dmg calculation
  16.  
  17.         v0.32: added anivia's passive check
  18.  
  19.         v0.31: added drawUltiInfo variable
  20.  
  21.         v0.3: added blitzcrank's handler, various fix
  22.  
  23.         v0.2: added trynda/blitz/zilean's ulti check
  24.  
  25.  
  26.  
  27.     based on
  28.  
  29.     Darius Ownage
  30.  
  31.     v1.1
  32.  
  33.     written by Weee
  34.  
  35.     Modified by Delusional Logic
  36.  
  37. ]]
  38.  
  39.  
  40.  
  41.  
  42.  
  43. if GetMyHero().charName ~= "Darius" then return end
  44.  
  45.  
  46.  
  47.  
  48.  
  49. --[[  Config  ]]
  50.  
  51. local drawQrange = true        -- Draw the range of Q
  52.  
  53. local useExecutioner = true     -- calculate Executioner or not? True / False
  54.  
  55. local havocPoints = 3           -- how many points in Havoc? 0 / 1 / 2 / 3
  56.  
  57. local drawUltiInfo = true
  58.  
  59.  
  60.  
  61. -- the R's dmg is multiplied with this value, 1.0 means nothing changes of course
  62.  
  63. local smoothMultR = 1.0
  64.  
  65. -- change to 0 if you don't want to smooth R's dmg calculation
  66.  
  67. local smoothStaticR = -2
  68.  
  69. -- -2 means that at lvl 18 the ultimate will be automatically casted on an enemy if his health is < than R's dmg-36
  70.  
  71. -- if you put this to false then the dmg removed from R will be the static number written in smoothStaticR
  72.  
  73. local smoothStaticPerLvl = true
  74.  
  75. -- put to 0 if you don't want to disabled the ulti's smoother at all, I put this to 12 because I don't want to risk
  76.  
  77. --  to lose in lane because the ulti isn't casted for like 12hp
  78.  
  79. local smoothDisabledBeforeLvl = 12
  80.  
  81.  
  82.  
  83. --[[  Advanced Config  ]]
  84.  
  85. local targetFindRange = 80        -- This is a distance between targeted spell coordinates and your real target's coordinates.
  86.  
  87. local qBladeRange = 270
  88.  
  89. local qRange = 425
  90.  
  91. local eRange = 500 -- lowered since most of the times enemies goes out of the E range while you're casting it
  92.  
  93. local rRange = 475
  94.  
  95. local wDmgRatioPerLvl = 0.2
  96.  
  97. local rDmgRatioPerHemo = 0.2
  98.  
  99. local hemoTimeOut = 5000
  100.  
  101.  
  102.  
  103.  
  104.  
  105. --[[  Globals  ]]
  106.  
  107. local enemyToAttack = nil
  108.  
  109. local enemyTable = {}
  110.  
  111. local player = GetMyHero()
  112.  
  113.  
  114.  
  115. local hemoTable = {
  116.  
  117.     [1] = "darius_hemo_counter_01.troy",
  118.  
  119.     [2] = "darius_hemo_counter_02.troy",
  120.  
  121.     [3] = "darius_hemo_counter_03.troy",
  122.  
  123.     [4] = "darius_hemo_counter_04.troy",
  124.  
  125.     [5] = "darius_hemo_counter_05.troy",
  126.  
  127. }
  128.  
  129.  
  130.  
  131. local damageTable = {
  132.  
  133.     Q = { base = 35, baseScale = 35, adRatio = 0.7, },
  134.  
  135.     R = { base = 70, baseScale = 90, adRatio = 0.75, },
  136.  
  137. }
  138.  
  139.  
  140.  
  141. local checkBuffForUlti = {
  142.  
  143.     {name="Tryndamere", spellName="undyingRage", enabled=false, spellType=0, spellLevel=1, duration=5000, spellParticle="undyingrage_glow"},
  144.  
  145.     {name="Kayle", spellName="eyeForEye", enabled=false, spellType=0, spellLevel=1, duration=3000, spellParticle="eyeforaneye"},
  146.  
  147.     {name="Zilean", spellName="nickOfTime", enabled=false, spellType=0, spellLevel=1, duration=7000, spellParticle="nickoftime_tar"},
  148.  
  149.     {name="Nocturne", spellName="shroudOfDarkness", enabled=false, spellType=0, spellLevel=1,duration=1500,spellParticle="nocturne_shroudofdarkness_shield_cas_02"},
  150.  
  151.     {name="Blitzcrank", spellName="manaBarrier", enabled=false, spellType=1, spellLevel=1, duration=10000, spellParticle="manabarrier"},
  152.  
  153.     {name="Sivir", spellName="spellShield", enabled=false, spellType=0, spellLevel=1, duration=3000, spellParticle="spellblock_eff"}
  154.  
  155. }
  156.  
  157.  
  158.  
  159. for i=0, heroManager.iCount, 1 do
  160.  
  161.     local playerObj = heroManager:GetHero(i)
  162.  
  163.     if playerObj and playerObj.team ~= player.team then
  164.  
  165.         playerObj.hemo = { tick = 0, count = 0, }
  166.  
  167.         playerObj.pauseTickQ = 0
  168.  
  169.         playerObj.pauseTickR = 0
  170.  
  171.         playerObj.canBeUlted = true
  172.  
  173.         playerObj.immuneTimeout = 0
  174.  
  175.         playerObj.shield = 0
  176.  
  177.         table.insert(enemyTable,playerObj)
  178.  
  179.         for i=1, #checkBuffForUlti, 1 do
  180.  
  181.             if checkBuffForUlti[i].name == playerObj.charName then
  182.  
  183.                 checkBuffForUlti[i].enabled = true
  184.  
  185.                 PrintChat(checkBuffForUlti[i].spellName.." check enabled")
  186.  
  187.             end
  188.  
  189.         end
  190.  
  191.     end
  192.  
  193. end
  194.  
  195.  
  196.  
  197. --[[   Code   ]]
  198.  
  199. function OnLoad()
  200.  
  201.     config = scriptConfig("Darius", "Darius Dunk")
  202.  
  203.     config:addParam("eActive", "Apprehend", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("S"))
  204.  
  205.     config:addParam("drawQrange", "Draw Q Range", SCRIPT_PARAM_ONOFF, true)
  206.  
  207.     config:addParam("toggleUlt", "Toggle Auto Ultimate", SCRIPT_PARAM_ONKEYTOGGLE, true, string.byte("O"))
  208.  
  209.     config:addParam("toggleQ", "Toggle Decimate harrass", SCRIPT_PARAM_ONKEYTOGGLE, true, string.byte("P"))
  210.  
  211.     config:addParam("qHarrass", "Decimate Harrass", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  212.  
  213.     config:permaShow("toggleUlt")
  214.  
  215.     config:permaShow("toggleQ")
  216.  
  217. end
  218.  
  219.  
  220.  
  221.  
  222.  
  223. function ChampionInfo(champion)
  224.  
  225.     local results = {}
  226.  
  227.     for i=1, #checkBuffForUlti, 1 do
  228.  
  229.         if checkBuffForUlti[i].name == champion or checkBuffForUlti[i].name == "*" then
  230.  
  231.             table.insert(results, checkBuffForUlti[i])
  232.  
  233.         end
  234.  
  235.     end
  236.  
  237.     return results
  238.  
  239. end
  240.  
  241.  
  242.  
  243. function CanUltiEnemy(target)
  244.  
  245.     for i, enemy in pairs(enemyTable) do
  246.  
  247.         if target.networkID == enemy.networkID then
  248.  
  249.             if enemy.canBeUlted == false and enemy.immuneTimeout < GetTickCount() then
  250.  
  251.                 enemy.canBeUlted = true
  252.  
  253.                 enemy.immuneTimeout = 0
  254.  
  255.             end
  256.  
  257.             return enemy.canBeUlted
  258.  
  259.         end
  260.  
  261.     end
  262.  
  263. end
  264.  
  265.  
  266.  
  267. function GetShieldValue(enemy,spellName)
  268.  
  269.     if spellName == "manaBarrier" then
  270.  
  271.         return enemy.mana*0.5
  272.  
  273.     end
  274.  
  275. end
  276.  
  277.  
  278.  
  279. function GetDuration(spellName,spellLevel)
  280.  
  281.     if spellName == "undyingRage" then return 5000 end
  282.  
  283.     if spellName == "eyeForEye" then return 1500+500*spellLevel end
  284.  
  285.     if spellName == "nickOfTime" then return 7000 end
  286.  
  287.     if spellName == "shroudOfDarkness" then return 1500 end
  288.  
  289. end
  290.  
  291.  
  292.  
  293. function OnTick()
  294.  
  295.     local rDmg = (damageTable.R.base + (damageTable.R.baseScale*player:GetSpellData(_R).level) +
  296.  
  297.             damageTable.R.adRatio*player.addDamage) * smoothMultR
  298.  
  299.     if player.level > smoothDisabledBeforeLvl then
  300.  
  301.         local rDmgInc = smoothStaticR
  302.  
  303.         if smoothStaticPerLvl == true then
  304.  
  305.             rDmgInc = rDmgInc * player.level
  306.  
  307.         end
  308.  
  309.         rDmg = rDmg + rDmgInc
  310.  
  311.     end
  312.  
  313.     local qDmg = damageTable.Q.base + (damageTable.Q.baseScale*player:GetSpellData(_Q).level) +
  314.  
  315.             damageTable.Q.adRatio*player.addDamage
  316.  
  317.     for i, enemy in pairs(enemyTable) do
  318.  
  319.         local enemyHP = enemy.health + enemy.shield
  320.  
  321.         if (GetTickCount() - enemy.hemo.tick > hemoTimeOut) or (enemy and enemy.dead) then enemy.hemo.count = 0 end
  322.  
  323.         if enemy and not enemy.dead and enemy.visible == true and enemy.bTargetable and enemy.bInvulnerable == 0 then
  324.  
  325.             local scale = 1 + havocPoints*0.005
  326.  
  327.             if useExecutioner and enemyHP < enemy.maxHealth*0.4 then scale = scale + 0.06 end
  328.  
  329.             qDmg = player:CalcDamage(enemy,qDmg)
  330.  
  331.             if (config.qHarrass or config.toggleQ) and player:CanUseSpell(_Q) == READY and GetDistance(enemy) < qRange then CastSpell(_Q) end
  332.  
  333.             if config.eActive and player:CanUseSpell(_E) == READY and GetDistance(enemy) < eRange then CastSpell(_E,enemy.x,enemy.z) end
  334.  
  335.             --if GetTickCount() - enemy.pauseTickQ >= 500 and GetTickCount() - enemy.pauseTickR >= 200 then
  336.  
  337.                 if qDmg * scale > enemyHP and player:CanUseSpell(_Q) == READY and GetDistance(enemy) < qRange then
  338.  
  339.                     CastSpell(_Q)
  340.  
  341.                     --enemy.pauseTickQ = GetTickCount()
  342.  
  343.                 elseif ( qDmg * 1.5 ) * scale > enemyHP and player:CanUseSpell(_Q) == READY and GetDistance(enemy) < qRange and GetDistance(enemy) >= qBladeRange then
  344.  
  345.                     CastSpell(_Q)
  346.  
  347.                     --enemy.pauseTickQ = GetTickCount()
  348.  
  349.                 elseif config.toggleUlt and rDmg * ( 1.0 + rDmgRatioPerHemo * enemy.hemo.count ) > enemyHP and player:CanUseSpell(_R) == READY and GetDistance(enemy) < rRange and CanUltiEnemy(enemy) == true then
  350.  
  351.                     CastSpell(_R,enemy)
  352.  
  353.                     --enemy.pauseTickR = GetTickCount()
  354.  
  355.                 end
  356.  
  357.  
  358.  
  359.                 if player:GetSpellData(_R).level > 0 and player:GetDistance(enemy) < 3500 and drawUltiInfo == true then
  360.  
  361.                     if CanUltiEnemy(enemy) == false then
  362.  
  363.                         PrintFloatText(enemy,0,"IMMUNE")
  364.  
  365.                     elseif rDmg * ( 1.0 + rDmgRatioPerHemo * enemy.hemo.count ) > enemyHP then
  366.  
  367.                         PrintFloatText(enemy,0,"DUNK")
  368.  
  369.                     else
  370.  
  371.                         PrintFloatText(enemy,0,"" .. math.ceil(enemyHP - (rDmg * ( 1.0 + rDmgRatioPerHemo * enemy.hemo.count ))) .. " hp" .. " - " .. enemy.hemo.count)
  372.  
  373.                     end
  374.  
  375.                 end
  376.  
  377.             --end
  378.  
  379.         end
  380.  
  381.     end
  382.  
  383. end
  384.  
  385.  
  386.  
  387. function OnCreateObj( object )
  388.  
  389.     if object then
  390.  
  391.         for i=1, #checkBuffForUlti, 1 do
  392.  
  393.             if string.find(string.lower(object.name),checkBuffForUlti[i].spellParticle) and checkBuffForUlti[i].enabled == true then
  394.  
  395.                 for i, enemy in pairs(enemyTable) do
  396.  
  397.                     if GetDistance2D(enemy,object) < 30 then
  398.  
  399.                         if checkBuffForUlti[i].spellType == 0 then
  400.  
  401.                             enemy.canBeUlted = false
  402.  
  403.                             enemy.immuneTimeout = GetTickCount()+checkBuffForUlti[i].duration
  404.  
  405.                         elseif checkBuffForUlti[i].spellType == 1 then
  406.  
  407.                             enemy.shield = enemy.shield + getShieldValue(checkBuffForUlti[i].spellName)
  408.  
  409.                         end
  410.  
  411.                     end
  412.  
  413.                 end
  414.  
  415.             end
  416.  
  417.         end
  418.  
  419.        
  420.  
  421.         if string.find(string.lower(object.name),"darius_hemo_counter") then
  422.  
  423.             for i, enemy in pairs(enemyTable) do
  424.  
  425.                 if enemy and not enemy.dead and enemy.visible and GetDistance2D(enemy,object) <= targetFindRange then
  426.  
  427.                     for k, hemo in pairs(hemoTable) do
  428.  
  429.                         if object.name == hemo then
  430.  
  431.                             enemy.hemo.tick = GetTickCount()
  432.  
  433.                             enemy.hemo.count = k
  434.  
  435.                             PrintFloatText(enemy,21,k .. " Bleedings")
  436.  
  437.                         end
  438.  
  439.                     end
  440.  
  441.                 end
  442.  
  443.             end
  444.  
  445.         end
  446.  
  447.     end
  448.  
  449. end
  450.  
  451.  
  452.  
  453. function OnDeleteObj(obj)
  454.  
  455.     if object then
  456.  
  457.         for i=1, #checkBuffForUlti, 1 do
  458.  
  459.             if string.find(string.lower(object.name),checkBuffForUlti[i].spellParticle) and checkBuffForUlti[i].enabled == true then
  460.  
  461.                 for i, enemy in pairs(enemyTable) do
  462.  
  463.                     if GetDistance2D(enemy,object) < 30 then
  464.  
  465.                         if checkBuffForUlti[i].spellType == 0 then
  466.  
  467.                             enemy.canBeUlted = true
  468.  
  469.                             enemy.immuneTimeout = 0
  470.  
  471.                         elseif checkBuffForUlti[i].spellType == 1 then
  472.  
  473.                             enemy.shield = enemy.shield - getShieldValue(checkBuffForUlti[i].spellName)
  474.  
  475.                             if enemy.shield < 0 then
  476.  
  477.                                 enemy.shield = 0
  478.  
  479.                             end
  480.  
  481.                         end
  482.  
  483.                     end
  484.  
  485.                 end
  486.  
  487.             end
  488.  
  489.         end
  490.  
  491.     end
  492.  
  493. end
Advertisement
Add Comment
Please, Sign In to add comment