-
Автор темы
- #1
C++:
void playeresp::draw_health(player_t* m_entity, const Box& box)
{
if (!g_cfg.player.type[type].health)
return;
if (!m_engine()->IsReplay())
return;
auto alpha = (int)(255.0f * esp_alpha_fade[m_entity->EntIndex()]);
auto back_color = Color(0, 0, 0, (int)(alpha * 0.6f));
constexpr float SPEED_FREQ = 255 / 1.0f;
int hp = m_entity->m_iHealth();
if (hp > 100)
hp = 100;
int red = 255 - (hp * 2.55);
int green = hp * 2.55;
Box n_box =
{
box.x - 5,
box.y,
2,
box.h
};
auto hp_color = m_entity->IsDormant() ? Color(130, 130, 130) : Color(150, (int)min(255.0f, hp * 225.0f / 100.0f), 0);
if (g_cfg.player.type[type].custom_health_color)
hp_color = m_entity->IsDormant() ? Color(130, 130, 130) : g_cfg.player.type[type].health_color;
hp_color.SetAlpha(min(alpha, hp_color.a()));
static float prev_player_hp[65];
if (prev_player_hp[m_entity->EntIndex()] > hp)
prev_player_hp[m_entity->EntIndex()] -= SPEED_FREQ * m_globals()->m_frametime;
else
prev_player_hp[m_entity->EntIndex()] = hp;
int hp_percent = box.h - (int)((box.h * prev_player_hp[m_entity->EntIndex()]) / 100);
int hp_percentw = box.w - (int)((box.w * prev_player_hp[m_entity->EntIndex()]) / 100);
int healthpos_X = 0;
int healthpos_Y = 0;
render::get().rect(box.x - 6, box.y, 4, box.h, back_color);
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 + hp_percent, 2, box.h - hp_percent, hp_color);
if (hp < 100)
render::get().text(fonts[ESP], n_box.x + 1, n_box.y + hp_percent, Color(255, 255, 255), HFONT_CENTERED_X | HFONT_CENTERED_Y, std::to_string(hp).c_str());
}