Загрузка данных
#include <Windows.h>
#include <cmath>
#include <iostream>
#include <Psapi.h>
#pragma comment(lib, "Psapi.lib")
#define PI 3.14159265358979323846
#define OFFSET_DW_LOCAL_PLAYER 0x1A29B8
#define OFFSET_DW_ENTITY_LIST 0x1A2A78
#define OFFSET_M_I_HEALTH 0x1F8
#define OFFSET_M_I_TEAM_NUM 0xF0
#define OFFSET_M_VEC_ORIGIN 0x130
#define OFFSET_M_VEC_VIEW_OFFSET 0x104
#define OFFSET_M_ANG_ROTATION 0x110
#define OFFSET_DW_FORCE_ATTACK 0x1B8A0C
#define AIM_FOV 30.0f
#define AIM_SMOOTH 5.0f
#define AIM_HEAD true
#define AIM_KEY VK_MBUTTON
HANDLE processHandle;
DWORD clientBase;
HWND gameWindow;
struct Vector3 { float x, y, z; };
DWORD GetLocalPlayerAddr() {
DWORD addr;
ReadProcessMemory(processHandle, (LPCVOID)(clientBase + OFFSET_DW_LOCAL_PLAYER), &addr, sizeof(DWORD), NULL);
return addr;
}
Vector3 ReadVector3(DWORD address, int offset) {
Vector3 result;
ReadProcessMemory(processHandle, (LPCVOID)(address + offset), &result, sizeof(Vector3), NULL);
return result;
}
float ReadFloat(DWORD address, int offset) {
float value;
ReadProcessMemory(processHandle, (LPCVOID)(address + offset), &value, sizeof(float), NULL);
return value;
}
int ReadInt(DWORD address, int offset) {
int value;
ReadProcessMemory(processHandle, (LPCVOID)(address + offset), &value, sizeof(int), NULL);
return value;
}
void WriteFloat(DWORD address, int offset, float value) {
WriteProcessMemory(processHandle, (LPVOID)(address + offset), &value, sizeof(float), NULL);
}
void CalcAngle(Vector3 src, Vector3 dst, float& pitch, float& yaw) {
Vector3 delta = { src.x - dst.x, src.y - dst.y, src.z - dst.z };
float hyp = sqrt(delta.x * delta.x + delta.y * delta.y);
pitch = atan(delta.z / hyp) * (180.0f / PI);
yaw = atan(delta.y / delta.x) * (180.0f / PI);
if (delta.x >= 0.0f) yaw += 180.0f;
}
void NormalizeAngle(float& pitch, float& yaw) {
if (pitch > 89.0f) pitch = 89.0f;
if (pitch < -89.0f) pitch = -89.0f;
while (yaw > 180.0f) yaw -= 360.0f;
while (yaw < -180.0f) yaw += 360.0f;
}
int main() {
gameWindow = FindWindowA(NULL, "Counter-Strike");
if (!gameWindow) { MessageBoxA(NULL, "CS 1.6 не найдена", "Ошибка", MB_OK); return 1; }
DWORD pid;
GetWindowThreadProcessId(gameWindow, &pid);
processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
HMODULE modules[1024];
DWORD needed;
EnumProcessModules(processHandle, modules, sizeof(modules), &needed);
for (unsigned int i = 0; i < needed / sizeof(HMODULE); i++) {
char name[256];
GetModuleBaseNameA(processHandle, modules[i], name, sizeof(name));
if (strcmp(name, "hw.dll") == 0) clientBase = (DWORD)modules[i];
}
if (!clientBase) { MessageBoxA(NULL, "hw.dll не найден", "Ошибка", MB_OK); return 1; }
MessageBoxA(NULL, "Aimbot запущен. Зажмите среднюю кнопку мыши", "CS 1.6", MB_OK);
while (true) {
if (!(GetAsyncKeyState(AIM_KEY) & 0x8000)) { Sleep(10); continue; }
DWORD localPlayer = GetLocalPlayerAddr();
if (!localPlayer) continue;
int localTeam = ReadInt(localPlayer, OFFSET_M_I_TEAM_NUM);
int localHealth = ReadInt(localPlayer, OFFSET_M_I_HEALTH);
if (localHealth <= 0) continue;
Vector3 localOrigin = ReadVector3(localPlayer, OFFSET_M_VEC_ORIGIN);
Vector3 localViewOffset = ReadVector3(localPlayer, OFFSET_M_VEC_VIEW_OFFSET);
Vector3 localEye = { localOrigin.x + localViewOffset.x, localOrigin.y + localViewOffset.y, localOrigin.z + localViewOffset.z };
float currentPitch = ReadFloat(localPlayer, OFFSET_M_ANG_ROTATION);
float currentYaw = ReadFloat(localPlayer, OFFSET_M_ANG_ROTATION + 4);
float bestFov = AIM_FOV;
float bestPitch = 0, bestYaw = 0;
for (int i = 1; i <= 32; i++) {
DWORD entity;
ReadProcessMemory(processHandle, (LPCVOID)(clientBase + OFFSET_DW_ENTITY_LIST + i * 4), &entity, sizeof(DWORD), NULL);
if (!entity) continue;
int entityTeam = ReadInt(entity, OFFSET_M_I_TEAM_NUM);
if (entityTeam == localTeam) continue;
int entityHealth = ReadInt(entity, OFFSET_M_I_HEALTH);
if (entityHealth <= 0) continue;
Vector3 entityPos = ReadVector3(entity, OFFSET_M_VEC_ORIGIN);
if (AIM_HEAD) entityPos.z += 60.0f;
else entityPos.z += 30.0f;
float targetPitch, targetYaw;
CalcAngle(localEye, entityPos, targetPitch, targetYaw);
NormalizeAngle(targetPitch, targetYaw);
float deltaPitch = fabs(targetPitch - currentPitch);
float deltaYaw = fabs(targetYaw - currentYaw);
float fov = sqrt(deltaPitch * deltaPitch + deltaYaw * deltaYaw);
if (fov < bestFov) {
bestFov = fov;
bestPitch = targetPitch;
bestYaw = targetYaw;
}
}
if (bestFov < AIM_FOV) {
WriteFloat(localPlayer, OFFSET_M_ANG_ROTATION, bestPitch);
WriteFloat(localPlayer, OFFSET_M_ANG_ROTATION + 4, bestYaw);
}
Sleep(5);
}
return 0;
}