samipote

[Script] Malbert's InSec Lee v.5.5 Fixed

Aug 16th, 2014
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 84.26 KB | None | 0 0
  1. require "Utils"
  2. require "spell_damage"
  3. require 'winapi'
  4. require 'SKeys'
  5. require 'yprediction'
  6. local YP = YPrediction()
  7. local send = require 'SendInputScheduled'
  8.  
  9. local metakey = SKeys.Control
  10. print("\nMalbert's")
  11. print("\nPrivate LeeSin")
  12. print("\nVersion 5.3")
  13. local target
  14. local targeti
  15. local target2
  16. local _registry = {}
  17. local targetItems={3144,3153,3128,3092,3146}
  18. --Bilgewater,BoTRK,DFG,FrostQueen,Hextech
  19. local aoeItems={3184,3143,3180,3131,3069,3023,3290,3142}
  20. --Entropy,Randuins,Odyns,SwordDivine,TalismanAsc,TwinShadows,TwinShadows,YoGBlade
  21. local hydraItems={3074,3077}
  22. --Hydra,Tiamat
  23.  
  24. local egg = {team = 0, enemy = 0}
  25. local zac = {team = 0, enemy = 0}
  26. local aatrox = {team = 0, enemy = 0}
  27. local range = myHero.range + GetDistance(GetMinBBox(myHero))
  28. local wards = {3340, 3350, 3154, 3160, 3361, 3362, 2044, 2043, 2045, 2049}
  29. --[[
  30. 2043, Vision Ward
  31. 2044, Sight Ward
  32. 2045, Ruby Sightstone
  33. 2049, Sightstone
  34. 2050, Explorer's Ward (Removed)
  35. 3154, Wriggle's Lantern
  36. 3340, Warding Totem (60s/3 max) (lv 0)
  37. 3350, Greater Totem (120s/3 max) (lv 9)
  38. 3361, Greater Stealth Totem (180s/3 max) (lv 9+purchase)
  39. 3362, Graeter Vision Totem (--s/1 max) (lv 9+purchase)
  40. ]]--
  41. local eye={unit=nil,x=nil,y=nil,z=nil}
  42.        
  43.         local success=false
  44.         local wardsuccess=false
  45.         local wardx
  46.         local wardy
  47.         local wardz
  48.         local wardNear={}
  49.         local lastWardJump=0
  50.         local wardObject=nil
  51.         local lastWardObject=nil
  52.         local TI
  53.         local startCombo=false
  54.         local PMod=0
  55.         local PTimer=0
  56.         local startHarass=false
  57.         local wardhx,wardhy,wardhz
  58.         local something
  59.         local enemies={}
  60.         local enemyIndex=2
  61.         local wardFound=false
  62.         local TITimer=0
  63. local www=nil
  64. local wUsedAt = 0
  65. local vUsedAt = 0
  66. local timer=os.clock()
  67. local bluePill = nil
  68. local QRDY=0
  69. local WRDY=0
  70. local ERDY=0
  71. local RRDY=0
  72. local targetR=nil
  73. local qdelay=0
  74. local qspeed=0
  75. local tfa={x=0,y=0,z=0}
  76. local tfax,tfay,tfaz
  77.  
  78.         LeeConfig = scriptConfig("LeeSin", "LeeSin Hotkeys")
  79. LeeConfig:addParam("Combo", "Combo", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("T"))--T
  80. LeeConfig:addParam("initiate", "InSec Ult Combo", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("X"))
  81. LeeConfig:addParam("harass", "Harass Jump", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("C"))
  82. LeeConfig:addParam("ward", "Ward Jump", SCRIPT_PARAM_ONKEYDOWN, false, string.byte("Z"))
  83. LeeConfig:addParam("smite", "Smitesteal", SCRIPT_PARAM_ONKEYTOGGLE, true, string.byte("7"))
  84. LeeConfig:addParam("ultLow", "Ult When Low", SCRIPT_PARAM_ONKEYTOGGLE, true, string.byte("8"))
  85. LeeConfig:addParam("ultKS", "Ult KS", SCRIPT_PARAM_ONKEYTOGGLE, true, string.byte("9"))
  86. LeeConfig:addParam("ultC", "Stylish Ult in Combo", SCRIPT_PARAM_ONKEYTOGGLE, false, string.byte("0"))
  87. LeeConfig:addParam("PU", "Prioritize InSec", SCRIPT_PARAM_NUMERICUPDOWN, 1,189,1,objManager:GetMaxHeroes()/2+2,1)-- "-" objManager:GetMaxHeroes()/2+1
  88. LeeConfig:addParam("iskey", "What to Insec To", SCRIPT_PARAM_DOMAINUPDOWN, 1, 187, {"Inventory Wards","Minions & Placed Wards","Both"})
  89.  
  90. LeeConfig:addParam('distanceR', "RA Distance", SCRIPT_PARAM_NUMERICUPDOWN, 550, 219,100,700,50)
  91. LeeConfig:addParam('distanceNR', "NRA Distance", SCRIPT_PARAM_NUMERICUPDOWN, 400, 221,100,700,50)
  92. LeeConfig:addParam('distanceNM', "NM Distance", SCRIPT_PARAM_NUMERICUPDOWN, 450, 191,100,700,50)
  93. LeeConfig:addParam('qd', "Q Delay", SCRIPT_PARAM_NUMERICUPDOWN, 2, 190,2,6,0.1)
  94. LeeConfig:addParam('qs', "Q Speed", SCRIPT_PARAM_NUMERICUPDOWN, 16, 191,14,17,0.1)
  95. LeeConfig:addParam("wardH", "Harass Can Use Ward", SCRIPT_PARAM_ONOFF, false)
  96. LeeConfig:addParam("wardF", "Ward Farthest", SCRIPT_PARAM_ONOFF, true)
  97. LeeConfig:addParam("mqi", "Manual Q Insec", SCRIPT_PARAM_ONOFF, true)
  98. LeeConfig:addParam("ignite", "Ignite KS", SCRIPT_PARAM_ONOFF, true)
  99. LeeConfig:addParam("insec2group", "Insec To Friendlies", SCRIPT_PARAM_ONOFF, true)
  100. LeeConfig:addParam("noPassive", "Dont Use Passive in Combo", SCRIPT_PARAM_ONOFF, false)
  101. LeeConfig:addParam('cw', "Circle Width", SCRIPT_PARAM_NUMERICUPDOWN, 5, 40,0,10,1)
  102. LeeConfig:addParam("circles", "Circles", SCRIPT_PARAM_ONOFF, true)
  103. LeeConfig:addParam("pots", "Auto Potions", SCRIPT_PARAM_ONOFF, true)
  104. LeeConfig:permaShow("smite")
  105. LeeConfig:permaShow("ultLow")
  106. LeeConfig:permaShow("ultKS")
  107. LeeConfig:permaShow("ultC")
  108. LeeConfig:permaShow("ignite")
  109.        
  110. function LeeRun()
  111.  
  112.         ------------
  113.         if myHero.SpellTimeQ > 1.0 and GetSpellLevel('Q') > 0 then
  114.                 QRDY = 1
  115.                 else QRDY = 0
  116.         end
  117.         if myHero.SpellTimeW > 1.0 and GetSpellLevel('W') > 0 then
  118.                 WRDY = 1
  119.                 else WRDY = 0
  120.         end
  121.         if myHero.SpellTimeE > 1.0 and GetSpellLevel('E') > 0 then
  122.                 ERDY = 1
  123.                 else ERDY = 0
  124.         end
  125.         if myHero.SpellTimeR > 1.0 and GetSpellLevel('R') > 0 then
  126.                 RRDY = 1
  127.         else
  128.                         RRDY = 0                      
  129.                                 TI=nil
  130.                                 startCombo=false
  131.                                 wardFound=false
  132.                                 success=false
  133.                         end
  134.         --------------------------
  135.  
  136.         qdelay=LeeConfig.qd
  137.         qspeed=LeeConfig.qs
  138.  
  139.         target = GetBestEnemy("PHYS", 1100, "NEARMOUSE")
  140.     target2 = GetBestEnemy('TRUE',600)
  141.         targetR = GetBestEnemy('PHYS',400)
  142.        
  143.         for i=1, objManager:GetMaxHeroes(), 1 do
  144.                 hero = objManager:GetHero(i)
  145.                 if hero~=nil and hero.team~=myHero.team and hero.name~="" then
  146.                         if enemies[hero.name]==nil then
  147.                                 enemies[hero.name]={unit=hero,number=enemyIndex}
  148.                                 enemyIndex=enemyIndex+1
  149.                         end
  150.                 end
  151.         end
  152.                
  153.         targeti =nil--GetWeakEnemy("PHYS", 975)
  154.         if RRDY==1 then
  155.                 findtargeti()
  156.     end
  157.  
  158.         www=nil
  159.                 for _, ward in pairs(wards) do
  160.                         if ward~=nil and GetWardSlot(ward) ~= nil and os.clock() > lastWardJump  then
  161.                                
  162.                                 www=GetWardSlot(ward)
  163.                                 --print("\nHere1 "..tostring(ward))
  164.                                 break
  165.                                
  166.                         end
  167.                 end
  168.                
  169.         if LeeConfig.ultKS and targetR~=nil then
  170.                 local rdmg= getDmg('R',targetR,myHero)*RRDY
  171.                 local edmg = getDmg("E",targetR,myHero)*ERDY
  172.                 if targetR.health<rdmg and ((targetR.health>getDmg("AD",targetR,myHero)+edmg or GetD(targetR)>200 or myHero.health<myHero.maxHealth*0.20)) then
  173.                         CastSpellTarget('R',targetR)
  174.                 end
  175.         end
  176.         if target~=nil and QRDY==1 then
  177.                 tfax,tfay,tfaz=GetFireahead(target,qdelay,qspeed)
  178.                 tfa={x=tfax,y=tfay,z=tfaz}
  179.         end
  180.     if IsChatOpen()==0 and LeeConfig.Combo then Combo() end    
  181.     if IsChatOpen()==0 and LeeConfig.harass then Harass() end    
  182.     if IsChatOpen()==0 and LeeConfig.initiate then initiate() end  
  183.     if IsChatOpen()==0 and myHero.dead~=1 and LeeConfig.ward and LeeConfig.wardF then ward(mousePos.x,mousePos.y,mousePos.z)
  184.     elseif IsChatOpen()==0 and myHero.dead~=1 and LeeConfig.ward and LeeConfig.wardF==false then ward() end  
  185.         if LeeConfig.mqi and RRDY==1 then
  186.                 if (TI==nil or TI.dead==1 or TITimer<os.clock()) and eye~=nil and eye.x~=nil and myHero.SpellNameQ == "blindmonkqtwo" and targeti~=nil then
  187.                         local TIHolder=nil
  188.                         for i = 1, objManager:GetMaxHeroes()  do
  189.             local enemy = objManager:GetHero(i)
  190.                         local invul=IsInvulnerable(enemy).status
  191.                                 if enemy~=nil and enemy.team~=myHero.team and enemy.dead==0 and enemy.visible==1 and invul~=1 and (TIHolder==nil or TIHolder.dead==1 or TIHolder.visible==0 or IsInvulnerable(TIHolder).status==1) and eye~=nil and GetD(enemy)<2000 then
  192.                                         TIHolder=enemy
  193.                                 elseif enemy~=nil and enemy.team~=myHero.team and enemy.dead==0 and enemy.visible==1 and invul~=1 and TIHolder~=nil and TIHolder.dead==0 and TIHolder.visible==1 and eye~=nil and GetD(enemy,eye)<GetD(TIHolder,eye) then
  194.                                         TIHolder=enemy                        
  195.                                 end
  196.                         end
  197.                         if TIHolder~=nil then
  198.                                 TI=TIHolder
  199.                                 startCombo=false
  200.                                 wardFound=false
  201.                                 success=false
  202.                                 TITimer=os.clock()+5
  203.                         end
  204.                 end
  205.         end  
  206.     if LeeConfig.smite then Smite() end
  207.         if LeeConfig.ignite then ignite() end
  208.         if LeeConfig.ultLow then ultSave() end
  209.         if LeeConfig.pots then RedElixir() end
  210. end
  211.  
  212. function findtargeti()
  213.         if LeeConfig.PU==1 then
  214.                 for j=1, objManager:GetMaxHeroes(), 1 do
  215.                         local herotarget = objManager:GetHero(j)
  216.                         local invul=IsInvulnerable(herotarget).status
  217.                         if herotarget~=nil and herotarget.team~=myHero.team and herotarget.dead~=1 and herotarget.visible==1 and invul~=1 and (targeti==nil or targeti.dead==1) and GetD(herotarget)<1500 then
  218.                                 targeti=herotarget
  219.                         elseif herotarget~=nil and herotarget.team~=myHero.team and herotarget.dead~=1 and herotarget.visible==1 and invul~=1 and GetD(herotarget)<1500 and herotarget.addDamage+herotarget.baseDamage>targeti.addDamage+targeti.baseDamage then
  220.                                 targeti=herotarget
  221.                         end
  222.                 end
  223.         elseif LeeConfig.PU==2 then
  224.                 targeti=GetBestEnemy("PHYS", 1100, "NEARMOUSE")
  225.         elseif LeeConfig.PU>2 then
  226.                
  227.                 for i, enemy in pairs(enemies) do
  228.                         local invul=IsInvulnerable(enemy.unit).status
  229.                         if enemy~=nil and enemy.unit~=nil and enemy.unit.dead~=1 and invul~=1 and enemy.unit.visible==1 and enemy.unit.x~=nil and enemy.number==LeeConfig.PU and myHero.dead~=1 and GetD(enemy.unit)<1500 then
  230.                                 targeti=enemy.unit
  231.                         end
  232.                 end
  233.         end
  234. end
  235.  
  236. function ignite()
  237.         local damage = (myHero.selflevel*20)+50
  238.         if target2 ~= nil then
  239.                 if myHero.SummonerD == "SummonerDot" then
  240.                         if target2.health < damage then
  241.                                 CastSpellTarget("D",target2)
  242.                         end
  243.                 end
  244.                 if myHero.SummonerF == "SummonerDot" then
  245.                         if target2.health < damage then
  246.                                 CastSpellTarget("F",target2)
  247.                         end
  248.                 end
  249.         end
  250. end
  251.  
  252. function Combo()
  253.     if target ~= nil then
  254.                
  255.         if myHero.SpellNameQ == "BlindMonkQOne" and QRDY==1 and (PMod>2 or PTimer<os.clock() or LeeConfig.noPassive) then
  256.                         Qspell(target)
  257.                 elseif myHero.SpellNameQ == "blindmonkqtwo" and RRDY==1 and LeeConfig.ultC and GetD(target)<400 and eye~=nil and eye.unit~=nil and eye.unit.x~=nil and GetD(eye.unit,target)<100 then
  258.                         CastSpellTarget("R",target) --printtext("\nR")
  259.                 elseif myHero.SpellNameQ == "blindmonkqtwo" and QRDY==1 and (PMod>2 or PTimer<os.clock()  or LeeConfig.noPassive or GetD(target) > 320 or (LeeConfig.ultC and GetD(target)>370)) and eye~=nil and eye.unit~=nil and eye.unit.x~=nil and GetD(eye.unit,target)<50 then
  260.                         CastSpellTarget("Q",target)  
  261.                 end
  262.         if ERDY==1 and myHero.SpellNameE == "BlindMonkEOne" and GetD(target) < 350 and (PMod>2 or PTimer<os.clock()  or LeeConfig.noPassive or GetD(target) > 340-35) then
  263.                         CastSpellXYZ('E',myHero.x,myHero.y,myHero.z) --printtext("\nE")
  264.                 elseif ERDY==1 and myHero.SpellNameE == "blindmonketwo" and (PMod>2 or PTimer<os.clock()  or LeeConfig.noPassive or GetD(target) > 320 ) then
  265.                         CastSpellXYZ('E',myHero.x,myHero.y,myHero.z) --printtext("\nE")
  266.                 elseif myHero.SpellNameW == "BlindMonkWOne" and WRDY==1 and GetD(target) < 350 and (PMod>2 or PTimer<os.clock()  or LeeConfig.noPassive) then
  267.                         run_every(0.2,WSpell,myHero)  
  268.                 end
  269.                 if myHero.SpellNameW == "blindmonkwtwo" and WRDY==1 and GetD(target) < 350 and (PMod>2  or PTimer<os.clock()  or LeeConfig.noPassive) then
  270.                         run_every(0.2,WSpell,myHero)  
  271.                 end
  272.                 if RRDY==1 then
  273.                         local rdmg = getDmg("R",target,myHero)*RRDY
  274.                         local edmg = getDmg("E",target,myHero)*ERDY
  275.                         if GetD(target)<400 and target.health<rdmg and (target.health>getDmg("AD",target,myHero)+edmg or myHero.health<myHero.maxHealth*0.20) and LeeConfig.ultKS then
  276.                                 CastSpellTarget('R',target)
  277.                         end
  278.                 end
  279.                 if  GetD(target)<400 then
  280.                         for _, item in pairs(hydraItems) do
  281.                                         if GetInventorySlot(item)~=nil and myHero["SpellTime"..GetInventorySlot(item)]>1.0 then
  282.                                                         CastSpellTarget(tostring(GetInventorySlot(item)),target)
  283.                                         end
  284.                         end
  285.                         for _, item in pairs(aoeItems) do
  286.                                         if GetInventorySlot(item)~=nil and myHero["SpellTime"..GetInventorySlot(item)]>1.0 then
  287.                                                         CastSpellTarget(tostring(GetInventorySlot(item)),target)
  288.                                         end
  289.                         end
  290.                         for _, item in pairs(targetItems) do
  291.                                         if GetInventorySlot(item)~=nil and myHero["SpellTime"..GetInventorySlot(item)]>1.0 then
  292.                                                         CastSpellTarget(tostring(GetInventorySlot(item)),target)
  293.                                         end
  294.                         end
  295.                 elseif GetD(target)<600 then
  296.                         for _, item in pairs(targetItems) do
  297.                                         if GetInventorySlot(item)~=nil and myHero["SpellTime"..GetInventorySlot(item)]>1.0 then
  298.                                                         CastSpellTarget(tostring(GetInventorySlot(item)),target)
  299.                                         end
  300.                         end
  301.                 end
  302.         if IsAttackReady() and GetDistance(target)<250 then
  303.                         AttackTarget(target)
  304.                 else
  305.                         local xx,yy,zz=GetFireahead(target,2,0)
  306.                         MoveToMouse()
  307.                 end
  308.                
  309.         else
  310.                 MoveToMouse()
  311.     end
  312. end
  313. function Qspell(target)
  314. if target~=nil then
  315. local Qrange,Qwidth,Qspeed,Qdelay = 1000.0000,60,1800.0000,.5
  316. local CastPosition,HitChance,Position = YP:GetLineCastPosition(target, Qdelay, Qwidth, Qrange, Qspeed, myHero, true)
  317. if HitChance==2 and GetDistance(myHero,CastPosition)<1000 then
  318. local x,y,z =  CastPosition.x,CastPosition.y,CastPosition.z          
  319. CastSpellXYZ('Q',x,0,z)
  320. end
  321. end
  322. end
  323. function WSpell(tt)
  324. CastSpellTarget('W',tt)
  325. end
  326. function ultSave()
  327.         if RRDY==1 and myHero.health<myHero.maxHealth*0.20 then
  328.                 local kicktarget=nil
  329.                 for j=1, objManager:GetMaxHeroes(), 1 do
  330.                         local herotarget = objManager:GetHero(j)
  331.                         local invul=IsInvulnerable(herotarget).status
  332.                         if herotarget~=nil and herotarget.team~=myHero.team and invul~=1 and invul~=2 and GetD(herotarget)<400 and (kicktarget==nil or kicktarget.dead==1) then
  333.                                 kicktarget=herotarget
  334.                         elseif herotarget~=nil and herotarget.team~=myHero.team and invul~=1 and invul~=2 and GetD(herotarget)<400 and GetD(herotarget)<GetD(kicktarget) then
  335.                                 kicktarget=herotarget
  336.                         end
  337.                 end
  338.                 if kicktarget~=nil then
  339.                         CastSpellTarget('R',kicktarget)
  340.                 end
  341.         end
  342. end
  343.  
  344. function ward(hx,hy,hz)
  345.         if hx~=nil and hy~=nil and hz~=nil then
  346.                
  347.                                 --print("\nHere38 "..tostring(WRDY).." "..myHero.SpellNameW.. " "..lastWardJump.." "..os.clock())
  348.                 if WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and os.clock() > lastWardJump then
  349.                        
  350.                                 --print("\nHere39")
  351.                         wardsuccess=false
  352.                         --wx,wy,wz=GetFireahead(myHero,5,0)
  353.                        
  354.                         if www~=nil and os.clock() > lastWardJump then
  355.                                 --print("\nHere40")
  356.                                 local wx,wy,wz=getWardSpot(hx,hy,hz)
  357.                                 CastSpellXYZ(www,wx,wy,wz,0)
  358.                                 lastWardJump=os.clock()+3
  359.                                 wardsuccess=true
  360.                         end    
  361.                 end
  362.                
  363.                 if WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and wardsuccess==true and lastWardObject~=nil and GetD(lastWardObject)<700 then
  364.                         run_every(0.2,WSpell, lastWardObject)
  365.                
  366.                 end
  367.  
  368.                 if ( WRDY==0 or myHero.SpellNameW=="blindmonkwtwo" or not gotAWard()) then
  369.                         MoveToMouse()
  370.                 end
  371.         else
  372.                                 --print("\nHere41")
  373.                 if WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and os.clock() > lastWardJump then
  374.                        
  375.                                 --print("\nHere42")
  376.                         wardsuccess=false
  377.                         --wx,wy,wz=GetFireahead(myHero,5,0)
  378.                         if www~=nil and os.clock() > lastWardJump then
  379.                                 --print("\nHere43")
  380.                                 CastSpellXYZ(www, mousePos.x,mousePos.y,mousePos.z,0)
  381.                                 lastWardJump=os.clock()+3
  382.                                 wardsuccess=true
  383.                         end    
  384.                        
  385.                 end
  386.                
  387.                 if WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and wardsuccess==true and lastWardObject~=nil and GetD(lastWardObject)<700 then
  388.                         run_every(0.2,WSpell, lastWardObject)
  389.                
  390.                 end
  391.                 if ( WRDY==0 or myHero.SpellNameW=="blindmonkwtwo" or not gotAWard()) then
  392.                         MoveToMouse()
  393.                 end
  394.         end
  395. end
  396.  
  397. function Harass()
  398.         if target~=nil and WRDY==1 then
  399.                 if myHero.SpellNameQ == "BlindMonkQOne" and QRDY==1 and (somethingNear(target)~=nil or gotAWard()) and (GetD(tfa)>100 or runningAway(target)) then
  400.                         startHarass=false
  401.                         Qspell(target)
  402.                 elseif myHero.SpellNameQ == "BlindMonkQOne" and QRDY==1 and (somethingNear(target)~=nil or gotAWard()) and GetD(tfa)<=100 then
  403.                         startHarass=false
  404.                         CastSpellXYZ('Q',target.x,target.y,target.z)
  405.                 end
  406.                 if myHero.SpellNameQ == "blindmonkqtwo" and QRDY==1 and WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and eye~=nil and eye.unit~=nil and eye.unit.x~=nil then
  407.                         if GetD(eye.unit,target)<50 and somethingNear(target)~=nil then
  408.                                 something=somethingNear(target)
  409.                                 startHarass=true
  410.                                 --
  411.                                 CastSpellTarget('Q',myHero)
  412.                         elseif GetD(eye.unit,target)<50 and LeeConfig.wardH and gotAWard() then
  413.                                 wardhx,wardhy,wardhz=getWardHarassSpot()
  414.                                 startHarass=true
  415.                                 --CastSpellTarget('E',myHero)
  416.                                 CastSpellTarget('Q',myHero)
  417.                         end
  418.                 end
  419.                 if startHarass==true and  QRDY==0 and WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and something~=nil and something.dead~=1 then
  420.                         if ERDY==1 then CastSpellTarget('E',myHero) end
  421.                         run_every(0.2,WSpell, something)
  422.                 elseif startHarass==true and  QRDY==0 and WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and (LeeConfig.wardH and gotAWard()) then
  423.                         ward(wardhx,wardhy,wardhz)
  424.                         if ERDY==1 then CastSpellTarget('E',myHero) end
  425.                         if WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and wardsuccess==true and lastWardObject~=nil and GetD(lastWardObject)<700 then
  426.                                 run_every(0.2,WSpell, lastWardObject)
  427.                         end
  428.                 end
  429.                
  430.         else
  431.                 something=nil
  432.                 MoveToMouse()
  433.         end
  434. end
  435.  
  436. function getWardHarassSpot()
  437.         if QRDY==1 then
  438.                 local dist=GetD(target,myHero)
  439.                         if target.x==myHero.x then
  440.                                         tx = target.x
  441.                                         if target.z>myHero.z then
  442.                                                         tz = target.z-450
  443.                                         else
  444.                                                         tz = target.z+(450)
  445.                                         end
  446.                    
  447.                         elseif target.z==myHero.z then
  448.                                         tz = target.z
  449.                                         if target.x>myHero.x then
  450.                                                         tx = target.x-(450)
  451.                                         else
  452.                                                         tx = target.x+(450)
  453.                                         end
  454.                    
  455.                         elseif target.x>myHero.x then
  456.                                         angle = math.asin((target.x-myHero.x)/dist)
  457.                                         zs = (450)*math.cos(angle)
  458.                                         xs = (450)*math.sin(angle)
  459.                                         if target.z>myHero.z then
  460.                                                         tx = target.x-xs
  461.                                                         tz = target.z-zs
  462.                                         elseif target.z<myHero.z then
  463.                                                         tx = target.x-xs
  464.                                                         tz = target.z+zs
  465.                                         end
  466.                    
  467.                         elseif target.x<myHero.x then
  468.                                         angle = math.asin((myHero.x-target.x)/dist)
  469.                                         zs = (450)*math.cos(angle)
  470.                                         xs = (450)*math.sin(angle)
  471.                                         if target.z>myHero.z then
  472.                                                         tx = target.x+xs
  473.                                                         tz = target.z-zs
  474.                                         elseif target.z<myHero.z then
  475.                                                         tx = target.x+xs
  476.                                                         tz = target.z+zs
  477.                                         end
  478.                         end
  479.                 return tx,target.y,tz
  480.         end
  481. end
  482.  
  483. function getWardSpot(a,b,c)
  484.         --print("\n
  485.                                 --print("\nHere37")
  486.                 local spot={x=a,y=b,z=c}
  487.                 local dist=GetD(spot,myHero)
  488.                         if myHero.x==spot.x then
  489.                                         tx = myHero.x
  490.                                         if myHero.z>spot.z then
  491.                                                         tz = myHero.z-610
  492.                                         else
  493.                                                         tz = myHero.z+(610)
  494.                                         end
  495.                    
  496.                         elseif spot.z==myHero.z then
  497.                                         tz = myHero.z
  498.                                         if myHero.x>spot.x then
  499.                                                         tx = myHero.x-(610)
  500.                                         else
  501.                                                         tx = myHero.x+(610)
  502.                                         end
  503.                    
  504.                         elseif myHero.x>spot.x then
  505.                                         angle = math.asin((myHero.x-spot.x)/dist)
  506.                                         zs = (610)*math.cos(angle)
  507.                                         xs = (610)*math.sin(angle)
  508.                                         if myHero.z>spot.z then
  509.                                                         tx = myHero.x-xs
  510.                                                         tz = myHero.z-zs
  511.                                         elseif myHero.z<spot.z then
  512.                                                         tx = myHero.x-xs
  513.                                                         tz = myHero.z+zs
  514.                                         end
  515.                    
  516.                         elseif myHero.x<spot.x then
  517.                                         angle = math.asin((spot.x-myHero.x)/dist)
  518.                                         zs = (610)*math.cos(angle)
  519.                                         xs = (610)*math.sin(angle)
  520.                                         if myHero.z>spot.z then
  521.                                                         tx = myHero.x+xs
  522.                                                         tz = myHero.z-zs
  523.                                         elseif myHero.z<spot.z then
  524.                                                         tx = myHero.x+xs
  525.                                                         tz = myHero.z+zs
  526.                                         end
  527.                         end
  528.                 return tx,spot.y,tz
  529.         end
  530.  
  531. function somethingNear(enemy)
  532.         local rturn=nil
  533.         if WRDY==1 and myHero.SpellNameW == "BlindMonkWOne" then
  534.         if enemy~=nil then
  535.                 for i=1, objManager:GetMaxObjects(), 1 do
  536.                         local object = objManager:GetObject(i)
  537.                         if object~=nil and object.x~=nil and object.dead~=1 and object.visible==1 and object.invulnerable==0 and (rturn==nil or (rturn.dead~=nil and rturn.dead==1)) and ((string.find(object.charName,"inion") and object.team==myHero.team) or string.find(object.charName,"SightWard") or string.find(object.charName,"VisionWard")) and GetD(object,enemy)<650 and GetD(object)<GetD(enemy) and nearAngle(enemy,object) then
  538.                                 rturn=object
  539.                         elseif object~=nil and object.x~=nil and object.dead~=1 and object.visible==1 and object.invulnerable==0 and rturn~=nil and rturn.x~=nil and ((string.find(object.charName,"inion") and object.team==myHero.team) or string.find(object.charName,"SightWard") or string.find(object.charName,"VisionWard")) and GetD(object,enemy)<650 and GetD(object)<GetD(enemy) and nearAngle(enemy,object) and GetD(rturn)>GetD(object) then
  540.                                 rturn=object
  541.                         end
  542.                 end
  543.                
  544.         end
  545.         end
  546.                 return rturn
  547. end
  548.  
  549. function initiate()
  550.         if (targeti~=nil or TI~=nil) and RRDY==1 then
  551.                 if myHero.SpellNameQ == "BlindMonkQOne" and QRDY==1 and targeti~=nil then
  552.                         local tfix,tfiy,tfiz=GetFireahead(targeti,qdelay,qspeed)
  553.                         local tfi={x=tfix,y=tfiy,z=tfiz}
  554.                         if GetD(tfi)<975 and CreepBlock(targeti.x, targeti.y, targeti.z) == 0 then --and CreepBlock(targeti.x,targeti.y,targeti.z) == 0 then
  555.                                 TI=targeti
  556.                                 startCombo=false
  557.                                 wardFound=false
  558.                                 success=false
  559.                                 Qspell(target)
  560.                                 --CastSpellXYZ('Q',GetFireahead(targeti,1.6,18))
  561.                                 --CastSpellXYZ('Q',mousePos.x,mousePos.y,mousePos.z)
  562.                                 --print("\nQ1")
  563.                                 TITimer=os.clock()+5
  564.                         end
  565.                 end
  566.                 if TI~=nil and TI.x~=nil and myHero.SpellNameQ == "blindmonkqtwo" and QRDY==1 and startCombo==false and eye~=nil and eye.unit~=nil and eye.unit.x~=nil then
  567.                         print("\nQ2")
  568.                         if GetD(eye.unit,TI)<255 then
  569.                         print("\nQ3")
  570.                                 if LeeConfig.iskey>1 and findWard()~=nil then
  571.                                 print("\nQ4")
  572.                                         success=true
  573.                                         startCombo=false
  574.                                         wardObject=findWard()
  575.                                         wardFound=true
  576.                                         CastSpellTarget('Q',myHero)
  577.                                         lastWardJump = os.clock()+5
  578.                                 elseif (LeeConfig.iskey==1 or LeeConfig.iskey==3) and gotAWard() then
  579.                                         print("\nQ5")
  580.                                         CastSpellTarget('Q',myHero)
  581.                                         startCombo=true
  582.                                 end
  583.                         end
  584.                 end
  585.                 if startCombo==true and wardz==nil and TI~=nil and GetD(TI)<300 and QRDY==0 then
  586.                 print("\nQ6")
  587.                         inSec(TI)
  588.                 elseif WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and QRDY==0 and os.clock() > lastWardJump and startCombo==true and wardz~=nil and TI~=nil and TI.x~=nil then                                            
  589.                         print("\nQ9")
  590.                         if www~=nil then
  591.                                 print("\nQ10")
  592.                                 CastSpellXYZ(www, wardx,wardy,wardz,0)
  593.                                 success=true
  594.                                 wardFound=true
  595.                                 startCombo=false
  596.                                 lastWardJump=os.clock()+5
  597.                                 wardx=nil
  598.                                 wardy=nil
  599.                                 wardz=nil
  600.                         end    
  601.                         --if wardFound==false then
  602.                                 --findWard()
  603.                         --end
  604.                 end
  605.                 if WRDY==1 and myHero.SpellNameW=="BlindMonkWOne" and QRDY==0 and success==true and lastWardJump>os.clock() and wardObject~=nil and GetD(wardObject)<600 then
  606.                         run_every(0.2,WSpell, wardObject)
  607.                 end
  608.                 if TI~=nil and TI.x~=nil and RRDY==1 and (myHero.SpellNameW=="blindmonkwtwo" or WRDY==0) then
  609.                         CastSpellTarget('R',TI)
  610.                 --elseif  RRDY==0 then
  611.                         --success=false
  612.                 end
  613.         else
  614.                 MoveToMouse()
  615.         end
  616. end
  617.  
  618. function findWard()
  619. --print("\nQ7")
  620.                 local wO=nil
  621.         if TI~=nil and TI.x~=nil then
  622.                 local check=false
  623.                 for i=1, objManager:GetMaxObjects(), 1 do
  624.                         local object = objManager:GetObject(i)
  625.                         if object~=nil and object.x~=nil and object.dead~=1 and object.visible==1 and object.invulnerable==0 and (wO==nil or (wO.dead~=nil and wO.dead==1)) and object.team==myHero.team and ((string.find(object.charName,"inion")) or string.find(object.charName,"SightWard") or string.find(object.charName,"VisionWard")) and TI~=nil and TI.x~=nil and ((GetD(object,TI)>0.15*TI.movespeed and not runningAway(TI) and isMoving(TI))  or (GetD(object,TI)>0.4*TI.movespeed and not isMoving(TI)) or (GetD(object,TI)>1.5*TI.movespeed and runningAway(TI) and isMoving(TI))) and GetD(object,TI)<600 and GetD(TI)<GetD(object) and nearAngle(TI,object) then
  626.                                 wO=object
  627.                         elseif object~=nil and object.x~=nil and object.dead~=1 and object.visible==1 and object.invulnerable==0 and wO~=nil and wO.x~=nil and object.team==myHero.team and ((string.find(object.charName,"inion")) or string.find(object.charName,"SightWard") or string.find(object.charName,"VisionWard")) and TI~=nil and TI.x~=nil and ((GetD(object,TI)>0.15*TI.movespeed and not runningAway(TI) and isMoving(TI))  or (GetD(object,TI)>0.4*TI.movespeed and not isMoving(TI)) or (GetD(object,TI)>1.5*TI.movespeed and runningAway(TI) and isMoving(TI))) and GetD(object,TI)<600 and GetD(TI)<GetD(object) and nearAngle(TI,object) and GetD(wO,TI)>GetD(object,TI) then
  628.                                 wO=object
  629.                         end
  630.                 end
  631.         end
  632.         return wO
  633. end
  634.  
  635. function inSec(enemy)
  636.         if WRDY==1 then
  637.         print("\nQ8")
  638.                 if LeeConfig.insec2group then
  639.                         if enemy~=nil then
  640.                                 local spot={x=enemy.x,y=enemy.y,z=enemy.z}
  641.                                 local Theta=0
  642.                                 for j=1, objManager:GetMaxHeroes(), 1 do
  643.                                         local herotarget = objManager:GetHero(j)
  644.                                         if herotarget.team==myHero.team and myHero.name~=herotarget.name and GetD(herotarget,enemy)<=1000 then
  645.                                                 local ThetaAngle=0                                            
  646.                                                 local zz=herotarget.z-enemy.z
  647.                                                 if enemy.z<=herotarget.z then
  648.                                                         if enemy.x<=herotarget.x then
  649.                                                                 ThetaAngle=math.asin(zz/GetD(enemy,herotarget))
  650.                                                                 spot.x=spot.x+math.floor(math.cos(ThetaAngle)*400)
  651.                                                                 spot.z=spot.z+math.floor(math.sin(ThetaAngle)*400)
  652.                                                         elseif enemy.x>herotarget.x then
  653.                                                                 ThetaAngle=math.asin(zz/GetD(enemy,herotarget))
  654.                                                                 spot.x=spot.x-math.floor(math.cos(ThetaAngle)*400)
  655.                                                                 spot.z=spot.z+math.floor(math.sin(ThetaAngle)*400)
  656.                                                         end
  657.                                                 else
  658.                                                         if enemy.x<=herotarget.x then
  659.                                                                 ThetaAngle=math.asin(zz/GetD(enemy,herotarget))
  660.                                                                 spot.x=spot.x+math.floor(math.cos(ThetaAngle)*400)
  661.                                                                 spot.z=spot.z+math.floor(math.sin(ThetaAngle)*400)
  662.                                                         elseif enemy.x>herotarget.x then
  663.                                                                 ThetaAngle=math.asin(zz/GetD(enemy,herotarget))
  664.                                                                 spot.x=spot.x-math.floor(math.cos(ThetaAngle)*400)
  665.                                                                 spot.z=spot.z+math.floor(math.sin(ThetaAngle)*400)
  666.                                                         end    
  667.                                                 end
  668.                                         end
  669.                                 end
  670.                                 if math.abs(spot.x-enemy.x)<=20 then
  671.                                         spot=myHero
  672.                                 end
  673.                                 local RDIST=LeeConfig.distanceR*340/enemy.movespeed
  674.                                 local NRDIST=LeeConfig.distanceNR*enemy.movespeed/340
  675.                                 local NMDIST=LeeConfig.distanceNM
  676.                                 local angle
  677.                                 local dist=GetD(enemy,spot)
  678.                                 local tx,tz
  679.                                 if not isMoving(enemy) then
  680.                                         if enemy.x==spot.x then
  681.                                                 tx = enemy.x
  682.                                                 if enemy.z>spot.z then
  683.                                                         tz = enemy.z+NMDIST
  684.                                                 else
  685.                                                         tz = enemy.z-NMDIST
  686.                                                 end
  687.                                        
  688.                                         elseif enemy.z==spot.z then
  689.                                                 tz = enemy.z
  690.                                                 if enemy.x>spot.x then
  691.                                                         tx = enemy.x+NMDIST
  692.                                                 else
  693.                                                         tx = enemy.x-NMDIST
  694.                                                 end
  695.                                        
  696.                                         elseif enemy.x>spot.x then
  697.                                                 angle = math.acos((enemy.x-spot.x)/dist)
  698.                                                 xs = NRDIST*math.cos(angle)
  699.                                                 zs = NRDIST*math.sin(angle)
  700.                                                 if enemy.z>spot.z then
  701.                                                         tx = enemy.x+xs
  702.                                                         tz = enemy.z+zs
  703.                                                 elseif enemy.z<spot.z then
  704.                                                         tx = enemy.x+xs
  705.                                                         tz = enemy.z-zs
  706.                                                 end
  707.                                        
  708.                                         elseif enemy.x<spot.x then
  709.                                                 angle = math.acos((spot.x-enemy.x)/dist)
  710.                                                 xs = NRDIST*math.cos(angle)
  711.                                                 zs = NRDIST*math.sin(angle)
  712.                                                 if enemy.z>spot.z then
  713.                                                         tx = enemy.x-xs
  714.                                                         tz = enemy.z+zs
  715.                                                 elseif enemy.z<spot.z then
  716.                                                         tx = enemy.x-xs
  717.                                                         tz = enemy.z-zs
  718.                                                 end                                            
  719.                                         end
  720.                                 elseif not runningAway(enemy) then
  721.                                         if enemy.x==spot.x then
  722.                                                 tx = enemy.x
  723.                                                 if enemy.z>spot.z then
  724.                                                         tz = enemy.z+NRDIST
  725.                                                 else
  726.                                                         tz = enemy.z-NRDIST
  727.                                                 end
  728.                                        
  729.                                         elseif enemy.z==spot.z then
  730.                                                 tz = enemy.z
  731.                                                 if enemy.x>spot.x then
  732.                                                         tx = enemy.x+NRDIST
  733.                                                 else
  734.                                                         tx = enemy.x-NRDIST
  735.                                                 end
  736.                                        
  737.                                         elseif enemy.x>spot.x then
  738.                                                 angle = math.acos((enemy.x-spot.x)/dist)
  739.                                                 xs = NRDIST*math.cos(angle)
  740.                                                 zs = NRDIST*math.sin(angle)
  741.                                                 if enemy.z>spot.z then
  742.                                                         tx = enemy.x+xs
  743.                                                         tz = enemy.z+zs
  744.                                                 elseif enemy.z<spot.z then
  745.                                                         tx = enemy.x+xs
  746.                                                         tz = enemy.z-zs
  747.                                                 end
  748.                                        
  749.                                         elseif enemy.x<spot.x then
  750.                                                 angle = math.acos((spot.x-enemy.x)/dist)
  751.                                                 xs = NRDIST*math.cos(angle)
  752.                                                 zs = NRDIST*math.sin(angle)
  753.                                                 if enemy.z>spot.z then
  754.                                                         tx = enemy.x-xs
  755.                                                         tz = enemy.z+zs
  756.                                                 elseif enemy.z<spot.z then
  757.                                                         tx = enemy.x-xs
  758.                                                         tz = enemy.z-zs
  759.                                                 end                                            
  760.                                         end
  761.                                 elseif runningAway(enemy) then
  762.                                         if enemy.x==spot.x then
  763.                                                 tx = enemy.x
  764.                                                 if enemy.z>spot.z then
  765.                                                         tz = enemy.z+RDIST
  766.                                                 else
  767.                                                         tz = enemy.z-RDIST
  768.                                                 end
  769.                                        
  770.                                         elseif enemy.z==spot.z then
  771.                                                 tz = enemy.z
  772.                                                 if enemy.x>spot.x then
  773.                                                         tx = enemy.x+RDIST
  774.                                                 else
  775.                                                         tx = enemy.x-RDIST
  776.                                                 end
  777.                                        
  778.                                         elseif enemy.x>spot.x then
  779.                                                 angle = math.acos((enemy.x-spot.x)/dist)
  780.                                                 xs = RDIST*math.cos(angle)
  781.                                                 zs = RDIST*math.sin(angle)
  782.                                                 if enemy.z>spot.z then
  783.                                                         tx = enemy.x+xs
  784.                                                         tz = enemy.z+zs
  785.                                                 elseif enemy.z<spot.z then
  786.                                                         tx = enemy.x+xs
  787.                                                         tz = enemy.z-zs
  788.                                                 end
  789.                                        
  790.                                         elseif enemy.x<spot.x then
  791.                                                 angle = math.acos((spot.x-enemy.x)/dist)
  792.                                                 xs = RDIST*math.cos(angle)
  793.                                                 zs = RDIST*math.sin(angle)
  794.                                                 if enemy.z>spot.z then
  795.                                                         tx = enemy.x-xs
  796.                                                         tz = enemy.z+zs
  797.                                                 elseif enemy.z<spot.z then
  798.                                                         tx = enemy.x-xs
  799.                                                         tz = enemy.z-zs
  800.                                                 end                                            
  801.                                         end                                    
  802.                                
  803.                                 end
  804.                                
  805.                         wardx=tx
  806.                         wardy=enemy.y
  807.                         wardz=tz
  808.                         wardNear={x=wardx,y=wardy,z=wardz}
  809.                         end
  810.                
  811.                 else
  812.                         if enemy~=nil then
  813.                                 local RDIST=LeeConfig.distanceR*340/enemy.movespeed
  814.                                 local NRDIST=LeeConfig.distanceNR*enemy.movespeed/340
  815.                                 local NMDIST=LeeConfig.distanceNM
  816.                                 local angle
  817.                                 local dist=GetD(enemy,myHero)
  818.                                 local tx,tz
  819.                                 if not isMoving(enemy) then
  820.                                         if enemy.x==myHero.x then
  821.                                                 tx = enemy.x
  822.                                                 if enemy.z>myHero.z then
  823.                                                         tz = enemy.z+NMDIST
  824.                                                 else
  825.                                                         tz = enemy.z-NMDIST
  826.                                                 end
  827.                                        
  828.                                         elseif enemy.z==myHero.z then
  829.                                                 tz = enemy.z
  830.                                                 if enemy.x>myHero.x then
  831.                                                         tx = enemy.x+NMDIST
  832.                                                 else
  833.                                                         tx = enemy.x-NMDIST
  834.                                                 end
  835.                                        
  836.                                         elseif enemy.x>myHero.x then
  837.                                                 angle = math.acos((enemy.x-myHero.x)/dist)
  838.                                                 xs = NRDIST*math.cos(angle)
  839.                                                 zs = NRDIST*math.sin(angle)
  840.                                                 if enemy.z>myHero.z then
  841.                                                         tx = enemy.x+xs
  842.                                                         tz = enemy.z+zs
  843.                                                 elseif enemy.z<myHero.z then
  844.                                                         tx = enemy.x+xs
  845.                                                         tz = enemy.z-zs
  846.                                                 end
  847.                                        
  848.                                         elseif enemy.x<myHero.x then
  849.                                                 angle = math.acos((myHero.x-enemy.x)/dist)
  850.                                                 xs = NRDIST*math.cos(angle)
  851.                                                 zs = NRDIST*math.sin(angle)
  852.                                                 if enemy.z>myHero.z then
  853.                                                         tx = enemy.x-xs
  854.                                                         tz = enemy.z+zs
  855.                                                 elseif enemy.z<myHero.z then
  856.                                                         tx = enemy.x-xs
  857.                                                         tz = enemy.z-zs
  858.                                                 end                                            
  859.                                         end
  860.                                 elseif not runningAway(enemy) then
  861.                                         if enemy.x==myHero.x then
  862.                                                 tx = enemy.x
  863.                                                 if enemy.z>myHero.z then
  864.                                                         tz = enemy.z+NRDIST
  865.                                                 else
  866.                                                         tz = enemy.z-NRDIST
  867.                                                 end
  868.                                        
  869.                                         elseif enemy.z==myHero.z then
  870.                                                 tz = enemy.z
  871.                                                 if enemy.x>myHero.x then
  872.                                                         tx = enemy.x+NRDIST
  873.                                                 else
  874.                                                         tx = enemy.x-NRDIST
  875.                                                 end
  876.                                        
  877.                                         elseif enemy.x>myHero.x then
  878.                                                 angle = math.acos((enemy.x-myHero.x)/dist)
  879.                                                 xs = NRDIST*math.cos(angle)
  880.                                                 zs = NRDIST*math.sin(angle)
  881.                                                 if enemy.z>myHero.z then
  882.                                                         tx = enemy.x+xs
  883.                                                         tz = enemy.z+zs
  884.                                                 elseif enemy.z<myHero.z then
  885.                                                         tx = enemy.x+xs
  886.                                                         tz = enemy.z-zs
  887.                                                 end
  888.                                        
  889.                                         elseif enemy.x<myHero.x then
  890.                                                 angle = math.acos((myHero.x-enemy.x)/dist)
  891.                                                 xs = NRDIST*math.cos(angle)
  892.                                                 zs = NRDIST*math.sin(angle)
  893.                                                 if enemy.z>myHero.z then
  894.                                                         tx = enemy.x-xs
  895.                                                         tz = enemy.z+zs
  896.                                                 elseif enemy.z<myHero.z then
  897.                                                         tx = enemy.x-xs
  898.                                                         tz = enemy.z-zs
  899.                                                 end                                            
  900.                                         end
  901.                                 elseif runningAway(enemy) then
  902.                                         if enemy.x==myHero.x then
  903.                                                 tx = enemy.x
  904.                                                 if enemy.z>myHero.z then
  905.                                                         tz = enemy.z+RDIST
  906.                                                 else
  907.                                                         tz = enemy.z-RDIST
  908.                                                 end
  909.                                        
  910.                                         elseif enemy.z==myHero.z then
  911.                                                 tz = enemy.z
  912.                                                 if enemy.x>myHero.x then
  913.                                                         tx = enemy.x+RDIST
  914.                                                 else
  915.                                                         tx = enemy.x-RDIST
  916.                                                 end
  917.                                        
  918.                                         elseif enemy.x>myHero.x then
  919.                                                 angle = math.acos((enemy.x-myHero.x)/dist)
  920.                                                 xs = RDIST*math.cos(angle)
  921.                                                 zs = RDIST*math.sin(angle)
  922.                                                 if enemy.z>myHero.z then
  923.                                                         tx = enemy.x+xs
  924.                                                         tz = enemy.z+zs
  925.                                                 elseif enemy.z<myHero.z then
  926.                                                         tx = enemy.x+xs
  927.                                                         tz = enemy.z-zs
  928.                                                 end
  929.                                        
  930.                                         elseif enemy.x<myHero.x then
  931.                                                 angle = math.acos((myHero.x-enemy.x)/dist)
  932.                                                 xs = RDIST*math.cos(angle)
  933.                                                 zs = RDIST*math.sin(angle)
  934.                                                 if enemy.z>myHero.z then
  935.                                                         tx = enemy.x-xs
  936.                                                         tz = enemy.z+zs
  937.                                                 elseif enemy.z<myHero.z then
  938.                                                         tx = enemy.x-xs
  939.                                                         tz = enemy.z-zs
  940.                                                 end                                            
  941.                                         end                                    
  942.                                
  943.                                 end
  944.                                
  945.                         wardx=tx
  946.                         wardy=enemy.y
  947.                         wardz=tz
  948.                         wardNear={x=wardx,y=wardy,z=wardz}
  949.                         end
  950.                 end
  951.         end
  952. end
  953.  
  954. function gotAWard()
  955.  
  956.         if myHero.dead~=1 then
  957.                 for _, ward in pairs(wards) do
  958.                                 if GetWardSlot(ward) ~= nil then
  959.                                                 return true
  960.                                 end
  961.                         end
  962.         end
  963.         return false
  964. end
  965.  
  966. function isMoving(unitM)
  967.         local mx,my,mz=GetFireahead(unitM,5,0)
  968.         if math.abs(mx-unitM.x)<20 and math.abs(mz-unitM.z)<20 then
  969.                 return false
  970.         else
  971.                 return true
  972.         end
  973. end
  974.  
  975. function Smite()
  976.     if myHero.SummonerD == "SummonerSmite" then
  977.         CastHotkey("AUTO 100,0 SPELLD:SMITESTEAL RANGE=700 TRUE COOLDOWN")
  978.         return
  979.     end
  980.     if myHero.SummonerF == "SummonerSmite" then
  981.         CastHotkey("AUTO 100,0 SPELLF:SMITESTEAL RANGE=700 TRUE COOLDOWN")
  982.         return
  983.     end
  984.    
  985.     for i=1, objManager:GetMaxObjects(), 1 do
  986.         local object = objManager:GetObject(i)
  987.         if object ~= nil and object.name ~= nil and (string.find(object.name,"Dragon") or string.find(object.name,"Worm")) then
  988.             if GetD(object,myHero) < 1200 then
  989.                 local damage = 460+(30*myHero.selflevel)
  990.                 if object.health <= damage then
  991.                     CustomCircle(100,10,7,object)
  992.                 end
  993.             end
  994.         end
  995.     end
  996. end
  997.  
  998. function runningAway(slowtarget)
  999.    local d1 = GetD(slowtarget)
  1000.    local x, y, z = GetFireahead(slowtarget,2,0)
  1001.    local d2 = GetD({x=x, y=y, z=z})
  1002.    local d3 = GetD({x=x, y=y, z=z},slowtarget)
  1003.    local angle = math.acos((d2*d2-d3*d3-d1*d1)/(-2*d3*d1))
  1004.    
  1005.    return angle%(2*math.pi)>math.pi/2 and angle%(2*math.pi)<math.pi*3/2
  1006.  
  1007. end
  1008.  
  1009. function OnCreateObj(obj)
  1010.         --if GetD(obj)<600 then
  1011.         --print("\n obj "..obj.charName)
  1012.         --end
  1013.         if string.find(obj.charName,"blindMonk_Q_tar_indicator") and myHero.SpellNameQ == "blindmonkqtwo" then
  1014.                 eye.unit=obj
  1015.                 eye.x=obj.x
  1016.                 eye.y=obj.y
  1017.                 eye.z=obj.z
  1018.         end
  1019.        
  1020.         if LeeConfig.initiate and GetD(obj)<800 and (string.find(obj.charName,"SightWard") or string.find(obj.charName,"VisionWard")) then
  1021.                 wardObject=obj        
  1022.                 lastWardJump = os.clock()+5
  1023.         elseif (LeeConfig.ward or LeeConfig.harass) and GetD(obj)<800 and (string.find(obj.charName,"SightWard") or string.find(obj.charName,"VisionWard")) then
  1024.                 lastWardObject=obj
  1025.                 lastWardJump = os.clock()+5
  1026.         end
  1027.         if (GetD(myHero, obj)) < 100 and LeeConfig.pots then
  1028.                 if string.find(obj.charName,"FountainHeal") then
  1029.                         timer=os.clock()
  1030.                         bluePill = obj
  1031.                 end
  1032.         end
  1033.         if obj.charName == 'EggTimer.troy' then
  1034.                 for i= 1,objManager:GetMaxHeroes(),1 do
  1035.                         local hero=objManager:GetHero(i)
  1036.                         if hero.name == 'Anivia' and GetDistance(obj, hero) < 10 then
  1037.                                 if hero.team == myHero.team then egg = {team = GetTickCount(), enemy = egg.enemy}
  1038.                                 else egg = {team = egg.team, enemy = GetTickCount()} end
  1039.                                 break
  1040.                         end
  1041.                 end
  1042.         elseif obj.charName == 'Aatrox_Passive_Death_Activate.troy' then
  1043.                 for i= 1,objManager:GetMaxHeroes(),1 do
  1044.                         local hero=objManager:GetHero(i)
  1045.                         if hero.name == 'Aatrox' and GetDistance(obj, hero) < 10 then
  1046.                                 if hero.team == myHero.team then aatrox = {team = GetTickCount(), enemy = aatrox.enemy}
  1047.                                 else aatrox = {team = aatrox.team, enemy = GetTickCount()} end
  1048.                                 break
  1049.                         end
  1050.                 end
  1051.         elseif obj.charName == 'ZacPassiveExplosion.troy' then
  1052.                 for i= 1,objManager:GetMaxHeroes(),1 do
  1053.                         local hero=objManager:GetHero(i)
  1054.                         if hero.name == 'Zac' and GetDistance(obj, hero) < 10 then
  1055.                                 if hero.team == myHero.team then zac = {team = GetTickCount(), enemy = zac.enemy}
  1056.                                 else zac = {team = zac.team, enemy = GetTickCount()} end
  1057.                                 break
  1058.                         end
  1059.                 end
  1060.         end
  1061. end
  1062.  
  1063. function OnProcessSpell(unit,spell)
  1064.         if unit.charName==myHero.charName then
  1065.                 --print("\nSP: "..spell.name)
  1066.                 --if string.find(spell.name,"BlindMonkRKick") then
  1067.                         --success=false
  1068.  
  1069.                 if string.find(spell.name,"BlindMonkQ") and LeeConfig.Combo then
  1070.                         PTimer=os.clock()+math.min(1.5,2/myHero.attackspeed)
  1071.                         PMod=0
  1072.                 elseif string.find(spell.name,"BlindMonkW") and LeeConfig.Combo then
  1073.                         PTimer=os.clock()+math.min(1.5,2/myHero.attackspeed)
  1074.                         PMod=0
  1075.                 elseif string.find(spell.name,"BlindMonkE") and LeeConfig.Combo then
  1076.                         PTimer=os.clock()+math.min(1.5,2/myHero.attackspeed)
  1077.                         PMod=0
  1078.                 elseif string.find(spell.name,"blindmonk") and LeeConfig.Combo then
  1079.                         PTimer=os.clock()+math.min(1.5,2/myHero.attackspeed)
  1080.                         PMod=0
  1081.                 elseif string.find(spell.name,"Attack") and LeeConfig.Combo then
  1082.                         PMod=PMod+1
  1083.                 end
  1084.         end
  1085. end
  1086.  
  1087. function OnDraw()
  1088. end
  1089.  
  1090. function nearWard()
  1091.         local ok=false
  1092.         if targeti~=nil and targeti.x~=nil and myHero.dead~=1 and GetD(targeti)<1000 then
  1093.                 local mt=wardObject
  1094.  
  1095.                         if mt~=nil and mt.dead~=nil and mt.dead~=1 and TI~=nil and TI.dead~=nil and TI.dead~=1 and nearAngle(mt,TI) then
  1096.                                 CustomCircle(100,20,3,mt)
  1097.                                 ok=true
  1098.                         elseif mt~=nil and mt.dead~=nil and mt.dead~=1 and nearAngle(mt,targeti) then
  1099.                                 CustomCircle(100,20,3,mt)
  1100.                                 ok=true
  1101.                         end
  1102.         end
  1103.        
  1104.                 if ok==true then
  1105.                 return true
  1106.                 else
  1107.                 return false
  1108.                 end
  1109. end
  1110.  
  1111.  
  1112. function nearAngle(unit1,unit2)
  1113.         if myHero.dead~=1 and unit1.z~=nil and unit2.z~=nil then
  1114.         local Theta=0
  1115.         local zz=unit1.z-myHero.z
  1116.         if unit1.x>=myHero.x then
  1117.                 Theta=math.acos(zz/GetD(unit1))
  1118.         elseif unit1.x<myHero.x then
  1119.                 Theta=-math.acos(zz/GetD(unit1))
  1120.         end
  1121.        
  1122.         local HTheta=0
  1123.         local Hzz=unit2.z-myHero.z
  1124.         if unit2.x>=myHero.x then
  1125.                 HTheta=math.acos(Hzz/GetD(unit2))
  1126.         elseif unit2.x<myHero.x then
  1127.                 HTheta=-math.acos(Hzz/GetD(unit2))
  1128.         end
  1129.         if HTheta>=Theta and HTheta-Theta<=2*math.pi/10 then
  1130.                 return true
  1131.         elseif HTheta<Theta and Theta-HTheta<=2*math.pi/10 then
  1132.                 return true
  1133.         end
  1134.         end
  1135.         return false
  1136. end
  1137. ------------------------------------Pots
  1138.  
  1139. function RedElixir()
  1140.         if bluePill == nil then
  1141.                 if myHero.health < 4/10*myHero.maxHealth and os.clock() > wUsedAt + 15 then
  1142.                         usePotion()
  1143.                         wUsedAt = os.clock()
  1144.                 end
  1145.                 if myHero.health < 0.5*myHero.maxHealth and os.clock() > vUsedAt + 10 then
  1146.                         useFlask()
  1147.                         vUsedAt = os.clock()
  1148.                 end
  1149.                 if myHero.health < 3/10*myHero.maxHealth then
  1150.                         useElixir()
  1151.                 end
  1152.         end
  1153.         if (os.clock() < timer + 5) then
  1154.                 bluePill = nil
  1155.         end
  1156. end
  1157.  
  1158.  
  1159. function usePotion()
  1160.         GetInventorySlot(2003)
  1161.         UseItemOnTarget(2003,myHero)
  1162. end
  1163.  
  1164. function useFlask()
  1165.         GetInventorySlot(2041)
  1166.         UseItemOnTarget(2041,myHero)
  1167. end
  1168.  
  1169.  
  1170. function useElixir()
  1171.         GetInventorySlot(2037)
  1172.         UseItemOnTarget(2037,myHero)
  1173. end
  1174.  
  1175. function GetWardSlot(item)
  1176.     if GetInventoryItem(1) == item then
  1177.                                 --print("\nHere2")
  1178.                 if item == 3154 or item == 3340 or item == 3350 or item == 3361 or item == 3362 then                      
  1179.                                         --print("\nHere3")
  1180.                                                 if myHero.SpellTime1 >= 1 then
  1181.                                                         --print("\nHere4")
  1182.                                                         return 1
  1183.                         else
  1184.                                                         --print("\nHere5")
  1185.                                                         return nil end
  1186.                 else
  1187.                                                 --print("\nHere6")
  1188.                         return 1
  1189.                 end
  1190.     elseif GetInventoryItem(2) == item then
  1191.                                 --print("\nHere7")
  1192.                 if item == 3154 or item == 3340 or item == 3350 or item == 3361 or item == 3362 then
  1193.                                         --print("\nHere8")
  1194.                         if myHero.SpellTime2 >= 1 then
  1195.                                                         --print("\nHere9")
  1196.                                                         return 2
  1197.                         else
  1198.                                                         --print("\nHere10")
  1199.                                                         return nil end
  1200.                 else
  1201.                                                 --print("\nHere11")
  1202.                         return 2
  1203.                 end
  1204.     elseif GetInventoryItem(3) == item then
  1205.                                 --print("\nHere12")
  1206.                 if item == 3154 or item == 3340 or item == 3350 or item == 3361 or item == 3362 then
  1207.                                         --print("\nHere13")
  1208.                         if myHero.SpellTime3 >= 1 then
  1209.                                                         --print("\nHere14")
  1210.                                                         return 3
  1211.                         else
  1212.                                                         --print("\nHere15")
  1213.                                                         return nil end
  1214.                 else
  1215.                                                 --print("\nHere16")
  1216.                         return 3
  1217.                 end
  1218.     elseif GetInventoryItem(4) == item then
  1219.                                 --print("\nHere17")
  1220.                 if item == 3154 or item == 3340 or item == 3350 or item == 3361 or item == 3362 then
  1221.                                         --print("\nHere18")
  1222.                         if myHero.SpellTime4 >= 1 then
  1223.                                                         --print("\nHere19")
  1224.                                                         return 4
  1225.                         else
  1226.                                                         --print("\nHere20")
  1227.                                                         return nil end
  1228.                 else
  1229.                                                 --print("\nHere21")
  1230.                         return 4
  1231.                 end
  1232.     elseif GetInventoryItem(5) == item then
  1233.                                 --print("\nHere22")
  1234.                 if item == 3154 or item == 3340 or item == 3350 or item == 3361 or item == 3362 then
  1235.                                         --print("\nHere23")
  1236.                         if myHero.SpellTime5 >= 1 then
  1237.                                                         --print("\nHere24")
  1238.                                                         return 5
  1239.                         else
  1240.                                                         --print("\nHere25")
  1241.                                                         return nil end
  1242.                 else
  1243.                                                 --print("\nHere26")
  1244.                         return 5
  1245.                 end
  1246.     elseif GetInventoryItem(6) == item then
  1247.                                 --print("\nHere27")
  1248.                 if item == 3154 or item == 3340 or item == 3350 or item == 3361 or item == 3362 then
  1249.                                         --print("\nHere28")
  1250.                         if myHero.SpellTime6 >= 1 then
  1251.                                                         --print("\nHere29")
  1252.                                                         return 6
  1253.                         else
  1254.                                                         --print("\nHere30")
  1255.                                                         return nil end
  1256.                 else
  1257.                                                 --print("\nHere31")
  1258.                         return 6
  1259.                 end
  1260.     elseif GetInventoryItem(7) == item then
  1261.                                 --print("\nHere32")
  1262.                 if item == 3154 or item == 3340 or item == 3350 or item == 3361 or item == 3362 then
  1263.                                         --print("\nHere33")
  1264.                         if myHero.SpellTime7 >= 1 then
  1265.                                                         --print("\nHere34")
  1266.                                                         return 7
  1267.                         else
  1268.                                                         --print("\nHere35")
  1269.                                                         return nil end
  1270.                 else
  1271.                                                 --print("\nHere36")
  1272.                         return 7
  1273.                 end
  1274.     end
  1275.     return nil
  1276. end
  1277.  
  1278. function GetTeamSize()
  1279.     return math.floor(objManager:GetMaxHeroes()/2)
  1280. end
  1281.  
  1282. function GetBestEnemy(damage_type, range, tag)
  1283.     if tag == nil then tag = "BASIC" end
  1284.         local QDMG=0
  1285.         local WDMG=0
  1286.         local EDMG=0
  1287.         local RDMG=0
  1288.         local ADMG=0
  1289.     local enemy, prospect
  1290.     for i=1,GetTeamSize() do    
  1291.         prospect = GetWeakEnemy(damage_type, range, tag, i)
  1292.         if prospect == nil then
  1293.             -- pass        
  1294.         else
  1295.                         if spellDmg[myHero.name] then
  1296.                                 if QRDY==1 and getDmg("Q",prospect,myHero)~=nil then
  1297.                                         QDMG=getDmg("Q",prospect,myHero)
  1298.                                 else
  1299.                                         QDMG=0
  1300.                                 end
  1301.                                 if WRDY==1 and getDmg("W",prospect,myHero)~=nil then
  1302.                                         WDMG=getDmg("W",prospect,myHero)
  1303.                                 else
  1304.                                         WDMG=0
  1305.                                 end
  1306.                                 if ERDY==1 and getDmg("E",prospect,myHero)~=nil then
  1307.                                         EDMG=getDmg("E",prospect,myHero)
  1308.                                 else
  1309.                                         EDMG=0
  1310.                                 end
  1311.                                 if RRDY==1 and getDmg("R",prospect,myHero)~=nil then
  1312.                                         RDMG=getDmg("R",prospect,myHero)
  1313.                                 else
  1314.                                         RDMG=0
  1315.                                 end
  1316.                                 if getDmg("AD",prospect,myHero)~=nil then
  1317.                                         ADMG=getDmg("AD",prospect,myHero)
  1318.                                 else
  1319.                                         ADMG=0
  1320.                                 end
  1321.                        
  1322.                         end
  1323.                        
  1324.                         local invul=IsInvulnerable(prospect).status
  1325.             if invul==1 or (invul==4 and QDMG+WDMG+EDMG+RDMG+ADMG>prospect.health) then
  1326.                 local msg = "*** target invulnerable, cycling ***"
  1327.                 print(msg)
  1328.                 DrawTextObject(msg,myHero,0xFFFF0000)
  1329.             else
  1330.                 enemy = prospect
  1331.                 break -- <-------- *** important ***
  1332.             end
  1333.         end
  1334.     end
  1335.     -- we should return nil if everyone is invuln, same as the original api when no enemies are in range
  1336.     --if target == nil then
  1337.     --    target = GetWeakEnemy(damage_type, range, tag)
  1338.     --end
  1339.     return enemy
  1340. end
  1341.  
  1342. local StatusReturn={}
  1343. local ChampList={}
  1344. function IsInvulnerable(target)
  1345.         if target ~= nil and target.dead == 0 then
  1346.                 if target.invulnerable == 1 then
  1347.                     ChampList[target.charName]={status = 1, name = nil, amount = nil, type = nil}
  1348.                     return {status = 1, name = nil, amount = nil, type = nil}
  1349.                 else
  1350.                     StatusReturn=nil
  1351.                                         run_every(0.3,getStatus,target)
  1352.                     if StatusReturn~=nil then
  1353.                         ChampList[target.charName]=StatusReturn
  1354.                         return  StatusReturn
  1355.                     end
  1356.                 end
  1357.                                 if ChampList[target.charName] then
  1358.                                         return ChampList[target.charName]
  1359.                                 else
  1360.                                         ChampList[target.charName]={status = 0, name = nil, amount = nil, type = nil}
  1361.                                         return {status = 0, name = nil, amount = nil, type = nil}
  1362.                                 end
  1363.         elseif target~=nil then
  1364.             ChampList[target.charName]={status = 0, name = nil, amount = nil, type = nil}
  1365.             return {status = 0, name = nil, amount = nil, type = nil}
  1366.         end
  1367. end
  1368.  
  1369. function getStatus(target)
  1370.         for i=1, objManager:GetMaxObjects(), 1 do
  1371.                         local object = objManager:GetObject(i)
  1372.                         if object ~= nil then
  1373.                                         if string.find(object.charName,"eyeforaneye") ~= nil and GetDistance(target,object) <= 20 then
  1374.                                                 StatusReturn = {status = 1, name = 'Intervention', amount = 0, type = 'ALL'}
  1375.                                                 return
  1376.                                         elseif string.find(object.charName,"nickoftime") ~= nil and GetDistance(target,object) <= 20 then
  1377.                                                 StatusReturn = {status = 4, name = 'Chrono Shift', amount = 0, type = 'REVIVE'}
  1378.                                                 return
  1379.                                         elseif target.name == 'Poppy' and string.find(object.charName,"DiplomaticImmunity_tar") ~= nil and GetDistance(myHero,object) > 20 then
  1380.                                                         for i=1, objManager:GetMaxObjects(), 1 do
  1381.                                                                         local diObject = objManager:GetObject(i)
  1382.                                                                         if diObject ~= nil and string.find(diObject.charName,"DiplomaticImmunity_buf") ~= nil and GetDistance(target,diObject) <= 20 then
  1383.                                                                                 StatusReturn = {status = 1, name = 'Diplomatic Immunity', amount = 0, type = 'ALL'} end
  1384.                                                                 return
  1385.                                                         end
  1386.                                         elseif target.name == 'Vladimir' and string.find(object.charName,"VladSanguinePool_buf") ~= nil and GetDistance(myHero,object) <= 20 then
  1387.                                                 StatusReturn = {status = 1, name = 'Sanguine Pool', amount = 0, type = 'ALL'}
  1388.                                                 return
  1389.                                                 --                                      elseif string.find(object.charName,"Summoner_Barrier") ~= nil and GetDistance(target,object) <= 20 then return 2--, 'NONE'
  1390.                                         elseif (string.find(object.charName,"Global_Spellimmunity") ~= nil or string.find(object.charName,"Morgana_Blackthorn_Blackshield") ~= nil) and GetDistance(target,object) <= 20 then
  1391.                                                         local amount = 0
  1392.                                                         for i= 1,objManager:GetMaxHeroes(),1 do
  1393.                                                                         local hero=objManager:GetHero(i)
  1394.                                                                         if hero.team == target.team and hero.name == 'Morgana' then
  1395.                                                                                         amount = 30+(65*hero.SpellLevelE)+(hero.ap*0.7)
  1396.                                                                                         StatusReturn = {status = 2, name = 'Black Shield', amount = amount, type = 'MAGIC'}
  1397.                                                                                 return
  1398.                                                                         end
  1399.                                                         end
  1400.                                         elseif string.find(object.charName,"bansheesveil_buf") ~= nil and GetDistance(target,object) <= 20 then
  1401.                                                 StatusReturn = {status = 2, name = 'Banshees Veil', amount = 0, type = 'SPELL'}
  1402.                                                 return
  1403.                                         elseif target.name == 'Sivir' and string.find(object.charName,"Sivir_Base_E_shield") ~= nil and GetDistance(target,object) <= 20 then
  1404.                                                 StatusReturn = {status = 2, name = 'Spell Shield', amount = 0, type = 'SPELL'}
  1405.                                                 return
  1406.                                         elseif target.name == 'Nocturne' and string.find(object.charName,"nocturne_shroudofDarkness_shield") ~= nil and GetDistance(target,object) <= 20 then
  1407.                                                 StatusReturn = {status = 2, name = 'Shroud of Darkness', amount = 0, type = 'SPELL'}
  1408.                                                 return
  1409.                                         elseif target.name == 'Tryndamere' and string.find(object.charName,"UndyingRage_buf") ~= nil and GetDistance(target,object) <= 20 then
  1410.                                                 StatusReturn = {status = 4, name = 'Undying Rage', amount = 0, type = 'NONE'}
  1411.                                                 return
  1412.                                         elseif string.find(object.charName,"rebirthready") ~= nil and GetDistance(target,object) <= 20 then
  1413.                                                 StatusReturn = {status = 3, name = 'Guardian Angel', amount = 0, type = 'REVIVE'}
  1414.                                                 return
  1415.                                         elseif target.name == 'Anivia' then
  1416.                                                         if target.team == myHero.team then
  1417.                                                                         if GetTickCount()-egg.allied.time > 240000 or egg.allied.time == 0 then
  1418.                                                                                 StatusReturn = {status = 3, name = 'Egg', amount = 0, type = 'REVIVE'}
  1419.                                                                                 return
  1420.                                                                         else
  1421.                                                                                 StatusReturn = {status = 0, name = nil, amount = nil, type = nil} end
  1422.                                                                                 return
  1423.                                                         else
  1424.                                                                         if GetTickCount()-egg.enemy.time > 240000 or egg.enemy.time == 0 then
  1425.                                                                                 StatusReturn = {status = 3, name = 'Egg', amount = 0, type = 'REVIVE'}
  1426.                                                                                 return
  1427.                                                                         else
  1428.                                                                                 StatusReturn = {status = 0, name = nil, amount = nil, type = nil} end
  1429.                                                                                 return
  1430.                                                         end
  1431.                                         elseif target.name == 'Zac' then
  1432.                                                         if target.team == myHero.team then
  1433.                                                                         if GetTickCount()-zac.allied.time > 300000 or zac.allied.time == 0 then
  1434.                                                                                 StatusReturn = {status = 3, name = 'Zac', amount = 0, type = 'REVIVE'}
  1435.                                                                                 return
  1436.                                                                         else
  1437.                                                                                 StatusReturn = {status = 0, name = nil, amount = nil, type = nil}
  1438.                                                                                 return
  1439.                                                                         end
  1440.                                                         elseif target.team ~= myHero.team then
  1441.                                                                         if GetTickCount()-zac.enemy > 300000 or zac.enemy.time == 0 then
  1442.                                                                                 StatusReturn = {status = 3, name = 'Zac', amount = 0, type = 'REVIVE'}
  1443.                                                                                 return
  1444.                                                                         else
  1445.                                                                                 StatusReturn = {status = 0, name = nil, amount = nil, type = nil}
  1446.                                                                                 return
  1447.                                                                         end
  1448.                                                         end
  1449. --                                      elseif string.find(object.charName,"GLOBAL_Item_FoM_Shield") ~= nil and GetDistance(target,object) <= 30 then return 2--, 'NONE'
  1450. --                                      elseif target.name == 'Nautilus' and string.find(object.charName,"Nautilus_W_shield_cas") ~= nil and GetDistance(target,object) <= 20 then return 2--, 'NONE'
  1451.                                         end
  1452.                         end
  1453.         end
  1454.         StatusReturn = {status = 0, name = nil, amount = nil, type = nil}
  1455.         return
  1456. end
  1457.  
  1458. function run_every(interval, fn, ...)
  1459.     return internal_run({fn=fn, interval=interval}, ...)
  1460. end
  1461.  
  1462. function internal_run(t, ...)    
  1463.     local fn = t.fn
  1464.     local key = t.key or fn
  1465.    
  1466.     local now = os.clock()
  1467.     local data = _registry[key]
  1468.        
  1469.     if data == nil or t.reset then
  1470.         local args = {}
  1471.         local n = select('#', ...)
  1472.         local v
  1473.         for i=1,n do
  1474.             v = select(i, ...)
  1475.             table.insert(args, v)
  1476.         end  
  1477.         -- the first t and args are stored in registry        
  1478.         data = {count=0, last=0, complete=false, t=t, args=args}
  1479.         _registry[key] = data
  1480.     end
  1481.        
  1482.     --assert(data~=nil, 'data==nil')
  1483.     --assert(data.count~=nil, 'data.count==nil')
  1484.     --assert(now~=nil, 'now==nil')
  1485.     --assert(data.t~=nil, 'data.t==nil')
  1486.     --assert(data.t.start~=nil, 'data.t.start==nil')
  1487.     --assert(data.last~=nil, 'data.last==nil')
  1488.     -- run
  1489.     local countCheck = (t.count==nil or data.count < t.count)
  1490.     local startCheck = (data.t.start==nil or now >= data.t.start)
  1491.     local intervalCheck = (t.interval==nil or now-data.last >= t.interval)
  1492.     --print('', 'countCheck', tostring(countCheck))
  1493.     --print('', 'startCheck', tostring(startCheck))
  1494.     --print('', 'intervalCheck', tostring(intervalCheck))
  1495.     --print('')
  1496.     if not data.complete and countCheck and startCheck and intervalCheck then                
  1497.         if t.count ~= nil then -- only increment count if count matters
  1498.             data.count = data.count + 1
  1499.         end
  1500.         data.last = now        
  1501.        
  1502.         if t._while==nil and t._until==nil then
  1503.             return fn(...)
  1504.         else
  1505.             -- while/until handling
  1506.             local signal = t._until ~= nil
  1507.             local checker = t._while or t._until
  1508.             local result
  1509.             if fn == checker then            
  1510.                 result = fn(...)
  1511.                 if result == signal then
  1512.                     data.complete = true
  1513.                 end
  1514.                 return result
  1515.             else
  1516.                 result = checker(...)
  1517.                 if result == signal then
  1518.                     data.complete = true
  1519.                 else
  1520.                     return fn(...)
  1521.                 end
  1522.             end            
  1523.         end
  1524.     end    
  1525. end
  1526.  
  1527. function GetD(p1, p2)
  1528. if p2 == nil then p2 = myHero end
  1529. if (p1.z == nil or p2.z == nil) and p1.x~=nil and p1.y ~=nil and p2.x~=nil and p2.y~=nil then
  1530. px=p1.x-p2.x
  1531. py=p1.y-p2.y
  1532. if px~=nil and py~=nil then
  1533. px2=px*px
  1534. py2=py*py
  1535. if px2~=nil and py2~=nil then
  1536. return math.sqrt(px2+py2)
  1537. else
  1538. return 99999
  1539. end
  1540. else
  1541. return 99999
  1542. end
  1543.  
  1544. elseif p1.x~=nil and p1.z ~=nil and p2.x~=nil and p2.z~=nil then
  1545. px=p1.x-p2.x
  1546. pz=p1.z-p2.z
  1547. if px~=nil and pz~=nil then
  1548. px2=px*px
  1549. pz2=pz*pz
  1550. if px2~=nil and pz2~=nil then
  1551. return math.sqrt(px2+pz2)
  1552. else
  1553. return 99999
  1554. end
  1555. else    
  1556. return 99999
  1557. end
  1558.  
  1559. else
  1560. return 99999
  1561. end
  1562. end
  1563.  
  1564. SetTimerCallback("LeeRun")
Advertisement
Add Comment
Please, Sign In to add comment