def waitForLoad(): while (openCVLocate.locateCenter(imgpath + '/blueTeam.png')) == None: print("waiting for load") if (openCVLocate.locateCenter(imgpath + '/dodge.PNG')) is not None: return False time.sleep(5) print("loaded") return True
def rowdownmid(team): time.sleep(5) T = time.clock() # assume loaded # click in screen BTcoords = None if (team == "blue"): while BTcoords is None: BTcoords = openCVLocate.locateCenter(imgpath + '/blueTeam.PNG') else: BTcoords = None clickInGame(BTcoords) # press y to lock camera keyHelper.PandRKey(keyHelper.cToHex('y')) # buy dorans blade screenshotArray = np.array(ImageGrab.grab().convert('RGB')) buyUpgradeAndBack.buy(buyorder, screenshotArray, BTcoords) cloop = 0 lastHealth = 0 time.sleep(40) # main loop # move back on big damage # remove slow move # make the loop[ faster for back and forth # buy on back # back on low health # level all abilities # use all abilities in a forward direction while True: cloop += 1 ctime = time.clock() screenshotArray = np.array(ImageGrab.grab().convert('RGB')) try: health = int(OCR.getWhiteText(screenshotArray, math.floor(BTcoords[0] - 545), 26, math.floor(BTcoords[1] + 120), 12, lower=150).replace('.', '').replace(' ', '')) if (health == 0): dead(screenshotArray, BTcoords) continue elif health < 200: keyHelper.PandRKey(keyHelper.cToHex('f')) buyUpgradeAndBack.back(buyorder, screenshotArray, BTcoords) continue if(health - lastHealth < -130): moveBackwards(1, BTcoords) autoDownMid(BTcoords, time.clock() - T) if(openCVLocate.locateCenter(imgpath + '/upgrade.PNG') is not None): buyUpgradeAndBack.upgrade() if cloop % 10 == 0: autoDownMid(BTcoords, time.clock() - T) print(health) lastHealth = health except ValueError: print("health got messed up") finally: time.sleep(max(.7 - (time.clock() - ctime), 0))
def runitdownbot(team): time.sleep(1) T = time.clock() # assume loaded # click in screen BTcoords = None if (team == "blue"): while BTcoords is None: BTcoords = openCVLocate.locateCenter(imgpath + '/blueTeamTT.PNG') else: BTcoords = None clickInGame(BTcoords) im = np.array(ImageGrab.grab().convert('RGB')) buyUpgradeAndBack.buy(buyorder, im, BTcoords, xoff=-296, yoff=70) cloop = 0 while True: cloop += 1 ctime = time.clock() im = np.array(ImageGrab.grab().convert('RGB')) health = getHealth(im, BTcoords) print("H:" + str(health)) if health is 0: buyUpgradeAndBack.buy(buyorder, im, BTcoords, xoff=-296, yoff=70) elif health < 20: dodgeBack(BTcoords) time.sleep(2) dodgeBack(BTcoords) time.sleep(2) buyUpgradeAndBack.back() buyUpgradeAndBack.buy(buyorder, im, BTcoords, xoff=-296, yoff=70) if (cloop + 2) % 10 == 0: dodgeBack(BTcoords) if cloop % 10 == 0: autoItDown(BTcoords) if cloop % 60 == 0: if (openCVLocate.locateCenter(imgpath + '/upgrade.PNG') is not None): buyUpgradeAndBack.upgrade(upgradeorder) time.sleep(max(.7 - (time.clock() - ctime), 0))
def autoAccept(): delay = 7 accepted = False while True: print("accepting") pos = openCVLocate.locateCenter(imgpath + '/accept.PNG') if (pos != None): acceptCoords = pos pyautogui.click(acceptCoords, duration=.1) pyautogui.click(acceptCoords[0], acceptCoords[1] - 50, duration=.5) accepted = True delay = 1 if (accepted and openCVLocate.locateCenter(imgpath + '/wardInChampSelect.PNG')): break time.sleep(delay)
def lockIn(champs): images = [] for champ in champs: if champ == 'ashe': images.append(imgpath + '/ashe.PNG') elif champ == 'jhin': images.append(imgpath + '/jhin.PNG') elif champ == 'vayne': images.append(imgpath + '/vayne.PNG') elif champ == 'jinx': images.append(imgpath + '/jinx.PNG') elif champ == 'varus': images.append(imgpath + '/varus.PNG') elif champ == 'sivir': images.append(imgpath + '/sivir.PNG') elif champ == 'caitlyn': images.append(imgpath + '/caitlyn.PNG') else: images.append(imgpath + '/ashe.PNG') while openCVLocate.locateCenter(imgpath + '/lockIn.png', thold=.9) == None: for image in images: if openCVLocate.locateCenter(image, thold=.9) is not None: pyautogui.click(openCVLocate.locateCenter(image, thold=.9)) time.sleep(1) while openCVLocate.locateCenter(imgpath + '/lockIn.png') is not None: pyautogui.click(openCVLocate.locateCenter(imgpath + '/lockIn.png'), duration=.2) time.sleep(2) for image in images: if openCVLocate.locateCenter(image, thold=.9) is not None: pyautogui.click(openCVLocate.locateCenter(image, thold=.9)) time.sleep(1) pyautogui.click(openCVLocate.locateCenter(imgpath + '/lockIn.png'), duration=.2) time.sleep(1)
def clickX(): while openCVLocate.locateCenter(imgpath + '/X.PNG', thold=.95) is None: pos = openCVLocate.locateCenter(imgpath + '/OK.PNG', thold=.65) if pos is not None: print('see OK') pyautogui.click(pos, duration=.6) pyautogui.moveTo(x=pos[0], y=pos[1] + 40) time.sleep(1) time.sleep(10) while openCVLocate.locateCenter(imgpath + '/X.PNG', thold=.95) is not None: pos = openCVLocate.locateCenter(imgpath + '/OK.PNG', thold=.65) if pos is not None: pyautogui.click(pos, duration=.6) pyautogui.moveTo(x=pos[0], y=pos[1] + 40) time.sleep(2) pyautogui.click(openCVLocate.locateCenter(imgpath + '/X.PNG')) time.sleep(2) pos = openCVLocate.locateCenter(imgpath + '/OK.PNG', thold=.65) if pos is not None: pyautogui.click(pos, duration=.6) pyautogui.moveTo(x=pos[0], y=pos[1] + 40)
def autoQueue(queue): if queue == "intro": Qimage = imgpath + "/introQueue.PNG" elif queue == "beginner": Qimage = imgpath + "/beginnerQueue.PNG" elif queue == "intermediate": Qimage = imgpath + "/intermediateQueue.PNG" else: Qimage = imgpath + "introQueue.PNG" #wait for play while openCVLocate.locateCenter(imgpath + '/play.PNG') == None: print("waiting for play") time.sleep(2) pyautogui.click(openCVLocate.locateCenter(imgpath + '/play.PNG'), duration=.06) pyautogui.click(openCVLocate.locateCenter(imgpath + '/play.PNG'), duration=.06) print("play clicked") #wait for coop v ai CvAIcount = 0 while openCVLocate.locateCenter(imgpath + '/CoopVAI.PNG') == None: print("waiting for coop") time.sleep(2) CvAIcount += 1 if (CvAIcount > 5): break pyautogui.click(openCVLocate.locateCenter(imgpath + '/CoopVAI.PNG'), duration=.07) print("CoopVAI clicked") #wait for queue Qcount = 0 while openCVLocate.locateCenter(Qimage) == None: print("waiting for Q") time.sleep(2) Qcount += 1 if (Qcount > 5): break pyautogui.click(openCVLocate.locateCenter(Qimage), duration=.07) print("Q clicked") #wait for confirm while openCVLocate.locateCenter(imgpath + '/confirmQueue.PNG') == None: print("waiting for confirm") time.sleep(2) pyautogui.click(openCVLocate.locateCenter(imgpath + '/confirmQueue.PNG'), duration=.07) print("ConfirmQ clicked") # wait for find match while openCVLocate.locateCenter(imgpath + '/findMatch.PNG') == None: print("waiting for find match") time.sleep(2) while openCVLocate.locateCenter(imgpath + '/findMatch.PNG') is not None: pyautogui.doubleClick(openCVLocate.locateCenter(imgpath + '/findMatch.PNG'), duration=.07) time.sleep(2) print("Find match clicked! Bye!")
def closeOptions(): if (openCVLocate.locateCenter(imgpath + '/options.PNG') != None): keyHelper.PandRKey(0x01)
def rundownmid(team): time.sleep(5) # main loop imageCoords = None if (team == "blue"): while imageCoords is None: imageCoords = openCVLocate.locateCenter(imgpath + '/blueTeam.PNG') else: imageCoords = None pyautogui.moveTo(imageCoords, duration=2) pyautogui.click(imageCoords, duration=.1) time.sleep(1) #buy dorans keyHelper.PandRKey(0x19) time.sleep(1) keyHelper.PressKey(0x1D) # CTRL time.sleep(1) keyHelper.PandRKey(0x1C) # RTRN time.sleep(1) keyHelper.ReleaseKey(0x1D) # CTRL keyHelper.PandRKey(0x30) # B keyHelper.PandRKey(0x26) # L keyHelper.PandRKey(0x1E) # A time.sleep(.5) keyHelper.PandRKey(0x1C) # RTRN keyHelper.PandRKey(0x1C) # RTRN keyHelper.PandRKey(0x01) # ESC time.sleep(60) curr = 0 while True: if curr % 5 == 0: print("pressing Q") keyHelper.PandRKey(0x10) # Q time.sleep(.5) if curr % 24 == 0: # buy vamp keyHelper.PandRKey(0x19) time.sleep(1) keyHelper.PressKey(0x1D) # CTRL time.sleep(.4) keyHelper.PandRKey(0x1C) # RTRN time.sleep(.4) keyHelper.ReleaseKey(0x1D) # CTRL keyHelper.PandRKey(0x2F) #V keyHelper.PandRKey(0x1E) #A keyHelper.PandRKey(0x32) #M keyHelper.PandRKey(0x19) #P keyHelper.PandRKey(0x17) #I time.sleep(1) keyHelper.PandRKey(0x1C) # RTRN keyHelper.PandRKey(0x1C) # RTRN keyHelper.PandRKey(0x01) # ESC if curr % 6 == 0: # move to target pyautogui.moveTo(x=imageCoords[0] - 800, y=imageCoords[1], duration=1) pyautogui.click(x=imageCoords[0] - 800, y=imageCoords[1], clicks=1, button='right', duration=.1) time.sleep(.2) pyautogui.mouseUp(button='right') time.sleep(.8) keyHelper.PressKey(0x1E) time.sleep(.2) pyautogui.moveTo(imageCoords[0] + 10, imageCoords[1] - 10, duration=1) pyautogui.click(imageCoords[0] + 10, imageCoords[1] - 10, clicks=1, button='left', duration=.1) time.sleep(.2) pyautogui.mouseUp(button='left') time.sleep(.2) keyHelper.ReleaseKey(0x1E) if curr % 15 == 2: print("pressing CTRL Q") #upgrade Q keyHelper.PressKey(0x1D) # CTRL keyHelper.PressKey(0x10) # Q time.sleep(.1) keyHelper.ReleaseKey(0x1D) keyHelper.ReleaseKey(0x10) curr += 1 if curr % 15 == 0: #close the menu if it some how is still open closeOptions() #check for end of game if openCVLocate.locateCenter(imgpath + '/continue.PNG') is not None: pyautogui.click(openCVLocate.locateCenter(imgpath + '/continue.PNG'), duration=.6) break time.sleep(2)
def checkTeam(): if (openCVLocate.locateCenter(imgpath + '/blueTeam.png')): return 'blue' else: return 'red'