Jump to content

Pixelsearch For Games


Recommended Posts

I want to make a script that will play a game for me. The game is "defend your castle" by XgenStudios, so, to play the game, you have got to click the little black/grey stick figures and throw them into the air with your mouse, I think i'm gonna need to use pixelsearch, but then may look too similar for that to work

However, my problem, is that the types of units vary, most of the time, its just normal stick figures but some have big pieces of wood (like a battering weapon), others are to big to grab and throw, and need to be killed with a special ability, and some are the terroriststs that are all black and explode when clicked

so how can i have AutoIt detect the difference in enemy units and react accordingly or make it available for me to act accordingly?

Link to comment
Share on other sites

  • Moderators

Maybe do a PixelCheckSum() of each individual character, store them in variables or an array and if it matches do whatever you need to do for that specifically?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

in a while/wend loop use different pixelsearchs for the correct "intruders" color and react accordingly

one use could be

MouseClickDrag()

to throw the intruders

8)

Thats what i was thinking, but how would i go about killing the bigger ones that can't be grabbed/thrown, they look the same as the normal ones, except bigger, and with a face.

And how could i set it up to run like 2-3 Pixelearches At once, ad how culd I make the mouse realse at te right time to effectively throw "intruders" high enough to kill them (if you throw them to little, then they don't die)

Link to comment
Share on other sites

  • Moderators

Thats what i was thinking, but how would i go about killing the bigger ones that can't be grabbed/thrown, they look the same as the normal ones, except bigger, and with a face.

And how could i set it up to run like 2-3 Pixelearches At once, ad how culd I make the mouse realse at te right time to effectively throw "intruders" high enough to kill them (if you throw them to little, then they don't die)

Trial and error?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

1

the bigger ones... check for a "face" color

2

How far to throw them... set the MouseClickDrag to the edge of the screen

see help for use

3

while 1

if pixelseach() = $color1 then
;do this
endif

if pixelseach() = $color2 then
;do this
endif

if pixelseach() = $color3 then
;do this
endif

Wend

8)

NEWHeader1.png

Link to comment
Share on other sites

Okay, now i have an idea, maybe i could get a script that just auto put my crsor on tem, and i threm them into te air, thatwould require a pixel seach for a color in like a 15 pixel area aroun my mouse, but how can i have the pixelsearch move with my mouse?

Link to comment
Share on other sites

Interesting,

Running multiple PixelSearch()'s is pretty easy. If you recall from the help files, PixelSearch() returns a two dimensional array (X and Y coords) where it found your color. So, you can just doing something like this:

;SearchA
$SearchA = PixelSearch(100,100, 150,150, 0xFF0000,10,1)
$SearchAError = @error

;SearchB
$SearchB = PixelSearch(200,200, 250,250, 0x00FF00,10,1)
$SearchBError = @error

;SearchC
$SearchC = PixelSearch(300,300, 350,350, 0x0000FF,10,1)
$SearchCError = @error

By doing this, you can call on each one seperately within the loop. Also, the search variable will become your coords for where it found the colors. Also, by saving the error state, we can tell if the search found your color at all. Let's take SearchA for example.

The variable $SearchA will become $SearchA[0] (X coord) and $SearchA[1] (Y coord) assuming $SearchAError is 0 (zero). So, to use this we do something like this:

If (Not $SearchAError) Then
    MouseClickDrag($SearchA[0],$SearchA[1], $SearchA[0]+100,$SearchA[1]+100)
EndIf

If (Not $SearchBError) Then
    MouseClickDrag($SearchB[0],$SearchB[1], $SearchB[0]+200,$SearchB[1]+200)
EndIf   

If (Not $SearchCError) Then
    MouseClickDrag($SearchC[0],$SearchC[1], $SearchC[0]+300,$SearchC[1]+300)
EndIf

Now, the problem you are going to face is object recognition. Doing a PixelSearch will find the first pixel of a said color within the area you search, but it may not be what you are looking for. So you may need to compare the pixels around PixelSearch aswell (PixelGetColor is a good function for this). If the background of the object is always the same (which is highly unlikely), then you can do a PixelChecksum instead to simplify your code.

I would continue on, but I must get to work :think:.

Best of luck,

CMR

Link to comment
Share on other sites

If you look at the aimbot example in my signature, the "Snap-To" and "Snap-To/Autoshoot" pixelsearches an area around your mose.

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...