Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

Ask gaming related questions (AHK v1.1 and older)
Valesthesi
Posts: 4
Joined: 22 Oct 2015, 23:35

Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

22 Oct 2015, 23:52

Dragomon Hunter is in open beta currently and I'm trying to get some sort of fishing script to work. It is released by Aeria Games.

The way fishing works in this game, for the most part, is:

1 - Cast the line (only has to be done once)
2 - Press 'reel in' when you hook a fish. You can spam this button at all times and this part can basically be ignored.
3 - If you hook a larger fish, one of four images comes up on the screen. It will be a box, similar to that of a key on a keyboard, with W,A,S or D in the middle. You then have to spam whatever key that is.

So, what I need the script to do is:

1 - Spam a key at all times.
2 - Check to see if a box comes up, if it does, press the relevant key 10-20 times. The box is essentially always in the same spot, but that can change depending on how I approach the fishing area. It's generally always in the middle of the screen, though.
3 - Loop

Currently the best I can do is a script that psams both the base key and then I spam W, which gives me a 25% chance at catching a rare fish.

I'd love to get this working. I have tried a ton of ImageSearches currently and nothing seems to work. Anyone have any tips I might try to get this working? I don't really have any working code to paste for help, but I am trying to do something like:

Code: Select all

#SingleInstance Force
#NoEnv
SetWorkingDir, C:\Rotations
SendMode Input
CoordMode Pixel

$F8::
Loop
{
  ImageSearch FoundX, FoundY, 1148, 585, 1462, 770, fishingicon.bmp
  if ErrorLevel = 0
    {
    Send 0
    Sleep 50
    }
}
1148,585 is the top left and 1462,770 is the bottom right of the area I am searching. Fishingicon.bmp is in the right directory and it looks like what's below.

Image
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

23 Oct 2015, 03:32

Is it a fullscreen DirectX game? Than you probably need to run it in windowed mode before ImageSearch can see the pixels. The image you posted also contains some background scenery with probably will be different every time. Crop the image to contain only a small part of the button and the letter, say the size of your cursor.
Valesthesi
Posts: 4
Joined: 22 Oct 2015, 23:35

Re: Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

23 Oct 2015, 04:38

Nextron wrote:Is it a fullscreen DirectX game? Than you probably need to run it in windowed mode before ImageSearch can see the pixels. The image you posted also contains some background scenery with probably will be different every time. Crop the image to contain only a small part of the button and the letter, say the size of your cursor.
Thanks. Would the best bet to be just do a small portion of the top of the S or something? I need to do the same thing for W,A,S,D. It's also in windowed full screen mode but can move it to just windowed.

How accurate do the ImageSearch coordinates have to be? I mean, the spot this little area is going to be in is pretty big. Can I do a really small image like the one you suggested and search for it in a large area?
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

23 Oct 2015, 05:11

Cropping it to the top of the letter S sound fine, as long as it's something that's not present in the other letters. Windowed is fine, fullscreen or otherwise. The complete image you are searching for should exist in the area you define, so you'll need to consider the height and width of the image, but it may also be the entire screen. It's just the larger the search area is, the longer it will take to completely search it, so you'll want to try to be conservative.
grant
Posts: 323
Joined: 14 Oct 2015, 17:27

Re: Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

23 Oct 2015, 06:45

First thing, you should add the error codes to your program and have them pop up messages. It goes a long way to figuring out what your search is actually finding. Use mousemove to point to where the search is starting and ending, keep in mind that the mouse icon changes the image so move it away before searching. Have the mouse point to where the image was found if it was found, you might be surprised to see where it found what you were looking for and may be the reason for your difficulty.

Something to keep in mind when using imagesearch is the image itself. It can be annoying if you are trying to figure it out and, like me, do not realise that there is a difference in the image files I was making.
Take a snapshop of the screen and paste that into ms-paint
Then crop what you want to look for.
**If you save this now you will not find the image as the size is different or the quality is not the same or something, it just has never worked for me.
Now copy that croped portion onto your clipboard.
Create a new file and paste the clipboard there
Now save the image file.

You asked for an alternate so here it is...
You can also use pixelsearch and look for a pattern of colors that make up part of the letter to be spammed but with the letter not being in the same location each time that will be a challenge.

You might want to...
- Find a trigger that you can use to spam the default key. If you keep spamming a key forever, there is a decent chance that you will be flagged as potentially in violation of TOS if applicable.
- Use some delays with variations, humans are not as accurate as a program, nor as fast.
- If the "WASD" key is only there for a short time i.e. less than a second, you might want to work in a chance for a mistake. Make it a small chance of a mistake, as you are supposed to be human after all, unless the letter is there all the time, in which case you will look like a hamster doing this.
Valesthesi
Posts: 4
Joined: 22 Oct 2015, 23:35

Re: Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

23 Oct 2015, 13:17

Thanks for all the information. This is what I currently have.

Code: Select all

#NoEnv
#Persistent
SetKeyDelay, 50, 1000 ; Added a delay betwen key presses of 50 ms and keep each key pressed for 1000 ms
SetTimer, PressTheKey, 2000 ; run PressTheKey every 2 seconds (the press in SetKeyDelay is now 1 second)
SetWorkingDir, C:\Fishing
SendMode Input
CoordMode Pixel

