Sign in to follow this  
Followers 0
CodeMaster Rapture

Advanced Pixel Search Method, Need help, Thanx.

6 posts in this topic

Hello,

I'm not an advanced user of AutoIt, but I turn to it to test certain things in the games I write. So, now I have a new script I want to write to test an in-game function.

Here is the situation:

In my game, a player can play a mini-game that requires them to watch the screen for a specific event and then right-click on it. I've made it easy on the players by giving them an object to watch which has a background sprite that goes off randomly within 30 seconds. The object appears randomly within the middle pixels of the screen, so for example, on resolution 1024x768, the object appears somewhere inside 512x512.

The object (a ball) is about 30x30 pixels in size and has a specific color pattern that is constant. Also, the sprite (background animation) of the ball has a constant color and effect.

What I'm trying to accomplish is to use AutoIt to search for:

The ball

Make sure the cursor has changed (an off-yellow Circle about 10x10 pixels)

And then do a repeating pixel search within a 40x40 pixel area of the ball.

This leads to another problem. Since I didn't do the artwork for it, nor am I gifted in the digital arts, I cannot figure out to find the hex numbers for the colors on the ball. I know the animation color is an off-white, so I was able to guesstimate and I got lucky. It finds it everytime.

My original design of AutoIt was to just search the entire area (512x512) for the sprite color every half second or so. It works fine, but it is a real hog on CPU usage. Since I like to keep things simple, I think my new way of searching will be less CPU hungry.

Also, another requirement of the game is to right click the ball within a second of the animation going off and again to confirm (same area). This hasn't been a problem with the script because it searches the whole area over and over (hence it being a CPU hog).

Finally, how do I figure out the color of something on the screen?

Here is the code I have currently that just loops a pixelsearch on the whole area in question (640x512):

$found = 0

While 1 
  If $found = 0 then
    $found = 1
    MouseClick("right", 500, 500, 1, 2)
               ;The above code just clicks to start the game
  EndIf

  MouseMove(500, 500) 
  $start = TimerInit() 
  $dif = TimerDiff($start) 
  While 1 
    If $time = 6 Then 
      $coord = PixelSearch (300, 400, 1024, 850, 0xF6F6F6, 30, 4) 
    Else 
      $coord = PixelSearch (300, 400, 1024, 850, 0xEEEEEE, 55, 3) 
    EndIf 

    If UBound($coord)>1 Then 
      MouseClick("right", $coord[0], $coord[1], 1, 3) 
      Sleep(1000) 
      MouseClick("right", $coord[0], $coord[1], 1, 3) 

      ExitLoop 
    Else 
      Sleep(250) 
      $dif = TimerDiff($start) 
      If $dif > 30000 Then 
    $found = 0
        ExitLoop 
      EndIf 
    EndIf 
  WEnd 
WEnd

Also, since I don't really understand the PixelSearch Function, I assume the syntax is something like so: PixelSearch (X,Y,X2,Y2,color,shades) where X and Y are the topleft and X2 and Y2 are the bottom right. Please inform me if I am correct on this.

Thank you for your time.

Share this post


Link to post
Share on other sites



One more thing I forgot to add:

There is a fade effect on the previous ball (it fades away after being clicked). So, I also need to be able to skip the pixelsearch on the previous ball location.

Yes, I know, I made it very hard to make a script for this game, but I know it can be done :)

Share this post


Link to post
Share on other sites

World of Warcraft fish bot?


I AM ORCA!! A VERY POWERFUL WHALE!!!

Share this post


Link to post
Share on other sites

Just asuming this is what your doing, because every detail you give falls into fishing in WoW. Have the mouse scan (move accross the screen) When the mouse hits the bobber a 'tooltip' pops up a fixed location (w/o ui mods) check that area for the yellow hex pixle....

I thought of dabling w/ checksums, but never got round to it. I'm working on my own fisher with fish detection and custom looting :) it's working great so far :-D


I AM ORCA!! A VERY POWERFUL WHALE!!!

Share this post


Link to post
Share on other sites

No... not really...

Similar principle though. I wish I had the time to play WoW. But I got the idea off of WoW after wathcing my friend "fish" while we hung out :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok, I've got a good start going, just need to know the best approach to the cursor change on the hover event (MouseMove) and also clarification of PixelSearch would be greatly appreciated.

Edited by CodeMaster Rapture

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0