Code:
#include "ScanContents.h"
bool TakeScreenshot(std::string WindowToFind, BITMAP &bm, HBITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot, HBITMAP &hBitmapOld, HWND &hwnd);
void SetupBitmapInfo(BITMAPINFO &bmi, int bWidth, int bHeight, int bitsPerPixel);
bool CompareColour(RGBQUAD *pPixels, int height, int width, int x, int y);
void ScanBMPHorizontal(ScanContents * scan);
//add after BASIC CONCEPT
bool Aim_BotThr(AimbotThr * aimThr1);
//heres our global mouse XY that remembers where the mouse last was
//-----
MouseCoord CurrentMouseXY(0, 0);
bool CompareColour(RGBQUAD *pPixels, int height, int width, int x, int y)
{
int p = (height-y-1)*width+x; // upside down
//int r = (int)pPixels[p].rgbRed;
//int g = (int)pPixels[p].rgbGreen;
//int b = (int)pPixels[p].rgbBlue;
//std::cout << (int)pPixels[p].rgbRed << ", " << (int)pPixels[p].rgbGreen << ", " << (int)pPixels[p].rgbBlue << std::endl;
//SetCursorPos(x, y);
//PINK
//CSS BLUE
if((int)pPixels[p].rgbRed < 30 && (int)pPixels[p].rgbGreen < 30 && (int)pPixels[p].rgbBlue > 215)
//css red
//if((int)pPixels[p].rgbRed > 215 && (int)pPixels[p].rgbGreen < 30 && (int)pPixels[p].rgbBlue < 30)
{
//std::cout << "FOUND PINK" << std::endl;
//system("PAUSE");
//std::cout << r << ", " << g << ", " << b << std::endl;
//std::cout << "Found color" << std::endl;
return true;
}
//else std::cout << "NOT FOUND PINK" << std::endl;
if(GetAsyncKeyState(VK_ESCAPE))
{
exit(0);
}
return false;
}
void ShootBot(int x, int y)
{
mouse_event(MOUSEEVENTF_LEFTDOWN,x, y,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,x, y,0,0);
}
//OUR MAIN SCANNER LOOP
void ScanBMPHorizontal(ScanContents * scan)
{
int startedInScanTime = clock();
//scan until it reaches the limits/bounds of the game window
//THIS CAN BE DIVIDED BY ANY NUMBER, 5 WAS JUST THE CHOICE THAT FELT RIGHT FOR ME, E.G. DOESNT SCAN TOO MUCH OF THE SCREEN. Lower numbers cover
//more of the game
//Just like well do below with the X, here we start scanning at about 1/4 of the screen, this allows us to scan the screen much faster
//and makes our aimbot much more efficient
for(int y = (scan->RcWindow.bottom - scan->RcWindow.top)/4;
y < ((scan->RcWindow.bottom - scan->RcWindow.top)-(scan->RcWindow.bottom - scan->RcWindow.top)/3.5);
y++)
//for(scan->Y = scan->StartingY-((int)(scan->RcWindow.bottom - scan->RcWindow.top)/5)/*GET'S THE WINDOW'S HEIGHT/5*/; scan->Y < scan->StartingY + ((int)(scan->RcWindow.bottom - scan->RcWindow.top)/5); scan->Y+=3)
{
//SetCursorPos(scan->X, scan->Y);
//3 because we are checking RGB every time
//ONLY SCAN about 2-3/4 of the screen, this way scans are much faster and we have much more control over the aimbot
//WE START X at about 1/4 of the screen and stop at 3/4, this way it can work at any window resolution
for(int x = (int)((scan->RcWindow.right - scan->RcWindow.left)/4)/*+15*/;
x < (int)((scan->RcWindow.right - scan->RcWindow.left)-(scan->RcWindow.right - scan->RcWindow.left)/4);
x ++)
{
//SetCursorPos(scan->X+scan->RcWindow.left, scan->Y+scan->RcWindow.top);
//Sleep(1);
//CHECK IF OUR CHOSEN COLOUR = TRUE
if(CompareColour(scan->PPixels, scan->Bm.bmHeight, scan->Bm.bmWidth, x, y))
{
int z = x;
//the width - itself/2
while(z < (int)((scan->RcWindow.right - scan->RcWindow.left)-(scan->RcWindow.right - scan->RcWindow.left)/4))
{
//comment this after
//SetCursorPos(z, scan->Y);
//search until our color is not the same and then DEFINE A CENTER POINT from the point found
//within the for loop(POINT 1 = scan->X to POINT 2 = z (Center = z - (z - scan->X)/2))
//the pixel between point 2 and point 1
if(!CompareColour(scan->PPixels, scan->Bm.bmHeight, scan->Bm.bmWidth, z, y))
{
break;
}
z++; //COULD ALSO BE 3, 2 is used because i am looking for the exact center point of the first and last pixel
}
//MouseCoord coord((z -( z - scan->X)/2)+scan->RcWindow.left means position CURSOR ON CENTER PIXEL(BETWEEN 1st and last), scan->Y+scan->RcWindow.top);
//4 IS A PERSONAL CHOICE, THIS MEANS AIM 4 pixels below where the top found pixel is
//that is usually the head, so i prefer to give a shot square in the face
//as the normal shot may skim the top of the head and miss
//this way there could be problems with the array, but not with our design
SetCursorPos((z -( z - x)/2)+scan->RcWindow.left, (y+4)+scan->RcWindow.top);
//Sleep(85);
//SmoothMouseMovement((z -( z - x)/2)+scan->RcWindow.left, y+scan->RcWindow.top);
//system("pause");
//SHOOT AT THE EXACT CENTER POINT of the color
//ADD AFTER BASIC CONCEPT
//GET OUR CURRENT MOUSE POSITION AND COMPARE TO PREVIOUS
POINT currentPos;
GetCursorPos(¤tPos);
//~ more or less in the same place as the last position therefor we shoot
//this tells us that the mouse didnt have to move much and is VERY CLOSE to
//our target, this stops us from shooting during aiming. Forcing us to conserve
//ammo and increasing accuracy 60% of the time works every time
//+ X is just a personal choice, this means if its within X pixels of the last scan then shoot
//just checking if the mouse is within a nice range
//2 IS A GOOD NUMBER FOR SNIPERS
//if(currentPos.x < CurrentMouseXY.X + 4 && currentPos.x > CurrentMouseXY.X-4 &&
// currentPos.y < CurrentMouseXY.Y + 4 && currentPos.y > CurrentMouseXY.Y-4)
//{
//ShootBot((z -( z - x)/2)+scan->RcWindow.left, y+scan->RcWindow.top);
//}
CurrentMouseXY.X = currentPos.x;
CurrentMouseXY.Y = currentPos.y;
//std::cout << "Bang bang " << std::endl;
//*scan->ColorFoundK = true;
return;
}
}
}
std::cout << "out of CLOCK, took " << clock() - startedInScanTime << " milliseconds" << std::endl;
}
bool Aim_BotThr(AimbotThr * aimThr1)