LostArk fishing Macro Complete (Fishing macro 3)

Now, if you just apply this post, you’ll be able to use the fishing macro. ! Let’s review it before entering. In the first hour, we got the mouse coordinates and stored them in init.txt along with the name of the fishing site. In the second hour, we learned how to detect exclamation points. This time, let’s take the code we developed in the previous post to the Keyboard and Mouse events so that it becomes automatic fishing.

 

First, open Pycharm as an administrator. 

And it creates init_config.py and lostark_fishing.py files. 

Then the folder structure will look like below. 

Project structure

1. Init.txt fix

Init.txt is a file that stores the variables needed to turn the fishing macro. 

If you’ve followed the post series to open the file and fix it, you’ll see the following on init.txt. 

[lostark_fishing]
width = 200
heght = 200

this part, type it just below as follows:

wait_time = 5
mark_image_name = LA_exclamation_mark.png
detect_cnt = 120

to wait until one fishing is done and another poke is thrown. (in seconds
) mark_image_name is the name of the exclamation point img file with a screenshot. detect_cnt is a routine that pokes and detects exclamation points, but how much you’re going to turn that routine, which can vary from monitor resolution to computer performance, but it’s likely to be 120 in Full HD.

Init.txt content

2. init_config.py coding

This file is no big deal. Just use Configparser to always pay the contents of a notepad as a Python variable. 

Enter the init_config.py file as shown below. 

import configparser
import os
configFile = os.path.dirname(os.path.realpath(__file__)) + '\\' + 'init.txt'
config = configparser.ConfigParser()
config.read(configFile)
FISHING_WIDTH = int(config['lostark_fishing']['width'])
FISHING_HEIGHT = int(config['lostark_fishing']['heght'])
FISHING_WAIT_TIME = int(config['lostark_fishing']['wait_time'])
FISHING_EXCLAMATION_MARK_IMG_NAME = config['lostark_fishing']['mark_image_name']
FISHING_EXCLAMATION_MARK_DETECT_CNT = int(config['lostark_fishing']['detect_cnt'])

 

We will use these fishing_~~ variables in lostark_fishing.py. So let’s write the code in the lostark_fishing.py file. 

3. Lostark_fishing.py

In this file, the actual fishing is done. 

The fishing_image.py, which i created in a previous post, is imported and is being used. And you can see that the findImgAndPressKey function raises key events through the PyAutoGui library. 

Let’s look at the input arguments for fishingLostArk. 

  • wait: As mentioned above, it’s time to wait for your next fishing after a successful fishing. 
  • setPos: If it is 0, you need to press F12 to specify a fishing point. If it is 1, use the information related to the fishing site stored in init.txt. 
  • FishingKey: This is the key to start steam fishing. In my case, it is ‘w’ and if you don’t type, it acts as a ‘w’. 

 

Enter the content below and try it out. 

import fishing_image as fi
import fishing_place as fp
import pyautogui as pa
import random
import time
from init_config import *
# - generate key event if image exist -
def findImgAndPressKey(imgName, key, startPos, cnt=60, confidence=.8, wait=0.1):
    posBtn = fi.findImageUntil(imgName, startPos=startPos, cnt=cnt, confidence=confidence, wait=wait)
    if posBtn == None:
        return False
    else:
        pa.press(key)
        return True
# - auto fishing main -
def fishingLostArk(wait, setPos = 1, fishingKey = 'w'):
    fishingFailCnt = 0
    posList = []
    # - set 3 point
    if setPos == 0:
        posList = fp.getMousePointWithKey(3)
    # -  get fishing place from init.txt
    else:
        posList = fp.getFishingPointList()
        print('point of init : ', str(posList))
    # - init_config.py 에서 저장한 값
    width = FISHING_WIDTH
    height = FISHING_HEIGHT
    
    while True:
        # - program exit if 20 fail -
        if fishingFailCnt > 20:
            print("Fishing Too Much Fail")
            return
        if len(posList) > 0:
            idx = random.randrange(0, len(posList))
            #idx = fising_cnt % 3
            pa.moveTo(posList[idx][0], posList[idx][1], 1)
        else:
            print("Can't get fishing point")
            return
        pa.press(fishingKey)
        time.sleep(1)
        # - region to check exmination mark
        region = fi.makeRegion(fi.getCenterOfScreen(), width, height)
        res = findImgAndPressKey(FISHING_EXCLAMATION_MARK_IMG_NAME, fishingKey, startPos=region, cnt=FISHING_EXCLAMATION_MARK_DETECT_CNT, confidence=0.8, wait=0.1)
        if res == True:
            print('Fishing Success')
            time.sleep(wait)
            if fishingFailCnt > 0:
                fishingFailCnt -= 1
        else:
            print('fishing Fail')
            fishingFailCnt += 1
            time.sleep(2)
        
if __name__=="__main__":
        fishingLostArk(FISHING_WAIT_TIME, setPos=1, fishingKey='w')

 

        

4. Test

The test was done at Silver Wave Lake. Note that it only works in full-screen mode. ~

If you run the code and switch jobs to the lost arc, the Pycharm result window will look like this: This is the content that turned setPos to zero. Set it to 1 and try it out! 

Fishing macro results screen

This completes the Lost Ark Chi Fishing Macro. 

The only inconvenience is that you have to run the macro and then select the lost arc to switch the work. 

Another problem is the team viewer. I use team viewers a lot. 

If the free version is disconnected, the team viewer pop-up window will pop up and obscure the center of the screen. And now we’re going to keep consuming the poke and the fishing is failing. 

The above problem can be solved by using a library called Pywinauto. 

In the next post, we’ll use this library to address the issues mentioned above. And let’s also post about the pain and the pitching. 

You may also like...