Difference between revisions of "Modding:NPC data"

From Stardew Valley Wiki
Jump to navigation Jump to search
(How to create a new NPC)
 
(→‎Portraits: remove broken hotlinked image (images should be uploaded to the wiki with an open license instead))
 
(67 intermediate revisions by 17 users not shown)
Line 1: Line 1:
{{stub}} [[Category:Modding]]
+
[[Modding:Index|Index]]
Creating Custom NPCs
 
  
Creation of NPCs is a small undertaking, as it requires editing and installing various files of the game.  Fortunately, creating NPCs does not require any coding experience and can be done via XNB modding (not recommended) and Content Patcher (very recommended).
+
This page provides an overview of what's needed to create a custom NPC. This is an advanced guide for mod developers.
I. Files
 
When creating a NPC, remember that the following files must be made or edited:
 
⦁ NPCDispositions.xnb: You need to add in the information of your character here.  This will determine their coded name, their birthday, relations to other characters, dispositions, if datable or not.
 
⦁ NPCGiftTastes.xnb: In order to gain friendship, you need to edit this file in order for the game to know what Items your NPC loves/likes/is neutral/dislikes/hates.  See https://stardewvalleywiki.com/Modding:Gift_taste_data for information
 
⦁ Spritesheet: This is a file you must make on your own.  The character sprite sheet will contain the movement and animation frames in rows of 4.  The sprites are 16x32 each and cannot exceed that framesize.  Certain frames MUST be reserved for certain actions. (such as Frame 33 must be the kissing sprite for marriageable NPCs.)
 
⦁ Portraits: This is the character's face sprites for dialogue.  Each frame is 64x64 pixels and are grouped in rows of 2.  In order to have a good universal feel you need to order the first 6 frames as follows: Neutral face, Happy face, Sad Face, Blush, Angry Face, and Unique Face.  This represents the universal codes for the game to recognize ($h, $s, $a, $l, $u). As of now you can place up to 12 portraits on one sheet ($11).
 
⦁ Schedule: This tells the game where the NPC starts and moves to depending on time.  You will need to add strings to a separate Schedules  file found in the Strings folder to allow custom dialogue.
 
⦁ Dialogue: This is a file you design usually formated by the name of the NPC (ex: Abigail).  It contains the dialogue for day to day speech when you interact with them.  For details see: https://stardewvalleywiki.com/Modding:Dialogue
 
⦁ Marriage Dialogue: Marriage dialogue is needed only if your NPC can be married to the farmer.  It is usually formatted as MarriageDialogue<Name> (Ex: MarriageDialogueHaley). This contains specific dialogue for the NPC while married and has special dialogue conditions for being married.  There is also a generic Marriage Dialogue you can edit for generic responses.
 
⦁ Event Presence: This is done by simple event creation. See: https://stardewvalleywiki.com/Modding:Event_data
 
⦁ Festival Presence: Todo Define how to do this.
 
II. NPC Disposition
 
This file contains some values used by the game that defines the character. 
 
Abigail1: "teen2/rude3/outgoing4/neutral5/female6/datable7/Sebastian8/Town9/fall 1310/Caroline 'mom' Pierre 'dad'11/SeedShop 1 912/Abigail13"
 
1. Coded name: This is what events use to identify your NPC
 
2. Age: This determines if the NPC is a child, teen(18),adult. As for what it changes, it is not yet known.(TODO: Get better understanding of this value)
 
3. Disposition: Mostly determines some generic lines that occasionally comes up.  The known values are polite, rude, neutral.
 
4. Specific Disposition: Determines more Generic dialogue, not much else is known. Known values are outgoing, shy, neutral
 
5. Optimisim: Shows the persons outlook on life.. not sure if it affects generic dialogue.  Known values are positive, negative, neutral.
 
6. Gender: This determines if the NPC is male or female.  There is more to it than the gender as it determines if you adopt a baby or become pregnant.  This also determines where on the spritesheet your reserved frames must go.
 
7. Datablility: Only two values are available datable, non-datable.  This will tell the game whether to lable them as single and activate the ability to give them a bouquet at 8 hearts and marry them at 10 hearts.
 
