void ESP::CollectESPData() {
if (!gui::settings::esp::enable || !engine->IsInGame())
return;
std::vector<ESPData> collectedData;
for (CEntity* player : hooks::playerList) {
if (player == globals::localPlayer || !player->IsAlive() || player == nullptr)
continue;
if ((player->m_vecOrigin - globals::localPlayer->m_vecOrigin).Length2D() > gui::settings::esp::espdistance)
continue;
if (player->m_iTeamNum == globals::localPlayer->m_iTeamNum || !player->m_iTeamNum)
continue;
ESPData data = {};
// Собираем данные для коробки
if (gui::settings::esp::boxes) {
Vector3 top, bottom;
if (!debugOverlay->ScreenPosition(player->GetBonePos(8) + Vector3{ 0.f, 0.f, 8.f }, top) &&
!debugOverlay->ScreenPosition(player->GetBonePos(8) - Vector3{ 0.f, 0.f, 60.f }, bottom)) {
data.top = top;
data.bottom = bottom;
data.boxColor = ImColor(gui::settings::esp::boxcolor.x, gui::settings::esp::boxcolor.y, gui::settings::esp::boxcolor.z, 1.0f);
}
}
// Собираем данные для здоровья
if (gui::settings::esp::health) {
data.healthFraction = player->m_iHealth / 100.0f;
data.health = player->m_iHealth;
if (!(gui::settings::esp::healthbarcolorcustom))
{
if (data.health > 50)
data.healthColor = ImColor(0.2f, 1.0f, 0.2f); // Зеленый
else if (data.healthColor > 20)
data.healthColor = ImColor(1.0f, 1.0f, 0.2f); // Желтый
else
data.healthColor = ImColor(1.0f, 0.2f, 0.2f); // Красный
}
else
{
data.healthColor = ImColor(gui::settings::esp::healthbarcolor.x, gui::settings::esp::healthbarcolor.y, gui::settings::esp::healthbarcolor.z, 1.0f);
}
}
// Собираем данные для имени
if (gui::settings::esp::name) {
player_info_t info;
if (engine->GetPlayerInfo(player->GetIndex(), &info)) {
std::wstring wname = util::ansi2unicode(info.name);
data.name = std::string(wname.begin(), wname.end());
}
}
// Собираем данные для offscreen-указателей
if (gui::settings::esp::offscreen) {
Vector3 screenPos;
if (!debugOverlay->ScreenPosition(player->m_vecOrigin, screenPos)) {
data.isOffscreen = true;
data.offscreenPos = CalculateOffscreenPosition(screenPos); // Функция вычисляет позицию индикатора
data.offscreenColor = ImColor(gui::settings::esp::outoffovcolor.x, gui::settings::esp::outoffovcolor.y, gui::settings::esp::outoffovcolor.z, 1.0f);
}
}
collectedData.push_back(data);
}
// Защита данных мьютексом
std::lock_guard<std::mutex> lock(espDataMutex);
espRenderData = std::move(collectedData);
}
void ESP::HandleESP() {
std::lock_guard<std::mutex> lock(espDataMutex);
for (const auto& data : espRenderData) {
if (!data.top.IsZero() && !data.bottom.IsZero()) {
ImVec2 top = ImVec2(data.top.x, data.top.y);
ImVec2 bottom = ImVec2(data.bottom.x, data.bottom.y);
float height = bottom.y - top.y;
float width = height * 0.3f;
if (gui::settings::esp::length <= 9) {
// Corner ESP
// Corner ESP
const int length = static_cast<int>(width * (gui::settings::esp::length / 10.0f));
// Вычисление координат углов
const auto lefttop = top.x - width;
const auto righttop = top.x + width;
const auto leftbottom = bottom.x - width;
const auto rightbottom = bottom.x + width;
const auto topYPlusLength = top.y + length;
const auto bottomYMinusLength = bottom.y - length;
ImColor outlineColor = ImColor(0, 0, 0, 255); // Чёрный цвет для обводки
float outlineThickness = 1.0f; // Толщина обводки
if (gui::settings::esp::outer)
{
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(lefttop - outlineThickness, top.y - outlineThickness), ImVec2(lefttop + length + outlineThickness, top.y - outlineThickness), outlineColor); // Outer
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(righttop + outlineThickness, top.y - outlineThickness), ImVec2(righttop - length - outlineThickness, top.y - outlineThickness), outlineColor); // Outer
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(leftbottom - outlineThickness, bottom.y - outlineThickness), ImVec2(leftbottom + length + outlineThickness, bottom.y - outlineThickness), outlineColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(rightbottom + outlineThickness, bottom.y - outlineThickness), ImVec2(rightbottom - length - outlineThickness, bottom.y - outlineThickness), outlineColor); // Outer
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(lefttop - outlineThickness, top.y - outlineThickness), ImVec2(lefttop - outlineThickness, topYPlusLength + outlineThickness), outlineColor); // Outer
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(leftbottom - outlineThickness, bottom.y - outlineThickness), ImVec2(leftbottom - outlineThickness, bottomYMinusLength + outlineThickness), outlineColor); // Outer
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(righttop + outlineThickness, top.y - outlineThickness), ImVec2(righttop + outlineThickness, topYPlusLength + outlineThickness), outlineColor); // Outer
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(rightbottom + outlineThickness, bottom.y - outlineThickness), ImVec2(rightbottom + outlineThickness, bottomYMinusLength + outlineThickness), outlineColor);
}
if (gui::settings::esp::inner)
{
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(rightbottom - outlineThickness, bottom.y + outlineThickness), ImVec2(rightbottom - outlineThickness, bottomYMinusLength - outlineThickness), outlineColor); // Inner
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(righttop - outlineThickness, top.y + outlineThickness), ImVec2(righttop - outlineThickness, topYPlusLength - outlineThickness), outlineColor); // Inner
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(leftbottom + outlineThickness, bottom.y + outlineThickness), ImVec2(leftbottom + outlineThickness, bottomYMinusLength - outlineThickness), outlineColor); // Inner
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(lefttop + outlineThickness, top.y + outlineThickness), ImVec2(lefttop + outlineThickness, topYPlusLength - outlineThickness), outlineColor); // Inner
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(rightbottom - outlineThickness, bottom.y + outlineThickness), ImVec2(rightbottom - length + outlineThickness, bottom.y + outlineThickness), outlineColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(leftbottom + outlineThickness, bottom.y + outlineThickness), ImVec2(leftbottom + length - outlineThickness, bottom.y + outlineThickness), outlineColor); // Inner
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(righttop - outlineThickness, top.y + outlineThickness), ImVec2(righttop - length + outlineThickness, top.y + outlineThickness), outlineColor); // Inner
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(lefttop + outlineThickness, top.y + outlineThickness), ImVec2(lefttop + length - outlineThickness, top.y + outlineThickness), outlineColor); // Inner
}
// Inner Outline (внутренняя обводка)
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(lefttop, top.y), ImVec2(lefttop + length, top.y), data.boxColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(righttop, top.y), ImVec2(righttop - length, top.y), data.boxColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(leftbottom, bottom.y), ImVec2(leftbottom + length, bottom.y), data.boxColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(rightbottom, bottom.y), ImVec2(rightbottom - length, bottom.y), data.boxColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(lefttop, top.y), ImVec2(lefttop, topYPlusLength), data.boxColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(righttop, top.y), ImVec2(righttop, topYPlusLength), data.boxColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(leftbottom, bottom.y), ImVec2(leftbottom, bottomYMinusLength), data.boxColor);
ImGui::GetBackgroundDrawList()->AddLine(ImVec2(rightbottom, bottom.y), ImVec2(rightbottom, bottomYMinusLength), data.boxColor);
}
else {
// Прямоугольные коробки
const auto left = top.x - width;
const auto right = top.x + width;
ImColor outlineColor = ImColor(0, 0, 0, 255); // Цвет обводки (чёрный)
float outlineThickness = 1.0f; // Толщина обводки
if (gui::settings::esp::outer)
{
// Рисуем outer обводку
ImGui::GetBackgroundDrawList()->AddRect(
ImVec2(left - outlineThickness, top.y - outlineThickness),
ImVec2(right + outlineThickness, bottom.y + outlineThickness),
outlineColor);
}
if (gui::settings::esp::inner)
{
ImGui::GetBackgroundDrawList()->AddRect(
ImVec2(left + outlineThickness, top.y + outlineThickness),
ImVec2(right - outlineThickness, bottom.y - outlineThickness),
outlineColor);
}
// Рисуем основной прямоугольник поверх обводки
ImGui::GetBackgroundDrawList()->AddRect(ImVec2(left, top.y), ImVec2(right, bottom.y), data.boxColor);
}
}
// Рисуем полоски здоровья
if (data.healthFraction > 0.0f) {
const float h = data.bottom.y - data.top.y;
const float w = h * 0.3f;
const float left = data.top.x - w;
const float right = data.top.x + w;
float barHeight = h * data.healthFraction;
ImGui::GetBackgroundDrawList()->AddRectFilled(ImVec2(left - 5, data.top.y), ImVec2(left - 2, data.bottom.y), ImColor(0, 0, 0, 255));
ImGui::GetBackgroundDrawList()->AddRectFilled(ImVec2(left - 4, data.top.y + h - barHeight), ImVec2(left - 3, data.bottom.y - 1), data.healthColor);
}
// Рисуем имена
if (!data.name.empty()) {
ImVec2 namePos = ImVec2(data.top.x - ImGui::CalcTextSize(data.name.c_str()).x / 2.0f, data.top.y - 15);
ImGui::GetBackgroundDrawList()->AddText(namePos, ImColor(255, 255, 255, 255), data.name.c_str());
}
// Рисуем offscreen-указатели
if (data.isOffscreen) {
ImVec2 offscreenTop = ImVec2(data.offscreenPos.x, data.offscreenPos.y);
ImVec2 offscreenBottom = ImVec2(data.offscreenPos.x - 10, data.offscreenPos.y + 20);
ImVec2 offscreenRight = ImVec2(data.offscreenPos.x + 10, data.offscreenPos.y + 20);
ImGui::GetBackgroundDrawList()->AddTriangleFilled(offscreenTop, offscreenBottom, offscreenRight, data.offscreenColor);
}
}
}