Modding:Dialogue

From Stardew Valley Wiki
Revision as of 15:34, 4 May 2017 by Pathoschild (talk | contribs) (standardise, reorganise, copyedit)
Jump to navigation Jump to search

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 three 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 Pierre and Caroline, 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).

Algorithm

The game finds 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).