8. Friends or love interests: Usually determines who the NPC is close to.  Not required but you have to put the space there (//).
 
9. Villager: Determines if they are a part of Pelican Town or not.  All villagers are labled with the Town value while Krobus, Dwarf, and Wizard are labled with Other.
 
10. Birthday: This determines the NPC's Birthday.
 
11. Relations: This value determines parents and siblings.
 
12. Sleep zone: Determines where the NPC starts and ends every day.
 
13. Name String: This does not have to match the Code name.  This will be the name that appears in text when speaking to the NPC.
 
  
 +
'''Before reading this page''', see [[Modding:Editing XNB files]] for the basic concepts.
  
III. Gift Tastes
+
==Files to edit==
This file contains the gift tastes of an NPC.
+
To create a new NPC, you need to edit a number of different files. However, you don't need any programming experience and it can be done with [[Modding:Content Patcher|Content Patcher]].
    Haley: "Oh my god, this is my favorite thing!!/221 421 610 88/1*gasp*...for me? Thank you!/18 60 62 64 70 88 222 223 232 233 234 402 418/2Ugh...that's such a stupid gift./-5 -6 -75 -79 -81 80 -27/3Gross!/-4 2 16 330 74/4Thank you. I love presents.// "
 
Each bit of dialogue is followed by item codes for various gifts. The order of taste is Love, Like, Neutral, Dislike, Hate. You do not have to make dialogue for every part as there is Generic Dialogue that works with it.  It is recommended to put Love, like, dislike and hate dialogue to keep the NPC original.
 
Item codes can be found here: https://stardewvalleywiki.com/Modding:Object_data
 
  
IV. Sprites and Portraits
+
===Basic info===
 +
The <samp>Data\NPCDispositions</samp> asset contains basic information for your character, including their name, birthday, relations to other characters, personality, and whether they can be dated.
  
Sprites and portraits can be done in any kind of drawing program.  The requirements for each are easy to remember: 16x32 per sprite and 64x64 per portrait.  There are only a few rules to remember:
+
The file has one row per NPC like this:
Movement Frames: These will be used on the first 16 slots of your spritesheet (4 frames per direction)
+
<syntaxhighlight lang="yaml">
Kiss Frame: Frame 33 is the kiss frame for Females, Frame 35 is for males
+
  Abigail: "teen/rude/outgoing/neutral/female/datable/Sebastian/Town/fall 13/Caroline 'mom' Pierre 'dad'/SeedShop 1 9/Abigail"
Flower Dance: If your NPC is to participate you need to reserve 40 - 47 for Females and 44 - 47 for males.
+
</syntaxhighlight>
Marriage: If you can marry your NPC, males need Frames 48- 50 to be reserved and 36 - 38 for Females.
 
Portrait Order: The first image is your neutral face, which is used with no emotion codes.  The second portrait should always be Happy ($h or $1).  Below the first Portrait should be Sad ($s or $2), Next to that is Unique ($3 or $u), Below Sad should be Blush ($l or $4), Next to that is anger ($a or $5).  After that you may put your portraits in any order.
 
  
V. Schedule
+
The key (before the colon) is the internal name which uniquely identifies that NPC. This name isn't shown to the player, but will be used when referencing the NPC in other files. The value contains the following fields:
See: https://stardewvalleywiki.com/Modding:Schedule_data
 
VI. Dialogue and Marriage Dialogue
 
See: https://stardewvalleywiki.com/Modding:Dialogue
 
VII. Event Presence
 
Just add them in as  you would any NPC.  See: https://stardewvalleywiki.com/Modding:Event_data
 
  
 +
{| class="wikitable"
 +
|-
 +
! index
 +
! field
 +
! example
 +
! purpose
 +
|-
 +
| 0
 +
| age
 +
| <samp>teen</samp>
 +
| Whether the NPC is a <samp>child</samp>, <samp>teen</samp>, or <samp>adult</samp>. This affects generated dialogue lines (''e.g.,'' a child would say ''stupid'' and an adult would say ''depressing''), generic dialogue (''e.g.,'' a child would respond to dumpster diving with "''Eww... What are you doing?''" and a teen would say "''Um... Why are you digging in the trash?''"), and the gift they choose as [[Feast of the Winter Star|a secret gift-giver]]. Children are also excluded from item delivery quests.
 +
|-
 +
| 1
 +
| manners
 +
| <samp>rude</samp>
 +
| Whether the NPC is <samp>polite</samp>, <samp>rude</samp>, or <samp>neutral</samp>. This affects some generic dialogue lines.
 +
|-
 +
| 2
 +
| social anxiety
 +
| <samp>outgoing</samp>
 +
| Whether the NPC is <samp>outgoing</samp>, <samp>shy</samp>, or <samp>neutral</samp>. This affects some generic dialogue lines.
 +
|-
 +
| 3
 +
| optimism
 +
| <samp>neutral</samp>
 +
| Whether the NPC is <samp>positive</samp>, <samp>negative</samp>, or <samp>neutral</samp>. ''Unused.''
 +
|-
 +
| 4
 +
| gender
 +
| <samp>female</samp>
 +
| Whether the NPC is <samp>male</samp>, <samp>female</samp>, or <samp>undefined</samp>. This affects dialogue, whether children in marriage are obtained through adoption or pregnancy, and the reserved frames' positions on the spritesheet.
 +
|-
 +
| 5
 +
| datable
 +
| <samp>datable</samp>
 +
| Whether the NPC is <samp>datable</samp>, <samp>not-datable</samp>, or <samp>secret</samp>. The former two toggle the romance features (''e.g.,'' 'single' label in the social menu, bouquet gifting, and marriage), while <samp>secret</samp> is used exclusively for Krobus, who cannot be married but can be made a roommate.
 +
|-
 +
| 6
 +
| love interest
 +
| <samp>Sebastian</samp>
 +
| ''Unused.''
 +
|-
 +
| 7
 +
| home region
 +
| <samp>Town</samp>
 +
| Whether the NPC lives in the <samp>Desert</samp>, <samp>Town</samp>, or <samp>Other</samp>. This is used when improving friendship points for all NPCs in a given region, which is currently only used for the [[Luau]] friendship boost (which only affects NPCs in the <samp>Town</samp> region).
 +
|-
 +
| 8
 +
| birthday
 +
| <samp>fall 13</samp>
 +
| The season and day for the NPC's birthday.
 +
|-
 +
| 9
 +
| relationships
 +
| <samp>Caroline 'mom' Pierre 'dad'</samp>
 +
| This affects generic dialogue for revealing likes and dislikes to family members. May also affect the inlaw_<NPC> dialogue. Can be empty if not applicable (''e.g.,'' <code>/fall 13//SeedShop 1 9/</code>).
 +
|-
 +
| 10
 +
| default map & position
 +
| <samp>SeedShop 1 9</samp>
 +
| The location name and [[Modding:Modder Guide/Game Fundamentals#Tiles|tile position]] where the NPC starts and ends each day.
 +
|-
 +
| 11
 +
| display name
 +
| <samp>Abigail</samp>
 +
| The NPC name shown to the player.
 +
|}
  
VIII. Adding your NPC via Content Patcher
+
===Gift tastes===
For simplicity, we will call our example NPC Dobson.
+
The <samp>Data\NPCGiftTastes</samp> asset contains their gift preferences (''e.g.,'' which gifts they love or hate), and their responses when they receive one. See [[Modding:Gift taste data]] for more info.
Your mod should be made in a folder Which we can name [CP]Dobson, you do not have to name it as such but it will help identify your mod in a sea of mod folders.
+
 
You must have the following files in your mod folder:
+
The file has one row per NPC like this:
content.json - the mod file itself.
+
<syntaxhighlight lang="yaml">
manifest.json - so SMAPI and Content Patch can identify your mod.
+
  Abigail: "I seriously love this! You're the best, @!/66 128 220 226 276 611/Hey, how'd you know I was hungry? This looks delicious!//What am I supposed to do with this?/-5 -75 -79 16 245 246/What were you thinking? This is awful!/330/You brought me a present? Thanks.// " #!String
DialogueDobson.json - This will be Dobson's Dialogue file.
+
</syntaxhighlight>
MarriageDialogueDobson.json - This is if you wish to marry Dobson
+
 
DobsonSprite.png - This is Dobson's sprite frames
+
The line can be broken down into 5 pairs of dialogue + item IDs in this order: Love, Like, Dislike, Hate, Neutral. If a dialogue field is empty, the game will use a generic dialogue text. See [[Modding:Items]] for the object IDs.
DobsonPortrait.png - This contains Dobson's portraits
+
 
DobsonSchedule.json - This contains where Dobson goes every day
+
====Birthday gift responses====
All the files except content.json and manifest.json can also be placed in a folder to keep your mod space clean. (such as you can make an assets folder for it to sit in)
+
The <samp>Strings\StringsFromCSFiles</samp> asset contains the generic responses given by NPCs to birthday gifts based on their gift preferences and manners. These shared strings can be customized for a specific NPC by editing them conditionally, such as only on the NPC's (non-shared) birthday. The following criteria are used to select from among the strings:
1. Load all the data
+
 
{
+
{| class="wikitable"
"LogName": "Dobson Spitesheet",  
+
|-
"Action": "Load",
+
! gift taste
"Target": "Characters/Dobson",
+
! manners
"FromFile": "DobsonSprite.png",
+
! chance
},
+
! string
A logname isn't required but you can use Patch Summary to see if it loads or not.
+
! english string
The target, Characters/Dobson it is referring to the folder target of Content/Characters/Dobson.xnb, which doesn't exist but will be placed there.
+
|-
The "FromFile" must have the extention on it or it won't recognize your file.. if you placed all the assets in a separate folder then use something like "assets/DobsonSprite.png",.
+
| rowspan="4" | love, like
{
+
| rowspan="2" | rude
"LogName": "Dobson Portrait",
+
| 50%
"Action": "Load",
+
| <samp>NPC.cs.4274</samp>
"Target": "Characters/Portraits/Dobson",
+
| <samp>"You remembered my birthday? I'm impressed. Thanks.$h"</samp>
"FromFile": "DobsonPortrait.png",
+
|-
},
+
| 50%
This loads the Portraits into the game.
+
| <samp>NPC.cs.4276</samp>
{
+
| <samp>"Oh, is it my birthday today? I guess it is. Thanks. This is nice.$h/Oh, is it my birthday today? I guess it is. Thanks. This is nice.$h"</samp>
"LogName": "Dobson Dialogue",
+
|-
"Action": "Load",
+
| rowspan="2" | polite, neutral
"Target": "Characters/Dialogue/Dobson",
+
| 50%
"FromFile": "DialogueDobson.json",
+
| <samp>NPC.cs.4275</samp>
},
+
| <samp>"A birthday gift? That's very kind of you! I love it.$h"</samp>
This will load Dobson's Dialogue into the game.
+
|-
{
+
| 50%
"LogName": "Dobson Marriage Dialogue",
+
| <samp>NPC.cs.4277</samp>
"Action": "Load",
+
| <samp>"You remembered my birthday! Thank you. This is great.$h"</samp>
"Target": "Characters/Dialogue/MarriageDialogueDobson",
+
|-
"FromFile": "MarriageDialogueDobson.json",
+
| rowspan="2" | dislike, hate
},
+
| rude
This will load Dobson's marriage dialogue into the game.  Remember that this is not needed if you are not making your NPC marriageable.
+
| 100%
{
+
| <samp>NPC.cs.4278</samp>
"LogName": "DobsonSchedule",
+
| <samp>"It's my birthday and you give me this? Is this some kind of joke?$s/It's my birthday and you give me this? Is this some kind of joke?$s"</samp>
"Action": "Load",
+
|-
"Target": "Characters/schedules/Dobson",
+
| polite, neutral
"FromFile": "DobsonSchedule.json",
+
| 100%
},
+
| <samp>NPC.cs.4279</samp>
This will load your NPC's Schedule into the game.
+
| <samp>"Oh... It's for my birthday? ... Thanks.$s/Oh... It's for my birthday? ... Thanks.$s"</samp>
That does it with your custom files.. now you need to Edit some existing files:
+
|-
{
+
| rowspan="2" | neutral
"LogName": "Add Dobson",
+
| rude
"Action": "Edit Data",
+
| 100%
"Target": "Data/NPCDispositions",
+
| <samp>NPC.cs.4280</samp>
"Entries": {
+
| <samp>"For my birthday? Thanks."</samp>
"Dobson": "adult/rude/neutral/positive/male/datable//Town/summer 7//BusStop 19 4/Dobson",
+
|-
},
+
| polite, neutral
},
+
| 100%
This will change NPCDispositions and add your NPC in.
+
| <samp>NPC.cs.4281</samp>
{
+
| <samp>"Oh, a birthday gift! Thank you./Oh, a birthday gift! Thank you."</samp>
"LogName": "Dobson Gifts",
+
|}
"Action": "EditData",  
+
 
"Target": "Data/NPCGiftTastes",
+
The <samp>$h</samp> and <samp>$s</samp> are [[Modding:Dialogue#Portrait_commands|portrait commands]] that select the portrait image of the character to use.
"Entries": {
+
 
"Demetrius: "You're giving this to me? This is amazing!/207 232 233 400/Thank you! This is a very interesting specimen./-5 -79 422/...What is this?/80 330/This is disgusting./2/That was very thoughtful of you./-4/ ",
+
===Overworld sprites===
},
+
 
},
+
[[File:Abigail-sprite-sheet.png|thumb|The sprite sheet for Abigail.]]
This adds in the NPC's Gift Tastes.  This will complete your character and will appear in a new game wondering around according to their schedule.  
+
 
If you wish to make Heart events for the NPC please see: https://stardewvalleywiki.com/Modding:Event_data
+
The overworld sprites are stored in <samp>Characters/NpcName</samp>, including movement and animation frames. Each frame is exactly 16x32 pixels. Here's an [https://cdn.discordapp.com/attachments/156109690059751424/729807097835028540/unknown.png example sprite guide], courtesy of TheLimeyDragon#1993 on Discord. Some positions are reserved for certain actions:
 +
<ul>
 +
<li>the first sixteen frames are generic movement (four frames per direction);</li>
 +
<li>frames 40–47 (female) and 44–47 (male) must be the Flower Dance dance, if they participate;</li>
 +
<li>frames 36–38 (female) 48–50 (male) are reserved for marriageable NPCs (Contains Wedding sprite);</li>
 +
<li>and the kissing sprite/direction varies depending on NPC:
 +
{| class="wikitable"
 +
|-
 +
! character
 +
! kissing frame
 +
! facing direction
 +
|-
 +
| [[Abigail]] and [[Emily]]
 +
| 33
 +
| left
 +
|-
 +
| [[Alex]]
 +
| 42
 +
| right
 +
|-
 +
| [[Elliott]]
 +
| 35
 +
| left
 +
|-
 +
| [[Haley]]
 +
| 28
 +
| right
 +
|-
 +
| [[Harvey]]
 +
| 31
 +
| left
 +
|-
 +
| [[Leah]]
 +
| 25
 +
| right
 +
|-
 +
| [[Maru]]
 +
| 28
 +
| left
 +
|-
 +
| [[Penny]]
 +
| 35
 +
| right
 +
|-
 +
| [[Sam]]
 +
| 36
 +
| right
 +
|-
 +
| [[Sebastian]]
 +
| 40
 +
| left
 +
|-
 +
| [[Shane]]
 +
| 34
 +
| left
 +
|-
 +
| ''any other NPC''
 +
| 28
 +
| right
 +
|}</li>
 +
</ul>
 +
 
 +
===Portraits===
 +
[[File:Modding - creating an XNB mod - example portraits.png|thumb|Abigail's portrait sprite sheet.]]
 +
 
 +
The dialogue portraits are stored in <samp>Portraits/NpcName</samp>. Each frame is exactly 64x64 per portrait. The first six represent specific emotions (see [[Modding:Dialogue#Portrait commands]]), followed by any number of custom portraits. The first portrait is used when the dialogue doesn't specify one.
 +
 
 +
===Schedule===
 +
Their schedule file tells the game where the NPC starts and moves based on on the time. You need to add strings to a separate schedules file found in the Strings folder to allow custom dialogue. See [[Modding:Schedule data]] for more info.
 +
 
 +
===Dialogue and events===
 +
The NPC dialogue and events are stored in several files; see [[Modding:Dialogue]] and [[Modding:Event data]] for more info.
 +
 
 +
===Festivals===
 +
Custom NPCs should be added to festivals via the <samp>Set-Up_additionalCharacters</samp> and <samp>MainEvent_additionalCharacters</samp> fields in the [[Modding:Festival_data#Data_file|festival's data file]]. You may also want to visit [https://stardewmodding.wiki.gg/wiki/Custom_NPC_Tiles Custom NPC festival tile positions] to check the positions of various existing NPCs for compatibility purposes.
 +
 
 +
(Prior to Stardew Valley 1.5, {{nexus mod|1820|TMXL}} was the recommended tool for adding festival spots.)
 +
 
 +
===Movie theater===
 +
An NPC's taste in movies and concessions are stored in <samp>Data\MoviesReactions.xnb</samp> and <samp>Data\ConcessionTastes.xnb</samp>, respectively. See [[Modding:Movie theater data]] for details on how these function.
 +
 
 +
===Spouse room===
 +
If your NPC will be a marriage candidate, note that you can add a spouse room for them much more easily after game version 1.5.5. See [[Modding:Migrate_to_Stardew_Valley_1.5.5#Custom_spouse_rooms]] for details.
 +
 
 +
===Sleep animation===
 +
When the NPC goes to bed, they'll play the looping sleep animation set via <samp>{{t|lowercase NPC name}}_sleep</samp> in <samp>Data/animationDescriptions</samp>, if it exists. For example, this content pack adds a sleep animation for an NPC named 'Pufferbob':
 +
{{#tag:syntaxhighlight|
 +
{
 +
    "Format": "{{Content Patcher version}}",
 +
    "Changes": [
 +
        {
 +
            "Action": "EditData",
 +
            "Target": "Data/animationDescriptions",
 +
            "Entries": {
 +
                "pufferbob_sleep": "50/50/50" // note: make name lowercase
 +
            }
 +
        }
 +
    ]
 +
}
 +
|lang=json}}
 +
}
 +
 
 +
==Adding your NPC==
 +
Here's how you'd create an example NPC we'll name Dobson:
 +
 
 +
<ol>
 +
<li>[https://github.com/Pathoschild/StardewMods/blob/develop/ContentPatcher/docs/author-guide.md#format Create an empty Content Patcher content pack]. By convention, we'll name the folder <samp>[CP] Dobson</samp>.</li>
 +
<li>Create the following files:
 +
* <samp>assets/dialogue.json</samp> containing the dialogue.
 +
* <samp>assets/marriageDialogue.json</samp> containing the marriage dialogue (if applicable).
 +
* <samp>assets/sprites.png</samp> containing their overworld sprites.
 +
* <samp>assets/portraits.png</samp> containing their portraits.
 +
* <samp>assets/schedule.json</samp> containing their schedule data.
 +
</li>
 +
<li>Edit the <samp>content.json</samp> to load the files:
 +
{{#tag:syntaxhighlight|
 +
{
 +
    "Format": "{{Content Patcher version}}",
 +
    "Changes": [
 +
        {
 +
            "Action": "Load",
 +
            "Target": "Characters/Dobson",
 +
            "FromFile": "assets/sprites.png"
 +
        },
 +
        {
 +
            "Action": "Load",
 +
            "Target": "Portraits/Dobson",
 +
            "FromFile": "assets/portraits.png"
 +
        },
 +
        {
 +
            "Action": "Load",
 +
            "Target": "Characters/Dialogue/Dobson",
 +
            "FromFile": "assets/dialogue.json"
 +
        },
 +
        {
 +
            "Action": "Load",
 +
            "Target": "Characters/Dialogue/MarriageDialogueDobson",
 +
            "FromFile": "assets/marriageDialogue.json"
 +
        },
 +
        {
 +
            "Action": "Load",
 +
            "Target": "Characters/schedules/Dobson",
 +
            "FromFile": "assets/schedule.json"
 +
        },
 +
        {
 +
            "Action": "EditData",
 +
            "Target": "Data/NPCDispositions",
 +
            "Entries": {
 +
                "Dobson": "adult/rude/neutral/positive/male/datable//Town/summer 7//BusStop 19 4/Dobson"
 +
            }
 +
        },
 +
        {
 +
            "Action": "EditData",
 +
            "Target": "Data/NPCGiftTastes",
 +
            "Entries": {
 +
                "Dobson": "You're giving this to me? This is amazing!/207 232 233 400/Thank you! This is a very interesting specimen./-5 -79 422/...What is this?/80 330/This is disgusting./2/That was very thoughtful of you./-4/ "
 +
            }
 +
        },
 +
        {
 +
            "Action": "EditData",
 +
            "Target": "Data/EngagementDialogue",
 +
            "Entries": {
 +
                "Dobson0": "I can't believe I am about to be married!$h",
 +
                "Dobson1": "I hope I don't get cold feet"
 +
            }
 +
        }
 +
    ]
 +
}
 +
|lang=json}}
 +
</li>
 +
</ol>
 +
That's it! If you load your game, the NPC should appear. If you want to create events, don't forget to add that file too.
 +
==Guidance on pixel art==
 +
If you'd like additional guidance on pixel art, See [[Modding:Index#See_also]] for some recommended guides.
 +
 
 +
[[Category:Modding]]
 +
 
 +
[[es:Modding:Datos de NPC]]
 +
[[pt:Modificações:Dados do NPC]]
 +
[[ru:Модификации:О NPC]]

Latest revision as of 19:55, 2 March 2024

Index

This page provides an overview of what's needed to create a custom NPC. This is an advanced guide for mod developers.

Before reading this page, see Modding:Editing XNB files for the basic concepts.

Files to edit

To create a new NPC, you need to edit a number of different files. However, you don't need any programming experience and it can be done with Content Patcher.

Basic info

The Data\NPCDispositions asset contains basic information for your character, including their name, birthday, relations to other characters, personality, and whether they can be dated.

The file has one row per NPC like this:

   Abigail: "teen/rude/outgoing/neutral/female/datable/Sebastian/Town/fall 13/Caroline 'mom' Pierre 'dad'/SeedShop 1 9/Abigail"

The key (before the colon) is the internal name which uniquely identifies that NPC. This name isn't shown to the player, but will be used when referencing the NPC in other files. The value contains the following fields:

index field example purpose
0 age teen Whether the NPC is a child, teen, or adult. This affects generated dialogue lines (e.g., a child would say stupid and an adult would say depressing), generic dialogue (e.g., a child would respond to dumpster diving with "Eww... What are you doing?" and a teen would say "Um... Why are you digging in the trash?"), and the gift they choose as a secret gift-giver. Children are also excluded from item delivery quests.
1 manners rude Whether the NPC is polite, rude, or neutral. This affects some generic dialogue lines.
2 social anxiety outgoing Whether the NPC is outgoing, shy, or neutral. This affects some generic dialogue lines.
3 optimism neutral Whether the NPC is positive, negative, or neutral. Unused.
4 gender female Whether the NPC is male, female, or undefined. This affects dialogue, whether children in marriage are obtained through adoption or pregnancy, and the reserved frames' positions on the spritesheet.
5 datable datable Whether the NPC is datable, not-datable, or secret. The former two toggle the romance features (e.g., 'single' label in the social menu, bouquet gifting, and marriage), while secret is used exclusively for Krobus, who cannot be married but can be made a roommate.
6 love interest Sebastian Unused.
7 home region Town Whether the NPC lives in the Desert, Town, or Other. This is used when improving friendship points for all NPCs in a given region, which is currently only used for the Luau friendship boost (which only affects NPCs in the Town region).
8 birthday fall 13 The season and day for the NPC's birthday.
9 relationships Caroline 'mom' Pierre 'dad' This affects generic dialogue for revealing likes and dislikes to family members. May also affect the inlaw_<NPC> dialogue. Can be empty if not applicable (e.g., /fall 13//SeedShop 1 9/).
10 default map & position SeedShop 1 9 The location name and tile position where the NPC starts and ends each day.
11 display name Abigail The NPC name shown to the player.

Gift tastes

The Data\NPCGiftTastes asset contains their gift preferences (e.g., which gifts they love or hate), and their responses when they receive one. See Modding:Gift taste data for more info.

The file has one row per NPC like this:

   Abigail: "I seriously love this! You're the best, @!/66 128 220 226 276 611/Hey, how'd you know I was hungry? This looks delicious!//What am I supposed to do with this?/-5 -75 -79 16 245 246/What were you thinking? This is awful!/330/You brought me a present? Thanks.// " #!String

The line can be broken down into 5 pairs of dialogue + item IDs in this order: Love, Like, Dislike, Hate, Neutral. If a dialogue field is empty, the game will use a generic dialogue text. See Modding:Items for the object IDs.

Birthday gift responses

The Strings\StringsFromCSFiles asset contains the generic responses given by NPCs to birthday gifts based on their gift preferences and manners. These shared strings can be customized for a specific NPC by editing them conditionally, such as only on the NPC's (non-shared) birthday. The following criteria are used to select from among the strings:

gift taste manners chance string english string
love, like rude 50% NPC.cs.4274 "You remembered my birthday? I'm impressed. Thanks.$h"
50% NPC.cs.4276 "Oh, is it my birthday today? I guess it is. Thanks. This is nice.$h/Oh, is it my birthday today? I guess it is. Thanks. This is nice.$h"
polite, neutral 50% NPC.cs.4275 "A birthday gift? That's very kind of you! I love it.$h"
50% NPC.cs.4277 "You remembered my birthday! Thank you. This is great.$h"
dislike, hate rude 100% NPC.cs.4278 "It's my birthday and you give me this? Is this some kind of joke?$s/It's my birthday and you give me this? Is this some kind of joke?$s"
polite, neutral 100% NPC.cs.4279 "Oh... It's for my birthday? ... Thanks.$s/Oh... It's for my birthday? ... Thanks.$s"
neutral rude 100% NPC.cs.4280 "For my birthday? Thanks."
polite, neutral 100% NPC.cs.4281 "Oh, a birthday gift! Thank you./Oh, a birthday gift! Thank you."

The $h and $s are portrait commands that select the portrait image of the character to use.

Overworld sprites

The sprite sheet for Abigail.

The overworld sprites are stored in Characters/NpcName, including movement and animation frames. Each frame is exactly 16x32 pixels. Here's an example sprite guide, courtesy of TheLimeyDragon#1993 on Discord. Some positions are reserved for certain actions:

  • the first sixteen frames are generic movement (four frames per direction);
  • frames 40–47 (female) and 44–47 (male) must be the Flower Dance dance, if they participate;
  • frames 36–38 (female) 48–50 (male) are reserved for marriageable NPCs (Contains Wedding sprite);
  • and the kissing sprite/direction varies depending on NPC:
    character kissing frame facing direction
    Abigail and Emily 33 left
    Alex 42 right
    Elliott 35 left
    Haley 28 right
    Harvey 31 left
    Leah 25 right
    Maru 28 left
    Penny 35 right
    Sam 36 right
    Sebastian 40 left
    Shane 34 left
    any other NPC 28 right

Portraits

Abigail's portrait sprite sheet.

The dialogue portraits are stored in Portraits/NpcName. Each frame is exactly 64x64 per portrait. The first six represent specific emotions (see Modding:Dialogue#Portrait commands), followed by any number of custom portraits. The first portrait is used when the dialogue doesn't specify one.

Schedule

Their schedule file tells the game where the NPC starts and moves based on on the time. You need to add strings to a separate schedules file found in the Strings folder to allow custom dialogue. See Modding:Schedule data for more info.

Dialogue and events

The NPC dialogue and events are stored in several files; see Modding:Dialogue and Modding:Event data for more info.

Festivals

Custom NPCs should be added to festivals via the Set-Up_additionalCharacters and MainEvent_additionalCharacters fields in the festival's data file. You may also want to visit Custom NPC festival tile positions to check the positions of various existing NPCs for compatibility purposes.

(Prior to Stardew Valley 1.5, TMXL was the recommended tool for adding festival spots.)

Movie theater

An NPC's taste in movies and concessions are stored in Data\MoviesReactions.xnb and Data\ConcessionTastes.xnb, respectively. See Modding:Movie theater data for details on how these function.

Spouse room

If your NPC will be a marriage candidate, note that you can add a spouse room for them much more easily after game version 1.5.5. See Modding:Migrate_to_Stardew_Valley_1.5.5#Custom_spouse_rooms for details.

Sleep animation

When the NPC goes to bed, they'll play the looping sleep animation set via <lowercase NPC name>_sleep in Data/animationDescriptions, if it exists. For example, this content pack adds a sleep animation for an NPC named 'Pufferbob':

{
    "Format": "2.0.0",
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/animationDescriptions",
            "Entries": {
                "pufferbob_sleep": "50/50/50" // note: make name lowercase
            }
        }
    ]
}

}

Adding your NPC

Here's how you'd create an example NPC we'll name Dobson:

  1. Create an empty Content Patcher content pack. By convention, we'll name the folder [CP] Dobson.
  2. Create the following files:
    • assets/dialogue.json containing the dialogue.
    • assets/marriageDialogue.json containing the marriage dialogue (if applicable).
    • assets/sprites.png containing their overworld sprites.
    • assets/portraits.png containing their portraits.
    • assets/schedule.json containing their schedule data.
  3. Edit the content.json to load the files:
    {
        "Format": "2.0.0",
        "Changes": [
            {
                "Action": "Load",
                "Target": "Characters/Dobson",
                "FromFile": "assets/sprites.png"
            },
            {
                "Action": "Load",
                "Target": "Portraits/Dobson",
                "FromFile": "assets/portraits.png"
            },
            {
                "Action": "Load",
                "Target": "Characters/Dialogue/Dobson",
                "FromFile": "assets/dialogue.json"
            },
            {
                "Action": "Load",
                "Target": "Characters/Dialogue/MarriageDialogueDobson",
                "FromFile": "assets/marriageDialogue.json"
            },
            {
                "Action": "Load",
                "Target": "Characters/schedules/Dobson",
                "FromFile": "assets/schedule.json"
            },
            {
                "Action": "EditData",
                "Target": "Data/NPCDispositions",
                "Entries": {
                    "Dobson": "adult/rude/neutral/positive/male/datable//Town/summer 7//BusStop 19 4/Dobson"
                }
            },
            {
                "Action": "EditData",
                "Target": "Data/NPCGiftTastes",
                "Entries": {
                    "Dobson": "You're giving this to me? This is amazing!/207 232 233 400/Thank you! This is a very interesting specimen./-5 -79 422/...What is this?/80 330/This is disgusting./2/That was very thoughtful of you./-4/ "
                }
            },
            {
                "Action": "EditData",
                "Target": "Data/EngagementDialogue",
                "Entries": {
                    "Dobson0": "I can't believe I am about to be married!$h",
                    "Dobson1": "I hope I don't get cold feet"
                }
            }
        ]
    }
    

That's it! If you load your game, the NPC should appear. If you want to create events, don't forget to add that file too.

Guidance on pixel art

If you'd like additional guidance on pixel art, See Modding:Index#See_also for some recommended guides.