Skip to content

Commit

Permalink
Add logic for Arcarum adjustments to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
steve1316 committed Feb 1, 2022
1 parent 036bf14 commit 24bc805
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src-tauri/backend/bot/game_modes/arcarum.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _choose_action() -> str:
MessageLog.print_message(f"\n[ARCARUM] Now determining what action to take...")

# Wait a second in case the "Do or Die" animation plays.
Game.wait(1)
Game.wait(2.0)

tries = 3
while tries > 0:
Expand All @@ -100,22 +100,22 @@ def _choose_action() -> str:

Game.check_for_captcha()

if ImageUtils.confirm_location("arcarum_party_selection", tries = 3):
if ImageUtils.confirm_location("arcarum_party_selection", tries = 3, bypass_general_adjustment = True):
return "Combat"
elif Game.find_and_click_button("ok", tries = 3):
elif Game.find_and_click_button("ok", tries = 3, bypass_general_adjustment = True):
return "Claimed Treasure/Keythorn"
else:
return "Claimed Spirethorn/No Action"

# Clear any detected Treasure popup after claiming a chest.
MessageLog.print_message(f"[ARCARUM] No action found for the current node. Looking for Treasure popup...")
if ImageUtils.confirm_location("arcarum_treasure", tries = 3):
if ImageUtils.confirm_location("arcarum_treasure", tries = 3, bypass_general_adjustment = True):
Game.find_and_click_button("ok")
return "Claimed Treasure"

# Next, determine if there is a available node to move to. Any bound monsters should have been destroyed by now.
MessageLog.print_message(f"[ARCARUM] No Treasure popup detected. Looking for an available node to move to...")
if Game.find_and_click_button("arcarum_node", tries = 3):
if Game.find_and_click_button("arcarum_node", tries = 3, bypass_general_adjustment = True):
Game.wait(1)
return "Navigating"

Expand All @@ -125,13 +125,14 @@ def _choose_action() -> str:

# Next, attempt to navigate to a node that is occupied by mob(s).
MessageLog.print_message(f"[ARCARUM] No available node to move to. Looking for nodes with mobs on them...")
if Game.find_and_click_button("arcarum_mob", tries = 3) or Game.find_and_click_button("arcarum_red_mob", tries = 3):
if Game.find_and_click_button("arcarum_mob", tries = 3, bypass_general_adjustment = True) or Game.find_and_click_button("arcarum_red_mob", tries = 3, bypass_general_adjustment = True):
Game.wait(1)
return "Navigating"

# If all else fails, see if there are any unclaimed chests, like the ones spawned by a random special event that spawns chests on all nodes.
MessageLog.print_message(f"[ARCARUM] No nodes with mobs on them. Looking for nodes with chests on them...")
if Game.find_and_click_button("arcarum_silver_chest", tries = 3) or Game.find_and_click_button("arcarum_gold_chest", tries = 3):
if Game.find_and_click_button("arcarum_silver_chest", tries = 3, bypass_general_adjustment = True) or \
Game.find_and_click_button("arcarum_gold_chest", tries = 3, bypass_general_adjustment = True):
Game.wait(1)
return "Navigating"

Expand All @@ -150,7 +151,7 @@ def _check_for_boss() -> bool:
if Settings.enable_stop_on_arcarum_boss:
MessageLog.print_message(f"\n[ARCARUM] Checking if boss is available...")

if ImageUtils.find_button("arcarum_boss", tries = 3) or ImageUtils.find_button("arcarum_boss2", tries = 3):
if ImageUtils.find_button("arcarum_boss", tries = 3, bypass_general_adjustment = True) or ImageUtils.find_button("arcarum_boss2", tries = 3, bypass_general_adjustment = True):
return True
else:
return False
Expand Down Expand Up @@ -206,6 +207,4 @@ def start() -> int:
MessageLog.print_message(f"[ARCARUM] Boss has been detected. Stopping the bot.")
raise ArcarumException("Boss has been detected. Stopping the bot.")

Game.wait(1)

return runs_completed
3 changes: 3 additions & 0 deletions src-tauri/backend/utils/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def _determine_adjustment(image_name: str) -> int:
dialog_list = ["dialog_lyria", "dialog_vyrn"]
skill_usage_list = ["use_skill", "skill_unusable"]
summon_usage_list = ["summon_details", "quick_summon1", "quick_summon2"]
arcarum_list = ["arcarum_party_selection", "arcarum_treasure", "arcarum_node", "arcarum_mob", "arcarum_red_mob", "arcarum_silver_chest", "arcarum_gold_chest", "arcarum_boss", "arcarum_boss2"]

if Settings.enable_calibration_adjustment and calibration_list.__contains__(image_name):
return Settings.adjust_calibration
Expand All @@ -238,6 +239,8 @@ def _determine_adjustment(image_name: str) -> int:
return Settings.adjust_skill_usage
elif Settings.enable_combat_mode_adjustment and summon_usage_list.__contains__(image_name):
return Settings.adjust_summon_usage
elif Settings.enable_arcarum_adjustment and arcarum_list.__contains__(image_name):
return Settings.adjust_arcarum
else:
return 0

Expand Down
2 changes: 2 additions & 0 deletions src-tauri/backend/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class Settings:
adjust_summon_usage: int = _data["adjustment"]["adjustSummonUsage"]
adjust_waiting_for_reload: int = _data["adjustment"]["adjustWaitingForReload"]
adjust_waiting_for_attack: int = _data["adjustment"]["adjustWaitingForAttack"]
enable_arcarum_adjustment: bool = _data["adjustment"]["enableArcarumAdjustment"]
adjust_arcarum: int = _data["adjustment"]["adjustArcarum"]
# #### end of adjustment ####
# ################## end of settings.json ###################
#############################################################
Expand Down

0 comments on commit 24bc805

Please sign in to comment.