#include <Windows.h>

class GameRange {
private:
    HANDLE hProcess = 0;
    DWORD64 base = 0x30000000;
    
    template<class T>
    T Read(DWORD64 addr) {
        T val;
        ReadProcessMemory(hProcess, (LPCVOID)addr, &val, sizeof(T), 0);
        return val;
    }
    
public:
    struct PlayerData {
        float x, y, z;
        float hp;
    };
    
    bool Connect() {
        HWND hwnd = FindWindowA(0, 0);
        DWORD pid = 0;
        GetWindowThreadProcessId(hwnd, &pid);
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
        return hProcess != 0;
    }
    
    std::vector<PlayerData> ReadPlayers() {
        std::vector<PlayerData> players;
        
        DWORD64 listAddr = Read<DWORD64>(base + 0x1000);
        int count = Read<int>(base + 0x1008);
        
        for (int i = 0; i < count; i++) {
            DWORD64 playerAddr = Read<DWORD64>(listAddr + i * 8);
            if (!playerAddr) continue;
            
            PlayerData p;
            p.x = Read<float>(playerAddr + 0x200);
            p.y = Read<float>(playerAddr + 0x204);
            p.z = Read<float>(playerAddr + 0x208);
            p.hp = Read<float>(playerAddr + 0x100);
            
            if (p.hp > 0) {
                players.push_back(p);
            }
        }
        
        return players;
    }
    
    void SetBigRange(float range) {
        WriteProcessMemory(hProcess, (LPVOID)(base + 0x2000), &range, sizeof(float), 0);
    }
}






//二改死妈妈原创辞酱