示例#1
0
        private byte[] GetBytes(SekiroItem sekiroItem)
        {
            var size = Marshal.SizeOf(sekiroItem);
            var arr  = new byte[size];

            var ptr = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(sekiroItem, ptr, true);
            Marshal.Copy(ptr, arr, 0, size);
            Marshal.FreeHGlobal(ptr);
            return(arr);
        }
示例#2
0
        public static Item ToItem(this SekiroItem sekiroItem)
        {
            foreach (var item in Items)
            {
                if (item.Id1 == sekiroItem.Id1 && item.Id2 == sekiroItem.Id2)
                {
                    return new Item {
                               Name       = item.Name,
                               Id1        = item.Id1,
                               Id2        = item.Id2,
                               SekiroItem = sekiroItem
                    }
                }
                ;
            }

            var emptyItem = new SekiroItem()
            {
                Id1      = 0,
                Id2      = 0xFFFFFFFF,
                Quantity = 0,
                Garbage  = 0
            };

            if (sekiroItem.Equals(emptyItem))
            {
                return(new Item {
                    Empty = true,
                    SekiroItem = sekiroItem
                });
            }

            return(new Item {
                Name = "Unknown",
                Id1 = sekiroItem.Id1,
                Id2 = sekiroItem.Id2,
                SekiroItem = sekiroItem
            });
        }
示例#3
0
        private void BtnSpider_Click(object sender, EventArgs e)
        {
            if (!_spiderInitialized)
            {
                InitializeSpider();
            }
            _inventory.Clear();
            var sekiro = Utils.Sekiro();

            if (sekiro == null)
            {
                return;
            }


            var emptyItem = new SekiroItem()
            {
                Id1      = 0,
                Id2      = 0xFFFFFFFF,
                Quantity = 0,
                Garbage  = 0
            };

            var    itemCount = 0;
            IntPtr address;

            var remoteProc = RemoteProc.Instance();

            if (remoteProc == null)
            {
                return;
            }

            address = Defs.PointerByName("inventory").GetAddress(remoteProc);
            var invStart = address.ToInt64();
            var invEnd   = invStart + 4800;

            Diag.WriteLine($"Inv Start: {address.ToString("X")}");
            var spiderIndex = 0;

            while (address.ToInt64() < invEnd)
            {
                var sekiroItem = remoteProc.Read <SekiroItem>(address);
                address += 16;
                var item = sekiroItem.ToItem();
                item.SpiderIndex = spiderIndex;
                spiderIndex++;
                _inventory.Add(item);
                if (sekiroItem.Equals(emptyItem))
                {
                    continue;
                }
                itemCount++;
            }

            Diag.WriteLine($"Inv End: {address.ToString("X")}");
            Diag.WriteLine($"Spidered {itemCount} items");

            var currentRow = 0;

            itemGrid.RowCount = itemCount;
            foreach (var item in _inventory)
            {
                if (item.Empty)
                {
                    continue;
                }
                itemGrid.CurrentCell       = itemGrid.Rows[currentRow].Cells[0];
                itemGrid.CurrentCell.Value = item.SpiderIndex;
                itemGrid.CurrentCell       = itemGrid.Rows[currentRow].Cells[1];
                var cbox = (DataGridViewComboBoxCell)itemGrid.CurrentCell;
                foreach (var defi in Defs.Items)
                {
                    cbox.Items.Add(defi.Name);
                }
                cbox.Items.Add("Unknown");
                cbox.Value = item.Name;

                itemGrid.CurrentCell       = itemGrid.Rows[currentRow].Cells[2];
                itemGrid.CurrentCell.Value = item.SekiroItem.Quantity;
                itemGrid.CurrentCell       = itemGrid.Rows[currentRow].Cells[3];
                itemGrid.CurrentCell.Value = "Not Implemented";
                currentRow++;
            }
        }