Advertisement
Guest User

D3-Sikuli Bot

a guest
Jun 16th, 2012
1,669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.51 KB | None | 0 0
  1. import random
  2. import java.awt.Robot as JRobot
  3. import java.awt.Color as Color
  4. from guide import *
  5.  
  6. myRobot = JRobot()
  7. picmonstersinmap = [Pattern("1339837131433.png").similar(0.52)]
  8. random.seed(10)
  9.  
  10. RunTime = 0.06 * (100 - 10) + 2 #10 is runspeed
  11.  
  12. def terminate():
  13.     print "USER TERMINATED"
  14.     popup("YalmBot has stopped!")
  15.     exit()
  16.  
  17. def checkMonsters(monsters, reg):
  18.     if not reg: reg = SCREEN # if no reg given, we look on the whole screen
  19.     for p in monsters:
  20.         if reg.exists(p, 0):
  21.             return getLastMatch()
  22.     return None
  23.  
  24. def LeaveGame():
  25.     type("t")
  26.     wait(7)
  27.     type(Key.ESC)
  28.     wait(0.4)
  29.     click(Location(playground.x + 397, playground.y + 337))
  30.    
  31.  
  32. def Pause():
  33.     paused = not paused
  34.  
  35. def Click(x, y):
  36.     x = playground.x + x
  37.     y = playground.y + y
  38.     click(Location(x-3+Math.random()*6,y-3+Math.random()*6))
  39.     sleep(1+Math.random()*0.5)
  40.  
  41.  
  42. def Move(x, y):
  43.     #print "nummer" + x
  44.     x = playground.x + x
  45.     y = playground.y + y
  46.     #click(Location(x-3+random.random()*6,y-3+random.random()*6))
  47.     hover(Location(x-3+random.random()*6,y-3+random.random()*6))
  48.     mouseDown(Button.MIDDLE)
  49.     mouseUp(Button.MIDDLE)
  50.     wait(1.2+random.random()*0.5)
  51.  
  52. def Point(x, y):
  53.     #print "nummer" + x
  54.     x = playground.x + x
  55.     y = playground.y + y
  56.     hover(Location(x-3+random.random()*6,y-3+random.random()*6))
  57.  
  58. def Attack(x, y):
  59.     x = playground.x + x
  60.     y = playground.y + y
  61.     rightClick(Location(x-3+random.random()*6,y-3+random.random()*6))      
  62.  
  63. def AttackNearbyMonster():
  64.     monster = checkMonsters(picmonstersinmap, playground)
  65.     if monster: # we found none in the moment
  66.         print "Found monster! Attack! :)"
  67.         rightClick(monster)
  68.         wait(0.3)
  69.         AttackNearbyMonster()
  70.  
  71.  
  72. def Rest(z):
  73.     sleep(math.random()*z)
  74.  
  75. def findItemsOfColor():
  76.     area = Region(playground.x + 75,playground.y + 90,600,400)
  77.     area.highlight(1)
  78.     wait(1)
  79. #    x = area.x
  80. #    y = area.y
  81.  #   i=0
  82.     #while i==0:
  83.         #x = x+1
  84.         #p = Location(x,y)
  85.  #       aColor = Color(0x6969FF)
  86.        # if myRobot.getPixelColor(p.x, p.y) == aColor:
  87.  #           print "FOUND ITEM!!!"
  88.  #           click(x+4,y+4)
  89.  #           wait(1)
  90.  #       if x > area.x + area.w:
  91.  #           x = area.x
  92.  #           y = y + 1
  93.  #           if y > area.y + area.h:
  94.  #               i = 1
  95.  #               break
  96.            
  97. Env.addHotkey(Key.ENTER, KeyModifier.CTRL, terminate)
  98.  
  99. myApp = App("Diablo III")
  100. myApp.focus()
  101.  
  102. playground = App.focusedWindow()
  103.  
  104. text(playground, "Running YalmBot 0.1")
  105. show(1)
  106.  
  107. exists("RESUITIEGAIT.png",1)
  108. click("RESUITIEGAIT-1.png")
  109. wait(2)
  110.  
  111. loc1 = 10
  112. loc12 = 115
  113. loc2 = 10
  114. loc22 = 215
  115. loc3 = 10
  116. loc32 = 195
  117.  
  118. while True:
  119.     if playground.exists(Pattern("wHX.png").similar(0.50)):
  120.         break
  121.     wait(1)
  122.  
  123. #starting game
  124. type("1")
  125. hover(Location(playground.x + 11,playground.y + 235))
  126. wait(0.4)
  127. type("2")
  128. mouseDown(Button.MIDDLE)
  129. wait(RunTime)
  130. mouseUp(Button.MIDDLE)
  131. type("3")
  132. wait(0.4)
  133. type("3")
  134.  
  135. foundCellar = playground.exists(Pattern("K.png").similar(0.60).targetOffset(7,12))
  136. if foundCellar:
  137.     type("2")
  138.     hover(foundCellar)
  139.     wait(0.2)
  140.     click(foundCellar)
  141.     wait(3)
  142.     Move(3,519)
  143.     Move(255,215)
  144.  
  145.     AttackX = 165
  146.     AttackY = 152
  147.    
  148.     Point(AttackX,AttackY)
  149.     type("2")
  150.     wait(0.1)
  151.     type("4")
  152.     Attack(AttackX,AttackY)
  153.     wait(0.4)
  154.     Attack(AttackX,AttackY)
  155.     wait(0.4)
  156.     Attack(AttackX,AttackY)
  157.     wait(0.4)
  158.     Attack(AttackX,AttackY)
  159.     wait(0.4)
  160.     Attack(AttackX,AttackY)
  161.     wait(0.4)
  162.     type("4")
  163.     wait(0.4)
  164.     Attack(15,196)
  165.     wait(0.4)
  166.     Attack(15,196)
  167.  
  168.     #Check for remaining monsters here!
  169.     Move(15,196)
  170.     realCenter = playground.getCenter()
  171.     playgroundCenter = Location(realCenter.x-playground.x,realCenter.y-playground.y)
  172.     Move(playgroundCenter.x-30,playgroundCenter.y+30)
  173.     AttackNearbyMonster()
  174.     Move(playgroundCenter.x+175,playgroundCenter.y-10)
  175.     AttackNearbyMonster()
  176.     Move(playgroundCenter.x+75,playgroundCenter.y-75)
  177.     AttackNearbyMonster()
  178.     Move(playgroundCenter.x-20,playgroundCenter.y-100)
  179.     AttackNearbyMonster()
  180.    
  181.     Move(playgroundCenter.x-50,playgroundCenter.y+100)
  182.     #Move(300,433)
  183.  
  184.     #Find blues
  185.     findItemsOfColor()
  186.     text(playground, "Done! Leaving game!")
  187.     show(2)
  188.     LeaveGame()
  189. else:
  190.     text(playground, "No cellar here! Leaving game...")
  191.     show(2)
  192.     type("3")
  193.     wait(0.2)
  194.     type("2")
  195.     LeaveGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement