Exemple #1
0
        private void DrawExplosivesESP(Explosive explosive)
        {
            if (!explosive.IsValid)
            {
                return;
            }

            PointF pos;

            if (!MathHelper.WorldToScreen(explosive.Origin, out pos))
            {
                return;
            }

            var rect = new RectangleF();

            rect.X      = pos.X - 3.5f;
            rect.Y      = pos.Y - 3.5f;
            rect.Width  = 7f;
            rect.Height = 7f;

            var namePoint = new PointF();

            namePoint.X = rect.X + 10f;
            namePoint.Y = rect.Y - 3.5f;

            FillRect(rect, Color.Brown);
            DrawSmallText(Explosive.NAME, namePoint, Color.White);
        }
        private void DrawExplosivesESP(Explosive explosive)
        {
            if (!explosive.IsValid)
                return;

            PointF pos;
            if (!MathHelper.WorldToScreen(explosive.Origin, out pos))
                return;

            var rect = new RectangleF();
            rect.X = pos.X - 3.5f;
            rect.Y = pos.Y - 3.5f;
            rect.Width = 7f;
            rect.Height = 7f;

            var namePoint = new PointF();
            namePoint.X = rect.X + 10f;
            namePoint.Y = rect.Y - 3.5f;

            FillRect(rect, Color.Brown);
            DrawSmallText(Explosive.NAME, namePoint, Color.White);
        }
        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;
                }
            }
        }
Exemple #4
0
        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;
                }
            }
        }