private void DrawHostilePlayerWarning(Player player, float baseDistance) { if (player.Team == PlayerTeam.Hostile && player.IsAlive && baseDistance < 400) { FillRect(new RectangleF(this.Width * 0.35f - 5f, this.Height * 0.7f + 1f, 320f, 25f), Color.FromArgb(140, 0, 0, 0)); DrawLargeText("Hostile player nearby!", new PointF(this.Width * 0.35f, this.Height * 0.7f), Color.Red); } }
private void DrawPlayerESP(Player player) { // Don't draw the ESP if the other vector is very close if (Vector.Distance(player.Origin, Game.ViewOrigin) < 80.0f) return; if (Settings.Default.OnlyHostilePlayers && player.Team == PlayerTeam.Friendly) return; string name = string.Format("#{0}{{{1}}}", player.Rank, player.Name); Color color; if (player.Team == PlayerTeam.Friendly) { color = Settings.Default.FriendlyColor; } else { color = Settings.Default.HostileColor; } if (!player.IsAlive) { if (!Settings.Default.DeadPlayers) return; name = string.Format("DEAD{{{0}}}", player.Name); color = Settings.Default.DeadPlayerColor; } PointF feetPoint, headPoint; if (MathHelper.WorldToScreen(player.Origin, out feetPoint)) { MathHelper.WorldToScreen(player.Origin + new Vector(0f, 0f, 63f), out headPoint); } else { return; } var drawPoint = new PointF(); drawPoint.Y = feetPoint.Y - headPoint.Y; if (drawPoint.Y < 10.0f) drawPoint.Y = 10.0f; if ((player.Flag & Flags.Crouched) != 0) { drawPoint.Y /= 1.4f; drawPoint.X = drawPoint.Y / 1.5f; } else if ((player.Flag & Flags.Prone) != 0) { drawPoint.Y /= 3.0f; drawPoint.X = drawPoint.Y * 2.0f; } else { drawPoint.X = drawPoint.Y / 2.75f; } var boundingBox = new RectangleF(); boundingBox.X = feetPoint.X - (drawPoint.X / 2.0f); boundingBox.Y = feetPoint.Y; boundingBox.Width = drawPoint.X; boundingBox.Height = -drawPoint.Y; var namePoint = new PointF(); namePoint.X = boundingBox.X + boundingBox.Width + 5.0f; namePoint.Y = feetPoint.Y - drawPoint.Y - 2.8f; var distancePoint = new PointF(); distancePoint.X = boundingBox.X + boundingBox.Width + 5.0f; distancePoint.Y = Settings.Default.PlayerName ? feetPoint.Y - drawPoint.Y + 9.8f : namePoint.Y; Distance distanceType = Settings.Default.DistanceType == 0 ? Distance.Meter() : Distance.Feet(); float baseDistance = Vector.Distance(Game.LocalPlayer.Origin, player.Origin); float distance = (float)Math.Round((double)baseDistance * distanceType.Const); string distanceString = string.Format("➔{0}{1}", distance, distanceType.Suffix); DrawRect(boundingBox, 2f, color); if (Settings.Default.PlayerName) DrawSmallText(name, namePoint, Settings.Default.PlayerNameColor); if (Settings.Default.DistanceToPlayer) DrawSmallText(distanceString, distancePoint, Settings.Default.DistanceToPlayerColor); if (Settings.Default.HostilePlayerWarning) DrawHostilePlayerWarning(player, baseDistance); }
public static void ReadGame() { if (hProcess == IntPtr.Zero) throw new SystemException("Failed to read structs from the game"); ViewOrigin = ProcessMemory.Read<Vector>(hProcess, Address.ViewOrigin); RefDef = ProcessMemory.Read<RefDef>(hProcess, Address.RefDef); Entities = ProcessMemory.ReadArray<Entity>(hProcess, Address.Entity, Entity.LENGTH, Entity.SIZE); Clients = ProcessMemory.ReadArray<ClientInfo>(hProcess, Address.ClientInfo, ClientInfo.LENGTH, ClientInfo.SIZE); Camera = ProcessMemory.Read<Camera>(hProcess, Address.Camera); CG = ProcessMemory.Read<ClientGame>(hProcess, Address.ClientGame); CGS = ProcessMemory.Read<ClientGameState>(hProcess, Address.ClientGameState); Players.Clear(); Turrets.Clear(); Helis.Clear(); Planes.Clear(); Explosives.Clear(); for (int i = 0; i < Entities.Length; i++) { bool isEntityValid = (Entities[i].isValid & 1) == 1; switch (Entities[i].type) { case EntityType.Player: var player = new Player(); player.IsValid = isEntityValid; player.ClientNum = Clients[i].clientNum; player.Origin = Entities[i].origin; player.Angles = Clients[i].angles; player.Flag = Entities[i].flags; player.IsAlive = isEntityValid; player.Name = Clients[i].name; player.Team = Clients[i].team1 == Clients[CG.clientNum].team1 && Clients[CG.clientNum].team2 != 0 ? PlayerTeam.Friendly : PlayerTeam.Hostile; player.Rank = Clients[i].rank + 1; player.Score = Clients[i].score; if (player.ClientNum == CG.clientNum) LocalPlayer = player; Players.Add(player); break; case EntityType.Turret: var turret = new Turret(); turret.IsValid = isEntityValid; turret.ClientNum = Entities[i].clientNum; turret.Origin = Entities[i].origin; Turrets.Add(turret); break; case EntityType.Helicopter: var heli = new Helicopter(); heli.IsValid = isEntityValid; heli.ClientNum = Entities[i].clientNum; heli.Origin = Entities[i].origin; Helis.Add(heli); break; case EntityType.Plane: var plane = new Plane(); plane.IsValid = isEntityValid; plane.ClientNum = Entities[i].clientNum; plane.Origin = Entities[i].origin; Planes.Add(plane); break; case EntityType.Explosive: var explosive = new Explosive(); explosive.IsValid = isEntityValid; explosive.ClientNum = Entities[i].clientNum; explosive.Origin = Entities[i].origin; Explosives.Add(explosive); break; } } }