The game already more or less works this way. The dialog system works on a series of weighted "conversation tags." Each line of dialog fits into a category (e.g. greetings), and has a set of associated tags. You can see some examples of this in the comment_strings.xml or voice_strings.xml files. The game checks to see if each tag associated with the line of dialog applies to the given situation, and adds the "weight" value of the tag to the dialog "score" if the conditions are met. The line of dialog from a particular category that has the highest score is the one that the npc speaks. If two lines of dialog have the same score, the one higher up on the list takes presidence. Here's a list of the various conversation tags:
Here are some examples of the requirements for the tags to apply:
- PlayerIsFamous: the player must be above 50 renown (low bar, I know).
- FriendlyRelationship: either a set of both npc and player traits need to be "compatible" and relations need to be above 5, OR just relations above 20.
- PlayerIsLiege: the player must be the ruler of the npc's faction.
- AttractedToPlayer: must be opposite gender, not at war, neither player nor npc married, and the npc must be physically "attracted" to the player.
- PlayerIsAllied: the factions of the npc and player must be in an alliance (hm... I wonder if that implies something).
- Sexist: the npc must not be in a clan that has a female party leader and must have a particular combination of the valor, mercy, generosity, and calculating traits.
The game also searches through the list of event log entries, and bases certain comments on the type of event and the 'importance' of it. You can see that after you take a fief for instance; nearly every lord will mention it the next time you see them.
The dialog system is really versatile, and you can add your own dialog simply by inserting it into one of the xml files and giving it various tags and weights.
There's actually a pretty large dialog tree for villagers and townsfolk that's based on a variety of conditions. There are at least 60+ distinct lines of dialog that villagers/townsfolk can say depending on which conditions are met, and there are 10-15 different condition types (such as seasons, prosperity level, traits, recent events, etc.).
Very few of the conditions directly rely on the player character though, unless they are a settlement owner or faction ruler. So maybe they could add a few of those in. Comments on equipment would be cool.
Lords and notables already have personality types that affect dialog. There are 4 different "personas" in the game, which are Curt, Ironic, Earnest, and Softspoken. You can see each lord's persona by looking at the "voice" variable in the lords.xml file. Their character traits also impact dialog lines given, so taken in conjunction with the personas, there are probably few lords that share the exact same dialog trees. However, they aren't going to write unique dialog for each individual lord; that's just not feasible with how many different situations there are in the game. Lords also have 1 of 3 political ideologies which affects which policies they vote for and their willingness to defect, as well as some other minor things.
All of that said, there's always room for more dialog, and I'm sure they will continue to pepper it in over time.
Edit: Also, it's almost a given that there are bugs within the conversation system, and that some dialogs might not appear because their conditions are rarely/never met. I found two bugs just while looking into the mechanic.