Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Issues with nexuiz esp... :/

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
drxxmz
How do I cheat?
Reputation: 0

Joined: 21 Jan 2025
Posts: 2

PostPosted: Mon Jan 27, 2025 11:09 am    Post subject: Issues with nexuiz esp... :/ Reply with quote

I know the last comment in under this category is mine but yall are slow as hell and i need to post this somewhere.
My code like the other code is formatted correctly it just doesnt work, the view matrix is somehow wrong? despite being a traditional view matrix?
ill pay 20usd for any solution or an explanation at this point.

Code:

#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[4][4];

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, float viewMatrix[4][4], int screenWidth, int screenHeight) {
    // Calculate clip coordinates
    float clipX = playerPos.x * viewMatrix[0][0] +
        playerPos.y * viewMatrix[0][1] +
        playerPos.z * viewMatrix[0][2] +
        viewMatrix[3][0];

    float clipY = playerPos.x * viewMatrix[1][0] +
        playerPos.y * viewMatrix[1][1] +
        playerPos.z * viewMatrix[1][2] +
        viewMatrix[3][1];

    float clipZ = playerPos.x * viewMatrix[2][0] +
        playerPos.y * viewMatrix[2][1] +
        playerPos.z * viewMatrix[2][2] +
        viewMatrix[3][2];

    float clipW = 1.0f;  // Force to 1

    // Perspective division
    float ndcX = clipX / clipW;
    float ndcY = clipY / clipW;

    // Screen mapping with scaling
    float screenX = (ndcX * 0.5f + 0.5f) * screenWidth;
    float screenY = (1.0f - ndcY * 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)0xC6A930, &viewMatrix, sizeof(viewMatrix), NULL);
        Vector2 ScreenPos = WorldToScreen({ 100,100,100 }, viewMatrix, 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;
}

youll need to manually fill in the view matrix address and thats it, also check it out while your at it please
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4695

PostPosted: Mon Jan 27, 2025 11:59 am    Post subject: Reply with quote

Multiplayer games aren't allowed here.
https://forum.cheatengine.org/faq.php#0

Even if they were, the "Cheat Engine Tutorials" form is not for asking questions.
https://forum.cheatengine.org/viewtopic.php?t=64

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Mon Jan 27, 2025 1:31 pm    Post subject: Reply with quote

Also, do not spam the same topic in multiple sections.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites