From ee4f2bf31bc1f7db791fda99232fc5b01685d6dd Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Tue, 10 Jan 2023 14:27:34 +0100 Subject: [PATCH] fixed azazel/players ESP being off-centered --- DevourClient/Helpers/Render.cs | 71 +++++++++++++++++++++++----------- DevourClient/MelonMain.cs | 40 ++----------------- 2 files changed, 51 insertions(+), 60 deletions(-) diff --git a/DevourClient/Helpers/Render.cs b/DevourClient/Helpers/Render.cs index c3185c1..789e163 100644 --- a/DevourClient/Helpers/Render.cs +++ b/DevourClient/Helpers/Render.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; +using MelonLoader; namespace DevourClient.Render { @@ -49,14 +50,6 @@ namespace DevourClient.Render GUI.color = color2; } - public static void DrawBox(float x, float y, float w, float h, Color color, float thickness) - { - DrawLine(new Vector2(x, y), new Vector2(x + w, y), color, thickness); - DrawLine(new Vector2(x, y), new Vector2(x, y + h), color, thickness); - DrawLine(new Vector2(x + w, y), new Vector2(x + w, y + h), color, thickness); - DrawLine(new Vector2(x, y + h), new Vector2(x + w, y + h), color, thickness); - } - public static void DrawNameESP(Vector3 pos, string name, Color color) { if (Camera.main == null) @@ -75,27 +68,59 @@ namespace DevourClient.Render } } - public static void DrawBoxESP(Vector3 footpos, Vector3 headpos, Color color, string playername = "", bool snapline = false, bool esp = true, bool only_name = false) + public static void RectFilled(float x, float y, float width, float height, Texture2D text) { - float height = headpos.y - footpos.y; - float widthOffset = 2f; - float width = height / widthOffset; + GUI.DrawTexture(new Rect(x, y, width, height), text); + } - if (playername != "" && esp || playername != "" && only_name) - { - Render.DrawString(new Vector2((footpos.x - (width / 2)) + 25, (float)Screen.height - footpos.y - height), color, playername, false); - } - - //ESP BOX + public static void RectOutlined(float x, float y, float width, float height, Texture2D text, float thickness = 1f) + { + RectFilled(x, y, thickness, height, text); + RectFilled(x + width - thickness, y, thickness, height, text); + RectFilled(x + thickness, y, width - thickness * 2f, thickness, text); + RectFilled(x + thickness, y + height - thickness, width - thickness * 2f, thickness, text); + } + + public static void Box(float x, float y, float width, float height, Texture2D text, float thickness = 1f) + { + RectOutlined(x - width / 2f, y - height, width, height, text, thickness); + } + + public static Texture2D texture2 = new Texture2D(2, 2, TextureFormat.ARGB32, false); + public static void DrawBoxESP(Vector3 pos, Transform child, Color color, string name, bool snapline = false, bool esp = false) + { if (esp) { - Render.DrawBox(footpos.x - (width / 2), (float)Screen.height - footpos.y - height, width, height, color, 2f); + //ESP BOX + texture2.SetPixel(0, 0, color); + texture2.SetPixel(1, 0, color); + texture2.SetPixel(0, 1, color); + texture2.SetPixel(1, 1, color); + texture2.Apply(); + + + child.transform.position = new Vector3(child.transform.position.x, child.transform.position.y + 2.0f, child.transform.position.z); + + Vector3 w2s = Camera.main.WorldToScreenPoint(pos); + Vector3 w2s2 = Camera.main.WorldToScreenPoint(child.position); + float num = Mathf.Abs(w2s.y - w2s2.y); + Box(w2s.x, Screen.height - w2s.y, num / 1.8f, num, texture2, 1f); + + DrawString(new Vector2(w2s.x, Screen.height - w2s2.y + child.transform.position.y - 10.0f), color, name); } - - //Snapline + + + // Snapline if (snapline) - { - Render.DrawLine(new Vector2((float)(Screen.width / 2), (float)(Screen.height / 2)), new Vector2(footpos.x, (float)Screen.height - footpos.y), color, 2f); + { + Vector3 pivotPos = pos; + Vector3 playerFootPos; playerFootPos.x = pivotPos.x; playerFootPos.z = pivotPos.z; playerFootPos.y = pivotPos.y; //At the feet + Vector3 w2s_footpos = Camera.main.WorldToScreenPoint(playerFootPos); + + if (w2s_footpos.z > 0f) + { + Render.DrawLine(new Vector2((float)(Screen.width / 2), (float)(Screen.height / 2)), new Vector2(w2s_footpos.x, (float)Screen.height - w2s_footpos.y), color, 2f); + } } } } diff --git a/DevourClient/MelonMain.cs b/DevourClient/MelonMain.cs index 2d8f3f8..78ac1ac 100644 --- a/DevourClient/MelonMain.cs +++ b/DevourClient/MelonMain.cs @@ -166,31 +166,12 @@ namespace DevourClient if (player != null) { - - Vector3 pivotPos = player.transform.position; //Pivot point NOT at the origin, at the center - Vector3 playerFootPos; playerFootPos.x = pivotPos.x; playerFootPos.z = pivotPos.z; playerFootPos.y = pivotPos.y - 2f; //At the feet - Vector3 playerHeadPos; playerHeadPos.x = pivotPos.x; playerHeadPos.z = pivotPos.z; playerHeadPos.y = pivotPos.y + 2f; //At the head - - if (Camera.main == null) + if (player.GetComponent().entity.IsOwner) { continue; } - Vector3 w2s_footpos = Camera.main.WorldToScreenPoint(playerFootPos); - Vector3 w2s_headpos = Camera.main.WorldToScreenPoint(playerHeadPos); - - if (w2s_footpos.z > 0f) - { - //string playername = player.field_Private_PhotonView_0.field_Private_ObjectPublicObInBoStBoHaStObInHaUnique_0.field_Private_String_0;//player.photonView._Controller_k__BackingField.NickName; - - if (player.GetComponent().entity.IsOwner) - { - continue; - } - - Render.Render.DrawBoxESP(w2s_footpos, w2s_headpos, Settings.Settings.player_esp_color, p.Name, this.player_snapline, this.player_esp); - } - + Render.Render.DrawBoxESP(player.transform.position, player.transform.GetComponentsInChildren()[0], Settings.Settings.player_esp_color, p.Name, this.player_snapline, this.player_esp); } } } @@ -258,22 +239,7 @@ namespace DevourClient { if (survivalAzazel != null) { - - - Vector3 pivotPos = survivalAzazel.transform.position; //Pivot point NOT at the origin, at the center - Vector3 playerFootPos; playerFootPos.x = pivotPos.x; playerFootPos.z = pivotPos.z; playerFootPos.y = pivotPos.y - 2f; //At the feet - Vector3 playerHeadPos; playerHeadPos.x = pivotPos.x; playerHeadPos.z = pivotPos.z; playerHeadPos.y = pivotPos.y + 2f; //At the head - - if (Camera.main != null) - { - Vector3 w2s_footpos = Camera.main.WorldToScreenPoint(playerFootPos); - Vector3 w2s_headpos = Camera.main.WorldToScreenPoint(playerHeadPos); - - if (w2s_footpos.z > 0f) - { - Render.Render.DrawBoxESP(w2s_footpos, w2s_headpos, Settings.Settings.azazel_esp_color, "Azazel", this.azazel_snapline, this.azazel_esp); - } - } + Render.Render.DrawBoxESP(survivalAzazel.transform.position, survivalAzazel.transform.GetComponentsInChildren()[0], Settings.Settings.azazel_esp_color, "Azazel", this.azazel_snapline, this.azazel_esp); } } }