MSFD Brief dialogue how-to
Dialogue is an art in itself that can not be fully covered here. However, when creating quests you will often mesh dialogue and scripting to control your quest and achieve certain effects. Therefore, I will give a brief introduction.
The concept of MW dialogue
In Morrowind, dialogue is organized in a database. This database is structured in the following way:
Top level:
The different "divisions" of dialogue are:
Topic: The actual topic words and responses for the dialogue window in the game.
Greetings: The text strings you are greeted with when you initiate dialogue with an Actor.
Persuasion: The answers you get for successful or failed persuasion attempts.
Journal: The entries for your journal.
Voice: The .mp3 sound files (and subtitles) that players "say" when you come near, are hit, are fleeing, etc.
Find these divisions on the tabs on the top left of the dialogue window (use the arrows to get to the hidden tabs).
Sub-level 1:
Each of these top level divisions has sublevels I call topics – for the Topics division, these are the actual "keywords" (topics) that Actors will have something to say about. These are the words that will be highlighted ("hyperlinked") in in-game text and listed in the right hand panel of the dialogue window. For Journal these are the different journals (usually one per quest). For Voices the different categories of sound responses that are "triggered" by the appropriate in-game conditions etc. For Greetings these are just general categories of greetings (diseased, quest offers, standard and so on). This is the way Bethesda has used them (forum info / Emma):
• Greetings 0: Npc is alarmed
• Greetings 1: Quests (actually quests where it doesn't matter if the Player is a vampire, is nude, is a criminal, is diseased).
• Greetings 2: Player is a vampire/player is nude
• Greetings 3: Traitors to Morag Tong
• Greetings 4: Crime and disease
• Greetings 5: Quests
• Greetings 6: Factions
• Greetings 7: Classes, Endgame, Slaves
• Greetings 8: Clothes (general greetings concerning how player is dressed)
• Greetings 9: Locations.
For Persuasion these are things like service refusals or bribe success/fail messages.
Sub-level 2:
For each topic there can be one or several sub-entries ("Info/Response") – these are the actual responses. For Topic and Greetings these are the actual answers of Actors to the topic phrase. For Journal these are the different entries describing the progress of a quest.
These entries represent a linked list, meaning that each entry contains (invisible) info on which is the next response in line and which is the previous. (This leads to a common error message when dialogue gets deleted or scrambled, e.g. by cleaning a mod with TESAME, or by loading several mods that change the same topic. The game doesn't know for sure any more which entry comes after which. This sometimes doesn’t matter, but it can also mean that certain responses are cut off, because the order isn’t right any more – this depends on the conditions). To check and/or change the next/previous ID strings, you can export the dialogue and re-import it if necessary (solution suggested by Kateri).
Dialogue entries come with conditions that you can set in the dialogue editor window. In the topic window you will find a list of general conditions on the left – here you can define which Actor (Actor ID) or group of Actors (Race, Class, Disposition, etc.) potentially know this response. There are also two conditions for the PC (PC faction and rank). To the right you can set a maximum of 6 "free" conditions that can refer to the Actor, the PC or other things like the state of global variables – lots of options here, you will have to see for yourself. Check for journal entries, player stats, local or global variables, items in inventory, and many other functions, some equivalent to script functions, some unique to dialogue (see below).
An important and initially confusing feature of the dialogue editor is the filter option (lower left-hand corner). When you select an Actor ID here, you only see the topics that this Actor can possibly know (as described above). Remember that when you create a new topic (maybe specifically for that NPC) it contains no responses. Thus the Actor cannot "know" it and thus the freshly created topic does not appear! Select the empty slot on the very top to see all topics again, make a response for the new topic that your Actor can "know" – then you can turn the filter on again, if you wish.
How dialogue works
To decide whether a dialogue topic is available during dialogue with an NPC, the game checks:
1. Whether the NPC "knows" the topic – this is determined by the conditions set in the "speaker conditions" field – if the NPC can fulfill the conditions for just one of the responses for that topic, he "knows" it.
2. Whether the Player knows it. The PC knows a topic if it (the topic word) either appeared previously in a response from an NPC or if it was specifically added with the AddTopic function. Note that the addition of a topic to the list of topics the PC knows only happens if the keyword becomes available in the same NPC's dialog that says the topic keyword. An example: let's say you try to trade with a weapon merchant and he denies you service because you have skooma in inventory. The word "skooma" is used in the dialogue, and there is a topic "skooma", but it is not familiar to weapon merchants. After that, you talk to a savant who is familiar with the topic... but you are still not. The topic will appear in your list only when he (or someone else familiar with it) will mention skooma in one of responses (Forum info / Kir).
3. If both the PC and the Actor "know" the topic it shows up in the topic list and gets highlighted in the text – it can now be selected by the player and an appropriate response will be given.
When the game has to select the correct response from the list of responses for that topic, it does the following:
• It starts checking from the top of the list, whether the conditions for that response are met, which means all conditions that have been defined for that response return "true".
• If not -> Game moves on to the next item in the list and checks again.
• If yes -> this entry is used and printed to the dialogue window.
Special rule for greetings: if none of the items in the list are met, move on to the next level 1 item (e.g. if no greeting in "Greeting 0" returns true, start checking "Greeting 1".
Special rule for Journal: there is only one condition here, the index (called by Journal function). It must be exactly met.
Once a response has been selected, the game will
• Output the text string to the dialogue window (or play the mp3 for Voice responses)
• Execute any Script commands in the Results field (at the very bottom). You can use all scripting functions here. Conditions (if command) can also be used (Thanks to Kir and Manauser for this info). Nested ifs are possible with Bloodmoon, not sure about earlier versions.
Be aware that the result field allows you to exchange information with scripts (e.g. by setting variables or adding journal entries) and that scripts can vice versa influence dialogue as well, by setting conditions that can be tested (e.g. you can check for local or global variables in the speaker conditions of dialogue). The simplest script that influences dialogue is the nolore script, which is just used as a flag to keep Actors from using standard dialogue.
Note: Result field scripts are not compiled by CS. You may write any rubbish there and MW will not complain until the line is told by an NPC and its script is compiled on-the-fly. If the script is complex enough to worry about possible syntax errors, it is recommended to copy/paste its text into a regular dummy script and try to save it. That is more reliable than using the "Error Test Results" button, as it can change preset values of global variables. On the other hand, the fact that resultbox scripts are compiled at runtime may allow some interesting effects, like addressing contents of another mod without duplicating it in the current mod, which can't be done with conventional scripts (Forum info / Kir).