Guest User

Draven's Loveshack 1.3.0

a guest
Nov 29th, 2012
1,331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.12 KB | None | 0 0
  1. --[[
  2. Draven's Loveshack 1.3.0
  3.    Created by Dottie
  4.    Original proof-of-concept by llama
  5.    
  6.    Disclaimer: A number of variables and
  7.    functions were reused from llama's
  8.    script. Thank you llama =)!!
  9.    
  10.     ==================================
  11.     |            Summary             |
  12.     ==================================
  13.         -Use "shift" in game for options and keybindings
  14.    
  15.     ==================================
  16.     |           Change Log           |
  17.     ==================================
  18.     Version info:
  19.         x.y.z
  20.         x = major release
  21.         y = major feature changes
  22.         z = feature tweaks and bug fixes
  23.        
  24.     1.1.0:
  25.         -Updated to use AllClass
  26.         -Added second target selector for "e" range, always uses low hp selector
  27.         -Updated picking up axes so it won't pick up axes if an enemy is between AA max range and E max range.
  28.             This allows you to chase instead of running back to pick up and axe and enemy getting away
  29.         -Updated Q prediction to be more accurate
  30.        
  31.     1.1.2:
  32.         -Added "autoBuffChampsOnAttack" option
  33.         -Fixed bug with W buff using the clearMinionsHK
  34.         -General cleanup
  35.        
  36.     1.2.0:
  37.         -Recoded most of the script
  38.         -Added orbwalking
  39.         -Additional checks for safe zone (based on reticle position and player position)
  40.         -Additional check for enemy turret zones
  41.         -Modified E logic and changed it to target closest target
  42.        
  43.     1.2.1:
  44.         -Fixed second reticle bug, readded logic
  45.    
  46.     1.3.0:
  47.         -Fixed bug with safe zones. Was picking up reticle if enemy was in player safe zone
  48.         -Fixed bug with not picking up axes in ally turret range
  49.         -Added "stand" zone around player
  50.         -Added autocast of w if enemy is within safe zone (easier escaping and kiting) if autoBuffChamps is enabled
  51.         -Changed reticle tracking to use table
  52.        
  53.        
  54.     ==================================
  55.     |   Various Useful Draven Info   |
  56.     ==================================
  57.         buff names
  58.             -buff name = dravenspinningattack  -- this is Q's buff
  59.             -dravenfurybuff   -- this is the Attack speed part of the buff
  60.             -dravenFury  -- this is the movement speed part of the buff
  61.  
  62.         spell names
  63.             -DravenBasicAttack
  64.             -DravenBasicAttack2
  65.             -DravenCritAttack
  66.             -DravenCritAttack2
  67.             -dravenspinning  --this is casting Q
  68.             -dravenspinningattack  this is attacking with Q
  69.             -dravenspinningattack2  this is attacking with Q on a 2nd attack
  70.             -DravenFury  -- this is casting W
  71.             -DravenDoubleShot  --casting E
  72.             -DravenRCast -- cast R
  73.             -dravendoublecast -- cast R again when deployed
  74.   ]]
  75.  
  76.  
  77. if GetMyHero().charName == "Draven" then
  78.     function OnLoad()
  79.         player = GetMyHero()
  80.        
  81.         --[[ Hotkeys ]]
  82.         moveAndAttackHK =   32      -- spacebar
  83.         clearMinionsHK  =   88      --"X"
  84.         EHK             =   69      --"E"
  85.         catchAxesHK     =   67      --"C"
  86.        
  87.        
  88.         --[[ Options ]]
  89.         playerSafeZone = 100
  90.         reticleSafeZone = 100
  91.        
  92.         drawAttackRange         =   true
  93.         drawAttackRangeColor    =   0x00FF0000
  94.  
  95.         drawERange              =   true
  96.         drawERangeColor         =   0x00FF0000
  97.  
  98.         drawStandRange          =   true
  99.         standRange              =   220
  100.         drawStandRangeColor     =   0xAA333333
  101.        
  102.         --[[
  103.         =============================================
  104.         == Below this line is for developers only! ==
  105.         =============================================
  106.         ]]
  107.        
  108.         --[[ Draven Attributes ]]
  109.         hitboxAvg = 200             --AA ranges are calculated from edge of hitboxes (varies slightly based on enemy hitbox)
  110.         aaRange = 550 + hitboxAvg
  111.         aaDelay = 300
  112.         startAttackSpeed = 0.679
  113.        
  114.         qRadius = 90
  115.        
  116.         eRange = 1100
  117.         eVelocity = 1.37
  118.         eCastDelay = 300
  119.  
  120.         --[[ Objects and Buffs ]]
  121.         aaParticles = {"Draven_BasicAttack_mis",
  122.                 "Draven_BasicAttack_mis_bloodless",             --untested
  123.                 "Draven_BasicAttack_mis_shadow",                --untested
  124.                 "Draven_BasicAttack_mis_shadow_bloodless",      --untested
  125.                 "Draven_crit_mis",
  126.                 "Draven_crit_mis_bloodless",                    --untested
  127.                 "Draven_crit_mis_shadow",                       --untested
  128.                 "Draven_crit_mis_shadow_bloodless" }            --untested
  129.         qParticles = {"Draven_Q_mis",
  130.                 "Draven_Q_mis_bloodless",                       --untested
  131.                 "Draven_Q_mis_shadow",                          --untested
  132.                 "Draven_Q_mis_shadow_bloodless",                --untested
  133.                 "Draven_Qcrit_mis",
  134.                 "Draven_Qcrit_mis_bloodless",                   --untested
  135.                 "Draven_Qcrit_mis_shadow",                      --untested
  136.                 "Draven_Qcrit_mis_shadow_bloodless" }
  137.         qreticleName = "Draven_Q_reticle_self.troy"
  138.         qHitName = "Draven_Q_tar.troy"  -- Q hit target, right before another _mis is generated
  139.         --qreticleCatchName = "Draven_Q_ReticleCatchSuccess.troy"  --not currently used, may use in future
  140.         qBuffName = "dravenspinningattack"
  141.         qbuffEndName = "draven_spinning_buff_end_sound.troy"
  142.         wBuffAttackSpeed = "dravenfurybuff"                     --attack speed buff
  143.         wBuffMovement = "DravenFury"                            --movement speed buff
  144.        
  145.         --[[ Misc Globals ]]
  146.         reticleDetectionRange = 1200                            -- will not track reticles outside this range
  147.         lastTarget = nil                                        -- last target that was attacked
  148.         shotFiredAt = GetTickCount()                            -- tracks last shot to allow orbwalking
  149.         shotFired = false                                       -- if false, assumes we can attack
  150.         towers = {}                                             -- array of all enemy turrets
  151.         reticles = {}                                           -- array of all reticles
  152.         qMis = {}                                               -- all q missile objects currently on the way to target
  153.         qStacks = 0
  154.         maxStacks = 2
  155.         mouseFlag = false                                       -- used for choosing when to hold position if mouse is near hero
  156.        
  157.         --[[ Script Menu ]]
  158.         DravenConfig = scriptConfig("Draven's Combo","dravencombo")
  159.         DravenConfig:addParam("moveAndAttack","Move and Attack",SCRIPT_PARAM_ONKEYDOWN, false, moveAndAttackHK)
  160.         DravenConfig:addParam("clearMinions","Clear Minions",SCRIPT_PARAM_ONKEYDOWN, false, clearMinionsHK)
  161.         DravenConfig:addParam("castE","Cast E on Target",SCRIPT_PARAM_ONKEYDOWN, false, EHK)
  162.         DravenConfig:addParam("catchAxes","Auto Catch Axes",SCRIPT_PARAM_ONKEYTOGGLE,false,catchAxesHK)
  163.         DravenConfig:addParam("autoBuffChamps","Auto Cast W (Champs)",SCRIPT_PARAM_ONOFF,true)
  164.         DravenConfig:addParam("autoBuffMinion","Auto Cast W (Minion)",SCRIPT_PARAM_ONOFF,false)
  165.         DravenConfig:permaShow("moveAndAttack")
  166.         DravenConfig:permaShow("clearMinions")
  167.         DravenConfig:permaShow("catchAxes")
  168.        
  169.         ts = TargetSelector(TARGET_LOW_HP, aaRange, DAMAGE_PHYSICAL)
  170.        
  171.         DravenConfig:addTS(ts)
  172.        
  173.         --[[ Build Towers Array ]]
  174.         for i = 1, objManager.iCount, 1 do
  175.             local obj = objManager:getObject(i)
  176.             if obj ~= nil and string.find(obj.type, "obj_Turret") ~= nil and string.find(obj.name, "_A") == nil and obj.health > 0 then
  177.                 if not string.find(obj.name, "TurretShrine") and obj.team ~= player.team then
  178.                     table.insert(towers, obj)
  179.                 end
  180.             end
  181.         end
  182.     end
  183.  
  184. --[[
  185.         API :
  186.         ----- Local Functions -----
  187.         FindMinion()                            -- return lowest hp minion in q range              
  188.         InTurretRange(v)                        -- return true if vector is in range of a turret
  189.         TimeToShoot()                           -- return true if basic attack is ready to be shot
  190.         GetClosestHero(int)                     -- returns closest valid enemy hero within range
  191.         IsZoneSafe(v, int)                      -- returns false if enemy is in "x" range of "v"
  192. ]]
  193.    
  194.     --[[ Local Functions ]]
  195.     local function FindMinion()
  196.         local minion = nil
  197.         local lowHp = math.huge
  198.         for i = 0, objManager.maxObjects, 1 do
  199.             local object = objManager:getObject(i)
  200.             if object and object.team ~= player.team and string.find(object.name, "Minion_") and not object.dead and object.visible and object.bTargetable and player:GetDistance(object) < aaRange then
  201.                 if object.health < lowHp then
  202.                     minion = object
  203.                     lowHp = object.health
  204.                 end
  205.             end
  206.         end
  207.         return minion
  208.     end
  209.  
  210.     local function InTurretRange(v)
  211.         local flag = false
  212.         for i, tow in ipairs(towers) do
  213.             if tow.health > 0 then
  214.                 if math.sqrt((tow.x - v.x) ^ 2 + (tow.z - v.z) ^ 2) < 975 then
  215.                     flag = true
  216.                 end
  217.             else
  218.                 table.remove(towers, i)
  219.             end
  220.         end
  221.         return flag
  222.     end
  223.    
  224.     local function TimeToShoot()
  225.         if GetTickCount() >= (shotFiredAt + (1000/(player.attackSpeed/(1/startAttackSpeed))) - aaDelay) then return true
  226.         else return false end
  227.     end
  228.    
  229.     local function GetClosestHero(range)
  230.         local closestTarget = nil
  231.    
  232.         for i = 1, heroManager.iCount, 1 do
  233.             local curHero = heroManager:GetHero(i)
  234.             if curHero ~= nil and ValidTarget(curHero, range, true) then
  235.                 if closestTarget == nil then
  236.                     closestTarget = curHero
  237.                 else
  238.                     if player:GetDistance(curHero) < player:GetDistance(closestTarget) then
  239.                         closestTarget = curHero
  240.                     end
  241.                 end
  242.             end
  243.         end
  244.        
  245.         return closestTarget
  246.     end
  247.    
  248.     local function IsZoneSafe(v, rng)
  249.         local flag = true
  250.        
  251.         for i=1, heroManager.iCount, 1 do
  252.             local curHero = heroManager:GetHero(i)
  253.             if curHero ~= nil and curHero.team ~= player.team
  254.                 and not curHero.dead and GetDistance(curHero, v) < (rng) then
  255.                 flag = false
  256.             end
  257.         end
  258.        
  259.         return flag
  260.     end
  261.    
  262.     local function InStandRange()
  263.         return (GetDistanceFromMouse(player) < standRange)
  264.     end
  265.    
  266.     --[[ Global Functions ]]
  267.     function OnTick()
  268.         ts:update()
  269.         Prediction__OnTick()
  270.        
  271.         local qTarget = nil
  272.         local qPrediction
  273.        
  274.         if shotFired and TimeToShoot() then
  275.             shotFired = false
  276.         end
  277.            
  278.         -- set q target if a keybind is held
  279.         if DravenConfig.moveAndAttack and ts.target ~= nil and ValidTarget(ts.target, aaRange, true) then
  280.             qTarget = ts.target
  281.         elseif DravenConfig.clearMinions then
  282.             qTarget = FindMinion()
  283.         else
  284.             qTarget = nil
  285.         end
  286.        
  287.        
  288.        
  289.         --[[ Begin Axe Catching Logic ]]
  290.         if DravenConfig.catchAxes and not DravenConfig.moveAndAttack and not DravenConfig.clearMinions then
  291.             if next(reticles) then
  292.                 if GetDistance(player, reticles[1]) > qRadius and IsZoneSafe(reticles[1], reticleSafeZone) and not InTurretRange(reticles[1]) then
  293.                     player:MoveTo(reticles[1].x, reticles[1].z)
  294.                 end
  295.             end
  296.         end
  297.         --[[ End Axe Catching Logic ]]
  298.        
  299.        
  300.        
  301.         --[[ Begin E Logic ]]
  302.         if DravenConfig.castE and player:CanUseSpell(_E) == READY then
  303.             local eTarget = nil
  304.            
  305.             if qTarget ~= nil then
  306.                 eTarget = qTarget
  307.             else
  308.                 eTarget = GetClosestHero(eRange)
  309.             end
  310.            
  311.             if eTarget ~= nil then
  312.                 qPrediction = GetPredictionPos(eTarget,math.floor(player:GetDistance(eTarget)/eVelocity) + eCastDelay)
  313.                 if qPrediction and GetDistance(player, qPrediction) < eRange - 50 then -- sub 50 for margin of error
  314.                     CastSpell(_E, qPrediction.x, qPrediction.z)
  315.                 end
  316.             end
  317.         end
  318.         --[[ End E Logic ]]
  319.        
  320.        
  321.        
  322.         --[[ Begin Auto-buff in Enemy In Safe Zone ]]
  323.         if DravenConfig.autoBuffChamps and not IsZoneSafe(player, playerSafeZone)
  324.             and player:CanUseSpell(_W) == READY and not TargetHaveBuff(wBuffAttackSpeed, player) then
  325.             CastSpell(_W)
  326.         end
  327.         --[[End Auto-buff if Enemy In Safe Zone ]]
  328.        
  329.        
  330.         --[[  Begin Main Hotkey Logic ]]
  331.         if DravenConfig.clearMinions or DravenConfig.moveAndAttack then
  332.             local curMouseRange = GetDistance(mousePos, player)
  333.             if not shotFired and qTarget ~= nil then
  334.                 if ValidTarget(qTarget, aaRange, true) then
  335.                     if ((DravenConfig.autoBuffChamps and DravenConfig.moveAndAttack) or (DravenConfig.autoBuffMinion and DravenConfig.clearMinions))
  336.                       and player:CanUseSpell(_W) == READY and not TargetHaveBuff(wBuffAttackSpeed, player) then
  337.                         CastSpell(_W)
  338.                     elseif player:CanUseSpell(_Q) == READY and qStacks < maxStacks
  339.                     and (IsZoneSafe(player, playerSafeZone) or curMouseRange < standRange) then
  340.                         CastSpell(_Q)
  341.                     else
  342.                         if InStandRange() and mouseFlag == false then
  343.                             player:HoldPosition()
  344.                             mouseFlag = true
  345.                         end
  346.                        
  347.                         if IsZoneSafe(player, playerSafeZone) or InStandRange() then
  348.                             player:Attack(qTarget)
  349.                             lastTarget = qTarget
  350.                         end
  351.                     end
  352.                 end
  353.             elseif next(reticles) then
  354.                 local closestHero = GetClosestHero(900)
  355.                 if InStandRange() and not InTurretRange(reticles[1]) then
  356.                     player:MoveTo(reticles[1].x, reticles[1].z)
  357.                     mouseFlag = false
  358.                 elseif GetDistance(player, reticles[1]) > qRadius and not InTurretRange(reticles[1]) and IsZoneSafe(reticles[1], reticleSafeZone) and IsZoneSafe(player, playerSafeZone)
  359.                     and not (closestHero ~= nil and GetDistance(reticles[1], closestHero) > aaRange) -- if enemy is found within 900 but the distance to him is greater than distance to reticle
  360.                     and not InStandRange() then
  361.                     player:MoveTo(reticles[1].x, reticles[1].z)
  362.                     mouseFlag = false
  363.                 else
  364.                     if not InStandRange() then
  365.                         player:MoveTo(mousePos.x, mousePos.z)
  366.                         mouseFlag = false
  367.                     else
  368.                         player:HoldPosition()
  369.                     end
  370.                 end
  371.             else
  372.                 if not InStandRange() then
  373.                     player:MoveTo(mousePos.x, mousePos.z)
  374.                     mouseFlag = false
  375.                 else
  376.                     player:HoldPosition()
  377.                 end
  378.             end
  379.         end
  380.         --[[ End Main Hotkey Logic ]]
  381.     end
  382.  
  383.     function OnWndMsg(msg, wParam)
  384.         SC__OnWndMsg(msg,wParam)
  385.     end
  386.  
  387.     function OnCreateObj(object)
  388.         if myHero.dead then return end
  389.        
  390.         for _, v in pairs(qParticles) do
  391.             if string.find(object.name, v) then
  392.                 if GetDistance(object, player) < 333 then
  393.                     shotFired = true
  394.                     shotFiredAt = GetTickCount()
  395.                 end
  396.             end
  397.         end
  398.        
  399.         for _, v in pairs(aaParticles) do
  400.             if string.find(object.name, v) then
  401.                 shotFired = true
  402.                 shotFiredAt = GetTickCount()
  403.             end
  404.         end
  405.        
  406.         if object ~= nil and object.name ~= nil and object.x ~= nil and object.z ~= nil and GetDistance(player, object) <= reticleDetectionRange then
  407.             if object.name == qreticleName then
  408.                 table.insert(reticles, object)
  409.             elseif object.name == qbuffEndName then
  410.                 qStacks = 0
  411.             end
  412.         end
  413.     end
  414.  
  415.     function OnDeleteObj(object)
  416.         if object ~= nil and object.name ~= nil and object.x ~= nil and object.z ~= nil and GetDistance(player, object) <= reticleDetectionRange then
  417.             if object.name == qreticleName then
  418.                 table.remove(reticles, 1)
  419.                 qStacks = qStacks - 1
  420.             end
  421.         end
  422.     end
  423.  
  424.     function OnDraw()
  425.         SC__OnDraw()
  426.        
  427.         if not myHero.dead then
  428.             if drawAttackRange == true then
  429.                 DrawCircle(player.x, player.y, player.z, aaRange, drawAttackRangeColor)
  430.             end
  431.             if drawERange == true then
  432.                 DrawCircle(player.x, player.y, player.z, eRange, drawERangeColor)
  433.             end
  434.             if drawStandRange == true then
  435.                 DrawCircle(player.x, player.y, player.z, standRange, drawStandRangeColor)
  436.             end
  437.         end
  438.     end
  439.  
  440.     PrintChat(" >> Draven's Loveshack 1.3.0 Loaded")
  441. end
Advertisement
Add Comment
Please, Sign In to add comment