Advertisement
Guest User

CounterBot

a guest
Mar 3rd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.26 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement