Skip to content

Navigation Menu

Sign in
Sign up
This repository was archived by the owner on Jul 2, 2023. It is now read-only.

✔️ Faster oakInn() #73

kevingrillet started this conversation in Ideas
Discussion options

I was looking at the forks of the repo when I saw this one: https://github.com/Fortigate/AFK-Daily/blob/master/deploy.sh

Original
# Collects Inn gifts
function collectInnGifts() {
 echo $CYAN"Attempting to collect gifts from the Inn."$NC
 #Click on the Inn whale
 input tap 800 290
 sleep 5
 CLICKS=0
 LOCATION=250
 let "LAUNCHTIMER=LAUNCHTIMER+1"
 # We click from left to right over the gift area to attempt to get them
 while [ $CLICKS -lt 20 ]; do
 input tap $LOCATION 1330
 sleep 0.25
 input tap 550 1400
 let "LOCATION=LOCATION+20"
 let "CLICKS=CLICKS+1"
 sleep 0.25
 done
 #Back arrow to exit 1 shop
 input tap 70 1810
 wait
 verifyRGB 1050 1800 493018 $GREEN"Inn gift collection attempted successfully."$NC
 echo
}

I think it could be updated to be secure and quite fast:

  • 1 screenshot per scan
  • look at each position from 250 to 650 with a step of 5/10
  • adding a control over the color to be certain to click on a chest (with high delta)
  • restart the row until 3 chests found
  • with maximum of 20 tries

Something like:

# ##############################################################################
# Function Name : oakInnSpeedy
# Descripton : Collect Oak Inn faster than oakInn()
# ##############################################################################
oakInnSpeedy() {
 if [ "$DEBUG" -ge 4 ]; then echo "[DEBUG] oakInn" >&2; fi
 inputTapSleep 780 270 5 # Oak Inn
 _oakInn_COUNT=0
 _oakInn_COLLECTED=0
 until [ "$_oakInn_COLLECTED" -ge "$totalAmountOakRewards" ] || [ "$_oakInn_COUNT" -ge 20 ]; do
 _oakInn_ROW_COUNT=0
 screenshotRequired=true
 until [ "$_oakInn_ROW_COUNT" -ge 100 ]; do
 if testColorOR -d 3 $((250 + _oakInn_ROW_COUNT * 5)) 1330 9b3e28 932017 e7af65 8d2911 ffd885; then
 inputTapSleep $((250 + _oakInn_ROW_COUNT * 5)) 1330 .5 # Tap present
 inputTapSleep 540 1650 1 # Ok
 inputTapSleep 540 1650 .5 # Collect reward
 _oakInn_COLLECTED=$((_oakInn_COLLECTED + 1)) # Increment
 break
 fi
 _oakInn_ROW_COUNT=$((_oakInn_ROW_COUNT + 1)) # Increment
 done
 _oakInn_COUNT=$((_oakInn_COUNT + 1)) # Increment
 done
 inputTapSleep 70 1810 0
 wait
 verifyHEX 20 1775 d49a61 "Attempted to collect Oak Inn presents." "Failed to collect Oak Inn presents."
}

(削除) Need to replace 000000 with the color of a chest (削除ここまで)

I did put more colors to lower the delta, doing my testing at the same time it's hard for me to know if it's working well 😅

You can test it easily by adding the function before tests and calling it like so:

tests() {
 # ./deploy.sh with AFK arena waiting in Ranhorn
 DEBUG=9
 oakInnSpeedy
 exit
}
# Run test functions
tests
You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

True, testing can be quite the pain now that I think about it! 😄

I'll give this a try later today as well and let you know if I find something useful!

You must be logged in to vote
2 replies
Comment options

kevingrillet Jun 9, 2021
Collaborator Author

It's in the PR, secured by the old method after the new one.

Comment options

Oh, I didn't realise that and still copy-pasted your code. Either way, it worked! If I understand this correctly, you take one screenshot and analyse a bunch of places where presents could be, and if none are found another screenshot is taken and the cycle repeats, right? And you do this a maximum of 20 times.

I like it! It worked pretty well on my machine, found all three presents in a matter of seconds. Pretty amazing stuff, I didn't think it'd be this fast and reliable. Definitely a must for our new PR! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /