Issue with new Nexuiz hack (esp) (offline)

Memory scanning, code injection, debugger internals and other gamemodding related discussion
Post Reply
drxxmz
What is cheating?
What is cheating?
Posts: 2
Joined: Sat Jan 25, 2025 6:45 am
Reputation: 0

Issue with new Nexuiz hack (esp) (offline)

Post by drxxmz »

I have posted this on another forum but i don't think im gonna a response anytime soon soo i wanna post this here as a sort of backup.
I have been working on a game hack for a game called Nexuiz v2.5.2, i have a world to screen script that seems to mainly work except some of the math is wrong in the world to screen and i have tried everything to try to fix it or find the right order but i can't come up with anything nor know how to differentiate forward right and up matrix's, here's the code:

Code: Select all

#include <iostream>
#include <Windows.h>
#include <TlHelp32.h>
#include <iomanip>
#define PI 3.1415927f

struct Vector2 { float x, y; };
struct Vector3 { float x, y, z; };
struct Vector4 { float x, y, z, w; };
float viewMatrix[16];

DWORD GetProcessId(const char* processName) {
    HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    PROCESSENTRY32 processEntry;
    processEntry.dwSize = sizeof(PROCESSENTRY32);

    if (Process32First(snapshot, &processEntry)) {
        do {
            if (!_stricmp(processEntry.szExeFile, processName)) {
                std::cout << "Process found: " << processEntry.szExeFile
                    << " (PID: " << processEntry.th32ProcessID << ")" << std::endl;
                CloseHandle(snapshot);
                return processEntry.th32ProcessID;
            }
        } while (Process32Next(snapshot, &processEntry));
    }

    std::cerr << "Process not found: " << processName << std::endl;
    CloseHandle(snapshot);
    return 0;
}

Vector2 WorldToScreen(const Vector3& playerPos, int screenWidth, int screenHeight) {
    float x = playerPos.x * viewMatrix[0] + playerPos.y * viewMatrix[4] + playerPos.z * viewMatrix[8] + viewMatrix[12];
    float y = playerPos.x * viewMatrix[1] + playerPos.y * viewMatrix[5] + playerPos.z * viewMatrix[9] + viewMatrix[13];
    float z = playerPos.x * viewMatrix[2] + playerPos.y * viewMatrix[6] + playerPos.z * viewMatrix[10] + viewMatrix[14];
    float w = playerPos.x * viewMatrix[3] + playerPos.y * viewMatrix[7] + playerPos.z * viewMatrix[11] + viewMatrix[15];

    if (z < 0.1f) return { -1, -1 };

    x /= z;
    y /= z;

    float screenX = (1.0f - x) * 0.5f * screenWidth;
    float screenY = (1.0f - y) * 0.5f * screenHeight;

    return { screenX, screenY };
}

void DrawESP(HDC hdc, Vector3 screenPos) {
    HPEN pen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
    HGDIOBJ oldPen = SelectObject(hdc, pen);

    Rectangle(hdc,
        screenPos.x - 25,
        screenPos.y - 25,
        screenPos.x + 25,
        screenPos.y + 25
    );

    SelectObject(hdc, oldPen);
    DeleteObject(pen);
}

int main() {
    const char* processName = "nexuiz-sdl.exe";
    DWORD processId = GetProcessId(processName);

    if (!processId) {
        std::cerr << "Failed to get process ID" << std::endl;
        return 1;
    }

    HANDLE processHandle = OpenProcess(PROCESS_VM_READ, FALSE, processId);
    if (!processHandle) {
        std::cerr << "Failed to open process. Error: " << GetLastError() << std::endl;
        return 1;
    }

    HWND gameWindow = FindWindowA(NULL, "Nexuiz");
    if (!gameWindow) {
        std::cerr << "Game window not found" << std::endl;
        CloseHandle(processHandle);
        return 1;
    }

    HDC gameDC = GetDC(gameWindow);
    if (!gameDC) {
        std::cerr << "Failed to get DC. Error: " << GetLastError() << std::endl;
        CloseHandle(processHandle);
        return 1;
    }

    DWORD viewMatrixAddress = 0xC7CA50;

    while (true) {
        ReadProcessMemory(processHandle, (LPVOID)0xC6A8F0, &viewMatrix, sizeof(viewMatrix), NULL);
        Vector2 ScreenPos = WorldToScreen({ 100,100,100 }, 664, 1176);
        std::cout << ScreenPos.x << " : " << ScreenPos.y << "\n";
        DrawESP(gameDC, {ScreenPos.x, ScreenPos.y, 0});
        Sleep(1);
    }

    ReleaseDC(gameWindow, gameDC);
    CloseHandle(processHandle);

    return 0;
}
If you run set multi-byte and set resolution to ingame res or change to the set resolution,
Any help or explanations as to how to differentiate forward up and right or just a solution is appreciate.
All code should run as the base address is set to 0x400000 (older game)

drxxmz
What is cheating?
What is cheating?
Posts: 2
Joined: Sat Jan 25, 2025 6:45 am
Reputation: 0

Re: Issue with new Nexuiz hack (esp) (offline)

Post by drxxmz »

Ok i really fucked up earlier and decided to post on a few different forums asking for a fix to code as nobody would reply, turned out the game i was trying to request was online and i had been so use to going straight into singleplayer i didnt notice, here i will post every single question i have relating to view matrix's and gamehacking in general, i really appreciate anything since replies are rare.

1. I don't understand what the right up and forward xyz values correspond to while looking up and down and i feel like i need to know this to differentiate them all while writing a world to screen, how do i differentiate them?
2. why do i keep on finding view matrix's shaped as 4x3 with camera position xyz first followed by right up and forward (xyz each)?
3. where can i find world to screen scripts for each view matrix layout instead of having tow rite it myself as i don't understand it and i don't think anybody will help me either?
4. is the reason I'm seeing all types of different view matrix's because every engine uses a different layout for theirs?
5. how do i find the legit view matrix as there should only be one but whenever i search for -1.0 then 1.0 then -1.0 in repeat it leads to 10 - 20 different values doing the same thing exactly, how do i filter out fake or duplicate values
6. how come AI always says that the view matrix for a specific game engine is totally incorrect to what it actually is, is AI literally lower than 20 IQ or am i just overthinking it?

Post Reply

Who is online

Users browsing this forum: No registered users