#include using namespace window; void get_map_position_from_origin( const math::position_t& m_position, float m_radius, float m_range, math::Vector3 start_origin, math::Vector3 end_origin, math::Angle3 view_angle, math::Vector3& out ) { const float x_center = (m_position.x); const float y_center = (m_position.y); auto delta = (start_origin - end_origin); float radians = (view_angle.y - 180.f) * (static_cast(M_PI) / 180.f); float view_sin = math::sinf(radians), view_cos = math::cosf(radians); out.x = static_cast(x_center) + (delta.y * (-view_cos) + delta.x * view_sin) / m_range; out.y = static_cast(y_center) + (delta.x * (-view_cos) - delta.y * view_sin) / m_range; out.z = 0.0f; auto center_screen = math::Vector3{ x_center, y_center, 0.0f }; auto center_delta = (out - center_screen); float distance = center_delta.Length2d(); if (distance > m_radius) { center_delta *= m_radius / center_delta.Length2d(); out = center_screen + center_delta; } } void c_radar::draw_base() { const auto Position = m_position; const auto Dimension = m_dimension; const auto Radius = cfg::radar_radius; m_radius = Radius; m_range = cfg::radar_range; g::p::render.draw_rect_filled({ 5, 5, 5 }, Position.x - Radius, Position.y - Radius, Position.x + Radius, Position.y + Radius, cfg::radar_opacity); g::p::render.draw_rect_bordered(respawn::colors::blue, Position.x - Radius, Position.y - Radius, Position.x + Radius, Position.y + Radius); g::p::render.draw_line(respawn::colors::blue, Position.x, Position.y - Radius, Position.x, Position.y + Radius); g::p::render.draw_line(respawn::colors::blue, Position.x - Radius, Position.y, Position.x + Radius, Position.y); } void c_radar::draw_objects() { if (!g::is_in_game) return; const auto& my_origin = g::p::cache.local_player.origin; const auto& my_angle = g::p::cache.local_player.eye_angle; const auto& my_team_num = g::p::cache.local_player.team_number; auto position = math::position_t( m_position.x, m_position.y ); for (auto i = 0ull; i < g::p::ent_cache.count(); i++) { auto data = g::p::ent_cache.get_neutral(i); if (!data.valid) continue; respawn::color_t color = respawn::colors::white; switch (data.type) { case cache::types::player: case cache::types::dummie: if (data.type_specific.plr.m_life_state != LIFE_ALIVE) continue; if (data.type_specific.plr.m_teammate) color = respawn::colors::cyan; else color = respawn::colors::red; if (data.type_specific.plr.m_bleedout_state != NULL && !data.type_specific.plr.m_teammate) color = respawn::colors::red; break; default: continue; } auto size = 4.0f; auto draw_pos = math::Vector3{}; get_map_position_from_origin( position, m_radius, m_range, my_origin, data.type_specific.plr.m_origin, my_angle, draw_pos ); g::p::render.draw_rect_filled( color, draw_pos.x - size, draw_pos.y - size, draw_pos.x + size, draw_pos.y + size, 255 ); g::p::render.draw_rect( respawn::colors::black, draw_pos.x - size, draw_pos.y - size, draw_pos.x + size, draw_pos.y + size, 255 ); } } void c_radar::paint() { if (!cfg::radar_enabled) return; set_flag(fl::draggable, true); draw_base(); draw_objects(); }