void playeresp::draw_health(player_t* m_entity, const Box& box, const HPInfo& hpbox)
{
if (!g_cfg.player.type[type].health)
return;
auto alpha = (int)(255.0f * esp_alpha_fade[m_entity->EntIndex()]);
auto text_color = m_entity->IsDormant() ? Color(130, 130, 130, alpha) : Color(255, 255, 255, alpha);
auto back_color = Color(0, 0, 0, (int)(alpha * 0.6f));
auto color = m_entity->IsDormant() ? Color(130, 130, 130) : Color(150, (int)min(255.0f, hpbox.hp * 225.0f / 100.0f), 0);
auto hp_effect_color = Color(215, 20, 20, alpha);
if (g_cfg.player.type[type].custom_health_color)
color = m_entity->IsDormant() ? Color(130, 130, 130) : g_cfg.player.type[type].health_color;
color.SetAlpha(alpha);
render::get().rect(box.x - 6, box.y, 4, box.h, back_color);
Box n_box =
{
box.x - 5,
box.y,
2,
box.h
};
auto bar_height = (int)((float)hpbox.hp * (float)n_box.h / 100.0f);
auto offset = n_box.h - bar_height;
render::get().rect_filled(n_box.x, n_box.y - 1, 2, n_box.h + 2, back_color);
render::get().rect_filled(n_box.x, n_box.y + offset, 2, bar_height, color);
auto height = n_box.h - hpbox.hp * n_box.h / 100;
if (hpbox.hp_difference)
render::get().rect_filled(n_box.x, n_box.y + height - hpbox.hp_difference * n_box.h / 100, 2, hpbox.hp_difference * n_box.h / 100, hp_effect_color);
if (hpbox.hp < 100)
render::get().text(fonts[ESP], n_box.x + 1, n_box.y + offset, text_color, HFONT_CENTERED_X | HFONT_CENTERED_Y, std::to_string(hpbox.hp).c_str());
}