Advertisement
Guest User

CounterBot

a guest
Mar 3rd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.52 KB | None | 0 0
  1. require("libs.Utils")
  2. require("libs.SideMessage")
  3. require("libs.ScriptConfig")
  4.  
  5. config = ScriptConfig.new()
  6. config:SetParameter("hotkey", "T", config.TYPE_HOTKEY)
  7. config:Load()
  8. toggleKey = config.hotkey
  9. local me = nil local play = false local activated = false local work = nil
  10.  
  11. function Tick(tick)
  12.     if not PlayingGame() then return end
  13.     me = entityList:GetMyHero() if not me then return end
  14.     if SleepCheck() and activated then
  15.         if me then
  16.             local cour = entityList:FindEntities({classId = CDOTA_Unit_Courier,team = me.team,alive = true})[1]
  17.             local fount = entityList:FindEntities({classId = CDOTA_Unit_Fountain,team = me.team})[1]
  18.             if cour then           
  19.                 if cour:GetAbility(6).state == LuaEntityAbility.STATE_READY then
  20.                     cour:CastAbility(cour:GetAbility(6))
  21.                 end
  22.                 if not work then   
  23.                     local notsafedistance = GetDistance2D(cour,fount)
  24.                     if SleepCheck("two") and cour.visibleToEnemy and notsafedistance < 6900 and notsafedistance > 4500 and not cour:GetProperty("CDOTA_Unit_Courier","m_bFlyingCourier") then
  25.                         cour:CastAbility(cour:GetAbility(1)) Sleep(1000,"two")
  26.                         work = nil
  27.                         activated = false
  28.                     end
  29.                     local player = entityList:GetMyPlayer()
  30.                     local phys = entityList:GetEntities(function (bl) return bl.type==LuaEntity.TYPE_ITEM_PHYSICAL and bl.itemHolds.name== "item_bottle" end)[1]
  31.                     local bot = me:FindItem("item_bottle")
  32.                     if cour then                           
  33.                         local distance = GetDistance2D(cour,me)
  34.                         if SleepCheck("one") then
  35.                             cour:Follow(me) Sleep(1000,"one")
  36.                         end            
  37.                         if distance < 200 and bot and not phys then
  38.                             player:Select(me)
  39.                             player:DropItem(bot,me.position)
  40.                         elseif phys then
  41.                             player:Select(cour)
  42.                             player:TakeItem(phys)
  43.                             player:Select(me)
  44.                             work = 1
  45.                         end
  46.                     end
  47.                 elseif work == 1 then
  48.                     local CourerB = cour:FindItem("item_bottle")
  49.                     if CourerB then
  50.                         if CourerB.charges ~= 3 then
  51.                             if cour.courState ~= LuaEntityCourier.STATE_B2BASE then
  52.                                 cour:CastAbility(cour:GetAbility(1))
  53.                             end
  54.                         elseif cour.courState ~= LuaEntityCourier.STATE_DELIVER then
  55.                             client:ExecuteCmd("dota_courier_deliver")
  56.                             cour:CastAbility(cour:GetAbility(5))
  57.                             entityList:GetMyPlayer():Select(me)
  58.                             work = nil
  59.                             activated = false
  60.                         end
  61.                     end
  62.                 end
  63.             end
  64.         end
  65.         Sleep(500)
  66.     end
  67. end
  68.  
  69. function Key()
  70.     if client.chat then return end
  71.     if IsKeyDown(toggleKey) then
  72.         activated = not activated
  73.         CourerSideMessage()
  74.     end
  75. end
  76.  
  77. function CourerSideMessage()
  78.     local test = sideMessage:CreateMessage(200,60) 
  79.     test:AddElement(drawMgr:CreateRect(5,5,80,50,0xFFFFFFFF,drawMgr:GetTextureId("NyanUI/spellicons/courier_take_stash_items")))
  80.     test:AddElement(drawMgr:CreateText(90,13,-1,"Wait!",drawMgr:CreateFont("defaultFont","Tahoma",25,500)))
  81. end
  82.  
  83. function Load()
  84.     if PlayingGame() then
  85.         play = true
  86.         script:RegisterEvent(EVENT_KEY,Key)
  87.         script:RegisterEvent(EVENT_FRAME,Tick)
  88.         script:UnregisterEvent(Load)
  89.     end
  90. end
  91.  
  92. function GameClose()
  93.     if play then
  94.         me = nil
  95.         work = nil
  96.         script:UnregisterEvent(Tick)
  97.         script:UnregisterEvent(Key)
  98.         script:RegisterEvent(EVENT_TICK,Load)
  99.         play = false
  100.     end
  101. end
  102.  
  103. script:RegisterEvent(EVENT_TICK,Load)
  104. script:RegisterEvent(EVENT_CLOSE,GameClose)
  105. require("libs.Utils")
  106. require("libs.SideMessage")
  107. require("libs.ScriptConfig")
  108.  
  109. config = ScriptConfig.new()
  110. config:SetParameter("hotkey", "T", config.TYPE_HOTKEY)
  111. config:Load()
  112. toggleKey = config.hotkey
  113. local me = nil local play = false local activated = false local work = nil
  114.  
  115. function Tick(tick)
  116.     if not PlayingGame() then return end
  117.     me = entityList:GetMyHero() if not me then return end
  118.     if SleepCheck() and activated then
  119.         if me then
  120.             local cour = entityList:FindEntities({classId = CDOTA_Unit_Courier,team = me.team,alive = true})[1]
  121.             local fount = entityList:FindEntities({classId = CDOTA_Unit_Fountain,team = me.team})[1]
  122.             if cour then           
  123.                 if cour:GetAbility(6).state == LuaEntityAbility.STATE_READY then
  124.                     cour:CastAbility(cour:GetAbility(6))
  125.                 end
  126.                 if not work then   
  127.                     local notsafedistance = GetDistance2D(cour,fount)
  128.                     if SleepCheck("two") and cour.visibleToEnemy and notsafedistance < 6900 and notsafedistance > 4500 and not cour:GetProperty("CDOTA_Unit_Courier","m_bFlyingCourier") then
  129.                         cour:CastAbility(cour:GetAbility(1)) Sleep(1000,"two")
  130.                         work = nil
  131.                         activated = false
  132.                     end
  133.                     local player = entityList:GetMyPlayer()
  134.                     local phys = entityList:GetEntities(function (bl) return bl.type==LuaEntity.TYPE_ITEM_PHYSICAL and bl.itemHolds.name== "item_bottle" end)[1]
  135.                     local bot = me:FindItem("item_bottle")
  136.                     if cour then                           
  137.                         local distance = GetDistance2D(cour,me)
  138.                         if SleepCheck("one") then
  139.                             cour:Follow(me) Sleep(1000,"one")
  140.                         end            
  141.                         if distance < 200 and bot and not phys then
  142.                             player:Select(me)
  143.                             player:DropItem(bot,me.position)
  144.                         elseif phys then
  145.                             player:Select(cour)
  146.                             player:TakeItem(phys)
  147.                             player:Select(me)
  148.                             work = 1
  149.                         end
  150.                     end
  151.                 elseif work == 1 then
  152.                     local CourerB = cour:FindItem("item_bottle")
  153.                     if CourerB then
  154.                         if CourerB.charges ~= 3 then
  155.                             if cour.courState ~= LuaEntityCourier.STATE_B2BASE then
  156.                                 cour:CastAbility(cour:GetAbility(1))
  157.                             end
  158.                         elseif cour.courState ~= LuaEntityCourier.STATE_DELIVER then
  159.                             client:ExecuteCmd("dota_courier_deliver")
  160.                             cour:CastAbility(cour:GetAbility(5))
  161.                             entityList:GetMyPlayer():Select(me)
  162.                             work = nil
  163.                             activated = false
  164.                         end
  165.                     end
  166.                 end
  167.             end
  168.         end
  169.         Sleep(500)
  170.     end
  171. end
  172.  
  173. function Key()
  174.     if client.chat then return end
  175.     if IsKeyDown(toggleKey) then
  176.         activated = not activated
  177.         CourerSideMessage()
  178.     end
  179. end
  180.  
  181. function CourerSideMessage()
  182.     local test = sideMessage:CreateMessage(200,60) 
  183.     test:AddElement(drawMgr:CreateRect(5,5,80,50,0xFFFFFFFF,drawMgr:GetTextureId("NyanUI/spellicons/courier_take_stash_items")))
  184.     test:AddElement(drawMgr:CreateText(90,13,-1,"Wait!",drawMgr:CreateFont("defaultFont","Tahoma",25,500)))
  185. end
  186.  
  187. function Load()
  188.     if PlayingGame() then
  189.         play = true
  190.         script:RegisterEvent(EVENT_KEY,Key)
  191.         script:RegisterEvent(EVENT_FRAME,Tick)
  192.         script:UnregisterEvent(Load)
  193.     end
  194. end
  195.  
  196. function GameClose()
  197.     if play then
  198.         me = nil
  199.         work = nil
  200.         script:UnregisterEvent(Tick)
  201.         script:UnregisterEvent(Key)
  202.         script:RegisterEvent(EVENT_TICK,Load)
  203.         play = false
  204.     end
  205. end
  206.  
  207. script:RegisterEvent(EVENT_TICK,Load)
  208. script:RegisterEvent(EVENT_CLOSE,GameClose)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement