예제 #1
0
def find_prayer_pot():
    rs_bag, bagx, bagy = RS.get_bag('bag coords', 'hsv')
    # prayer potion color ranges
    low = np.array([78,140,0])
    high= np.array([81,225,211])
    mask = cv2.inRange(rs_bag, low, high)

    kernel = np.ones((5,5), np.uint8)
    dilation = cv2.dilate(mask, kernel, iterations = 1)
    
    _,contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    for con in contours:
        x, y, w, h = cv2.boundingRect(con)
        cv2.rectangle(mask,(x,y), (x+w, y+h), (255,255,255),-1)

    _,contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    for con in contours[::-1]:
        M = cv2.moments(con)
        mx, my = int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"])
        mx += RSX + bagx
        my += RSY + bagy

        mx += random.randint(-7,7)
        my += random.randint(-12,5)

        Mouse.moveClick(mx,my,1)
        #Mouse.moveTo(mx,my)
        break
예제 #2
0
def find_template(template_file, option=None):#pass template to function
    #option == to option in menu when righ-clicked on item
    #checks to see wheater to add cur dir or not
    if "/" not in template_file:
        template_file = cwd+"/imgs/"+template_file

    rs_bag, bagx,bagy = RS.get_bag("bag, and it's coords") #Screenshot taken here, 
    #loc is where the templates found are in 
    loc, w, h = Match.this(rs_bag, template_file)
    #for loops iterates through every found template
    for pt in zip(*loc[::-1]):#goes through each found image
        #pt = ((pt[0]+bagx),(pt[1]+bagy))
        #pt is the Top-left coord of the found template


        #create Bott-Right coord of found template
        btmX = pt[0] + w - ((w/2)/2)
        btmY = pt[1] + h - ((h/2)/2)
        #moving the pt coord of the template a bit to the right, so options menu get brought up
        pt = (pt[0]+((w/2)/2), pt[1]+((h/2)/2))

        #gencoord adds RS position
        x, y = gen_coords(pt,btmX, btmY)#gets random x, y coords relative to RSposition on where to click
        #x, y = Mouse.randCoord(pt, w, h)
        if option == 'click' or option == 1:
            Mouse.moveClick(x,y, 1)#left clicks on given x,y coords
        else:
            Mouse.moveClick(x,y, 3)#right clicks on given x,y coords
            #menu_x, menu_y, menu = RS.getOptionsMenu(x,y)#takes screenshot of options menu and returns the point at Top-left of the menu
            RandTime.randTime(0,0,0,0,0,1)

            #RS.findOptionClick(x,y, menu_x, menu_y, menu, option)
            RS.findOptionClick(x,y,option)
        break
예제 #3
0
def count_logs(template_file):
    rs_bag = RS.get_bag('only')
    loc, w, h = Match.this(rs_bag, template_file)
    count = 0
    for pt in zip(*loc[::-1]):
        count += 1
        break
    return count
예제 #4
0
def count_logs(template_file):
    rs_bag = RS.get_bag('only')
    loc, w, h = Match.this(rs_bag, template_file)
    count = 0
    for pt in zip(*loc[::-1]):
        count +=1
        break
    return count
예제 #5
0
파일: stringer.py 프로젝트: jjvilm/osrmacro
def checkInv(template):
    """Finds bowstring and unstrung bow in inventory and clicks them, if not found then returns false, true otherwise"""
    rs_bag, bgx, bgy = RS.get_bag('bag and other variables')
    loc, w, h = Match.this(rs_bag,template )
    for pt in zip(*loc[::-1]):
        #assigns random values to pt 
        x, y = pt
        x = random.randint(pt[0], pt[0]+w)
        y = random.randint(pt[1], pt[1]+h)
        pt = (x,y)
        dobowstring(pt, w, h, bgx, bgy)
        return True
    return False
예제 #6
0
def checkInv(template):
    """Finds bowstring and unstrung bow in inventory and clicks them, if not found then returns false, true otherwise"""
    rs_bag, bgx, bgy = RS.get_bag('bag and other variables')
    loc, w, h = Match.this(rs_bag, template)
    for pt in zip(*loc[::-1]):
        #assigns random values to pt
        x, y = pt
        x = random.randint(pt[0], pt[0] + w)
        y = random.randint(pt[1], pt[1] + h)
        pt = (x, y)
        dobowstring(pt, w, h, bgx, bgy)
        return True
    return False
예제 #7
0
def click_item(item):
    bag, bagx, bagy = RS.get_bag("bag x y")
    loc, w, h = Match.this(bag, item)
    for pt in zip(*loc[::-1]):
        x1 = pt[0] + bagx
        y1 = pt[1] + bagy

        x2 = x1 + w - ((w / 2) / 2)
        y2 = y1 + h - ((h / 2) / 2)

        # Moving first point inwards
        x1 += (w / 2) / 2
        y1 += (h / 2) / 2

        # Gen random coords within the bound
        x, y = Mouse.genCoords(x1, y1, x2, y2)
        Mouse.moveClick(x, y, 1)
        #RandTime.randTime(0,5,0,0,5,0)
        break
예제 #8
0
def click_item(item):
    bag, bagx,bagy = RS.get_bag("bag x y")
    loc, w, h = Match.this(bag, item)
    for pt in zip(*loc[::-1]):
        x1 = pt[0] + bagx
        y1 = pt[1] + bagy

        x2 = x1 + w - ((w/2)/2)
        y2 = y1 + h - ((h/2)/2)

        # Moving first point inwards 
        x1 += (w/2) / 2
        y1 += (h/2) / 2

        # Gen random coords within the bound
        x,y = Mouse.genCoords(x1,y1,x2,y2)
        Mouse.moveClick(x,y,1)
        #RandTime.randTime(0,5,0,0,5,0)
        break
