As for coming up with riff just messing around and wanting to maybe use it in a song. First think of where you would be using it in a song. As an intro, verse, or a bridge? If it's an intro, look at the first chord. That is usually the key. Everything else you should look for it to fit in any key signature. Pay attention to the first and last chord, there's a good starting point. The root is interchangeable with the fifth so watch.
To add on Seiko about 3 note patterns. Arpeggios are good to use as those 3 note patterns, especially if you have to go over a chord. Since Arpeggios are broken chords themselves, they work well. Try ascending/descending in a major/minor scale using each notes arpeggio. Works very well!
Example in E minor (v, VII, ii(dim), iv, i)
B D F# A E
E:----------------------------------12--|
E:----------------------10h13p10h13-----|
G:-------------11h14p11-----------------|
D:----12h16p12--------------------------|
A:-14-----------------------------------|
E:--------------------------------------|
Running up and down a scale in good for getting a solo from point A to point B Sort of like a transition.
"My whole life is a dark room...ONE BIG DARK ROOM" - a.f.i.