Jump to content

Implementing CPU intencive algorithms


Recommended Posts

I am trying to write a aim bot for Combat Arms using Pixel processing.

By now you probably know what I will be talking about. AutoIt has only 3 functions related to Pixel processing (one of the most CPU intensive functions) one of them GetPixelColor can't be used to do for loops or anything else other then working with a single pixel because of overhead processing.

With a next release of the AutoIt there will be expanded possibilities for PixelSearch() that now can handle searching in different directions. that is very welcome addition!

One way or another I am (and probably a lot of other people) looking for the way to implement a PixelSearchPatch() that will search a given area in 4 possible directions but instead of a pixel will search a certain amount of pixels within the shade-variation. Like so:

PixelSearchPatch

--------------------------------------------------------------------------------

Searches a rectangle of pixels for the number of pixels of a color provided.

PixelSearchPatch ( left, top, right, bottom, color, pixels [, shade-variation [, step [, hwnd]]] )

Parameters

left - left coordinate of rectangle.

top - top coordinate of rectangle.

right - right coordinate of rectangle.

bottom - bottom coordinate of rectangle.

colour - Colour value of pixel to find (in decimal or hex).

pixels - amount of pixels of a given color located in a patch.

shade-variation [optional] A number between 0 and 255 to indicate the allowed number of shades of variation of the red, green, and blue components of the colour. Default is 0 (exact match).

step [optional] Instead of searching each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel. Default is 1.

hwnd [optional] Window handle to be used.

Return Value

Success: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)

Failure: Sets @error to 1 if color is not found.

Alsow PixelSearchClose()

That could search the for a pixel that is the closes to a given $X and $Y input withing a number of "pixels".

PixelSearchClose ( x, y, pixels, color, [, shade-variation [, step [, hwnd]]] )

Basically a search starting from he x and y and checking for similar colors around expanding pixel by pixel until "pixels" away from x and y was reached.

Edited by dexto
Link to comment
Share on other sites

I came out with a prototype of one of the functions in C++

how can i use it with Autoit?

int PixelSearchCloseBy(int x, int y, int squareSize, int color){

    int out[2]={-1,-1};
    int left, right, top, bottom, xx;
    HDC hdc = GetDC(HWND_DESKTOP);
    for(int i=1; i < squareSize/2; i++){

        left = x-i;
        right = x+i;
        top = y-i;
        bottom= y+i;
        for(xx=left;xx<right;xx++){//check top side of the squre

            if(GetPixel(hdc,xx,top)==color){out[0]=xx;out[1]=top;return out;}

        }
        for(xx=top;xx<bottom;xx++){//check right side

            if(GetPixel(hdc,right,xx)==color){out[0]=right;out[1]=xx;return out;}

        }
        for(xx=right;xx<left;xx--){//bottom side

            if(GetPixel(hdc,xx,bottom)==color){out[0]=xx;out[1]=bottom;return out;}

        }
        for(xx=bottom;xx<top;xx--){//left side

            if(GetPixel(hdc,left,xx)==color){out[0]=left;out[1]=xx;return out;}

        }

    }

}

Valik:

"Further, while the code is logically sound it uses GetPixel() rendering it useless. I would not be surprised at all if you (or at least somebody) can't write something in AutoIt faster than that. GetPixel() is horrible for repeated operations because it involves a tremendous amount of overhead per call.

Since you know C++ I suggest you write a DLL (optionally make it a plugin DLL). The API is undocumented but it is still there and people on the forum do know how to write plugins. You just need to start asking the right questions in the right place which is something you haven't done so far."

So i guess the question is what function is faster to use in C++ to get a color?

Edited by dexto
Link to comment
Share on other sites

http://www.autoitscript.com/forum/index.ph...4&hl=aimbot

there ya go. next time, ask for help instead of spazzing on the apparent inability of autoit to get something done. AutoIt is more than capable of doing aimbots, you just need to program it the right way. Brute force searching algorithms might be faster for whole screen searches, but intelligent heuristics make the script based solution faster, and force you to write the program in a rational and re-usable context.

Your behavior thus far is a prime example of why we don't like botters and game scripters around here. Most of us have nothing against botting or scripting games in practice, its just the script kiddies and slackers who pop in for a question, try to get other people to write scripts or complicated functions specific to their own needs, and then disappear.

http://www.autoitscript.com/forum/index.ph...hlite=%2Baimbot

Oh, and for God's sake. USE THE SEARCH FUNCTION.

Link to comment
Share on other sites

I came out with a prototype of one of the functions in C++

how can i use it with Autoit?

Valik:

"Further, while the code is logically sound it uses GetPixel() rendering it useless. I would not be surprised at all if you (or at least somebody) can't write something in AutoIt faster than that. GetPixel() is horrible for repeated operations because it involves a tremendous amount of overhead per call.

Since you know C++ I suggest you write a DLL (optionally make it a plugin DLL). The API is undocumented but it is still there and people on the forum do know how to write plugins. You just need to start asking the right questions in the right place which is something you haven't done so far."

So i guess the question is what function is faster to use in C++ to get a color?

You don't truly think that GetPixel is used to accomplish the PixelSearch don't you? Maybe this may get you farther: http://cboard.cprogramming.com/windows-pro...html#post846645

Link to comment
Share on other sites

  • Moderators

You don't truly think that GetPixel is used to accomplish the PixelSearch don't you? Maybe this may get you farther: http://cboard.cprogramming.com/windows-pro...html#post846645

GetPixel() was actually used before Valik changed it I believe.

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

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...