-
Автор темы
- #1
C++:
void Visuals::VelocityInfo()
{
auto last_log = 0;
if (!g_LocalPlayer || !g_LocalPlayer->IsAlive())
return;
if (!g_Options.velocity_info)
return;
int x, y;
g_EngineClient->GetScreenSize(x, y);
int screenWidth, screenHeight;
g_EngineClient->GetScreenSize(screenWidth, screenHeight);
Vector vec = g_LocalPlayer->m_vecVelocity();
float velocity = sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
bool in_air = g_LocalPlayer->m_fFlags() & IN_JUMP /*|| g_LocalPlayer->m_fFlags() & IN_SPEED*/;
Render::Get().RenderText(std::to_string(round(velocity)), screenWidth / 2 + 2, screenHeight - 100, 27.f, g_Options.Velocitycol, false, false, g_VeloFont);
Render::Get().RenderText("u/s", ImVec2(x / 2 + 1, y / 2 + 485), 2, g_Options.Velocitycol, false, false, g_VeloFont);
Render::Get().RenderLine(x / 2 - 100, y / 2 + 325, x / 2 - 100, y / 2 + 445, Color(100, 100, 100, 125));
Render::Get().RenderLine(x / 2 - 115, y / 2 + 430, x / 2 + 95, y / 2 + 430, Color(100, 100, 100, 125));
struct velo_info {
public:
float velocity;
bool on_ground;
};
std::deque<velo_info>velocity_data;
if (g_GlobalVars->curtime - last_log > g_GlobalVars->interval_per_tick) {
last_log = g_GlobalVars->curtime;
velocity_data.push_back({ velocity, in_air });
}
if (velocity_data.size() > 40) {
velocity_data.pop_front();
}
for (auto i = 0; i < velocity_data.size() - 1; i++)
{
auto cur = velocity_data[i].velocity;
auto next = velocity_data[i + 1].velocity;
auto landed = velocity_data[i].on_ground && !velocity_data[i + 1].on_ground;
Render::Get().RenderLine(x / 2 + 90 - (i - 1) * 5, y / 2 + 430 - (std::clamp(cur, 0, 450) * 75 / 320), x / 2 + 90 - i * 5, y / 2 + 130 - (std::clamp(next, 0, 450) * 75 / 320), Color(200, 200, 200, 255));
if (landed)
{
Render::Get().RenderLine(x / 2 + 90 - (i - 1) * 5, y / 2 + 430 - (std::clamp(cur, 0, 450) * 75 / 320), x / 2 + 90 - i * 5, y / 2 + 130 - (std::clamp(next, 0, 450) * 75 / 320), Color(200, 200, 200, 255));
Render::Get().RenderText(std::to_string(round(next)), ImVec2(x / 2 + 100 - (i + 1) * 5, y / 2 + 415 - (std::clamp(next, 0, 450) * 75 / 320)), 3, Color(245, 245, 220, 255));
}
}
}