I just finished Psychonauts, and all the witty, genuinely funny dialogue got me thinking about writing in games.
Good writing and complex stories in games is still often the exception instead of the rule. I'll admit that we've come a long way and things are a little more complicated usually than "that monkey/dragon/demon stole your girlfriend," the standby for so long.
But despite all the cutscenes and CGI, a lot of the storylines in games I've played boil down to "There are bastards. Kill them!" If not, there are sometimes a lot of corny jokes or cliched "kids save world" storylines, a focus on action packed set pieces regardless of logic or bad or poorly translated dialogue. The stories sometimes feel tacked on to the game or just really don't make sense.
I guess that's why when there are exceptions they stand out so much for me. The best written game that I've played is almost certainly Planescape: Torment. Following the nameless one to discover his identity is like interacting with a mindbending fantasy novel that really transcends its D&D trappings. It's wordier than most RPGS, and following the dialogue paths is worth it because they reveal a rather rich world. There's one part where you can use crystals to experience other lives and they play out like fascinating little short stories.
Since I've already mentioned Tim Schafer's Psychonauts, I won't go into it in detail, but some of the funnier and better written games I've played have been Lucasarts graphic adventures. It was humor and dialogue that gave Lucasarts an edge over all the others who were doing that type of game for me. Sam and Max was probably the most hilarious of them, I think, and Loom and Grim Fandango the deepest and most interesting.
So, of what you've played, which do you think are best written?