-
Автор темы
- #1
Взял за основу
Начал заниматься esp, но что-то пошло не так
код, который использовался:
Думаю, что ошибка в get_bbox либо world_to_screen
Пожалуйста, авторизуйтесь для просмотра ссылки.
Начал заниматься esp, но что-то пошло не так
код, который использовался:
C++:
// game/helpers/helpers.cpp
std::pair<math::vec2_t, bool> world_to_screen(const math::vec3_t& world) {
static const auto& matrix = *reinterpret_cast<math::matrix4x4_t*>(*SIG("client.dll", "0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9").self_offset(+0x3).cast<std::uintptr_t*>() + 0xb0);
auto ret = math::vec2_t();
ret.x = matrix[0u].x * world.x + matrix[0u].y * world.y + matrix[0u].z * world.z + matrix[0u].w;
ret.y = matrix[1u].x * world.x + matrix[1u].y * world.y + matrix[1u].z * world.z + matrix[1u].w;
const auto length = matrix[3u].x * world.x + matrix[3u].y * world.y + matrix[3u].z * world.z + matrix[3u].w;
if (length <= 0.001f)
return std::make_pair(ret, true);
ret /= length;
const auto screen_size = render::m_screen_size;
ret.x = screen_size.x / 2.f + ret.x * screen_size.x / 2.f;
ret.y = screen_size.y / 2.f - ret.y * screen_size.y / 2.f;
return std::make_pair(ret, true);
}
RECT get_bbox(game::entity_t* entity) {
RECT rect{};
auto collideable = entity->get_collideable();
if (!collideable)
return rect;
math::vec3_t min = collideable->get_obb_mins();
math::vec3_t max = collideable->get_obb_maxs();
const math::matrix3x4_t& trans = entity->coordinate_frame();
math::vec3_t points[] = {
math::vec3_t(min.x, min.y, min.z),
math::vec3_t(min.x, max.y, min.z),
math::vec3_t(max.x, max.y, min.z),
math::vec3_t(max.x, min.y, min.z),
math::vec3_t(max.x, max.y, max.z),
math::vec3_t(min.x, max.y, max.z),
math::vec3_t(min.x, min.y, max.z),
math::vec3_t(max.x, min.y, max.z)
};
math::vec3_t pointsTransformed[8];
math::vec2_t screen_points[8];
bool init = false;
for (int i = 1; i < 8; i++) {
math::vector_transform(points[i], trans, pointsTransformed[i]);
auto screen = world_to_screen(pointsTransformed[i]);
screen_points[i] = screen.first;
if (!screen.second)
return rect;
if (!init) {
rect.left = screen_points[0].x;
rect.top = screen_points[0].y;
rect.right = screen_points[0].x;
rect.bottom = screen_points[0].y;
init = true;
}
else {
if (rect.left > screen_points[i].x)
rect.left = screen_points[i].x;
if (rect.top < screen_points[i].y)
rect.top = screen_points[i].y;
if (rect.right < screen_points[i].x)
rect.right = screen_points[i].x;
if (rect.bottom > screen_points[i].y)
rect.bottom = screen_points[i].y;
}
}
return rect;
}
C++:
// player_
ctx.box = game::get_bbox(entity);
// player_::boxes
render::rect(math::vec2_t(ctx.box.left, ctx.box.top), math::vec2_t(ctx.box.right, ctx.box.bottom), math::col_t(255, 255, 255), ctx.settings->box_round, ctx.settings->box_thickness);
//render::rect
void rect(const math::vec2_t& pos, const math::vec2_t& pos2, const math::col_t& color, float round, float thickness) {
m_draw_list->add_rect(*reinterpret_cast<const im_vec2_t*>(&pos), *reinterpret_cast<const im_vec2_t*>(&pos2), color.hex(), round, thickness);
}
Последнее редактирование: