The trick in writing good RPG dialogue that differentiates it from book writing is that RPG plot is fluid, and the characters who can end up in a situation can be different each time. So writing dialogue means weaving conditional branches for every other line.
Example:
A party stands near the entrance of a Fire Cave. Two mandatory characters are required by the plot; the third can be anyone of the available party members.
Dramatis Personae:
Mandatory party members:
Oscar, a brooding, silent monster hunter, a protagonist
Presto, a spy, jester and sorcerer, the resident black mage, the knowledgeable guy
Possible party members
Mira, a jolly and a bit rude paladin of a common upbringing
Melle, white mage, a well brought up princess
Kaori, the extremely silent and terse ninja maid, speaks more or less like Fujin from FF8
Nightwind, the repentant thief, anxious
Solomon, gadgeteer genius extraordinaire, speaks like a professor, which he is
Geas, a cat familiar. Does not speak, meows
Oscar: The Caves of Fire?
Presto: Exactly, my friend. Aren't they majestic and intimidating?
- check if Mira is in party, if yes then say this line:
Mira: Yikes! Presto, are you sure you won't get us a-barbecued?
- else check if Melle is in party, if yes then say:
Melle: It is clear that it is hot inside. Isn't it dangerous?
- else check if Kaori is in party, if yes then say:
Kaori: HOT. Dangerous?
- else check if Nightwind is in party, if yes then say:
Nightwind: This place looks like hell! I'm sure that it's very hot down there. I wouldn't enter this place if I were you!
- else check if Solomon is in party, if yes then say:
Solomon: What an interesting phenomenon! Doubtless, we shall encounter volcanic magma. However, it seems risky to explore this cave!
- else check if Geas is in party, if yes then display message:
* Geas anxiously nips Oscar's finger (lose 1 hp, play sound effect Cat)
Oscar: See, Geas is afraid to enter. Maybe, the creature is smarter than we think!
(end conditional branches)
Presto: Poppycock! I've been to these caves. Yes, it is hot and the air is harsh, but it's not fatal.
This is a very simple example: the same line is retold in the style of everyone who can theoretically say it. However, writing dialogue like this helps you learn understanding the characters and switching between them on the fly. Giving each character a memorable and distinct speech pattern, such as Mira's copious colloquialisms, Kaori's kanjispeak or Solomon's professorial sesquipedalian loquaciousness helps.