-
Автор темы
- #1
Здравствуйте. Только начал разрабатывать читы для кс2. Не могу понять, почему не работает ESP в кс2 (его отрисовка)
Простите если я просто ступил, я не понимаю в чем ошибка. Делал опять же по туториалу. MessageBox'ы добавил для дебага (знаю плохая практика). Заранее спасибо, уже несколько дней бошку ломлю. Сделал на kiero hook dx11
Простите если я просто ступил, я не понимаю в чем ошибка. Делал опять же по туториалу. MessageBox'ы добавил для дебага (знаю плохая практика). Заранее спасибо, уже несколько дней бошку ломлю. Сделал на kiero hook dx11
C++:
float(*ViewMatrix)[4][4] = (float(*)[4][4])(client + dwViewMatrix);
if (!ViewMatrix)
MessageBox(NULL, "ViewMatrix not found", "Error", MB_OK | MB_ICONERROR);
return;
auto localPlayer = *(uintptr_t*)(client + dwLocalPlayerPawn);
if (!localPlayer)
MessageBox(NULL, "LocalPlayer not found", "Error", MB_OK | MB_ICONERROR);
return;
auto localTeam = *(UINT8*)(server + m_iTeamNum);
auto entityList = *(uintptr_t*)(client + dwEntityList);
if (!entityList)
MessageBox(NULL, "EntityList not found", "Error", MB_OK | MB_ICONERROR);
return;
for (int i = 1; i < 64; i++) {
uintptr_t listEntry = *(uintptr_t*)(entityList + (8 * (i & 0x7FFF) >> 9) + 16);
if (!listEntry) continue;
uintptr_t playerController = *(uintptr_t*)(listEntry + 120 * (i & 0x1FF));
if (!playerController) continue;
uint32_t playerPawn = *(uint32_t*)(playerController + m_hPlayerPawn);
if (!playerPawn) continue;
uintptr_t listEntry2 = *(uintptr_t*)(entityList + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16);
if (!listEntry2) continue;
uintptr_t pCSPlayerPawnPtr = *(uintptr_t*)(listEntry2 + 120 * (playerPawn & 0x1FF));
if (!pCSPlayerPawnPtr) continue;
if (!test) {
MessageBox(NULL, "Found Entity", "Test", MB_ICONINFORMATION | MB_OK);
test = true;
}
int health = *(INT32*)(pCSPlayerPawnPtr + m_iHealth);
if (health <= 0)
continue;
int team = *(UINT8*)(pCSPlayerPawnPtr + m_iTeamNum);
if (team == localTeam)
continue;
if (!test2) {
MessageBox(NULL, "Found Enemy", "Test", MB_ICONINFORMATION | MB_OK);
test2 = true;
}
Vector3 feetpos = *(Vector3*)(pCSPlayerPawnPtr + m_vOldOrigin);
Vector3 headpos = { feetpos.x, feetpos.y, feetpos.z + 65.0f };
Vector2 feet, head;
if (feetpos.WorldToScreen(feet, ViewMatrix) && headpos.WorldToScreen(head, ViewMatrix)) {
float height = (feet.y - head.y) * 1.5f;
float width = height / 1.5f;
float x = feet.x - width / 2;
float y = head.y;
ImGui::GetBackgroundDrawList()->AddRect({ x, y }, { x + width, y + height }, ImColor(255, 0, 0));
}
}
C++:
const bool Vector3::WorldToScreen(Vector2& out, float(*ViewMatrix)[4][4])
{
const float w = (*ViewMatrix)[3][0] * x + (*ViewMatrix)[3][1] * y + (*ViewMatrix)[3][2] * z + (*ViewMatrix)[3][3];
if (w <= 0.01f)
return false;
const float invW = 1.0f / w;
const float screenWidth = static_cast<float>(GetSystemMetrics(SM_CXSCREEN));
const float screenHeight = static_cast<float>(GetSystemMetrics(SM_CYSCREEN));
out.x = (screenWidth / 2) + (((*ViewMatrix)[0][0] * x + (*ViewMatrix)[0][1] * y + (*ViewMatrix)[0][2] * z + (*ViewMatrix)[0][3]) * invW * (screenWidth / 2));
out.y = (screenHeight / 2) - (((*ViewMatrix)[1][0] * x + (*ViewMatrix)[1][1] * y + (*ViewMatrix)[1][2] * z + (*ViewMatrix)[1][3]) * invW * (screenHeight / 2));
return true;
}