728x90

물가(캐릭터가 우측 끝에 붙어야 함)를 오른쪽에 두고, 5개 포인트에 랜덤으로 낚시함.

주변에 사람 있으면 낚시 멈춤.

보름정도 잘 사용하다가 정지먹음. (주변에 사람 오면 멈추는거 구현하기 전에 누가 신고한듯?)

import pyautogui as pag
from PIL import Image, ImageGrab, ImageChops, ImageStat
from pynput.keyboard import Key, Listener
import time
from datetime import datetime
import threading as th
import keyboard
import random
import playsound

keep_going = True
waiting = True #대기중
casting = False #미끼 던져놓은 중
fishing = False #낚는중

width, height = pag.size()

h_width = int(width/2) # 1920인 경우 960, 2560인 경우 1280
h_height = int(height/2) #1080이니까 540

rand = 0
jji_x = h_width + 605
jji_y = h_height - 85


def parse_dates(ts):
    return datetime.fromtimestamp(ts).strftime("%Y-%m-%d %H:%M:%S") #타임스탬프를 시간형식으로 전환

def curr_status():
    global waiting, casting, fishing
    if waiting == True:
        return "/ 캐릭터 상태 : 기다리는 중"
    elif casting == True:
        return "/ 캐릭터 상태 : 던져놓은 중"
    else:
        return "/ 캐릭터 상태 : 릴링중"
In [2]:
def play_sound():
    playsound.playsound("./sounds/wrong-answer-129254.mp3", block=True)
In [3]:
def find_position():
    global rand
    global jji_x, jji_y
    
    # 캐스팅중 아니면 리턴
    if get_status() != 'W':
        return 
    
    rand = random.randrange(-1,4)
    
    if rand == -1:
        rand = -150
        jji_x = h_width + 535
        jji_y = h_height - 201
    elif rand == 0:
        rand = 0
        jji_x = h_width + 601
        jji_y = h_height - 90
    elif rand == 1:
        rand = 150
        jji_x = h_width + 640
        jji_y = h_height + 42
    elif rand == 2:
        rand = 250
        jji_x = h_width + 642
        jji_y = h_height + 133
    elif rand == 3:
        rand = 350
        jji_x = h_width + 630
        jji_y = h_height + 210
        
    pag.moveTo(h_width + 700, h_height - 80 + rand)
    time.sleep(0.1)
    fishing_start()
In [4]:
def fishing_start():
    pag.mouseDown()
    time.sleep(1)
    pag.mouseUp()
    hook()
In [5]:
def hook():
    global jji_x, jji_y
    
    time.sleep(2)    
        
    hook_limit = 120
    
    start_time = time.time()        
    
    while True:
        end_time = time.time()
        
        elapsed_time = end_time - start_time
        
        if elapsed_time > 30:
            pag.leftClick()
            return
            
        
        if getPixelColorOne(jji_x, jji_y) < hook_limit:
            print(str(parse_dates(time.time())+"hook"))
            rolling()
            break
In [6]:
def rolling():
    pag.mouseDown()
    time.sleep(0.2)
    
    roll_limit = 600
    
    
    while True:    
        px=ImageGrab.grab((h_width-130, h_height+15, h_width+130, h_height+16)).load()        
        i = 0
        for i in range(260):
            color = px[i,0]
            c1, c2, c3 = color
            if int(c1)+int(c2)+int(c3) > roll_limit:
                if i <= 180:
                    pag.mouseDown()
                    
                if i > 180:
                    pag.mouseUp()
                
                break     
                
        
        if i==259:
            pag.mouseUp()
            pag.leftClick()
            print("fishing completed.")
            return
            
In [7]:
def getPixelColorOne(x1, y1):
    px=ImageGrab.grab((x1, y1, x1+1, y1+1)).load()
    color=px[0,0]   
    c1, c2, c3 = color
    return int(c1)
In [8]:
def getPixelColor(x1, y1):
    px=ImageGrab.grab((x1, y1, x1+1, y1+1)).load()
    color=px[0,0]   
    c1, c2, c3 = color
    
    return int(c1)+int(c3)
In [9]:
def get_status():
    global waiting, casting, fishing   
    global jji_x, jji_y
    
    if getPixelColorOne(jji_x, jji_y) > 150: # 찌가 있으면
        casting = True
        waiting = False
        fishing = False
        return 'R'
    else:
        rill_bar = getPixelColor(h_width-130, h_height+20)
        if rill_bar > 260 and rill_bar < 280 and getPixelColorOne(h_width-130, h_height+20) > 230: # 낚시 바 가 있으면
            casting = False
            waiting = False
            fishing = True
            return 'F'
        else:
            casting = False
            waiting = True
            fishing = False
            return 'W'
In [10]:
def food():
    time.sleep(2)
    keyboard.press('2')
    time.sleep(1)
In [11]:
def do_stuff():
    cnt = 0
    while True:
        stat = get_status()
        if pag.locateOnScreen("./albion/player.png", confidence = 0.76) is None : 
            if stat == 'W':
                find_position() #기다리는중이면 낚시 시작                
        else:
            print("someone is near by")
                
        time.sleep(2)
        
        
        
    
In [12]:
do_stuff()
728x90

+ Recent posts