public override void DoAction(PlayerCharacter character, ItemSlot slot) { int half = slot.GetQuantity() / 2; ItemData item = slot.GetItem(); InventoryData inventory = slot.GetInventory(); InventoryItemData item_data = inventory.GetItem(slot.index); inventory.RemoveItemAt(slot.index, half); bool can_take = inventory.CanTakeItem(item.id, half); InventoryData ninventory = can_take ? inventory : character.Inventory.GetValidInventory(item, half); //If cant take, find a valid one int new_slot = ninventory.GetFirstEmptySlot(); ninventory.AddItemAt(item.id, new_slot, half, item_data.durability, UniqueID.GenerateUniqueID()); }