diff --git a/src/hacks/CMakeLists.txt b/src/hacks/CMakeLists.txt index 4147cf76..9b26643b 100755 --- a/src/hacks/CMakeLists.txt +++ b/src/hacks/CMakeLists.txt @@ -29,7 +29,6 @@ set(files "${CMAKE_CURRENT_LIST_DIR}/AutoJoin.cpp" "${CMAKE_CURRENT_LIST_DIR}/KillSay.cpp" "${CMAKE_CURRENT_LIST_DIR}/DominateSay.cpp" "${CMAKE_CURRENT_LIST_DIR}/Killstreak.cpp" - "${CMAKE_CURRENT_LIST_DIR}/LightESP.cpp" "${CMAKE_CURRENT_LIST_DIR}/Misc.cpp" "${CMAKE_CURRENT_LIST_DIR}/MiscPlayerInfo.cpp" "${CMAKE_CURRENT_LIST_DIR}/NavBot.cpp" @@ -47,6 +46,7 @@ if(EnableVisuals) "${CMAKE_CURRENT_LIST_DIR}/DominateMark.cpp" "${CMAKE_CURRENT_LIST_DIR}/ESP.cpp" "${CMAKE_CURRENT_LIST_DIR}/ExplosionCircles.cpp" + "${CMAKE_CURRENT_LIST_DIR}/HeadESP.cpp" "${CMAKE_CURRENT_LIST_DIR}/KillfeedColor.cpp" "${CMAKE_CURRENT_LIST_DIR}/Tracers.cpp" "${CMAKE_CURRENT_LIST_DIR}/Radar.cpp" diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp index bba2226d..4aff3c96 100644 --- a/src/hacks/ESP.cpp +++ b/src/hacks/ESP.cpp @@ -17,20 +17,16 @@ static settings::Boolean enable{ "esp.enable", "false" }; static settings::Int max_dist{ "esp.range", "4096" }; static settings::Int box_esp{ "esp.box.mode", "2" }; -static settings::Int box_corner_size{ "esp.box.corner-size", "10" }; +static settings::Int box_corner_size_height{ "esp.box.corner-size.height", "10" }; +static settings::Int box_corner_size_width{ "esp.box.corner-size.width", "10" }; static settings::Boolean box_3d_player{ "esp.box.player-3d", "false" }; static settings::Boolean box_3d_building{ "esp.box.building-3d", "false" }; -static settings::Int tracers{ "esp.tracers-mode", "0" }; - -static settings::Int emoji_esp{ "esp.emoji.mode", "0" }; -static settings::Int emoji_esp_size{ "esp.emoji.size", "32" }; -static settings::Boolean emoji_esp_scaling{ "esp.emoji.scaling", "true" }; -static settings::Int emoji_min_size{ "esp.emoji.min-size", "20" }; +static settings::Boolean draw_bones{ "esp.bones", "false" }; +static settings::Float bones_thickness{ "esp.bones.thickness", "0.5" }; +static settings::Boolean bones_color{ "esp.bones.color", "false" }; static settings::Int healthbar{ "esp.health-bar", "3" }; -static settings::Boolean draw_bones{ "esp.bones", "false" }; -static settings::Boolean bones_color{ "esp.bones.color", "false" }; static settings::Int sightlines{ "esp.sightlines", "0" }; static settings::Int esp_text_position{ "esp.text-position", "0" }; static settings::Int esp_expand{ "esp.expand", "0" }; @@ -87,7 +83,7 @@ void AddEntityString(CachedEntity *entity, const std::string &string, const rgba // Entity Processing void __attribute__((fastcall)) ProcessEntity(CachedEntity *ent); void __attribute__((fastcall)) ProcessEntityPT(CachedEntity *ent); -void __attribute__((fastcall)) emoji(CachedEntity *ent); +void __attribute__((fastcall)) hitboxUpdate(CachedEntity *ent); // helper funcs void __attribute__((fastcall)) Draw3DBox(CachedEntity *ent, const rgba_t &clr); void __attribute__((fastcall)) DrawBox(CachedEntity *ent, const rgba_t &clr); @@ -204,7 +200,7 @@ struct bonelist_s } if (i > 0) { - draw::Line(last_screen.x, last_screen.y, current_screen.x - last_screen.x, current_screen.y - last_screen.y, color, 0.5f); + draw::Line(last_screen.x, last_screen.y, current_screen.x - last_screen.x, current_screen.y - last_screen.y, color, *bones_thickness); } last_screen = current_screen; } @@ -342,9 +338,6 @@ static void Draw() for (auto &i : entities_need_repaint) { ProcessEntityPT(ENTITY(i.first)); -#ifndef FEATURE_EMOJI_ESP_DISABLED - emoji(ENTITY(i.first)); -#endif } } @@ -378,22 +371,24 @@ static void cm() { // Prof section ends when out of scope, these brackets here. PROF_SECTION(CM_ESP_EntityLoop); // Loop through entities - for (int i = 0; i < limit; i++) + for (int i = 0; i <= limit; i++) { // Get an entity from the loop tick and process it CachedEntity *ent = ENTITY(i); if (CE_INVALID(ent) || !ent->m_bAlivePlayer()) continue; - bool player = i <= max_clients; + bool player = i < max_clients; if (player) { ProcessEntity(ent); + hitboxUpdate(ent); } else if (entity_tick) { ProcessEntity(ent); + hitboxUpdate(ent); } if (data[ent->m_IDX].needs_paint) @@ -409,9 +404,6 @@ static void cm() std::sort(entities_need_repaint.begin(), entities_need_repaint.end(), [](std::pair &a, std::pair &b) { return a.second > b.second; }); } // namespace hacks::shared::esp -static draw::Texture atlas{ paths::getDataPath("/textures/atlas.png") }; -static draw::Texture idspec{ paths::getDataPath("/textures/idspec.png") }; - Timer retry{}; void Init() { @@ -424,61 +416,21 @@ void Init() });*/ } -void _FASTCALL emoji(CachedEntity *ent) +// This is used to stop the bone ESP from lagging +void _FASTCALL hitboxUpdate(CachedEntity *ent) { // Check to prevent crashes if (CE_BAD(ent) || !ent->m_bAlivePlayer()) return; - // Emoji esp - if (emoji_esp) + if (ent->m_Type() == ENTITY_PLAYER) { - if (ent->m_Type() == ENTITY_PLAYER) + auto hit = ent->hitboxes.GetHitbox(0); + if (!hit) + return; + Vector hbm, hbx; + if (draw::WorldToScreen(hit->min, hbm) && draw::WorldToScreen(hit->max, hbx)) { - auto hit = ent->hitboxes.GetHitbox(0); - if (!hit) - return; - Vector hbm, hbx; - if (draw::WorldToScreen(hit->min, hbm) && draw::WorldToScreen(hit->max, hbx)) - { - Vector head_scr; - if (draw::WorldToScreen(hit->center, head_scr)) - { - float size = emoji_esp_scaling ? fabs(hbm.y - hbx.y) : *emoji_esp_size; - if (!size || !emoji_min_size) - return; - if (emoji_esp_scaling && (size < *emoji_min_size)) - size = *emoji_min_size; - player_info_s info{}; - unsigned int steamID = 0; - unsigned int steamidarray[32]{}; - bool hascall = false; - steamidarray[0] = 479487126; - steamidarray[1] = 263966176; - steamidarray[2] = 840255344; - steamidarray[3] = 147831332; - steamidarray[4] = 854198748; - if (g_IEngine->GetPlayerInfo(ent->m_IDX, &info)) - steamID = info.friendsID; - if (playerlist::AccessData(steamID).state == playerlist::k_EState::CAT) - draw::RectangleTextured(head_scr.x - size / 2, head_scr.y - size / 2, size, size, colors::white, idspec, 2 * 64, 1 * 64, 64, 64, 0); - for (int i = 0; i < 4; i++) - { - if (steamID == steamidarray[i]) - { - static int ii = 1; - while (i > 3) - { - ii++; - i -= 4; - } - draw::RectangleTextured(head_scr.x - size / 2, head_scr.y - size / 2, size, size, colors::white, idspec, i * 64, ii * 64, 64, 64, 0); - hascall = true; - } - } - if (!hascall) - draw::RectangleTextured(head_scr.x - size / 2, head_scr.y - size / 2, size, size, colors::white, atlas, (3 + (int) emoji_esp) * 64, 4 * 64, 64, 64, 0); - } - } + Vector head_scr; } } } @@ -533,28 +485,6 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) // Get if ent should be transparent bool transparent = vischeck && ent_data.transparent; - // Tracers - if (tracers && type == ENTITY_PLAYER) - { - - // Grab the screen resolution and save to some vars - int width, height; - g_IEngine->GetScreenSize(width, height); - - // Center values on screen - width = width / 2; - // Only center height if we are using center mode - if ((int) tracers == 1) - height = height / 2; - - // Get world to screen - Vector scn; - draw::WorldToScreen(*position, scn); - - // Draw a line - draw::Line(scn.x, scn.y, width - scn.x, height - scn.y, fg, 0.5f); - } - // Sightline esp if (sightlines && type == ENTITY_PLAYER) { @@ -741,7 +671,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) bone_color = colors::Transparent(bone_color); bonelist_s bl; - if (!CE_INVALID(ent) && ent->m_bAlivePlayer() && !RAW_ENT(ent)->IsDormant() && LOCAL_E->m_bAlivePlayer()) + if (!CE_INVALID(ent) && ent->m_bAlivePlayer() && !RAW_ENT(ent)->IsDormant()) { if (bones_color) bl.Draw(ent, bone_color); @@ -750,8 +680,8 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) } } - // Top horizontal health bar - if (*healthbar == 1) + // Health bar + if (*healthbar != 0) { // We only want health bars on players and buildings @@ -786,104 +716,29 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) // Get Colors rgba_t hp = colors::Transparent(colors::Health(health, healthmax), fg.a); rgba_t border = ((classid == RCC_PLAYER) && IsPlayerInvisible(ent)) ? colors::FromRGBA8(160, 160, 160, fg.a * 255.0f) : colors::Transparent(colors::black, fg.a); - // Get bar width + // Get bar width and height int hbw = (max_x - min_x - 1) * std::min((float) health / (float) healthmax, 1.0f); - - // Draw - draw::RectangleOutlined(min_x, min_y - 6, max_x - min_x + 1, 7, border, 0.5f); - draw::Rectangle(min_x + hbw, min_y - 5, -hbw, 5, hp); - } - } - } - - // Bottom horizontal health bar - else if (*healthbar == 2) - { - - // We only want health bars on players and buildings - if (type == ENTITY_PLAYER || type == ENTITY_BUILDING) - { - - // Get collidable from the cache - if (GetCollide(ent)) - { - - // Pull the cached collide info - int max_x = ent_data.collide_max.x; - int max_y = ent_data.collide_max.y; - int min_x = ent_data.collide_min.x; - int min_y = ent_data.collide_min.y; - - // Get health values - int health = 0; - int healthmax = 0; - switch (type) - { - case ENTITY_PLAYER: - health = g_pPlayerResource->GetHealth(ent); - healthmax = g_pPlayerResource->GetMaxHealth(ent); - break; - case ENTITY_BUILDING: - health = CE_INT(ent, netvar.iBuildingHealth); - healthmax = CE_INT(ent, netvar.iBuildingMaxHealth); - break; - } - - // Get Colors - rgba_t hp = colors::Transparent(colors::Health(health, healthmax), fg.a); - rgba_t border = ((classid == RCC_PLAYER) && IsPlayerInvisible(ent)) ? colors::FromRGBA8(160, 160, 160, fg.a * 255.0f) : colors::Transparent(colors::black, fg.a); - // Get bar width - int hbw = (max_x - min_x - 1) * std::min((float) health / (float) healthmax, 1.0f); - - // Draw - draw::RectangleOutlined(min_x, max_y, max_x - min_x + 1, 7, border, 0.5f); - draw::Rectangle(min_x + hbw, max_y + 1, -hbw, 5, hp); - } - } - } - - // Vertical health bar - else if (*healthbar == 3) - { - - // We only want health bars on players and buildings - if (type == ENTITY_PLAYER || type == ENTITY_BUILDING) - { - - // Get collidable from the cache - if (GetCollide(ent)) - { - - // Pull the cached collide info - int max_x = ent_data.collide_max.x; - int max_y = ent_data.collide_max.y; - int min_x = ent_data.collide_min.x; - int min_y = ent_data.collide_min.y; - - // Get health values - int health = 0; - int healthmax = 0; - switch (type) - { - case ENTITY_PLAYER: - health = g_pPlayerResource->GetHealth(ent); - healthmax = g_pPlayerResource->GetMaxHealth(ent); - break; - case ENTITY_BUILDING: - health = CE_INT(ent, netvar.iBuildingHealth); - healthmax = CE_INT(ent, netvar.iBuildingMaxHealth); - break; - } - - // Get Colors - rgba_t hp = colors::Transparent(colors::Health(health, healthmax), fg.a); - rgba_t border = ((classid == RCC_PLAYER) && IsPlayerInvisible(ent)) ? colors::FromRGBA8(160, 160, 160, fg.a * 255.0f) : colors::Transparent(colors::black, fg.a); - // Get bar height int hbh = (max_y - min_y - 2) * std::min((float) health / (float) healthmax, 1.0f); - // Draw - draw::RectangleOutlined(min_x - 7, min_y, 7, max_y - min_y, border, 0.5f); - draw::Rectangle(min_x - 6, max_y - hbh - 1, 5, hbh, hp); + // Top horizontal health bar + if (*healthbar == 1) + { + draw::RectangleOutlined(min_x, min_y - 6, max_x - min_x + 1, 7, border, 0.5f); + draw::Rectangle(min_x + hbw, min_y - 5, -hbw, 5, hp); + + } + // Bottom horizontal health bar + else if (*healthbar == 2) + { + draw::RectangleOutlined(min_x, max_y, max_x - min_x + 1, 7, border, 0.5f); + draw::Rectangle(min_x + hbw, max_y + 1, -hbw, 5, hp); + } + // Vertical health bar + else if (*healthbar == 3) + { + draw::RectangleOutlined(min_x - 7, min_y, 7, max_y - min_y, border, 0.5f); + draw::Rectangle(min_x - 6, max_y - hbh - 1, 5, hbh, hp); + } } } } @@ -934,7 +789,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) } break; case 3: - { // ABOVE + { // ABOVE CENTER draw_point = Vector((min_x + max_x) / 2.0f, min_y - data.at(ent->m_IDX).string_count * 16, 0); } break; @@ -1820,36 +1675,37 @@ void _FASTCALL DrawBox(CachedEntity *ent, const rgba_t &clr) // Function to draw box corners, Used by DrawBox void BoxCorners(int minx, int miny, int maxx, int maxy, const rgba_t &color, bool transparent) { - const rgba_t &black = transparent ? colors::Transparent(colors::black) : colors::black; - const int size = *box_corner_size; + const rgba_t &black = transparent ? colors::Transparent(colors::black) : colors::black; + const float heightSize = ((float) *box_corner_size_height / 100) * (maxy - miny - 3); + const float widthSize = ((float) *box_corner_size_width / 100) * (maxx - minx - 2); // Black corners // Top Left - draw::Rectangle(minx, miny, size, 3, black); - draw::Rectangle(minx, miny + 3, 3, size - 3, black); + draw::Rectangle(minx, miny, widthSize + 1, 3, black); + draw::Rectangle(minx, miny + 3, 3, heightSize - 3, black); // Top Right - draw::Rectangle(maxx - size + 1, miny, size, 3, black); - draw::Rectangle(maxx - 3 + 1, miny + 3, 3, size - 3, black); + draw::Rectangle(maxx, miny, -widthSize - 1, 3, black); + draw::Rectangle(maxx - 3 + 1, miny + 3, 3, heightSize - 3, black); // Bottom Left - draw::Rectangle(minx, maxy - 3, size, 3, black); - draw::Rectangle(minx, maxy - size, 3, size - 3, black); + draw::Rectangle(minx, maxy - 3, widthSize + 1, 3, black); + draw::Rectangle(minx, maxy, 3, -heightSize - 3, black); // Bottom Right - draw::Rectangle(maxx - size + 1, maxy - 3, size, 3, black); - draw::Rectangle(maxx - 2, maxy - size, 3, size - 3, black); + draw::Rectangle(maxx, maxy - 3, -widthSize - 1, 3, black); + draw::Rectangle(maxx - 2, maxy, 3, -heightSize - 3, black); // Colored corners // Top Left - draw::Line(minx + 1, miny + 1, size - 2, 0, color, 0.5f); - draw::Line(minx + 1, miny + 1, 0, size - 2, color, 0.5f); + draw::Line(minx + 1, miny + 1, widthSize, 0, color, 0.5f); + draw::Line(minx + 1, miny + 1, 0, heightSize, color, 0.5f); // Top Right - draw::Line(maxx - 1, miny + 1, -(size - 2), 0, color, 0.5f); - draw::Line(maxx - 1, miny + 1, 0, size - 2, color, 0.5f); + draw::Line(maxx - 1, miny + 1, -widthSize, 0, color, 0.5f); + draw::Line(maxx - 1, miny + 1, 0, heightSize, color, 0.5f); // Bottom Left - draw::Line(minx + 1, maxy - 2, size - 2, 0, color, 0.5f); - draw::Line(minx + 1, maxy - 2, 0, -(size - 2), color, 0.5f); + draw::Line(minx + 1, maxy - 2, widthSize, 0, color, 0.5f); + draw::Line(minx + 1, maxy - 2, 0, -heightSize, color, 0.5f); // Bottom Right - draw::Line(maxx - 1, maxy - 2, -(size - 2), 0, color, 0.5f); - draw::Line(maxx - 1, maxy - 2, 0, -(size - 2), color, 0.5f); + draw::Line(maxx - 1, maxy - 2, -widthSize, 0, color, 0.5f); + draw::Line(maxx - 1, maxy - 2, 0, -heightSize, color, 0.5f); } // Used for caching collidable bounds diff --git a/src/hacks/HeadESP.cpp b/src/hacks/HeadESP.cpp new file mode 100644 index 00000000..32bbc0c7 --- /dev/null +++ b/src/hacks/HeadESP.cpp @@ -0,0 +1,134 @@ +#include "config.h" +#if ENABLE_VISUALS +#include "common.hpp" + +namespace hacks::shared::headesp +{ +static settings::Int mode{ "headesp.mode", "0" }; +static settings::Float size_scaling{ "headesp.size-scaling", "2" }; +static settings::Boolean teammates{ "headesp.teammates", "false" }; + +static Vector hitp[PLAYER_ARRAY_SIZE]; +static Vector minp[PLAYER_ARRAY_SIZE]; +static Vector maxp[PLAYER_ARRAY_SIZE]; +static bool drawEsp[PLAYER_ARRAY_SIZE]; + +rgba_t HeadESPColor(CachedEntity *ent) +{ + if (!playerlist::IsDefault(ent)) + { + return playerlist::Color(ent); + } + return colors::green; +} + +static void cm() +{ + if (*mode == 0) + return; + for (int i = 1; i <= g_IEngine->GetMaxClients(); i++) + { + if (g_pLocalPlayer->entity_idx == i) + continue; + CachedEntity *pEntity = ENTITY(i); + if (CE_BAD(pEntity) || !pEntity->m_bAlivePlayer()) + { + drawEsp[i] = false; + continue; + } + if (pEntity->m_iTeam() == LOCAL_E->m_iTeam() && playerlist::IsDefault(pEntity) && !*teammates) + { + drawEsp[i] = false; + continue; + } + if (!pEntity->hitboxes.GetHitbox(0)) + continue; + hitp[i] = pEntity->hitboxes.GetHitbox(0)->center; + minp[i] = pEntity->hitboxes.GetHitbox(0)->min; + maxp[i] = pEntity->hitboxes.GetHitbox(0)->max; + drawEsp[i] = true; + } +} + +static draw::Texture atlas{ paths::getDataPath("/textures/atlas.png") }; +static draw::Texture idspec{ paths::getDataPath("/textures/idspec.png") }; + +void draw() +{ + if (*mode == 0) + return; + for (int i = 1; i <= g_IEngine->GetMaxClients(); i++) + { + if (!drawEsp[i]) + continue; + CachedEntity *pEntity = ENTITY(i); + if (CE_BAD(pEntity) || !pEntity->m_bAlivePlayer()) + continue; + if (pEntity == LOCAL_E) + continue; + Vector out; + if (draw::WorldToScreen(hitp[i], out)) + { + auto distance = pEntity->m_flDistance(); + if (*mode == 1) + { + float thickness = (20.0f * *size_scaling) / (distance / 125); + if (thickness < (2.0f * *size_scaling)) + thickness = 2.0f * *size_scaling; + draw::Circle(out.x, out.y, 1, hacks::shared::headesp::HeadESPColor(pEntity), thickness, 100); + } + else if (*mode == 2 || *mode == 3 || *mode == 4) + { + float size = (40.0f * *size_scaling) / (distance / 125); + if (size < (2.0f * *size_scaling)) + size = 2.0f * *size_scaling; + player_info_s info{}; + unsigned int steamID = 0; + unsigned int steamidarray[32]{}; + bool hascall = false; + steamidarray[0] = 479487126; + steamidarray[1] = 263966176; + steamidarray[2] = 840255344; + steamidarray[3] = 147831332; + steamidarray[4] = 854198748; + if (g_IEngine->GetPlayerInfo(pEntity->m_IDX, &info)) + steamID = info.friendsID; + if (playerlist::AccessData(steamID).state == playerlist::k_EState::CAT) + draw::RectangleTextured(out.x - size / 2, out.y - size / 2, size, size, colors::white, idspec, 2 * 64, 1 * 64, 64, 64, 0); + for (int i = 0; i < 4; i++) + { + if (steamID == steamidarray[i]) + { + static int ii = 1; + while (i > 3) + { + ii++; + i -= 4; + } + draw::RectangleTextured(out.x - size / 2, out.y - size / 2, size, size, colors::white, idspec, i * 64, ii * 64, 64, 64, 0); + hascall = true; + } + } + if (!hascall && *mode == 2) + { + int emojiClass = CE_INT(pEntity, netvar.iClass) - 1; + draw::RectangleTextured(out.x - size / 2, out.y - size / 2, size, size, colors::white, atlas, emojiClass * 64, 5 * 64, 64, 64, 0); + } + else if (!hascall) + { + draw::RectangleTextured(out.x - size / 2, out.y - size / 2, size, size, colors::white, atlas, (1 + *mode) * 64, 4 * 64, 64, 64, 0); + } + } + } + } +} + +static InitRoutine init([]() { + EC::Register(EC::CreateMove, cm, "cm_headesp", EC::average); +#if ENABLE_VISUALS + EC::Register(EC::Draw, draw, "draw_headesp", EC::average); +#endif +}); + +} // namespace hacks::shared::headesp +#endif diff --git a/src/hacks/LightESP.cpp b/src/hacks/LightESP.cpp deleted file mode 100644 index 80e25a59..00000000 --- a/src/hacks/LightESP.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "config.h" -#if ENABLE_VISUALS -#include "common.hpp" - -namespace hacks::shared::lightesp -{ -static settings::Boolean enable{ "lightesp.enable", "false" }; - -static Vector hitp[PLAYER_ARRAY_SIZE]; -static Vector minp[PLAYER_ARRAY_SIZE]; -static Vector maxp[PLAYER_ARRAY_SIZE]; -static bool drawEsp[PLAYER_ARRAY_SIZE]; - -rgba_t LightESPColor(CachedEntity *ent) -{ - if (!playerlist::IsDefault(ent)) - { - return playerlist::Color(ent); - } - return colors::green; -} - -static void cm() -{ - if (!*enable) - return; - for (int i = 1; i <= g_IEngine->GetMaxClients(); i++) - { - if (g_pLocalPlayer->entity_idx == i) - continue; - CachedEntity *pEntity = ENTITY(i); - if (CE_BAD(pEntity) || !pEntity->m_bAlivePlayer()) - { - drawEsp[i] = false; - continue; - } - if (pEntity->m_iTeam() == LOCAL_E->m_iTeam() && playerlist::IsDefault(pEntity)) - { - drawEsp[i] = false; - continue; - } - if (!pEntity->hitboxes.GetHitbox(0)) - continue; - hitp[i] = pEntity->hitboxes.GetHitbox(0)->center; - minp[i] = pEntity->hitboxes.GetHitbox(0)->min; - maxp[i] = pEntity->hitboxes.GetHitbox(0)->max; - drawEsp[i] = true; - } -} - -void draw() -{ - if (!enable) - return; - for (int i = 1; i <= g_IEngine->GetMaxClients(); i++) - { - if (!drawEsp[i]) - continue; - CachedEntity *pEntity = ENTITY(i); - if (CE_BAD(pEntity) || !pEntity->m_bAlivePlayer()) - continue; - if (pEntity == LOCAL_E) - continue; - Vector out; - if (draw::WorldToScreen(hitp[i], out)) - { - float size = 0.0f; - Vector pout, pout2; - if (draw::WorldToScreen(minp[i], pout) && draw::WorldToScreen(maxp[i], pout2)) - size = fmaxf(fabsf(pout2.x - pout.x), fabsf(pout2.y - pout.y)); - - float minsize = 20.0f; - if (size < minsize) - size = minsize; - draw::Rectangle(out.x - fabsf(pout.x - pout2.x) / 4, out.y - fabsf(pout.y - pout2.y) / 4, fabsf(pout.x - pout2.x) / 2, fabsf(pout.y - pout2.y) / 2, hacks::shared::lightesp::LightESPColor(pEntity)); - draw::Rectangle(out.x - size / 8, out.y - size / 8, size / 4, size / 4, colors::red_s); - } - } -} - -static InitRoutine init([]() { - EC::Register(EC::CreateMove, cm, "cm_lightesp", EC::average); -#if ENABLE_VISUALS - EC::Register(EC::Draw, draw, "draw_lightesp", EC::average); -#endif -}); - -} // namespace hacks::shared::lightesp -#endif diff --git a/src/hacks/Tracers.cpp b/src/hacks/Tracers.cpp index 8fd3bc0f..bce16c72 100644 --- a/src/hacks/Tracers.cpp +++ b/src/hacks/Tracers.cpp @@ -7,6 +7,8 @@ namespace hacks::shared::tracers { static settings::Boolean enabled("tracers.enabled", "false"); +static settings::Boolean teammates("tracers.teammates", "false"); +static settings::Int coloring_mode("tracers.coloring-mode", "0"); static settings::Float green_dist("tracers.green-distance", "1500"); static settings::Float max_dist("tracers.max-dist", "0"); static settings::Float min_fov("tracers.min-fov", "0"); @@ -60,18 +62,27 @@ inline std::optional getColor(CachedEntity *ent) { if (ent->m_Type() == ENTITY_BUILDING) { - if (!ent->m_bEnemy() || !ent->m_vecDormantOrigin()) + if (!ent->m_vecDormantOrigin()) + return std::nullopt; + if (!ent->m_bEnemy() && !teammates) return std::nullopt; float dist = ent->m_vecDormantOrigin()->DistTo(LOCAL_E->m_vecOrigin()); if (*max_dist && dist > *max_dist) return std::nullopt; if (GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, *ent->m_vecDormantOrigin()) < *min_fov) return std::nullopt; - float hf = float(std::min(dist, *green_dist)) / float(*green_dist); - rgba_t color(0.0f, 2.0f * hf, 2.0f * (1.0f - hf)); - color.g = std::min(1.0f, color.g); - color.b = std::min(1.0f, color.b); - return color; + if (*coloring_mode == 0) + { + float hf = float(std::min(dist, *green_dist)) / float(*green_dist); + rgba_t color(0.0f, 2.0f * hf, 2.0f * (1.0f - hf)); + color.g = std::min(1.0f, color.g); + color.b = std::min(1.0f, color.b); + return color; + } + else if (*coloring_mode == 1) + { + return colors::EntityF(ent); + } } else { @@ -79,22 +90,27 @@ inline std::optional getColor(CachedEntity *ent) auto state = playerlist::AccessData(ent->player_info.friendsID); if (state.state == playerlist::k_EState::DEFAULT) { - if (!ent->m_bEnemy() || !ent->m_vecDormantOrigin()) + if (!ent->m_vecDormantOrigin()) + return std::nullopt; + if (!ent->m_bEnemy() && !teammates) return std::nullopt; float dist = ent->m_vecDormantOrigin()->DistTo(LOCAL_E->m_vecOrigin()); if (*max_dist && dist > *max_dist) return std::nullopt; - return colors::Health(std::min(dist, *green_dist), *green_dist); + if (*coloring_mode == 0) + return colors::Health(std::min(dist, *green_dist), *green_dist); + else if (*coloring_mode == 1) + return colors::EntityF(ent); } if (!player_tools::shouldTargetSteamId(ent->player_info.friendsID)) { if (*draw_friendlies == 1) { if (ent->m_bEnemy()) - return colors::blu; + return colors::white; } else if (*draw_friendlies == 2) - return colors::blu; + return colors::white; return std::nullopt; } if (!ent->m_bEnemy()) @@ -117,9 +133,9 @@ void draw() if (CE_INVALID(ent)) { - if (i > g_IEngine->GetMaxClients()) + if (i > g_IEngine->GetMaxClients() || !g_pPlayerResource->isAlive(i)) continue; - if (g_pPlayerResource->GetTeam(i) == g_pLocalPlayer->team || !g_pPlayerResource->isAlive(i)) + if (g_pPlayerResource->GetTeam(i) == g_pLocalPlayer->team && !teammates) continue; auto vec = soundcache::GetSoundLocation(i); if (!vec) diff --git a/src/visual/menu/GuiInterface.cpp b/src/visual/menu/GuiInterface.cpp index 3fd19b27..a69d6414 100644 --- a/src/visual/menu/GuiInterface.cpp +++ b/src/visual/menu/GuiInterface.cpp @@ -32,59 +32,6 @@ static zerokernel::special::PlayerListData createPlayerListData(int userid) return data; } -class PlayerListEventListener : public IGameEventListener -{ -public: - void FireGameEvent(KeyValues *event) override - { - if (!controller) - return; - - auto userid = event->GetInt("userid"); - if (!userid) - return; - - std::string name = event->GetName(); - if (name == "player_connect_client") - { - logging::Info("addPlayer %d", userid); - controller->addPlayer(userid, createPlayerListData(userid)); - } - else if (name == "player_disconnect") - { - // logging::Info("removePlayer %d", userid); - controller->removePlayer(userid); - } - else if (name == "player_team") - { - // logging::Info("updatePlayerTeam %d", userid); - controller->updatePlayerTeam(userid, event->GetInt("team") - 1); - } - else if (name == "player_changeclass") - { - // logging::Info("updatePlayerClass %d", userid); - controller->updatePlayerClass(userid, event->GetInt("class")); - } - else if (name == "player_changename") - { - // logging::Info("updatePlayerName %d", userid); - controller->updatePlayerName(userid, event->GetString("newname")); - } - else if (name == "player_death") - { - // logging::Info("updatePlayerLifeState %d", userid); - controller->updatePlayerLifeState(userid, true); - } - else if (name == "player_spawn") - { - // logging::Info("updatePlayerLifeState %d", userid); - controller->updatePlayerLifeState(userid, false); - } - } -}; - -static PlayerListEventListener listener{}; - static void initPlayerlist() { auto pl = dynamic_cast(zerokernel::Menu::instance->wm->getElementById("special-player-list")); @@ -118,6 +65,102 @@ static void initPlayerlist() } } +void sortPList() +{ + for (auto i = 1; i <= MAX_PLAYERS; ++i) + { + player_info_s info{}; + if (g_IEngine->GetPlayerInfo(i, &info)) + { + auto idx = g_IEngine->GetPlayerForUserID(info.userID); + if (g_pPlayerResource->getTeam(idx) == 2) + { + controller->addPlayer(info.userID, createPlayerListData(info.userID)); + } + } + } + for (auto i = 1; i <= MAX_PLAYERS; ++i) + { + player_info_s info{}; + if (g_IEngine->GetPlayerInfo(i, &info)) + { + auto idx = g_IEngine->GetPlayerForUserID(info.userID); + if (g_pPlayerResource->getTeam(idx) == 3) + { + controller->addPlayer(info.userID, createPlayerListData(info.userID)); + } + } + } + for (auto i = 1; i <= MAX_PLAYERS; ++i) + { + player_info_s info{}; + if (g_IEngine->GetPlayerInfo(i, &info)) + { + auto idx = g_IEngine->GetPlayerForUserID(info.userID); + if (g_pPlayerResource->getTeam(idx) != 2 && g_pPlayerResource->getTeam(idx) != 3) + { + controller->addPlayer(info.userID, createPlayerListData(info.userID)); + } + } + } +} + +class PlayerListEventListener : public IGameEventListener +{ +public: + void FireGameEvent(KeyValues *event) override + { + if (!controller) + return; + + auto userid = event->GetInt("userid"); + if (!userid) + return; + + std::string name = event->GetName(); + if (name == "player_connect_client") + { + logging::Info("addPlayer %d", userid); + controller->removeAll(); + sortPList(); + } + else if (name == "player_disconnect") + { + // logging::Info("removePlayer %d", userid); + controller->removeAll(); + sortPList(); + } + else if (name == "player_team") + { + // logging::Info("updatePlayerTeam %d", userid); + controller->removeAll(); + sortPList(); + } + else if (name == "player_changeclass") + { + // logging::Info("updatePlayerClass %d", userid); + controller->updatePlayerClass(userid, event->GetInt("class")); + } + else if (name == "player_changename") + { + // logging::Info("updatePlayerName %d", userid); + controller->updatePlayerName(userid, event->GetString("newname")); + } + else if (name == "player_death") + { + // logging::Info("updatePlayerLifeState %d", userid); + controller->updatePlayerLifeState(userid, true); + } + else if (name == "player_spawn") + { + // logging::Info("updatePlayerLifeState %d", userid); + controller->updatePlayerLifeState(userid, false); + } + } +}; + +static PlayerListEventListener listener{}; + static void load() { zerokernel::Menu::instance->loadFromFile(paths::getDataPath("/menu"), "menu.xml"); @@ -170,6 +213,7 @@ void gui::draw() zerokernel::Menu::instance->update(); zerokernel::Menu::instance->render(); } + static Timer update_players{}; bool gui::handleSdlEvent(SDL_Event *event) { @@ -178,14 +222,7 @@ bool gui::handleSdlEvent(SDL_Event *event) if (controller && CE_GOOD(LOCAL_E) && update_players.test_and_set(10000)) { controller->removeAll(); - for (auto i = 1; i <= MAX_PLAYERS; ++i) - { - player_info_s info{}; - if (g_IEngine->GetPlayerInfo(i, &info)) - { - controller->addPlayer(info.userID, createPlayerListData(info.userID)); - } - } + sortPList(); } if (event->type == SDL_KEYDOWN) { @@ -222,13 +259,6 @@ void gui::onLevelLoad() if (controller) { controller->removeAll(); - for (auto i = 1; i < MAX_PLAYERS; ++i) - { - player_info_s info{}; - if (g_IEngine->GetPlayerInfo(i, &info)) - { - controller->addPlayer(info.userID, createPlayerListData(info.userID)); - } - } + sortPList(); } }