ESP now shows NPC and Avatar names

This commit is contained in:
m0nkrel 2022-07-19 17:48:46 +03:00
parent 43109d22fd
commit f102c75f54
2 changed files with 63 additions and 0 deletions

View File

@ -146,6 +146,59 @@ namespace cheat::feature
return instance; return instance;
} }
void ESP::GetNpcName(std::string& name)
{
if (name.find("Avatar") != std::string::npos)
{
//cause name is like "Avatar_Catalyst_Boy_Heizo(Clone)" - We'll get name between 3rd underscore and 1st bracket
int j = 0; // j is the number of spaces before the name starts
int pos1 = 0;
int pos2 = 0;
for (int i = 0; i < name.length(); i++)
{
if (name[i] == '_')
{
j++;
if (j == 3)
{
pos1 = i;
}
}
if (name[i] == '(')
{
pos2 = i;
break;
}
}
name = name.substr(pos1 + 1, pos2 - pos1 - 1);
}
else
{
int j = 0; //number of underscores in the name
int pos1 = 0; //position of the first underscore in the name
int pos2 = 0; //position of the second underscore in the name
for (int i = 0; i < name.length(); i++)
{
if (name[i] == '_')
{
j++;
if (j == 4)
{
pos1 = i;
}
if (j == 5)
{
pos2 = i;
break;
}
}
}
name = name.substr(pos1 + 1, pos2 - pos1 - 1);
}
return;
}
void ESP::AddFilter(const std::string& section, const std::string& name, game::IEntityFilter* filter) void ESP::AddFilter(const std::string& section, const std::string& name, game::IEntityFilter* filter)
{ {
if (m_Sections.count(section) == 0) if (m_Sections.count(section) == 0)
@ -261,6 +314,14 @@ namespace cheat::feature
if (!entry.m_Enabled || !m_FilterExecutor.ApplyFilter(entity, filter)) if (!entry.m_Enabled || !m_FilterExecutor.ApplyFilter(entity, filter))
continue; continue;
if (entry.m_Name == "Npc" || "AvatarOwn" || "AvatarTeammate")
{
auto name = entity->name();
GetNpcName(name);
esp::render::DrawEntity(name, entity, entry.m_Color, entry.m_ContrastColor);
break;
}
esp::render::DrawEntity(entry.m_Name, entity, entry.m_Color, entry.m_ContrastColor); esp::render::DrawEntity(entry.m_Name, entity, entry.m_Color, entry.m_ContrastColor);
break; break;
} }

View File

@ -79,6 +79,8 @@ namespace cheat::feature
void DrawSection(const std::string& section, const Filters& filters); void DrawSection(const std::string& section, const Filters& filters);
void DrawFilterField(const config::Field<esp::ESPItem>& field); void DrawFilterField(const config::Field<esp::ESPItem>& field);
void GetNpcName(std::string& name);
void OnKeyUp(short key, bool& cancelled); void OnKeyUp(short key, bool& cancelled);
ESP(); ESP();