Jump to content

question help with coding aimbot


GramCrackers0
 Share

Recommended Posts

still selfcoding an aimbot, so it works but it looks about 90 degrees straight above them when toggled, any help?

code: 

#include <iostream>
#include <windows.h>
#include <Tlhelp32.h>
#include "offsets.h"
#include "main.h"
using namespace hazedumper::signatures;
using namespace hazedumper::netvars;

// gets screen resolution
const int screen_width = GetSystemMetrics(SM_CXSCREEN); const int xhairx = screen_width / 2;
const int screen_height = GetSystemMetrics(SM_CYSCREEN); const int xhairy = screen_height / 2;

// declare general variables
HWND hwnd;
DWORD procid;
HANDLE  hProcess; //tunnel to communicate with csgo 
uintptr_t moduleBase; // store base of paranorma dll here 
HDC hdc; 
int closest; // use to optimize cpu usage when finding target 

uintptr_t GetModuleBaseAddress(const char* modName) {
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procid);
    if (hSnap != INVALID_HANDLE_VALUE) {
        MODULEENTRY32 modEntry;
        modEntry.dwSize = sizeof(modEntry);
        if (Module32First(hSnap, &modEntry)) {
            do {
                if (!strcmp(modEntry.szModule, modName)) {
                    CloseHandle(hSnap);
                    return (uintptr_t)modEntry.modBaseAddr;
                }
            } while (Module32Next(hSnap, &modEntry));
        }
    }
}

template<typename T> T RPM(SIZE_T address) {
    T buffer; 
    ReadProcessMemory(hProcess, (LPCVOID)address, &buffer, sizeof(T), NULL);
    return buffer; 
}

// class for storing enemy xyz coords 
class Vector3 {
public: 
    float x, y, z;
    Vector3() : x(0.0f), y(0.0f), z(0.0f) {}
    Vector3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
};

int  getTeam(uintptr_t player) {
    return RPM<int>(player + m_iTeamNum);
}

uintptr_t GetLocalPlayer() {
    return RPM< uintptr_t>(moduleBase + dwLocalPlayer);
}

uintptr_t GetPlayer(int index ) {
    return RPM< uintptr_t>(moduleBase + dwEntityList + index * 0x10);
}

int GetPlayerHealth(uintptr_t player) {
    return RPM<int>(player + m_iHealth); 
}

Vector3 PlayerLocation(uintptr_t player) {
    return RPM<Vector3>(player + m_vecOrigin); 
}

bool DormantCheck(uintptr_t player) {
    return RPM<int>(player + m_bDormant);
}

Vector3 get_head(uintptr_t player) {
    struct boneMatrix_t {
        byte pad3[12];
        float x;
        byte pad1[12];
        float y;
        byte pad2[12];
        float z;
    };
    uintptr_t boneBase = RPM<uintptr_t>(player + m_dwBoneMatrix);
    boneMatrix_t boneMatrix = RPM<boneMatrix_t>(boneBase + sizeof(boneMatrix) * 8);
    return Vector3(boneMatrix.x, boneMatrix.y, boneMatrix.z);
}

struct view_matrix_t {
    float matrix[16];
} vm; 

struct Vector3 WorldToScreen(const struct Vector3 pos, struct view_matrix_t matrix) {
    struct Vector3 out;
    float _x = matrix.matrix[0] * pos.x + matrix.matrix[1] * pos.y + matrix.matrix[2] * pos.z + matrix.matrix[3];
    float _y = matrix.matrix[4] * pos.x + matrix.matrix[5] * pos.y + matrix.matrix[6] * pos.z + matrix.matrix[7];
    out.z = matrix.matrix[12] * pos.x + matrix.matrix[13] * pos.y + matrix.matrix[14] * pos.z + matrix.matrix[15];

    _x *= 1.f / out.z; 
    _y *= 1.f / out.z; 

    out.x = screen_width * .5f;
    out.y - screen_height * .5f; 

    out.x += 0.5f * _x * screen_width + .5f;
    out.y -= 0.5f * _y * screen_height + .5f;

