Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AutoAFK2.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def emit(self, record):
bot.open_afk_stages(afkstages=False)
bot.blind_push("afkstages")

if args.fish:
bot.safe_open_and_close(
name=inspect.currentframe().f_code.co_name, state="open"
)
bot.fishing()

# If no function launch argument we pop the UI
options = [
"Run Dailies",
Expand Down
83 changes: 83 additions & 0 deletions automation/afkj_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2025,3 +2025,86 @@ def quest_push(self) -> None:
):
self.logger.info("Time changed!")
self.wait(4)

def fishing(self) -> None:
"""Farms the fishing.
An experimental feature for AutoAFK2. Currently not completely implemented.

The overall logic as follows:
1. **Open and choose a map**
1. click upper right corner to open map
2. click Starter Story
3. if found "check" button then click it. (character currently not in Starter Story maps)
4. swipe from left to right, homing the location of submaps
5. click the first submap
2. **Find fishing spot**
1. if found any available fishing spot then click it.
2. click "goto" button
3. wait until the "fishing_cast" button shows up. This means the character has arrived at the spot and start fishing.
3. **Fishing activity**
1. wait until "fishing_cast" or "fishing_pull" or "fishing_locked" buttons shows up then apply corresponding logic.
2. (see the fishing logic in following comments, which inspired by the so called "bang-bang control")
"""

self.logger.info("Farming fishing!\n")
self.click_xy(880, 200, seconds=3) # Open map
self.click_xy(400, 1800, seconds=3) # Select Starter Story
self.swipe(400, 1600, 1000, 1600, 500) # "Homing" sub-maps
self.click_xy(170, 1600, seconds=3) # Select first sub-map, TODO: add support for iterating through all sub-maps

# Find fishing spot
spot = self.is_visible_array(
["buttons/fishing_available_collected_spot", # 100% collected spots
"buttons/fishing_available_spot"], # Available spots
confidence=0.9,
seconds=3,
)

if spot != "not_found":
self.logger.info("Fishing spot found\n")
self.click(spot, confidence=0.9, seconds=3) # Click the spot
self.click("buttons/goto", seconds=3) # Click "goto" button

# Wait until the "fishing_cast" button shows up with limited patience and click it
for _ in range(20):
self.wait(1)
if self.is_visible("buttons/fishing_cast", confidence=0.9, seconds=0) or \
self.is_visible("buttons/fishing_pull", confidence=0.9, seconds=0):
break

# Fishing activity
while True:
if self.is_visible("buttons/fishing_cast", confidence=0.9, seconds=0, click=True):
self.logger.info("Fish caught!, cast again!\n")

elif self.is_visible("buttons/fishing_pull", confidence=0.9, seconds=0, click=True):
self.logger.info("Start fighting!\n")

# The following logic is inspired by the so called "bang-bang control"
while not self.is_visible("buttons/fishing_cast", confidence=0.9, seconds=0):
if self.is_visible("buttons/fishing_skill", confidence=0.9, seconds=0, click=True):
# cast the skill, this will be the major contributor under the fishing logic
pass
elif self.is_visible("buttons/fishing_in_range", confidence=0.9, seconds=0):
# do nothing, let the hook go left
pass
elif self.is_visible("buttons/fishing_cast", confidence=0.9, seconds=0):
self.logger.info("Fish caught!, cast again!\n")
break
else:
# TODO: press the "fishing_pull" button, move the hook righ until its in the "circle". (I'm not sure how to do "press" in the current framework)
pass
self.wait(1) # if there's any way to decrease the waiting time, it would be better (e.g. directly call `time.sleep()`)

elif self.is_visible("buttons/fishing_locked", confidence=0.9, seconds=0):
self.logger.info("Spot locked!\n")

else:
self.logger.info("Something went wrong!\n")

self.wait(1)

else:
self.logger.info("No fishing spots found\n")

self.logger.info("Fishing farmed!\n")
1 change: 1 addition & 0 deletions automation/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def parse_arguments() -> argparse.Namespace:
)
parser.add_argument("-afks", action="store_true", help="Run AFK Stages")
parser.add_argument("-afkt", action="store_true", help="Run AFK Talent Stages")
parser.add_argument("-fish", action="store_true", help="Run the Fishing farming")
parser.add_argument("-test", action="store_true", help="Used for testing functions")
parser.add_argument(
"-charms", action="store_true", help="Run the Dura's Trials function"
Expand Down
Binary file added img/buttons/fishing_available_collected_spot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/buttons/fishing_available_spot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/buttons/fishing_cast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/buttons/fishing_locked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/buttons/fishing_pull.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/buttons/fishing_skill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/buttons/fising_in_range.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/buttons/goto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.