Hey, I've been playing for a while, yet I find it impossible to write an original and high-quality riff. I've tried it all, and nothing seems to work. Can anyone offer some help?
Patience and continued writing. You don't always get that awesome riff on the first try. Just keep writing and overtime you'll have some golden riffs.

You should also keep listening to all kinds of genres of music because they all could inspire you one day. There's no magic process or everyone would have written hits.

Try gaining knowledge of theory too, that can help a lot along with a well trained ear.

Gibson Les Paul Custom (Aged White)
Custom Kramer Baretta
Custom Fender Strat
Epiphone Black Beauty
Epiphone AJ
Marshall JCM900 4201
Blackheart Little Giant
MXR Dist. +
MXR Six Band EQ
MXR Phase 90
I can't find the video clip where someone famous talks about it but the best thing you can do is just try and write as many riffs as possible, build up a massive body of work, the more you do that the more good material you will have to work with.

Almost every good songwriter I know works for hours a day on writing material and out of a whole day they'll have maybe one riff that they think is really good. You just have to keep working.
R.I.P. My Signature. Lost to us in the great Signature Massacre of 2014.

Quote by Master Foo
“A man who mistakes secrets for knowledge is like a man who, seeking light, hugs a candle so closely that he smothers it and burns his hand.”

I don't think you should try so hard. Chances are, unless you're into tech death or something, your favourite riffs are simple. They might even be simpler than other parts of the same song. It's one thing to labor over a song, or analyze a certain section, but I think you should just let riffs flow. I find this happens the most when I'm practicing or just letting loose.
What works for me is to not think about writing a riff. I like to practice writing music by imposing limits on myself, which range from key signature to the kind of rhythmic pulse that occurs in each measure. I find that I'm at my most creative and interesting when I'm trying to form some kind of musical and coherent idea when I surround myself with random impositions.

Like everyone above me said, it's a tough process. Sometimes I'll have really awesome days where I write a dozen riffs I really like and other days I won't be able to come up with anything at all that appeals to me.

Another thing that helps is listening to everything I can and taking the ideas I like from those sources and implementing them into my writing. I'm right now experimenting with some Afro-Cuban rhythm ideas in a progressive metal context; it's working really well, at least to my ears. The best ideas are all out there if you can only find them; the best way to find those ideas is to look absolutely everywhere.
What I do is have a really long improvisation session, not thinking about writing at all. I just play for a few hours straight and I record it. Then I'll listen to it a few times over the next few days and if anything jumps out and sounds awesome, that's where I start. At least then I have a key signature and time signature to work with, for a while at least (I play a lot of prog metal so key signatures and time signatures may change several times in one song).
Quote by Geldin
Junior's usually at least a little terse, but he knows his stuff. I've always read his posts in a grouchy grandfather voice, a grouchy grandfather with a huge stiffy for alternate picking.
Besides that, he's right this time. As usual.
I don't really "try" to write riffs, they just happen. I just start playing some warmup riffs and stuff and gradually start altering them. One piece of advice (and I need to follow this advice as well) is to get some kind of handy recording device.

Yesterday I was playing a little bit before work and came up with this awesome thrashy/death metal riff, or at least it had some potential -- but I didn't have enough time to lock it into my memory, nor to record it. Came home at the end of the day -- it was gone. I remembered the chords/notes, but not the timing.
I have trouble riffing/song writing myself. Usually when I actually write something I love it's out of nowhere (when I'm not trying to write.) The best thing for me is to write something basic and build off of it. Sometimes the way the final product sounds is completely different from the "rough draft" because I alter and change it so much. Also, if I record the rough idea with a drum beat it helps me to hear what should/should not be there.

Hope that helps a little bit, good luck!
Try this: Limit yourself to three chords. Or three scale positions. Or just three strings. And see what imposing limits can do to someone. It's the same as putting a deadline on a project. But, yeah, like the others said, even after that, it won't come magically. It takes time. Days, maybe even weeks. But it comes. Everyone who's had half an interest in the guitar has gone through this learning curve. It comes on its own.

Best of luck,
they come from how good your ear is. a lot of times I can hear in my head what I want the next note to be, and it was torturous before my ear was good enough to find it on the guitar. I would usually lose it before I found the note/chord I wanted. Then I would have to start over.

Once you get good, they come from everywhere, penta box, minor scale, radio, tv... when I play with my band I like to find new ways to play the natural harmonics for the NBC song (ya know da DA dun)
Not saying you have to but I'm just going to pitch the idea at you; writing with friends/other musicians has so many benefits. I recently got back together in a band with a few old friends of mine. I play guitar and I'm a perfectionist and our other guitarist is extremely loose with his works, so when we mix it's like magic~