Вопрос Баг в esp box

std::X$$V::Z::_Func_impl_no_alloc
Пользователь
Статус
Оффлайн
Регистрация
30 Мар 2019
Сообщения
389
Реакции[?]
103
Поинты[?]
1K
Время от времени боксы как-бы "прыгают". Т.е на один кадр слезают с противника и рисуются вообще в другом углу (например).
C++:
inline void draw_box(CBasePlayer* ent)
{
    CLocalPlayer* local_player = CLocalPlayer::get_local_player();

    Math::CVector v_origin = ent->get_origin();
    Math::CVector v_head = ent->get_entity_bone(head_0);

    v_head += 15.0f;

    Math::CVector v_screen_origin, v_screen_head;

    if (Math::WorldToScreen(v_head, v_screen_head) && Math::WorldToScreen(v_origin, v_screen_origin))
    {
        int h = v_screen_origin.y - v_screen_head.y;
        int w = h / 2.4f;

        int x = v_screen_origin.x;
        int y = v_screen_origin.y - h;
        

        if (x > 0 && y > 0)
            RenderTool::get().draw_border_box(x - (w / 2), y, w, h, Color(255, 0, 0, 100));
    }
}

void ESP::draw()
{
    if (!CInterfaces::get().engine->is_in_game())
        return;

    CLocalPlayer* local_player = CLocalPlayer::get_local_player();

    if (!local_player)
        return;


    for (size_t i = 0; i <= CInterfaces::get().client_entity_list->get_highest_enetity_index(); ++i)
    {
        CBasePlayer* ply = (CBasePlayer*)CBasePlayer::get_by_index(i);

        if (!ply || !ply->is_alive() || ply == local_player || ply->is_dormant())
            continue;

        if (ply->get_client_class()->ClassId != class_ids::ccsplayer)
            continue;

        if (G::get().check_team)
            if (ply->get_team_num() == local_player->get_team_num())
                continue;

        draw_box(ply);
    }
}

C++:
void RenderTool::draw_filled_box(int x, int y, int w, int h, const Color& color)
{
    D3DRECT rect = { x, y, x + w, y + h };

    this->set_draw_color(color);
    this->device->Clear(1, &rect, D3DCLEAR_TARGET, this->color, 0, 0);
}

void RenderTool::draw_border_box(int x, int y, int w, int h, const Color& color, int l)
{
    draw_filled_box(x, y, w, l, color);
    draw_filled_box(x, y, l, h, color);
    draw_filled_box(x + w, y, l, h, color);
    draw_filled_box(x, y + h, w + l, l, color);
}

C++:
    static bool WorldToScreen(Math::CVector in, Math::CVector& out)
    {
        const Math::VMatrix w2sm = CInterfaces::get().engine->world_to_screen_matrix();
        float w = w2sm[3][0] * in.x + w2sm[3][1] * in.y + w2sm[3][2] * in.z + w2sm[3][3];

        if (w > 0.001f)
        {
            int width, height; CInterfaces::get().engine->get_screen_size(width, height);

            float fl1DBw = 1 / w;
            out.x = (width / 2) + (0.5f * ((w2sm[0][0] * in.x + w2sm[0][1] * in.y + w2sm[0][2] * in.z + w2sm[0][3]) * fl1DBw) * width + 0.5f);
            out.y = (height / 2) - (0.5f * ((w2sm[1][0] * in.x + w2sm[1][1] * in.y + w2sm[1][2] * in.z + w2sm[1][3]) * fl1DBw) * height + 0.5f);
            return true;
        }
        return false;
    }
 
Сверху Снизу