Загрузка данных


static void DrawESP() {
    if (!cfg.espEn) return;
    uintptr_t vmAddr = mem::Read<uintptr_t>(offs::dwViewMatrix);
    Matrix4x4 vm = mem::Read<Matrix4x4>(vmAddr);
    ImGuiIO& io = ImGui::GetIO();
    int sw = (int)io.DisplaySize.x;
    int sh = (int)io.DisplaySize.y;
    ImDrawList* dl = ImGui::GetBackgroundDrawList();

    uintptr_t lp = mem::Read<uintptr_t>(offs::dwLocalPawn);
    if (!lp) return;
    Pawn me(lp);
    int myTeam = me.team();

    for (int i = 1; i <= 64; ++i) {
        Controller ctrl = GetPlayer(i);
        if (!ctrl.ok()) continue;
        Pawn p = ctrl.pawn();
        if (!p.ok() || !p.alive()) continue;
        if (p.team() == myTeam) continue;
        if (cfg.visOnly && !p.spotted()) continue;

        Vec3 o = p.origin();
        Vec3 h = p.bone(6);
        Vec2 so, shh;
        if (!WorldToScreen(o, so, vm, sw, sh)) continue;
        if (!WorldToScreen(h, shh, vm, sw, sh)) continue;

        float bh = so.y - shh.y;
        float bw = bh * 0.5f;
        float bx = shh.x - bw * 0.5f;
        float by = shh.y;
        ImU32 c = Col(cfg.col);

        if (cfg.box) dl->AddRect(ImVec2(bx, by), ImVec2(bx + bw, by + bh), c, 0, 0, cfg.thick);
        if (cfg.hp) {
            float f = p.hp() / 100.f;
            dl->AddRectFilled(ImVec2(bx - 6, by + bh * (1 - f)), ImVec2(bx - 2, by + bh), ImGui::GetColorU32(ImVec4(1 - f, f, 0.1f, 1)));
        }
        if (cfg.name) dl->AddText(ImVec2(bx, by - 16), c, ctrl.name());
        if (cfg.skel) {
            static const int b[][2] = { {6,5},{5,4},{4,3},{5,7},{7,8},{8,9}, {5,11},{11,12},{12,13},{4,14},{14,15},{15,16}, {4,17},{17,18},{18,19} };
            for (int j = 0; j < 15; ++j) {
                Vec2 a, c2;
                if (WorldToScreen(p.bone(b[j][0]), a, vm, sw, sh) && WorldToScreen(p.bone(b[j][1]), c2, vm, sw, sh)) {
                    dl->AddLine(ImVec2(a.x, a.y), ImVec2(c2.x, c2.y), c, cfg.thick);
                }
            }
        }
        if (cfg.dist) {
            float d = (o - me.origin()).Length() / 100.f;
            char buf[32];
            snprintf(buf, sizeof buf, "[%.0fm]", d);
            dl->AddText(ImVec2(bx, by + bh + 2), c, buf);
        }
    }
}