Skip to content

Commit

Permalink
[Feature] Role-based ESP (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
cddjr committed Jun 1, 2022
1 parent bfecb62 commit 781bed4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gui/esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ImGuiWindow* CurrentWindow = nullptr;
static void RenderText(const char* text, const ImVec2& pos, const ImVec4& color, const bool outlined = true, const bool centered = true)
{
if (!text) return;
ImVec2& ImScreen = *(ImVec2*)&pos; // Type punning is safe here
ImVec2 ImScreen = pos;
if (centered)
{
auto size = ImGui::CalcTextSize(text);
Expand Down
3 changes: 1 addition & 2 deletions gui/esp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ typedef struct Drawing
{
std::mutex m_DrawingMutex;

static const int MaxPlayersInLevel = 15;
std::array<PlayerData, MaxPlayersInLevel> m_Players;
std::array<PlayerData, MAX_PLAYERS> m_Players;

ImVec2 LocalPosition{ 0.0f, 0.0f };
} drawing_t;
Expand Down
30 changes: 18 additions & 12 deletions gui/tabs/esp_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@
namespace EspTab {

void Render() {
if (IsInGame())
{
if (ImGui::BeginTabItem("Esp"))
{
ImGui::Checkbox("Enable", &State.ShowEsp);
if (not IsInGame())
return;

ImGui::Checkbox("Show Ghosts", &State.ShowEsp_Ghosts);
ImGui::Checkbox("Hide During Meetings", &State.HideEsp_During_Meetings);
bool changed = false;
if (ImGui::BeginTabItem("Esp")) {

ImGui::Checkbox("Show Box", &State.ShowEsp_Box);
ImGui::Checkbox("Show Tracers", &State.ShowEsp_Tracers);
ImGui::Checkbox("Show Distance", &State.ShowEsp_Distance);
changed |= ImGui::Checkbox("Enable", &State.ShowEsp);

ImGui::EndTabItem();
}
changed |= ImGui::Checkbox("Show Ghosts", &State.ShowEsp_Ghosts);
changed |= ImGui::Checkbox("Hide During Meetings", &State.HideEsp_During_Meetings);

changed |= ImGui::Checkbox("Show Box", &State.ShowEsp_Box);
changed |= ImGui::Checkbox("Show Tracers", &State.ShowEsp_Tracers);
changed |= ImGui::Checkbox("Show Distance", &State.ShowEsp_Distance);

changed |= ImGui::Checkbox("Role-based", &State.ShowEsp_RoleBased);

ImGui::EndTabItem();
}
if (changed) {
State.Save();
}
}
}
10 changes: 6 additions & 4 deletions gui/tabs/self_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ namespace SelfTab {
if (ImGui::Checkbox("Reveal Votes", &State.RevealVotes)) {
State.Save();
}
ImGui::SameLine();
if (ImGui::Checkbox("Reveal Anonymous Votes", &State.RevealAnonymousVotes)) {
State.Save();
RevealAnonymousVotes();
if (!IsInGame() && !IsInLobby() || (*Game::pGameOptionsData)->fields.AnonymousVotes) {
ImGui::SameLine();
if (ImGui::Checkbox("Reveal Anonymous Votes", &State.RevealAnonymousVotes)) {
State.Save();
RevealAnonymousVotes();
}
}

if (ImGui::Checkbox("See Ghosts", &State.ShowGhosts)) {
Expand Down
6 changes: 4 additions & 2 deletions hooks/PlayerControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,14 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {
espPlayerData.Position = WorldToScreen(playerPos);
if (outfit != NULL)
{
espPlayerData.Color = AmongUsColorToImVec4(GetPlayerColor(outfit->fields.ColorId));
espPlayerData.Color = State.ShowEsp_RoleBased == false ? AmongUsColorToImVec4(GetPlayerColor(outfit->fields.ColorId))
: AmongUsColorToImVec4(GetRoleColor(playerData->fields.Role));
espPlayerData.Name = convert_from_string(outfit->fields._playerName);
}
else
{
espPlayerData.Color = ImVec4(0.f, 0.f, 0.f, 1.f);
espPlayerData.Color = State.ShowEsp_RoleBased == false ? ImVec4(0.f, 0.f, 0.f, 1.f)
: AmongUsColorToImVec4(GetRoleColor(playerData->fields.Role));
espPlayerData.Name = "<Unknown>";
}
espPlayerData.OnScreen = IsWithinScreenBounds(playerPos);
Expand Down
2 changes: 2 additions & 0 deletions user/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void Settings::Load() {
JSON_TRYGET("ShowEsp_Tracers", this->ShowEsp_Tracers);
JSON_TRYGET("ShowEsp_Distance", this->ShowEsp_Distance);
JSON_TRYGET("HideEsp_During_Meetings", this->HideEsp_During_Meetings);
JSON_TRYGET("ShowEsp_RoleBased", this->ShowEsp_RoleBased);

JSON_TRYGET("MaxVision", this->MaxVision);
JSON_TRYGET("Wallhack", this->Wallhack);
Expand Down Expand Up @@ -127,6 +128,7 @@ void Settings::Save() {
{"ShowEsp_Tracers", this->ShowEsp_Tracers},
{"ShowEsp_Distance", this->ShowEsp_Distance},
{"HideEsp_During_Meetings", this->HideEsp_During_Meetings},
{"ShowEsp_RoleBased", this->ShowEsp_RoleBased},

{"MaxVision", this->MaxVision},
{"Wallhack", this->Wallhack},
Expand Down
1 change: 1 addition & 0 deletions user/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Settings {
bool ShowEsp_Tracers = true;
bool ShowEsp_Distance = true;
bool HideEsp_During_Meetings = false;
bool ShowEsp_RoleBased = false;

bool InMeeting = false;
bool PlayMedbayScan = false;
Expand Down

0 comments on commit 781bed4

Please sign in to comment.