Difference between revisions of "Modding:Dialogue"

From Stardew Valley Wiki
Jump to navigation Jump to search
Line 137: Line 137:
 
| TODO. Stands for "dialogueQuickResponse"; works like $q, but within one and the same text line.
 
| TODO. Stands for "dialogueQuickResponse"; works like $q, but within one and the same text line.
 
|-
 
|-
| <tt>$p</tt>
+
| <tt>$p {{t|value}}</tt>
| TODO. Stands for "dialoguePrerequisite".
+
| Stands for "dialoguePrerequisite". {{t|value}} refers to the value of a response picked by the player to a preceding question.
 
|-
 
|-
 
| <tt>$1 {{t|character name}}1</tt>
 
| <tt>$1 {{t|character name}}1</tt>

Revision as of 21:35, 8 September 2017

Index

This page explains how the game stores dialogue text, its format, and how the game parses it. This is an advanced guide for mod developers.

Data

The dialogue text is stored in four sets of files.

Character-specific dialogue

Characters\Dialogue\*.xnb contains most of the dialogue for each character (one file per character). The format in this file is:

"<preface>[heart level]_[date]_[year][suffix]": "String"

...where:

  • <preface> is an arbitrary key which identifies what it's for (like _Introduction_, _Event_, _Season_, etc).
  • [heart level] is the minimum heart level the player must have reached with the NPC for this dialogue to appear.
  • [date] is the numeric day of the month (like _28_), or the three-character weekday (like _Mon_).
  • [year] is _1_ for year one, or _2_ for any year after that.
  • [suffix] is any string further identifying the dialogue (like _inlaw_Abigail, for dialogue that only appears when you're married to Abigail).

If multiple dialogues are eligible, the game prioritises by the following:

  1. marriage status;
  2. preface;
  3. suffix;
  4. in-law status;
  5. day of month;
  6. year;
  7. heart level;
  8. day of week.

Strings from CS files

Data\Strings\StringsFromCSFiles.xnb contains many translation strings, including NPC dialogue defined in the code. That includes every bit of dialogue that's shared between multiple characters, and dialogue for some hardcoded events like marriage. The format in this file is:

"<key>": "dialogue string"

The key is generated based on the file that contained it before translations were added (in the form <file name>.<int id>), but doesn't have any particular meaning now.

Event files

Data\Events\*.xnb contains event scripts, including any dialogue in the event (see Modding:Event data).

Animation descriptions

Data\animationDescriptions.xnb contains short bits of dialogue to go with certain schedule points.

Algorithm

The game finds dialogue as follows:

  1. Event dialogue is read from the appropriate event commands (see Modding:Event data).
  2. Location-specific dialogue is read from StringsFromCSFiles <location>.cs.
  3. Else character dialogue is read from the character-specific files.
  4. If no dialogues were found, the game resorts to hardcoded dialogue from the StringsFromCSFiles files (specifically keys prefixed with NPC.cs NPC.cs).

Format

Dialogue text can contain tokens and commands which control the dialogue box, change the text (e.g. switch between gender-specific strings), inject values, etc. These are parsed by the Dialogue class.

Special tokens:

character description
# Separates two commands in a dialogue string.
{ TODO. Stands for "breakSpecialCharacter".
^ Gender switch character. The text before it is shown for male farmers, the text after it for female farmers.
Example: Oh, good morning Mr. @!^Oh, good morning Ms. @!
* TODO. Stands for "quickResponseDelineator".

Portrait commands

These commands determine which portrait will be shown in the dialogue box. Portrait commands go to the end of a line of dialogue:

"fall_Fri6": "When I was a little girl, my father abandoned us.$s#$b#I'm sorry to make things uncomfortable for you...$u#$e#Anyway... How's the farming life going?",
command description
$h Switch the speaking character to their happy portrait.
$s Switch the speaking character to their sad portrait.
$u Switch the speaking character to their unique portrait.
$neutral Switch the speaking character to their neutral portrait.
$l Switch the speaking character to their love portrait.
$a Switch the speaking character to their angry portrait.
$<id> Switch the speaking character to the portrait at the given index in their portraits file. NOTE: $1 can't be used as the first dialogue command (see $1 below).

Dialogue commands

$q <?> <?>#<text> TODO. Show a dialogue box containing the given question text.
$r <value A> <value B> <response ID>#<answer text> TODO. Adds an <answer text> option to the question dialogue, which when selected triggers the response indicated by <response ID> from the speaker's Content\Characters\Dialogue\*.xnb file. Values are used to group responses for future reference.
$e End the current dialogue. Everything before $e is shown the first time you talk to an NPC; everything after is shown in subsequent conversations.
$b End the current textbox, so the next part of the dialogue is shown in a new box.
$k TODO. Stands for "dialogueKill".
$c <probability> Choose the given text with a <probability> between 0 and 1.
$d <bus|joja|cc> TODO. Stands for "dialogueDependingOnWorldState". Format:

"Tue4": "$d (dependence)#|Dialogue when dependence value is true.|Dialogue in other situations.",
bus: "bus fixed?" joja: "JoJa Mart in business? cc: "Community Centre completed?"

$y TODO. Stands for "dialogueQuickResponse"; works like $q, but within one and the same text line.
$p <value> Stands for "dialoguePrerequisite". <value> refers to the value of a response picked by the player to a preceding question.
$1 <character name>1 TODO. When used as the first dialogue command, stands for "dialogueSingle". Likely a check for whether the player is dating the specified character.
%fork TODO. Seems to have to do with questions and forks, however is used sparingly in originals game code. Seems to be replaced with the actual question command.

Replacer commands

Replacer commands will be replaced with the relevant string.

@ Farmer's name.
Example: Hi there @!
%adj Random adjective.
%noun Random noun.
%place Random place name.
%spouse The name of Farmer's spouse.
%name TODO. Stands for "randomNameSpecialCharacter". Seems to return a random name?
%firstnameletter TODO. Stands for "firstNameLettersSpecialCharacter".
%time Current time.
%band TODO. Possibly the genre of Sam and Sebastian's band.
%book TODO. Possibly the genre of Elliott's book.
%rival TODO. Possibly the name or personal pronoun of Leah's ex.
%pet The name of Farmer's pet.
%farm Farm name.
%favorite TODO. Returns favorite thing? Unused?
%kid1 The name of Farmer's first child.
%kid2 The name of Farmer's second child.