    return out;
} 

float pythag(int x1, int y1, int x2, int y2) {
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

int FindClosestEnemy() {
    float Finish; 
    int ClosestEntity = 1;
    Vector3 Calc = { 0, 0, 0 };
    float Closest = FLT_MAX; 
    int localTeam = getTeam(GetLocalPlayer());
    for (int i = 1; i < 32; i++) {
        DWORD Entity = GetPlayer(i); 
        int  EnmTeam = getTeam(Entity); if (EnmTeam == localTeam) continue;
        int EnmHealth = GetPlayerHealth(Entity); if (EnmHealth < 1 || EnmHealth > 100) continue;
        int Dormant = DormantCheck(Entity); if (Dormant) continue; 

        Vector3 headBone = WorldToScreen(get_head(Entity), vm);
        Finish = pythag(headBone.x, headBone.y, xhairx, xhairy);

        if (Finish < Closest) {
            Closest = Finish;
            ClosestEntity = i;
        }
    }
    return ClosestEntity;
}

void FindClosestEnemyThread() {
    while (1) {
        closest = FindClosestEnemy();
    }
}

int main() {
    hwnd = FindWindowA(NULL, "Counter-Strike: Global Offensive");
    GetWindowThreadProcessId(hwnd, &procid);
    moduleBase = GetModuleBaseAddress("client.dll");
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, procid);

        CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)FindClosestEnemyThread, NULL, NULL, NULL);

        while (!GetAsyncKeyState(VK_END)) {
            vm = RPM<view_matrix_t>(moduleBase + dwViewMatrix);
            Vector3 closestw2shead = WorldToScreen(get_head(GetPlayer(closest)), vm); 
                                                                                               //if statement below is keybind for aimbot
            if(GetAsyncKeyState(VK_MENU) && closestw2shead.z >= 0.001f) 
                SetCursorPos(closestw2shead.x, closestw2shead.y);
        }
}

 

Edited by ONERIS
Link to comment
Share on other sites

19 minutes ago, GramCrackers0 said:

still selfcoding an aimbot, so it works but it looks about 90 degrees straight above them when toggled, any help?

code: 


#include <iostream>
#include <windows.h>
#include <Tlhelp32.h>
#include "offsets.h"
#include "main.h"
using namespace hazedumper::signatures;
using namespace hazedumper::netvars;

// gets screen resolution
const int screen_width = GetSystemMetrics(SM_CXSCREEN); const int xhairx = screen_width / 2;
const int screen_height = GetSystemMetrics(SM_CYSCREEN); const int xhairy = screen_height / 2;

// declare general variables
HWND hwnd;
DWORD procid;
HANDLE  hProcess; //tunnel to communicate with csgo 
uintptr_t moduleBase; // store base of paranorma dll here 
HDC hdc; 
int closest; // use to optimize cpu usage when finding target 

uintptr_t GetModuleBaseAddress(const char* modName) {
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procid);
    if (hSnap != INVALID_HANDLE_VALUE) {
        MODULEENTRY32 modEntry;
        modEntry.dwSize = sizeof(modEntry);
        if (Module32First(hSnap, &modEntry)) {
            do {
                if (!strcmp(modEntry.szModule, modName)) {
                    CloseHandle(hSnap);
                    return (uintptr_t)modEntry.modBaseAddr;
                }
            } while (Module32Next(hSnap, &modEntry));
        }
    }
}

template<typename T> T RPM(SIZE_T address) {
    T buffer; 
    ReadProcessMemory(hProcess, (LPCVOID)address, &buffer, sizeof(T), NULL);
    return buffer; 
}

// class for storing enemy xyz coords 
class Vector3 {
public: 
    float x, y, z;
    Vector3() : x(0.0f), y(0.0f), z(0.0f) {}
    Vector3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
};

int  getTeam(uintptr_t player) {
    return RPM<int>(player + m_iTeamNum);
}

uintptr_t GetLocalPlayer() {
    return RPM< uintptr_t>(moduleBase + dwLocalPlayer);
}