예제 #9
0
    def check_list(self):
        items_dict = imd.ImageStorage()
        items_dict = items_dict.pickled_dict

        RS.press_button('equipment')
        time.sleep(1)
        for key in items_dict.keys():
            template = items_dict[key]
            #save for DEBUG
            #cv2.imwrite('debug_template_file', template_)
            w, h = template.shape[::-1]
            pattern = RS.get_bag('only', 'gray')
            res = cv2.matchTemplate(pattern, template, cv2.TM_CCOEFF_NORMED)
            threshold = .8  #default is 8
            loc = np.where(res >= threshold)

            for pt in zip(*loc[::-1]):  #goes through each found image
                print('{} found'.format(key))
                break
            else:
                print('{} not found'.format(key))
예제 #10
0
    def check_list(self):
        items_dict = imd.ImageStorage()
        items_dict = items_dict.pickled_dict

        RS.press_button('equipment')
        time.sleep(1)
        for key in items_dict.keys():
            template = items_dict[key]
            #save for DEBUG
            #cv2.imwrite('debug_template_file', template_)
            w, h = template.shape[::-1]
            pattern = RS.get_bag('only','gray')
            res = cv2.matchTemplate(pattern,template,cv2.TM_CCOEFF_NORMED)
            threshold = .8 #default is 8 
            loc = np.where( res >= threshold)

            for pt in zip(*loc[::-1]):#goes through each found image
                print('{} found'.format(key))
                break
            else:
                print('{} not found'.format(key))
예제 #11
0
def find_template(template_file, option=None):  #pass template to function
    #option == to option in menu when righ-clicked on item
    #checks to see wheater to add cur dir or not
    if "/" not in template_file:
        template_file = cwd + "/imgs/" + template_file

    rs_bag, bagx, bagy = RS.get_bag(
        "bag, and it's coords")  #Screenshot taken here,
    #loc is where the templates found are in
    loc, w, h = Match.this(rs_bag, template_file)
    #for loops iterates through every found template
    for pt in zip(*loc[::-1]):  #goes through each found image
        #pt = ((pt[0]+bagx),(pt[1]+bagy))
        #pt is the Top-left coord of the found template

        #create Bott-Right coord of found template
        btmX = pt[0] + w - ((w / 2) / 2)
        btmY = pt[1] + h - ((h / 2) / 2)
        #moving the pt coord of the template a bit to the right, so options menu get brought up
        pt = (pt[0] + ((w / 2) / 2), pt[1] + ((h / 2) / 2))

        #gencoord adds RS position
        x, y = gen_coords(
            pt, btmX, btmY
        )  #gets random x, y coords relative to RSposition on where to click
        #x, y = Mouse.randCoord(pt, w, h)
        if option == 'click' or option == 1:
            Mouse.moveClick(x, y, 1)  #left clicks on given x,y coords
        else:
            Mouse.moveClick(x, y, 3)  #right clicks on given x,y coords
            #menu_x, menu_y, menu = RS.getOptionsMenu(x,y)#takes screenshot of options menu and returns the point at Top-left of the menu
            RandTime.randTime(0, 0, 0, 0, 0, 1)

            #RS.findOptionClick(x,y, menu_x, menu_y, menu, option)
            RS.findOptionClick(x, y, option)
        break
예제 #12
0
def find_grimmy_herbs_in_inventory(herb_object):
    rs_bag, bagx, bagy = RS.get_bag('bag and its coords', 'hsv')
    # finds all grimmys first
    low, high = herb_object.herbdic['grimmy2']
    low = np.array(low)
    high = np.array(high)
    # applies mask based on above values
    mask = cv2.inRange(rs_bag, low, high)

    kernel = np.ones((5,5), np.uint8)
    dilation = cv2.dilate(mask, kernel, iterations = 1)

    _, contours, _ = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    # adds a white rectangle to all grimmys
    for con in contours:
        x, y, w, h = cv2.boundingRect(con)
        cv2.rectangle(mask,(x,y),(x+w,y+h),(255,255,255),-1)
    # goes through each item and clicks it
    _, contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    items_coords = []
    row = []
    col = 0
    for con in contours[::-1]:
        M = cv2.moments(con)
        #print(M)
        # gets center of object
        x,y = int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"])
        # makes coords relative to the window
        x += RSX + bagx
        y += RSY + bagy 
        # creates a list from -20 to 20
        pixels = [i for i in range(-10,10)]
        # randomly adds value from pixels list
        x += random.choice(pixels)
        y += random.choice(pixels)

        row.append((x,y))

        col += 1
        # appends the row 
        if col == 4:
            items_coords.append(row)
            row = []
            col = 0
    # makes sure to clean the last 3 herbs in bank
    if len(contours) <= 3:
        items_coords.append(row)
    
    # clicks on herbs in a zigzag pattern
    row = 2
    for rows in items_coords:
        # first row gets clicked from left to right
        if row % 2 == 0:
            for coords in rows:
                x, y = coords
                Mouse.moveClick(x,y, 1)#right clicks on given x,y coords
                randTime(0,0,0,0,0,7)
                randTime(0,0,0,0,0,5)
                randTime(0,0,1,0,0,1)

            row += 1
            continue
        else:
        # inverts this row, from right to left
            for coords in rows[::-1]:
                x, y = coords
                Mouse.moveClick(x,y, 1)#right clicks on given x,y coords
                randTime(0,0,0,0,0,7)
                randTime(0,0,0,0,0,5)
                randTime(0,0,1,0,0,1)
        row += 1