Exemple #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);



            HotKeyManager.RegisterHotKey(Keys.F1, KeyModifiers.Alt);
            //开关车辆
            HotKeyManager.RegisterHotKey(Keys.NumPad7, KeyModifiers.Alt);
            //开关物品
            HotKeyManager.RegisterHotKey(Keys.NumPad8, KeyModifiers.Alt);
            //开关雷达
            HotKeyManager.RegisterHotKey(Keys.NumPad9, KeyModifiers.Alt);

            HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed;

            //HotKeyManager.RegisterHotKey(Keys.Space, 0);
            //HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed2;


            _mainForm = new mainFrom();
            Application.Run(_mainForm);
            Application.ThreadExit += (a, b) =>
            {
                KReader.Close();
            };
        }
Exemple #2
0
 static DoGame()
 {
     while (baseAdd == 0)
     {
         baseAdd = KReader.readPuBase();
     }
 }
Exemple #3
0
        public static Vector3 GetBoneWithRotation(ulong mesh, Bones bone)
        {
            var fbone            = GetBoneWithIndex(mesh, bone);
            var componentToWorld = KReader.readFtransform(mesh + 0x0190);
            var matrix           = Matrix.Multiply(fbone.ToMatrixWithScale(), componentToWorld.ToMatrixWithScale());

            return(new Model.Vector3(matrix.M41, matrix.M42, matrix.M43));
        }
Exemple #4
0
 public static string GetGName(int actorId)
 {
     if (GCahce.TryGetValue(actorId, out var gname))
     {
         return(gname);
     }
     gname = KReader.getGNameFromId(actorId);
     GCahce.Add(actorId, gname);
     return(gname);
 }
Exemple #5
0
 public static string GetPlayerName(int playerId)
 {
     if (PlayerCache.TryGetValue(playerId, out var playerName))
     {
         return(playerName);
     }
     playerName = KReader.getGNameFromId(playerId);
     PlayerCache.Add(playerId, playerName);
     return(playerName);
 }
