Need assistance Improving and Optimizing a script to Automate a Browser Game

Ask gaming related questions (AHK v1.1 and older)
Drknyss
Posts: 14
Joined: 21 Jan 2022, 16:32

Need assistance Improving and Optimizing a script to Automate a Browser Game

Post by Drknyss » 22 Jan 2022, 08:19

Greetings,

I'm new to this.. so please forgive my not great code and issues. I'm working on a fishing script for a game called FarmRPG and need some help perfecting it and optimizing it. I'll try to provide plenty of info and details below.

Explanation of Fishing:
There is a graphic of water where an image of a fish fades in and out at random places among the water. The areas sometimes have different shades for the water, thus resulting in slight differences in the color of the fish overall (Its subtle.. but in trying to code this I've noted differences because I can't seem to get a consistent bot across them. After clicking on the fish a slider rises from the bottom of the screen with a blue dot that randomly moves back and forth. Speed of the movement varies and gets faster the more difficult the fishing becomes. Each attempt at fishing uses one bait whether you catch a fish or not.

My Code Process:
Ive setup my code where you input the bait you have, Press F1 to select the Top Left of the Fishing Area, Followed by a second F1 press in the bottom right to rectangle out the actual fishing area. Then the code scans for the Fish and left clicks when it sees it. Then scans for the blue button and clicks it when it sees it. Then adds a count to the number of fish caught. The Script terminates when you press F2, or if your fish caught matches the bait you wanted to use.

Since the slider for catching the fish rises from the bottom of the screen, I enlarge the browser window so that it comes up inside the area that I have selected for my rectangle using F1 above so that it looks for it in the same area.

Here is what I have so far:

Code: Select all

xpos1=
xpos2=
SetMouseDelay,-1
SetBatchLines, -1
Process, Priority,, High

InputBox, howmuchbait, Bait Amount,How much bait to use?, ; Input Amount of Bait to Use
tooltip, Put mouse in top left corner of pond and press F1
Return
f1::
If xpos1 =  
	{
	MouseGetPos, xpos1, ypos1
	tooltip, Put mouse in bottom right corner of pond and press F1
	Return
	}
If xpos2 =  
	{
	MouseGetPos, xpos2, ypos2
	}
tooltip, fishing will begin in 3 seconds. Press F2 to end early
sleep 3000
tooltip
loop{
	sleep 500
	PixelSearch, Px, Py, %xpos1%, %ypos1%, %xpos2%, %ypos2%, 0x50452F, 7, Fast ; Find Fish
	if ErrorLevel	
		{
		}
	else	
		{
		MouseClick, left, %Px%, %Py% ; Click on Fish
		sleep 300
		PixelSearch, Px, Py, %xpos1%, %ypos1%, %xpos2%, %ypos2%, 0xFF0000, 7, Fast ; Find Blue Button
		Py:=Py+15
		MouseClick, left, %Px%, %Py% ; Click on Blue Button
		sleep 1000
		fishcount++	; Increase Fish Count
		if fishcount = %howmuchbait%	; End Fishing if Fishcount = Bait Wanted to Use
			{
			break
			}
		}
	}	
	
f2::
Msgbox, I got you %fishcount% fish ; Display number of fish caught
reload	;exitapp
Here are the issues that I have run into:
1. Due to what I assume are suble differences in the color of the fish because of the water graphic, I am unable to consistently get a click 100% of the time on the fish itself. I also have issues with it consistently detecting the fish every time it appears on the same area. I don't know if its how quickly the fish fades in and out or if it is that there a slight color differences across the different areas of the water.
2. Due to the speed increase of the blue dot I have been unable to get something that can reliably click it at later levels.
3. My Fishing counter also seems to be inaccurate.. as the amount of fish caught often does not equal the amount of bait used.. It usually counts up more quickly than the usage of bait.

Images of Each Level
https://imgur.com/a/Ueqa5rR
I tried to screenshot a point when the fish was visible.. Since it fades in from 0 Opacity to whatever the max is then back to 0 the opacity levels are all different of course.. but This kinda shows how the color shifts a little for each background. Especially the lava area.

Video of Level 1 being farmed with Bot:
https://imgur.com/l0fYbxE
Note How the bot just doesn't detect the fish all the time.

Video of Bot on Level 9:

https://imgur.com/QTevKA3
Note How bot does not detect fish at all. Also shows example of speed of Blue dot at the end of the video.

If anyone is willing to help with this it will be greatly appreciated. I can provide any more info if necessary. Thanks in advance!

User avatar
boiler
Posts: 16915
Joined: 21 Dec 2014, 02:44

Re: Need assistance Improving and Optimizing a script to Automate a Browser Game

Post by boiler » 22 Jan 2022, 08:59

Please don’t create multiple threads asking the same thing. If no one has answered after a day or so has passed, you can bump your original thread.

Ref: original thread

gregster
Posts: 9000
Joined: 30 Sep 2013, 06:48

Re: Need assistance Improving and Optimizing a script to Automate a Browser Game

Post by gregster » 22 Jan 2022, 10:07

Topic locked.

Locked

Return to “Gaming Help (v1)”