Пример #1
0
        /// <summary>
        /// Creates the SelectedWeapon directly into the player's inventory
        /// </summary>
        public override void CreateWeapon(BlackKnightWeapon weapon)
        {
            if (Process.Hooked)
            {
                byte[] asm = (byte[])Assembly.PTDE.Clone();

                // Get the pointer to CharBasePtr
                IntPtr pointer = pBasePtr.Resolve();
                pointer = Process.CreateChildPointer(pBasePtr, 0, 8).Resolve();

                // Have to allocate first to rebase the code
                IntPtr memory      = Process.Allocate((uint)asm.Length);
                uint   funcPointer = (uint)(FUNC_ITEM_GET_PTR - (uint)memory);

                // Now we can write the rebased bytes
                byte[] bytes = BitConverter.GetBytes((ulong)pointer + INVENTORY_INDEX_START);
                Array.Copy(bytes, 0, asm, 0x1, 4);
                bytes = BitConverter.GetBytes(ItemCategory);
                Array.Copy(bytes, 0, asm, 0x6, 4);
                bytes = BitConverter.GetBytes(weapon.ID);
                Array.Copy(bytes, 0, asm, 0xB, 4);
                bytes = BitConverter.GetBytes(ItemQuantity);
                Array.Copy(bytes, 0, asm, 0x10, 4);
                bytes = BitConverter.GetBytes((ulong)funcPointer);
                Array.Copy(bytes, 0, asm, 0x22, 4);

                // Write, Execute and Free
                Kernel32.WriteBytes(Process.Handle, memory, asm);
                int result = Process.Execute(memory);
                Process.Free(memory);
            }
        }
Пример #2
0
        /// <summary>
        /// Returns true if the SelectedWeapon is already in the player's inventory
        /// </summary>
        /// <returns>bool</returns>
        public bool FindBlackKnightWeapon(BlackKnightWeapon weapon)
        {
            InventoryItem[] items = GetInventoryItems()
                                    .Where(i => i.ID != 0 && i.ID != -1).ToArray();

            bool alreadyOwn = false;

            for (int i = 0; i < items.Length; i++)
            {
                if (items[i].Category == weapon.Category && weapon.Upgrade.Contains(items[i].ID))
                {
                    // Found the weapon in the inventory!
                    alreadyOwn = true;
                    break;
                }
            }

            return(alreadyOwn);
        }
Пример #3
0
        /// <summary>
        /// Creates the SelectedWeapon directly into the player's inventory
        /// </summary>
        public override void CreateWeapon(BlackKnightWeapon weapon)
        {
            if (Process.Hooked)
            {
                byte[] asm = (byte[])Assembly.REMASTERED.Clone();

                byte[] bytes = BitConverter.GetBytes(ItemCategory);
                Array.Copy(bytes, 0, asm, 0x1, 4);
                bytes = BitConverter.GetBytes(ItemQuantity);
                Array.Copy(bytes, 0, asm, 0x7, 4);
                bytes = BitConverter.GetBytes(weapon.ID);
                Array.Copy(bytes, 0, asm, 0xD, 4);
                bytes = BitConverter.GetBytes((ulong)pBasePtr.Resolve());
                Array.Copy(bytes, 0, asm, 0x19, 8);
                bytes = BitConverter.GetBytes((ulong)pItemAddr.Resolve());
                Array.Copy(bytes, 0, asm, 0x46, 8);

                Process.Execute(asm);
            }
        }
Пример #4
0
        /// <summary>
        /// Removes a weapon from the player's inventory
        /// </summary>
        /// <param name="weapon"></param>
        public override void DeleteItem(BlackKnightWeapon weapon)
        {
            InventoryItem[] result = new InventoryItem[0];

            if (Process.Hooked)
            {
                result = new InventoryItem[2048];
                IntPtr    pointer    = pInventoryData.Resolve();
                PHPointer pInventory = Process.CreateChildPointer(pInventoryData, 0, 0x10, 0x3B8);
                byte[]    bytes      = pInventory.ReadBytes(0, 2048 * 0x1C);

                for (int i = 0; i < 2048; i++)
                {
                    result[i] = new InventoryItem(bytes, i * 0x1C);
                    if (result[i].Category == weapon.Category && result[i].ID == weapon.ID)
                    {
                        pInventory.WriteBytes(i * 0x1C, new byte[0x1C]);
                    }
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Removes a weapon from the player's inventory
 /// </summary>
 /// <param name="weapon"></param>
 public abstract void DeleteItem(BlackKnightWeapon weapon);
Пример #6
0
 /// <summary>
 /// Method that will create the weapon and put it into the player's inventory
 /// </summary>
 public abstract void CreateWeapon(BlackKnightWeapon weapon);