Exemple #6
0
        public Cpuz()
        {
            InitializeComponent();
            //Make the window's border completely transparant

            #region D3D初始化
            // ANTI BATTLEYE SIG SCAN ;)
            this.Text = Guid.NewGuid().ToString().Replace("-", "");

            // TRANSPARENCY KEY
            this.BackColor = System.Drawing.Color.Black;

            // SETTINGS
            this.FormBorderStyle = FormBorderStyle.None;
            this.ShowIcon        = false;
            this.ShowInTaskbar   = false;
            this.TopMost         = true;
            this.WindowState     = FormWindowState.Maximized;

            // MAKE WINDOW TRANSPARENT
            Win32.SetWindowLong(this.Handle, Win32.GWL_EXSTYLE, (IntPtr)(Win32.GetWindowLong(this.Handle, Win32.GWL_EXSTYLE) ^ Win32.WS_EX_LAYERED ^ Win32.WS_EX_TRANSPARENT));

            // MAKE WINDOW SOLID
            Win32.SetLayeredWindowAttributes(this.Handle, 0, 255, Win32.LWA_ALPHA);

            var targetProperties = new HwndRenderTargetProperties
            {
                Hwnd           = this.Handle,
                PixelSize      = new Size2(this.Bounds.Right - this.Bounds.Left, this.Bounds.Bottom - this.Bounds.Top),
                PresentOptions = PresentOptions.Immediately
            };

            var prop = new RenderTargetProperties(RenderTargetType.Hardware, new PixelFormat(Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);

            var d3dFactory = new SharpDX.Direct2D1.Factory();

            var device = new WindowRenderTarget(d3dFactory, prop, targetProperties)
            {
                TextAntialiasMode = TextAntialiasMode.Cleartype,
                AntialiasMode     = AntialiasMode.Aliased
            };

            #endregion

            var       k         = KReader.readPuBase();
            JSON_DATA json_data = null;
            var       dxthread  = new Thread(() =>
            {
                var brushWhite   = new SolidColorBrush(device, RawColorFromColor(Color.White));
                var brushBlack   = new SolidColorBrush(device, RawColorFromColor(Color.Black));
                var brushGreen   = new SolidColorBrush(device, RawColorFromColor(Color.Green));
                var brushRed     = new SolidColorBrush(device, RawColorFromColor(Color.Red));
                var brushPurple  = new SolidColorBrush(device, RawColorFromColor(Color.Purple));
                var fontFactory  = new SharpDX.DirectWrite.Factory();
                var fontConsolas = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 15);
                var fontESP      = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 12);

                while (true)
                {
                    // attempt to download JSON data as a string
                    try
                    {
                        json_data = DoGame.getGameDate();

                        if (json_data != null && json_data.players.Count > 0)
                        {
                            mainFrom.STATE = true;
                            device.BeginDraw();
                            device.Clear(null);

                            #region RADAR

                            int radarSize       = 600;
                            Vector2 centerpoint = new Vector2(2356, 1210);

                            if (Setting.雷达)
                            {
                                Ellipse el3 = new Ellipse(new RawVector2(2356, 1210), 1, 1);
                                device.DrawEllipse(el3, brushRed);
                                device.FillEllipse(el3, brushRed);

                                // TODO: INTEGRATE INTO MINIMAP
                                //if (Setting.雷达)
                                //{
                                //    var radarOuterRectangle = new RawRectangleF(radarX, radarY, radarX + radarSize,
                                //        radarY + radarSize);
                                //    var radarRectangle = new RawRectangleF(radarX + radarBorder, radarY + radarBorder,
                                //        radarX + radarSize - radarBorder, radarY + radarSize - radarBorder);

                                //    var radarCenterRectangle = new RoundedRectangle()
                                //    {
                                //        RadiusX = 4,
                                //        RadiusY = 4,
                                //        Rect = new RawRectangleF(centerpoint.X, centerpoint.Y, centerpoint.X + 4,
                                //            centerpoint.Y + 4)
                                //    };

                                //    device.FillRectangle(radarRectangle, brushBlack);
                                //    device.DrawRectangle(radarRectangle, brushWhite);

                                //    device.FillRoundedRectangle(radarCenterRectangle, brushGreen);

                                //}
                            }

                            #endregion


                            var vecLocalLocation = new Model.Vector3
                            {
                                X = json_data.camera[1].X,
                                Y = json_data.camera[1].Y,
                                Z = json_data.camera[1].Z
                            };

                            var PlayerCameraManager = new PlayerCameraManager
                            {
                                CameraCache = new FCameraCacheEntry
                                {
                                    POV = new FMinimalViewInfo
                                    {
                                        Fov      = json_data.camera[2].X,
                                        Location = new Model.Vector3
                                        {
                                            X = json_data.camera[1].X,
                                            Y = json_data.camera[1].Y,
                                            Z = json_data.camera[1].Z
                                        },
                                        Rotation = new Model.FRotator
                                        {
                                            Pitch = json_data.camera[0].X,
                                            Yaw   = json_data.camera[0].Y,
                                            Roll  = json_data.camera[0].Z
                                        }
                                    }
                                }
                            };

                            #region 车

                            if (Setting.车辆显示)
                            {
                                foreach (var v in json_data.vehicles)
                                {
                                    var vecActorLocation = new Vector3 {
                                        X = v.rx, Y = v.ry, Z = v.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecActorLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;
                                    if (lDeltaInMeters <= 400)
                                    {
                                        Vector2 screenlocation;
                                        if (WorldToScreen(vecActorLocation, PlayerCameraManager, out screenlocation))
                                        {
                                            DrawText($"[{v.v}] {(int)lDeltaInMeters}m", (int)screenlocation.X,
                                                     (int)screenlocation.Y, v.v == "Deat" ? brushBlack : brushGreen,
                                                     fontFactory, fontESP, device);
                                        }
                                    }
                                }
                            }

                            #endregion

                            #region 物品

                            //todo:有BUG
                            if (Setting.物品显示)
                            {
                                foreach (var v in json_data.items)
                                {
                                    var vecActorLocation = new Vector3 {
                                        X = v.rx, Y = v.ry, Z = v.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecActorLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;

                                    Vector2 screenlocation;
                                    if (WorldToScreen(vecActorLocation, PlayerCameraManager, out screenlocation))
                                    {
                                        DrawText($"{v.n}", (int)screenlocation.X,
                                                 (int)screenlocation.Y, brushWhite, fontFactory, fontESP, device);
                                    }
                                }
                            }

                            #endregion

                            #region 人物

                            var playerList  = json_data.players.OrderBy(z => z.id).ToList();
                            var localPlayer = playerList[0];
                            foreach (var player in playerList)
                            {
                                if (player.health > 0 && player.isInactive > 0 && player.id != 0)
                                {
                                    var vecPlayerLocation = new Vector3 {
                                        X = player.rx, Y = player.ry, Z = player.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecPlayerLocation;
                                    //距离
                                    var lDeltaInMeters = vecRelativePos.Length / 100.0f;


                                    if (lDeltaInMeters >= 750)
                                    {
                                        continue;
                                    }
                                    #region 线条
                                    if (Setting.线条)
                                    {
                                        if (lDeltaInMeters > 3)
                                        {
                                            if (
                                                //超过200米不显示线
                                                lDeltaInMeters <= 200
                                                //超过40人不显示线
                                                && json_data.players.Count <= 40
                                                //队友不显示
                                                && player.t != localPlayer.t
                                                )
                                            {
                                                if (WorldToScreen(vecPlayerLocation, PlayerCameraManager,
                                                                  out var screenlocation))
                                                {
                                                    device.DrawLine(new RawVector2(Setting.Screen.Width / 2f, Setting.Screen.Height),
                                                                    new RawVector2(screenlocation.X, screenlocation.Y), lDeltaInMeters <= 100 ? brushRed : brushWhite);
                                                }
                                            }
                                        }
                                    }
                                    #endregion

                                    #region Distance ESP
                                    if (lDeltaInMeters > 3)
                                    {
                                        if (Setting.距离和血量)
                                        {
                                            if (WorldToScreen(vecPlayerLocation, PlayerCameraManager,
                                                              out var screenlocation))
                                            {
                                                SolidColorBrush brush = brushRed;

                                                if (lDeltaInMeters >= 250)
                                                {
                                                    brush = brushPurple;
                                                }
                                                if (lDeltaInMeters >= 500)
                                                {
                                                    brush = brushGreen;
                                                }
                                                if (player.t == localPlayer.t)
                                                {
                                                    brush = brushGreen;
                                                }

                                                DrawText($"[{player.id}]{(int)player.health} {(int)lDeltaInMeters}m",
                                                         (int)screenlocation.X,
                                                         (int)screenlocation.Y,
                                                         brush,
                                                         fontFactory, fontESP, device);
                                            }
                                        }
                                    }

                                    #endregion

                                    #region Radar
                                    if (Setting.雷达)
                                    {
                                        var loclalLocation = new Vector3 {
                                            X = playerList[0].x, Y = playerList[0].y, Z = playerList[0].z
                                        };
                                        var currentActorLocation = new Vector3 {
                                            X = player.x, Y = player.y, Z = player.z
                                        };

                                        var relativePos = loclalLocation - currentActorLocation;

                                        if (relativePos.Length / 100.0f <= radarSize / 2 /*DISTANCE FROM CENTER TO EDGE*/)
                                        {
                                            Vector2 screenpos = centerpoint - relativePos.To2D() / 118f;

                                            Ellipse el22 = new Ellipse(new RawVector2(screenpos.X, screenpos.Y), 3, 3);
                                            device.DrawEllipse(el22, brushRed);
                                            device.FillEllipse(el22, brushRed);
                                        }
                                    }
                                    #endregion

                                    #region 骨骼

                                    if (lDeltaInMeters < 250 && lDeltaInMeters > 5)
                                    {
                                        DrawSkeleton(player.mesh, PlayerCameraManager, device, brushRed, fontESP);
                                    }
                                    #endregion
                                }
                            }
                            #endregion
                            // DRAW END
                            device.EndDraw();
                        }
                        else
                        {
                            mainFrom.STATE = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        System.IO.File.WriteAllText("c:\\log\\bug_json.txt", JsonConvert.SerializeObject(json_data));
                    }
                    Thread.Sleep(10);
                }
            })
            {
                IsBackground = true
            };
            dxthread.Start();

            #region Web端
            var webThread = new Thread(() =>
            {
                while (true)
                {
                    using (var webClient = new WebClient())
                    {
                        if (Setting.Web端 && json_data.players.Count > 0 && !webClient.IsBusy)
                        {
                            try
                            {
                                // 指定 WebClient 編碼
                                webClient.Encoding = Encoding.UTF8;
                                // 指定 WebClient 的 Content-Type header
                                webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                                // 指定 WebClient 的 authorization header
                                //webClient.Headers.Add("authorization", "token {apitoken}");
                                // 執行 PUT 動作
                                var result = webClient.UploadString("http://127.0.0.1:3000/api/5", "PUT", JsonConvert.SerializeObject(json_data));
                            }
                            catch (Exception e)
                            {
                                continue;
                            }
                        }
                    }
                    Thread.Sleep(500);
                }
            });

            webThread.IsBackground = true;
            webThread.Start();
            #endregion


            var marg = new Win32.Margins {
                Left = 0, Top = 0, Right = this.Width, Bottom = this.Height
            };
            Win32.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
        }
Exemple #7
0
 public UDropItem this[int index] =>
 new UDropItem(KReader.readUlong(BasePoint + (ulong)(index * 位移)));
Exemple #8
0
 public AItemPackage this[int index] =>
 new AItemPackage(KReader.readUlong(BasePoint + (ulong)(index * 位移)));
Exemple #9
0
 public AActor this[int index] => new AActor(KReader.readUlong(BasePoint + (ulong)(index * 位移)));
Exemple #10
0
 public ULocalPlayer this[int index] =>
 new ULocalPlayer(KReader.readUlong(BasePoint + (ulong)(index * 占位)));
Exemple #11
0
 private void main_Leave(object sender, EventArgs e)
 {
     KReader.Close();
     Application.Exit();
 }
Exemple #12
0
        public static FTransform GetBoneWithIndex(ulong mesh, Bones bone)
        {
            var cachedBoneSpaceTransforms = KReader.readUlong(mesh + 0x0790);

            return(KReader.readFtransform(cachedBoneSpaceTransforms + (ulong)((int)bone * 0x30)));
        }
Exemple #13
0
        public static JSON_DATA getGameDate()
        {
            if (baseAdd == 0)
            {
                return(null);
            }
            var json = new JSON_DATA();

            if (Setting.模式 == 模式.模式一)
            {
                #region mode1
                var pubg           = new Pubg(baseAdd + Setting.UWorldOffset);
                var uworld         = pubg.UWorld;
                var gameInstance   = uworld.OwningGameInstance;
                var localPlayers   = gameInstance.LocalPlayers;
                var localPlayer    = localPlayers[0];
                var viewportClient = localPlayer.ViewportClient;
                var pWorld         = viewportClient.UWorld;

                for (int i = 0; i < pWorld.PersistentLevel.PlayerCount; i++)
                {
                    var actor         = pWorld.PersistentLevel.AActors[i];
                    var actorId       = actor.ActorID;
                    var actorGName    = Cache.GetGName(actorId);// KReader.getGNameFromId(actorId);
                    var rootComponent = actor.RootComponent;
                    var actorLocation = rootComponent.Location;
                    //玩家
                    if (actor.isPlayer)
                    {
                        var playerState    = actor.PlayerState;
                        var _actorLocation = actorLocation + pWorld.WorldLocation;

                        json.players.Add(new Players
                        {
                            //AName = actorGName,
                            AName      = playerState.PlayerName,
                            AID        = actorId,
                            x          = _actorLocation.X,
                            y          = _actorLocation.Y,
                            z          = _actorLocation.Z,
                            health     = actor.Health,
                            id         = playerState.PlayerId,
                            rotator    = rootComponent.RelativeRotation.Y,
                            t          = playerState.TeamNumber,
                            isInactive = playerState.bIsInactive,
                            rx         = rootComponent.RelativeLocation.X,
                            ry         = rootComponent.RelativeLocation.Y,
                            rz         = rootComponent.RelativeLocation.Z,
                            mesh       = actor.Mesh.mesh
                        });
                    }
                    //车辆
                    else if (actor.isVehicle)
                    {
                        var _actorLocation = actorLocation + pWorld.WorldLocation;
                        json.vehicles.Add(new Vehicle
                        {
                            v  = actorGName.Substring(0, 4),
                            x  = _actorLocation.X,
                            y  = _actorLocation.Y,
                            z  = _actorLocation.Z,
                            rx = rootComponent.RelativeLocation.X,
                            ry = rootComponent.RelativeLocation.Y,
                            rz = rootComponent.RelativeLocation.Z,
                        });
                    }
                    //物品
                    else if (actor.isDropItems)
                    {
                        var droppedItemArray = actor.DropItems;
                        var droppedItemCount = actor.DropItemsCount;
                        for (var j = 0; j < droppedItemCount; j++)
                        {
                            var aDroppedItem = droppedItemArray[j];
                            var UItem        = aDroppedItem.UItem;
                            //var UItemID = UItem.ItemId;
                            var itemName = UItem.ItemName;
                            if (string.IsNullOrEmpty(InCareList(itemName)))
                            {
                                continue;
                            }
                            var droppedLocation  = aDroppedItem.Location;
                            var relativeLocation = droppedLocation + actorLocation;
                            droppedLocation += actorLocation + pWorld.WorldLocation;
                            //a.Add(itemName);
                            json.items.Add(new Item
                            {
                                n  = InCareList(itemName),
                                x  = droppedLocation.X,
                                y  = droppedLocation.Y,
                                z  = droppedLocation.Z,
                                rx = relativeLocation.X,
                                ry = relativeLocation.Y,
                                rz = relativeLocation.Z
                            });
                        }
                    }
                    else if (actor.isAirdropOrDeathdrop)
                    {
                        //var droppedItemArray = actor.AItemPackages;
                        //var droppedItemCount = actor.AItemPackagesCount;
                        //for (var j = 0; j < droppedItemCount; j++)
                        //{
                        //    var dropItem = droppedItemArray[j];
                        var _actorLocation = actorLocation + pWorld.WorldLocation;

                        json.vehicles.Add(new Vehicle
                        {
                            v  = actor.ActorName.Substring(0, 4),
                            x  = _actorLocation.X,
                            y  = _actorLocation.Y,
                            z  = _actorLocation.Z,
                            rx = rootComponent.RelativeLocation.X,
                            ry = rootComponent.RelativeLocation.Y,
                            rz = rootComponent.RelativeLocation.Z
                        });
                        //}
                    }
                }

                var povRotation = localPlayer.PlayerController.PlayerCameraManager.povRotation;
                var povLocation = localPlayer.PlayerController.PlayerCameraManager.povLocation;
                //get zone info
                json.camera.Add(new Camera {
                    n = "Rotation", X = povRotation.X, Y = povRotation.Y, Z = povRotation.Z
                });
                json.camera.Add(new Camera {
                    n = "Location", X = povLocation.X, Y = povLocation.Y, Z = povLocation.Z
                });
                json.camera.Add(new Camera {
                    n = "Fov", X = localPlayer.PlayerController.PlayerCameraManager.Fov, Y = 0, Z = 0
                });
                json.zone.Add(new Zone {
                    r = pWorld.GameState.blueR, x = pWorld.GameState.blue.X, y = pWorld.GameState.blue.Y
                });
                json.zone.Add(new Zone {
                    r = pWorld.GameState.whiteR, x = pWorld.GameState.white.X, y = pWorld.GameState.white.Y
                });
                #endregion
            }
            else
            {
                var m_UWorld         = KReader.readUlong(KReader.m_PUBase + Setting.UWorldOffset);
                var m_gameInstance   = KReader.readUlong(m_UWorld + 0x140);
                var m_ULocalPlayer   = KReader.readUlong(m_gameInstance + 0x38);
                var m_localPlayer    = KReader.readUlong(m_ULocalPlayer + 0x0);
                var m_viewportclient = KReader.readUlong(m_localPlayer + 0x58);
                var m_localPawn      = KReader.readUlong(m_localPlayer + 0x3A8);
                //var m_localPlayerState = KReader.readUlong(m_localPawn + 0x03C0);
                var m_PWorld      = KReader.readUlong(m_viewportclient + 0x80);
                var m_ULevel      = KReader.readUlong(m_PWorld + 0x30);
                var m_playerCount = KReader.readInt32(m_ULevel + 0xA8);

                var m_localPlayerControl      = KReader.readUlong(m_localPlayer + 0x30);
                var m_localPlayerCamerManager = KReader.readUlong(m_localPlayerControl + 0x438);

                var ATslGameState = KReader.readUlong(m_PWorld + 0x00F8);
                var m_AActorPtr   = KReader.readUlong(m_ULevel + 0xA0);


                var povRotation = KReader.readVec(m_localPlayerCamerManager + 0x42C);
                var povLocation = KReader.readVec(m_localPlayerCamerManager + 0x420);
                var Fov         = KReader.readFloat(m_localPlayerCamerManager + 0x438);


                //get zone info
                Vector3 blue  = KReader.readVec(ATslGameState + 0x440);
                float   blueR = KReader.readFloat(ATslGameState + 0x44C);

                Vector3 white  = KReader.readVec(ATslGameState + 0x450);
                float   whiteR = KReader.readFloat(ATslGameState + 0x45C);


                json.camera.Add(new Camera {
                    n = "Rotation", X = povRotation.X, Y = povRotation.Y, Z = povRotation.Z
                });
                json.camera.Add(new Camera {
                    n = "Location", X = povLocation.X, Y = povLocation.Y, Z = povLocation.Z
                });
                json.camera.Add(new Camera {
                    n = "Fov", X = Fov, Y = 0, Z = 0
                });
                json.zone.Add(new Zone {
                    r = blueR, x = blue.X, y = blue.Y
                });
                json.zone.Add(new Zone {
                    r = whiteR, x = white.X, y = white.Y
                });

                var worldLocation = new Vector3
                {
                    X = KReader.readInt32(m_PWorld + 0x918),
                    Y = KReader.readInt32(m_PWorld + 0x91C),
                    Z = KReader.readInt32(m_PWorld + 0x920)
                };
                //this just for test
                //List<string> a = new List<string>();

                for (int i = 0; i < m_playerCount; i++)
                {
                    var curActor         = KReader.readUlong(m_AActorPtr + (ulong)(i * 0x8));
                    var curActorID       = KReader.readInt32(curActor + 0x0018);
                    var actorGName       = Cache.GetGName(curActorID);// KReader.getGNameFromId(curActorID);
                    var rootCmpPtr       = KReader.readUlong(curActor + 0x0180);
                    var actorLocation    = KReader.readVec(rootCmpPtr + 0x1A0);
                    var relativeLocation = KReader.readVec(rootCmpPtr + 0x01E0);
                    //玩家
                    if (isPlayer(actorGName))
                    {
                        var   playerState      = KReader.readUlong(curActor + 0x03C0);
                        var   actorTeam        = KReader.readInt32(playerState + 0x0444);
                        var   _actorLocation   = actorLocation + worldLocation;
                        var   Health           = KReader.readFloat(curActor + 0x107C);
                        ulong mesh             = KReader.readUlong(curActor + 0x0400);
                        var   RelativeRotation = KReader.readVec(rootCmpPtr + 0x01EC);
                        var   playerId         = KReader.readInt32(playerState + 0x03C8);
                        var   isInactive       = KReader.readChar(playerState + 0x03CC);

                        json.players.Add(new Players
                        {
                            x          = _actorLocation.X,
                            y          = _actorLocation.Y,
                            z          = _actorLocation.Z,
                            health     = Health,
                            id         = playerId,
                            rotator    = RelativeRotation.Y,
                            t          = actorTeam,
                            isInactive = isInactive,
                            rx         = relativeLocation.X,
                            ry         = relativeLocation.Y,
                            rz         = relativeLocation.Z,
                            mesh       = mesh
                        });
                    }
                    //车辆
                    else if (isVehicle(actorGName))
                    {
                        var _actorLocation = actorLocation + worldLocation;

                        json.vehicles.Add(new Vehicle
                        {
                            v  = actorGName.Substring(0, 4),
                            x  = _actorLocation.X,
                            y  = _actorLocation.Y,
                            z  = _actorLocation.Z,
                            rx = relativeLocation.X,
                            ry = relativeLocation.Y,
                            rz = relativeLocation.Z,
                        });
                    }
                    //物品
                    else if (isDropItems(actorGName))
                    {
                        var DroppedItemArray = KReader.readUlong(curActor + 0x02D8);
                        var DroppedItemCount = KReader.readInt32(curActor + 0x02E0);

                        for (var j = 0; j < DroppedItemCount; j++)
                        {
                            var ADroppedItem = KReader.readUlong(DroppedItemArray + (ulong)(j * 0x10));
                            var UItem        = KReader.readUlong(ADroppedItem + 0x0448);
                            var UItemID      = KReader.readInt32(UItem + 0x18);
                            var itemName     = Cache.GetGName(UItemID);// KReader.getGNameFromId(UItemID);

                            if (string.IsNullOrEmpty(InCareList(itemName)))
                            {
                                continue;
                            }
                            var droppedLocation   = KReader.readVec(ADroppedItem + 0x01E0);
                            var _relativeLocation = droppedLocation + actorLocation;
                            droppedLocation = droppedLocation + actorLocation + worldLocation;

                            //a.Add(itemName);
                            json.items.Add(new Item
                            {
                                n  = InCareList(itemName),
                                x  = droppedLocation.X,
                                y  = droppedLocation.Y,
                                z  = droppedLocation.Z,
                                rx = _relativeLocation.X,
                                ry = _relativeLocation.Y,
                                rz = _relativeLocation.Z
                            });
                        }
                    }
                    else if (isAirdropOrDeathdrop(actorGName))
                    {
                        //var droppedItemArray = actor.AItemPackages;
                        //var droppedItemCount = actor.AItemPackagesCount;
                        //for (var j = 0; j < droppedItemCount; j++)
                        //{
                        //    var dropItem = droppedItemArray[j];
                        var _actorLocation = actorLocation + worldLocation;
                        json.vehicles.Add(new Vehicle
                        {
                            v  = actorGName.Substring(0, 3),
                            x  = _actorLocation.X,
                            y  = _actorLocation.Y,
                            z  = _actorLocation.Z,
                            rx = relativeLocation.X,
                            ry = relativeLocation.Y,
                            rz = relativeLocation.Z
                        });
                        //}
                    }
                }
            }
            return(json);
        }
Exemple #14
0
        public static JSON_DATA getGameDate()
        {
            if (baseAdd == 0)
            {
                return(null);
            }
            var json           = new JSON_DATA();
            var pubg           = new Pubg(baseAdd + Setting.UWorldOffset);
            var uworld         = pubg.UWorld;
            var gameInstance   = uworld.OwningGameInstance;
            var localPlayers   = gameInstance.LocalPlayers;
            var localPlayer    = localPlayers[0];
            var viewportClient = localPlayers[0].ViewportClient;
            var pWorld         = viewportClient.UWorld;

            for (int i = 0; i < pWorld.PersistentLevel.PlayerCount; i++)
            {
                var actor         = pWorld.PersistentLevel.AActors[i];
                var actorId       = actor.ActorID;
                var actorGName    = KReader.getGNameFromId(actorId);
                var rootComponent = actor.RootComponent;
                var actorLocation = rootComponent.Location;
                //玩家
                if (actor.isPlayer)
                {
                    var playerState    = actor.PlayerState;
                    var _actorLocation = actorLocation + pWorld.WorldLocation;

                    json.players.Add(new Players
                    {
                        //AName = actorGName,
                        AName      = playerState.PlayerName,
                        AID        = actorId,
                        x          = _actorLocation.X,
                        y          = _actorLocation.Y,
                        z          = _actorLocation.Z,
                        health     = actor.Health,
                        id         = playerState.PlayerId,
                        rotator    = rootComponent.RelativeRotation.Y,
                        t          = playerState.TeamNumber,
                        isInactive = playerState.bIsInactive,
                        rx         = rootComponent.RelativeLocation.X,
                        ry         = rootComponent.RelativeLocation.Y,
                        rz         = rootComponent.RelativeLocation.Z,
                        mesh       = actor.Mesh.mesh
                    });
                }
                //车辆
                else if (actor.isVehicle)
                {
                    var _actorLocation = actorLocation + pWorld.WorldLocation;
                    json.vehicles.Add(new Vehicle
                    {
                        v  = actorGName.Substring(0, 4),
                        x  = _actorLocation.X,
                        y  = _actorLocation.Y,
                        z  = _actorLocation.Z,
                        rx = rootComponent.RelativeLocation.X,
                        ry = rootComponent.RelativeLocation.Y,
                        rz = rootComponent.RelativeLocation.Z,
                    });
                }
                //物品
                else if (actor.isDropItems)
                {
                    var droppedItemArray = actor.DropItems;
                    var droppedItemCount = actor.DropItemsCount;
                    for (var j = 0; j < droppedItemCount; j++)
                    {
                        var aDroppedItem = droppedItemArray[j];
                        var UItem        = aDroppedItem.UItem;
                        //var UItemID = UItem.ItemId;
                        var itemName = UItem.ItemName;
                        if (string.IsNullOrEmpty(InCareList(itemName)))
                        {
                            continue;
                        }
                        var droppedLocation  = aDroppedItem.Location;
                        var relativeLocation = droppedLocation + actorLocation;
                        droppedLocation += actorLocation + pWorld.WorldLocation;
                        //a.Add(itemName);
                        json.items.Add(new Item
                        {
                            n  = InCareList(itemName),
                            x  = droppedLocation.X,
                            y  = droppedLocation.Y,
                            z  = droppedLocation.Z,
                            rx = relativeLocation.X,
                            ry = relativeLocation.Y,
                            rz = relativeLocation.Z
                        });
                    }
                }
                else if (actor.isAirdropOrDeathdrop)
                {
                    //var droppedItemArray = actor.AItemPackages;
                    //var droppedItemCount = actor.AItemPackagesCount;
                    //for (var j = 0; j < droppedItemCount; j++)
                    //{
                    //    var dropItem = droppedItemArray[j];
                    var _actorLocation = actorLocation + pWorld.WorldLocation;

                    json.vehicles.Add(new Vehicle
                    {
                        v  = actor.ActorName.Substring(0, 4),
                        x  = _actorLocation.X,
                        y  = _actorLocation.Y,
                        z  = _actorLocation.Z,
                        rx = rootComponent.RelativeLocation.X,
                        ry = rootComponent.RelativeLocation.Y,
                        rz = rootComponent.RelativeLocation.Z
                    });
                    //}
                }
            }

            var povRotation = localPlayer.PlayerController.PlayerCameraManager.povRotation;
            var povLocation = localPlayer.PlayerController.PlayerCameraManager.povLocation;

            //get zone info
            json.camera.Add(new Camera {
                n = "Rotation", X = povRotation.X, Y = povRotation.Y, Z = povRotation.Z
            });
            json.camera.Add(new Camera {
                n = "Location", X = povLocation.X, Y = povLocation.Y, Z = povLocation.Z
            });
            json.camera.Add(new Camera {
                n = "Fov", X = localPlayer.PlayerController.PlayerCameraManager.Fov, Y = 0, Z = 0
            });
            json.zone.Add(new Zone {
                r = pWorld.GameState.blueR, x = pWorld.GameState.blue.X, y = pWorld.GameState.blue.Y
            });
            json.zone.Add(new Zone {
                r = pWorld.GameState.whiteR, x = pWorld.GameState.white.X, y = pWorld.GameState.white.Y
            });


            //var m_UWorld = KReader.readUlong(KReader.m_PUBase + 0x37E5988);
            //var m_gameInstance = KReader.readUlong(m_UWorld + 0x140);
            //var m_ULocalPlayer = KReader.readUlong(m_gameInstance + 0x38);
            //var m_localPlayer = KReader.readUlong(m_ULocalPlayer + 0x0);
            //var m_viewportclient = KReader.readUlong(m_localPlayer + 0x58);
            //var m_localPawn = KReader.readUlong(m_localPlayer + 0x3A8);
            //var m_localPlayerState = KReader.readUlong(m_localPawn + 0x03C0);
            //var m_PWorld = KReader.readUlong(m_viewportclient + 0x80);
            //var m_ULevel = KReader.readUlong(m_PWorld + 0x30);
            //var m_playerCount = KReader.readInt32(m_ULevel + 0xA8);

            //var m_localPlayerControl = KReader.readUlong(m_localPlayer + 0x30, PROTO_NORMAL_READ);
            //var m_localPlayerCamerManager = KReader.readUlong(m_localPlayerControl + 0x438, PROTO_NORMAL_READ);

            //var ATslGameState = KReader.readUlong(m_PWorld + 0x00F8, PROTO_NORMAL_READ);
            ////var m_localPlayerPosition = KReader.readVec(m_localPlayer + 0x70, PROTO_NORMAL_READ);
            ////var m_localPlayerBasePointer = KReader.readUlong(m_localPlayer, PROTO_NORMAL_READ);
            ////var m_localTeam = KReader.readUlong(m_localPlayerState + 0x0444, PROTO_NORMAL_READ);
            //var m_AActorPtr = KReader.readUlong(m_ULevel + 0xA0, PROTO_NORMAL_READ);


            //var povRotation = KReader.readVec(m_localPlayerCamerManager + 0x42C, PROTO_NORMAL_READ);
            //var povLocation = KReader.readVec(m_localPlayerCamerManager + 0x420, PROTO_NORMAL_READ);
            //var Fov = KReader.readFloat(m_localPlayerCamerManager + 0x438, PROTO_NORMAL_READ);


            ////get zone info
            //Vector3 blue = KReader.readVec(ATslGameState + 0x440, PROTO_NORMAL_READ);
            //float blueR = KReader.readFloat(ATslGameState + 0x44C, PROTO_NORMAL_READ);

            //Vector3 white = KReader.readVec(ATslGameState + 0x450, PROTO_NORMAL_READ);
            //float whiteR = KReader.readFloat(ATslGameState + 0x45C, PROTO_NORMAL_READ);


            //json.camera.Add(new Camera { n = "Rotation", X = povRotation.X, Y = povRotation.Y, Z = povRotation.Z });
            //json.camera.Add(new Camera { n = "Location", X = povLocation.X, Y = povLocation.Y, Z = povLocation.Z });
            //json.camera.Add(new Camera { n = "Fov", X = Fov, Y = 0, Z = 0 });
            //json.zone.Add(new Zone { r = blueR, x = blue.X, y = blue.Y });
            //json.zone.Add(new Zone { r = whiteR, x = white.X, y = white.Y });

            ////this just for test
            //List<string> a = new List<string>();

            //for (int i = 0; i < m_playerCount; i++)
            //{
            //    var curActor = KReader.readUlong(m_AActorPtr + (ulong)(i * 0x8), PROTO_NORMAL_READ);
            //    var curActorID = KReader.readInt32(curActor + 0x0018, PROTO_NORMAL_READ);

            //    var actorGName = KReader.getGNameFromId(curActorID);


            //    //玩家
            //    if (curActorID == 66943 || curActorID == 66948)
            //    {
            //        var rootCmpPtr = KReader.readUlong(curActor + 0x0180, PROTO_NORMAL_READ);
            //        var playerState = KReader.readUlong(curActor + 0x03C0, PROTO_NORMAL_READ);
            //        Vector3 actorLocation = KReader.readVec(rootCmpPtr + 0x1A0, PROTO_NORMAL_READ);

            //        var actorTeam = KReader.readInt32(playerState + 0x0444, PROTO_NORMAL_READ);

            //        actorLocation.X += KReader.readInt32(m_PWorld + 0x918, PROTO_NORMAL_READ);
            //        actorLocation.Y += KReader.readInt32(m_PWorld + 0x91C, PROTO_NORMAL_READ);
            //        actorLocation.Z += KReader.readInt32(m_PWorld + 0x920, PROTO_NORMAL_READ);

            //        var Health = KReader.readFloat(curActor + 0x107C, PROTO_NORMAL_READ);
            //        ulong mesh = KReader.readUlong(curActor + 0x0400, PROTO_NORMAL_READ);


            //        var relativeLocation = KReader.readVec(rootCmpPtr + 0x01E0, PROTO_NORMAL_READ);
            //        var RelativeRotation = KReader.readVec(rootCmpPtr + 0x01EC, PROTO_NORMAL_READ);
            //        var playerId = KReader.readInt32(playerState + 0x03C8, PROTO_NORMAL_READ);
            //        var isInactive = KReader.readChar(playerState + 0x03CC, PROTO_NORMAL_READ);

            //        json.players.Add(new Players
            //        {
            //            //AName = actorGName,
            //            //AID = curActorID,
            //            x = actorLocation.X,
            //            y = actorLocation.Y,
            //            z = actorLocation.Z,
            //            health = Health,
            //            id = playerId,
            //            rotator = RelativeRotation.Y,
            //            t = actorTeam,
            //            isInactive = isInactive,
            //            rx = relativeLocation.X,
            //            ry = relativeLocation.Y,
            //            rz = relativeLocation.Z,
            //            mesh = mesh
            //        });
            //    }
            //    //车辆
            //    else if (!string.IsNullOrEmpty(IsVehicle(actorGName)))
            //    {
            //        var rootCmpPtr = KReader.readUlong(curActor + 0x180, PROTO_NORMAL_READ);
            //        Vector3 actorLocation = KReader.readVec(rootCmpPtr + 0x1A0, PROTO_NORMAL_READ);

            //        actorLocation.X += KReader.readInt32(m_PWorld + 0x918, PROTO_NORMAL_READ);
            //        actorLocation.Y += KReader.readInt32(m_PWorld + 0x91C, PROTO_NORMAL_READ);
            //        actorLocation.Z += KReader.readInt32(m_PWorld + 0x920, PROTO_NORMAL_READ);
            //        Vector3 relativeLocation = KReader.readVec(rootCmpPtr + 0x01E0, PROTO_NORMAL_READ);

            //        json.vehicles.Add(new Vehicle
            //        {
            //            v = actorGName.Substring(0, 4),
            //            x = actorLocation.X,
            //            y = actorLocation.Y,
            //            z = actorLocation.Z,
            //            rx = relativeLocation.X,
            //            ry = relativeLocation.Y,
            //            rz = relativeLocation.Z,
            //        });
            //    }
            //    //物品
            //    else if (IsDropGroup(actorGName))
            //    {
            //        var rootCmpPtr = KReader.readUlong(curActor + 0x180, PROTO_NORMAL_READ);
            //        Vector3 actorLocation = KReader.readVec(rootCmpPtr + 0x1A0, PROTO_NORMAL_READ);

            //        var DroppedItemArray = KReader.readUlong(curActor + 0x02D8, PROTO_NORMAL_READ);
            //        var DroppedItemCount = KReader.readInt32(curActor + 0x02E0, PROTO_NORMAL_READ);

            //        for (int j = 0; j < DroppedItemCount; j++)
            //        {
            //            var ADroppedItem = KReader.readUlong(DroppedItemArray + (ulong)(j * 0x10), PROTO_NORMAL_READ);
            //            var UItem = KReader.readUlong(ADroppedItem + 0x0448, PROTO_NORMAL_READ);
            //            var UItemID = KReader.readInt32(UItem + 0x18, PROTO_NORMAL_READ);
            //            var itemName = KReader.getGNameFromId(UItemID);

            //            if (!string.IsNullOrEmpty(InCareList(itemName)))
            //            {

            //                Vector3 droppedLocation = KReader.readVec(ADroppedItem + 0x01E0, PROTO_NORMAL_READ);
            //                Vector3 relativeLocation = droppedLocation + actorLocation;
            //                droppedLocation.X = droppedLocation.X + actorLocation.X + KReader.readInt32(m_PWorld + 0x918, PROTO_NORMAL_READ);
            //                droppedLocation.Y = droppedLocation.Y + actorLocation.Y + KReader.readInt32(m_PWorld + 0x91C, PROTO_NORMAL_READ);
            //                droppedLocation.Z = droppedLocation.Z + actorLocation.Z + KReader.readInt32(m_PWorld + 0x920, PROTO_NORMAL_READ);

            //                a.Add(itemName);
            //                json.items.Add(new Item
            //                {
            //                    n = InCareList(itemName),
            //                    x = droppedLocation.X,
            //                    y = droppedLocation.Y,
            //                    z = droppedLocation.Z,
            //                    rx = relativeLocation.X,
            //                    ry = relativeLocation.Y,
            //                    rz = relativeLocation.Z
            //                });
            //            }



            //        }


            //    }
            //}
            return(json);
        }