Here's a preview of what I have so far. It's nowhere near complete and these files are not playable by themselves, so don't copy them into your game install. If you want a look at how I've been doing this, download them somewhere safe and examine them with your choice of text editor.
I started with "Fox Ratter_dialog.c" because there several other storekeepers have identical dialog. Looking at that, you'll see that big chunks are missing compared to the version currently in the game. All the stuff for cargo and item trading is now split off, as is almost everything for quests - only a skeletal case "quests" remains as a base point in case anyone wants to add sidequest or storyline quest material for him. (Emiliano Rionda, the storekeeper in San Juan, has a small amount of sidequest code because he has a part in the "Nigel Blythe" quest; that stays in "Emiliano Rionda_dialog.c".)
"storekeeper_dialog.c" is the new general file. At the top is a switch based on "NPChar.id" which classifies all storekeepers that I've done so far and assigns them a number, "store_type". You'll see that there are a lot of store_type 1 - all of those have identical dialog, at least for the parts which were moved here. Some of them have code so that, if you've been recognised as hostile and have a high enough "Commerce" skill, you can still trade goods at a reduced rate. And some don't. That's handled by dialog case "First time", which remains in each storekeeper's own file so he can have his own greeting as well. (Some storekeepers are evidently more corrupt than others!) What that means is that "storekeeper_dialog.c" doesn't need to account for that difference.
But there aren't many clones of James Griffith's dialog, which in turn is almost but not quite identical to that for John Filbert, the storekeeper in Bridgetown. Presumably someone made a slight change to "John Filbert_dialog.c/h", then the changed dialog was copied for a couple of others. That's type 2, while the original John Filbert is type 3 to keep him different.
"store_type" is used for several switches within the dialog code, e.g. in case "quests":
Code:
switch(store_type)
{
case 1: Dialog.text = DLG_TEXT[4]; break;
case 2: dialog.text = DLG_TEXT[33]; break;
case 3: dialog.text = DLG_TEXT[33]; break;
case 4: dialog.text = DLG_TEXT[47]; break;
Dialog.text = DLG_TEXT[4];
}
That means it's going to be a more complicated to add a new storekeeper. Ideally you'd either clone his dialog from an existing storekeeper, then find that one's line at the top of "storekeeper_dialog.c" and copy it for your new character. Or you could write whole new dialog, add the relevant parts to "storekeeper_dialog.h", give him his own line at the top of "storekeeper_dialog.c", and then add switch cases at all points later. If you don't, it defaults to using the dialogs for store_type 1 as that's the most commonly used set.