uintptr_t GetPlayer(int index ) {
    return RPM< uintptr_t>(moduleBase + dwEntityList + index * 0x10);
}

int GetPlayerHealth(uintptr_t player) {
    return RPM<int>(player + m_iHealth); 
}

Vector3 PlayerLocation(uintptr_t player) {
    return RPM<Vector3>(player + m_vecOrigin); 
}

bool DormantCheck(uintptr_t player) {
    return RPM<int>(player + m_bDormant);
}

Vector3 get_head(uintptr_t player) {
    struct boneMatrix_t {
        byte pad3[12];
        float x;
        byte pad1[12];
        float y;
        byte pad2[12];
        float z;
    };
    uintptr_t boneBase = RPM<uintptr_t>(player + m_dwBoneMatrix);
    boneMatrix_t boneMatrix = RPM<boneMatrix_t>(boneBase + sizeof(boneMatrix) * 8);
    return Vector3(boneMatrix.x, boneMatrix.y, boneMatrix.z);
}

struct view_matrix_t {
    float matrix[16];
} vm; 

struct Vector3 WorldToScreen(const struct Vector3 pos, struct view_matrix_t matrix) {
    struct Vector3 out;
    float _x = matrix.matrix[0] * pos.x + matrix.matrix[1] * pos.y + matrix.matrix[2] * pos.z + matrix.matrix[3];
    float _y = matrix.matrix[4] * pos.x + matrix.matrix[5] * pos.y + matrix.matrix[6] * pos.z + matrix.matrix[7];
    out.z = matrix.matrix[12] * pos.x + matrix.matrix[13] * pos.y + matrix.matrix[14] * pos.z + matrix.matrix[15];

    _x *= 1.f / out.z; 
    _y *= 1.f / out.z; 

    out.x = screen_width * .5f;
    out.y - screen_height * .5f; 

    out.x += 0.5f * _x * screen_width + .5f;
    out.y -= 0.5f * _y * screen_height + .5f;

    return out;
} 

float pythag(int x1, int y1, int x2, int y2) {
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

int FindClosestEnemy() {
    float Finish; 
    int ClosestEntity = 1;
    Vector3 Calc = { 0, 0, 0 };
    float Closest = FLT_MAX; 
    int localTeam = getTeam(GetLocalPlayer());
    for (int i = 1; i < 32; i++) {
        DWORD Entity = GetPlayer(i); 
        int  EnmTeam = getTeam(Entity); if (EnmTeam == localTeam) continue;
        int EnmHealth = GetPlayerHealth(Entity); if (EnmHealth < 1 || EnmHealth > 100) continue;
        int Dormant = DormantCheck(Entity); if (Dormant) continue; 

        Vector3 headBone = WorldToScreen(get_head(Entity), vm);
        Finish = pythag(headBone.x, headBone.y, xhairx, xhairy);

        if (Finish < Closest) {
            Closest = Finish;
            ClosestEntity = i;
        }
    }
    return ClosestEntity;
}

void FindClosestEnemyThread() {
    while (1) {
        closest = FindClosestEnemy();
    }
}

int main() {
    hwnd = FindWindowA(NULL, "Counter-Strike: Global Offensive");
    GetWindowThreadProcessId(hwnd, &procid);
    moduleBase = GetModuleBaseAddress("client.dll");
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, procid);

        CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)FindClosestEnemyThread, NULL, NULL, NULL);

        while (!GetAsyncKeyState(VK_END)) {
            vm = RPM<view_matrix_t>(moduleBase + dwViewMatrix);
            Vector3 closestw2shead = WorldToScreen(get_head(GetPlayer(closest)), vm); 
                                                                                               //if statement below is keybind for aimbot
            if(GetAsyncKeyState(VK_MENU) && closestw2shead.z >= 0.001f) 
                SetCursorPos(closestw2shead.x, closestw2shead.y);
        }
}

 

1. Stop pasting

2. Learn cpp

3. Clamp Angles

4. Dont use SetCursorPos LMAO

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...