fixed item/goat/demon ESP being off-centered

This commit is contained in:
2023-01-10 12:08:54 +01:00
parent 4230bcd431
commit 90bc75c7f8
2 changed files with 25 additions and 134 deletions

View File

@@ -57,6 +57,24 @@ namespace DevourClient.Render
DrawLine(new Vector2(x, y + h), 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)
{
return;
}
Vector3 vector = Camera.main.WorldToScreenPoint(pos);
if (vector.z > 0f)
{
vector.y = (float)Screen.height - (vector.y + 1f);
GUI.color = color;
GUI.DrawTexture(new Rect(new Vector2(vector.x, vector.y), new Vector2(5f, 5f)), Texture2D.whiteTexture, 0);
GUI.Label(new Rect(new Vector2(vector.x, vector.y), new Vector2(100f, 100f)), name);
GUI.color = Color.white;
}
}
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 DrawBoxESP(Vector3 footpos, Vector3 headpos, Color color, string playername = "", bool snapline = false, bool esp = true, bool only_name = false)
{ {
float height = headpos.y - footpos.y; float height = headpos.y - footpos.y;

View File

@@ -201,27 +201,7 @@ namespace DevourClient
{ {
if (goat != null) if (goat != null)
{ {
Render.Render.DrawNameESP(goat.transform.position, goat.name.Replace("Survival", "").Replace("(Clone)", ""), new Color(0.94f, 0.61f, 0.18f, 1.0f));
Vector3 pivotPos = goat.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 + 0.3f; //At the middle
if (Camera.main == null)
{
continue;
}
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, new Color(0.94f, 0.61f, 0.18f, 1.0f), goat.name.Replace("Survival", "").Replace("(Clone)", ""), false, false, true);
}
} }
} }
} }
@@ -232,30 +212,7 @@ namespace DevourClient
{ {
if (obj != null) if (obj != null)
{ {
Render.Render.DrawNameESP(obj.transform.position, obj.prefabName.Replace("Survival", ""), new Color(1.0f, 1.0f, 1.0f));
Vector3 pivotPos = obj.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 + 0.3f; //At the middle
if (Camera.main == null)
{
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;
Render.Render.DrawBoxESP(w2s_footpos, w2s_headpos, new Color(1.0f, 1.0f, 1.0f), obj.prefabName.Replace("Survival", ""), false, false, true);
}
} }
} }
@@ -263,28 +220,7 @@ namespace DevourClient
{ {
if (key != null) if (key != null)
{ {
Render.Render.DrawNameESP(key.transform.position, "Key", new Color(1.0f, 1.0f, 1.0f));
Vector3 pivotPos = key.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 + 0.3f; //At the middle
if (Camera.main == null)
{
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;
Render.Render.DrawBoxESP(w2s_footpos, w2s_headpos, new Color(1.0f, 1.0f, 1.0f), "Key", false, false, true);
}
} }
} }
} }
@@ -295,28 +231,7 @@ namespace DevourClient
{ {
if (demon != null) if (demon != null)
{ {
Render.Render.DrawNameESP(demon.transform.position, demon.name.Replace("Survival", "").Replace("(Clone)", ""), new Color(1.0f, 0.0f, 0.0f, 1.0f));
Vector3 pivotPos = demon.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 + 0.3f; //At the middle
if (Camera.main == null)
{
continue;
}
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, new Color(1.0f, 0.0f, 0.0f, 1.0f), demon.name.Replace("Survival", "").Replace("(Clone)", ""), false, false, true);
}
} }
} }
@@ -324,28 +239,7 @@ namespace DevourClient
{ {
if (spider != null) if (spider != null)
{ {
Render.Render.DrawNameESP(spider.transform.position, "Spider", new Color(1.0f, 0.0f, 0.0f, 1.0f));
Vector3 pivotPos = spider.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 + 0.3f; //At the middle
if (Camera.main == null)
{
continue;
}
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, new Color(1.0f, 0.0f, 0.0f, 1.0f), "Spider", false, false, true);
}
} }
} }
@@ -353,28 +247,7 @@ namespace DevourClient
{ {
if (ghost != null) if (ghost != null)
{ {
Render.Render.DrawNameESP(ghost.transform.position, "Ghost", new Color(1.0f, 0.0f, 0.0f, 1.0f));
Vector3 pivotPos = ghost.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 + 0.3f; //At the middle
if (Camera.main == null)
{
continue;
}
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, new Color(1.0f, 0.0f, 0.0f, 1.0f), "Ghost", false, false, true);
}
} }
} }
} }
@@ -644,7 +517,7 @@ namespace DevourClient
int i = 0; int i = 0;
foreach (BasePlayer bp in Entities.Players) foreach (BasePlayer bp in Entities.Players)
{ {
if (bp == null) if (bp == null || bp.Name == "")
{ {
continue; continue;
} }