PressTheKey:
Loop
{
  Send, {1}
  ImageSearch FoundX, FoundY, 1050, 475, 1500, 800, a.bmp
  if ErrorLevel = 0
    {
    Send, {A}
    MsgBox, Inside of A If	
    }
  ImageSearch FoundX, FoundY, 1050, 475, 1500, 800, s.bmp
  if ErrorLevel = 0
    {
    Send, {S}
    MsgBox, Inside of  SIf	
    }
  ImageSearch FoundX, FoundY, 1050, 475, 1500, 800, w.bmp
  if ErrorLevel = 0
    {
    Send, {W}
    MsgBox, Inside of W If	
    }
  ImageSearch FoundX, FoundY, 1050, 475, 1500, 800, d.bmp
  if ErrorLevel = 0
    {
    Send, {D}
    MsgBox, Inside of D If	
    1}
}
Some things to note:

I'm 99% sure that my coordinates are right. My file names are right and my directory is right. I am not sure what ErrorLevel is, but without it goes nuts and spasm me with MsgBoxs. Also... I am having problems with sends again. I have the following script that works to send inputs but the above doesn't.

Code: Select all

#Persistent
SetKeyDelay, 50, 1000 ; Added a delay betwen key presses of 50 ms and keep each key pressed for 1000 ms
SetTimer, PressTheKey, 2000 ; run PressTheKey every 2 seconds (the press in SetKeyDelay is now 1 second)
Return

PressTheKey:
  SoundBeep, 500, 500 ; Just to be sure this works, you should hear a beep every two seconds.
  Send, {1}
Return
grant
Posts: 323
Joined: 14 Oct 2015, 17:27

Re: Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

03 Nov 2015, 03:20

Ok, so you are not doing what you wanted in your description.

If you find nothing you are sending : 11111...
if you find d, you are sending: 1d1d1d1d1...

NOT TESTED!

Code: Select all

#NoEnv
#Persistent
SetKeyDelay, 50, 1000 ; Added a delay betwen key presses of 50 ms and keep each key pressed for 1000 ms
SetTimer, PressTheKey, 2000 ; run PressTheKey every 2 seconds (the press in SetKeyDelay is now 1 second)
SetWorkingDir, C:\Fishing
SendMode Input
CoordMode Pixel
 
PressTheKey:
Loop
{
ImageSearch FoundX, FoundY, 1050, 475, 1500, 800, a.bmp		;look for the "a.bmp" image

													;checking for error level 2
if ErrorLevel = 2
	{
	MsgBox Could not conduct your search, your filename "a.bmp" does not egsist ... exiting the program
	exitapp
	}

;We do not want to check for error level 1 because we expect not to find the image most of the time.

													;If the image is found we do this bit
if ErrorLevel = 0
	{							
	Send, a
	continue											;Skip the rest of the loop and start a new iteration
	}



ImageSearch FoundX, FoundY, 1050, 475, 1500, 800, s.bmp			;look for the "s.bmp" image

													;checking for error level 2
if ErrorLevel = 2
	{
	MsgBox Could not conduct your search, your filename "s.bmp" does not egsist ... exiting the program
	exitapp
	}

													;If the image is found we do this bit
if ErrorLevel = 0
	{
	Send, s
	continue											;Skip the rest of the loop and start a new iteration
	}



ImageSearch FoundX, FoundY, 1050, 475, 1500, 800, w.bmp		;look for the "w.bmp" image

													;checking for error level 2
if ErrorLevel = 2
	{
	MsgBox Could not conduct your search, your filename "w.bmp" does not egsist ... exiting the program
	exitapp
	}

													;If the image is found we do this bit
if ErrorLevel = 0
	{
	Send, w
	continue											;Skip the rest of the loop and start a new iteration
	}



ImageSearch FoundX, FoundY, 1050, 475, 1500, 800, d.bmp		;look for the "d.bmp" image

													;checking for error level 2
if ErrorLevel = 2
	{
	MsgBox Could not conduct your search, your filename "d.bmp" does not egsist ... exiting the program
	exitapp
	}

													;If the image is found we do this bit
if ErrorLevel = 0
	{
	Send, d
	continue											;Skip the rest of the loop and start a new iteration
	}

send, 1												;If we get here, we have searched for "a", "s", "w" and "d" and not found any of them so we hit "1" and start the loop again.
}

esc::exitapp											;Press escape to exit.

I have no idea why my comments are all over the place. Looks yuk, sorry.
Your next steps are to add some random timers so that your program does not look like a bot.
Ehysier
Posts: 1
Joined: 10 Nov 2015, 05:58

Re: Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

10 Nov 2015, 06:00

Now, how would I go about making this scan 10 different locations? with a specific one needing to have the key pressed 10 times, while the others only once?
grant
Posts: 323
Joined: 14 Oct 2015, 17:27

Re: Help with ImageSearch (or an Alternative) for a new game (Dragomon Hunter)

10 Nov 2015, 06:28

I assume that you are looking for the same images adn they are always going to be at the same location?

If this is the case you can:
loop
find image
if foundx == xa && foundy == ya - spam key 10 times
else hit key only once
if not found - continue

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 158 guests