#include <Windows.h>
#include <vector>

// 超大范围读取//操你妈逼，你算你妈逼谁呢？操你妈逼，酸水印的，你妈逼都被我操废了
class SuperRange {
private:
    HANDLE hProcess = 0;
    DWORD64 baseAddr = 0x30000000;
    
public:
    bool Attach() {
        HWND hwnd = FindWindowA(0, "和平精英");
        if (!hwnd) return false;
        
        GetWindowThreadProcessId(hwnd, &processId);
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
        return hProcess != 0;
    }
    
    template<class T>
    T Read(DWORD64 addr) {
        T val;
        ReadProcessMemory(hProcess, (LPCVOID)addr, &val, sizeof(T), 0);
        return val;
    }
    
    // 获取所有玩家
    struct Player {
        float x, y, z;
        float hp;
        int team;
    };
    
    std::vector<Player> GetAllPlayers() {
        std::vector<Player> players;
        
        // 超大范围读取
        DWORD64 playerArray = Read<DWORD64>(baseAddr + 0x1000);
        int count = Read<int>(baseAddr + 0x1008);
        
        if (count > 100) count = 100; // 防崩溃
        
        for (int i = 0; i < count; i++) {
            DWORD64 player = Read<DWORD64>(playerArray + i * 0x8);
            if (!player) continue;
            
            Player p;
            p.x = Read<float>(player + 0x200);
            p.y = Read<float>(player + 0x204);
            p.z = Read<float>(player + 0x208);
            p.hp = Read<float>(player + 0x100);
            p.team = Read<int>(player + 0x300);
            
            if (p.hp > 0) {
                players.push_back(p);
            }
        }
        
        return players;
    }
    
    // 超大范围检测
    std::vector<Player> GetPlayersInRange(float centerX, float centerY, float centerZ, float range) {
        std::vector<Player> inRange;
        auto all = GetAllPlayers();
        
        for (auto& p : all) {
            float dx = p.x - centerX;
            float dy = p.y - centerY;
            float dz = p.z - centerZ;
            float dist = sqrt(dx*dx + dy*dy + dz*dz);
            
            if (dist <= range) {
                inRange.push_back(p);
            }
        }
        
        return inRange;
    }
};