Изменения

Перейти к навигации Перейти к поиску
Новая страница: «← Индекс {{Переведите}} This page provides an overview of what's needed to create a custom NPC. This is...»
← [[Модификации:Индекс|Индекс]]
{{Переведите}}
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 {{nexus mod|1915|Content Patcher}}.

===Basic info===
The <tt>Data\NPCDispositions</tt> 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:
<syntaxhighlight lang="yaml">
Abigail: "teen/rude/outgoing/neutral/female/datable/Sebastian/Town/fall 13/Caroline 'mom' Pierre 'dad'/SeedShop 1 9/Abigail"
</syntaxhighlight>

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:

{| class="wikitable"
|-
! index
! field
! example
! purpose
|-
| 0
| age
| <tt>teen</tt>
| Whether the NPC is a <tt>child</tt>, <tt>teen</tt>, or <tt>adult</tt>. 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
| <tt>rude</tt>
| Whether the NPC is <tt>polite</tt>, <tt>rude</tt>, or <tt>neutral</tt>. This affects some generic dialogue lines.
|-
| 2
| social anxiety
| <tt>outgoing</tt>
| Whether the NPC is <tt>outgoing</tt>, <tt>shy</tt>, or <tt>neutral</tt>. This affects some generic dialogue lines.
|-
| 3
| optimism
| <tt>neutral</tt>
| Whether the NPC is <tt>positive</tt>, <tt>negative</tt>, or <tt>neutral</tt>. ''Unused.''
|-
| 4
| gender
| <tt>female</tt>
| Whether the NPC is <tt>male</tt>, <tt>female</tt>, or <tt>undefined</tt>. This affects dialogue, whether children in marriage are obtained through adoption or pregnancy, and the reserved frames' positions on the spritesheet.
|-
| 5
| datable
| <tt>datable</tt>
| Whether the NPC is <tt>datable</tt> or <tt>not-datable</tt>. This toggles the romance features (e.g. 'single' label in the social menu, bouquet gifting, and marriage).
|-
| 6
| love interest
| <tt>Sebastian</tt>
| ''Unused.''
|-
| 7
| home region
| <tt>Town</tt>
| Whether the NPC lives in the <tt>Desert</tt>, <tt>Town</tt>, or <tt>Other</tt>. 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 <tt>Town</tt> region).
|-
| 8
| birthday
| <tt>fall 13</tt>
| The season and day for the NPC's birthday.
|-
| 9
| relationships
| <tt>Caroline 'mom' Pierre 'dad'</tt>
| 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
| <tt>SeedShop 1 9</tt>
| The location name and [[Modding:Modder Guide/Game Fundamentals#Tiles|tile position]] where the NPC starts and ends each day.
|-
| 11
| display name
| <tt>Abigail</tt>
| The NPC name shown to the player.
|}

===Gift tastes===
The <tt>Data\NPCGiftTastes</tt> 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:
<syntaxhighlight lang="yaml">
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
</syntaxhighlight>

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

====Birthday gift responses====
The <tt>Strings\StringsFromCSFiles</tt> 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:

{| class="wikitable"
|-
! gift taste
! manners
! chance
! string
|-
| rowspan="4" | love, like
| rowspan="2" | rude
| 50%
| <tt>NPC.cs.4274</tt>
|-
| 50%
| <tt>NPC.cs.4276</tt>
|-
| rowspan="2" | polite, neutral
| 50%
| <tt>NPC.cs.4275</tt>
|-
| 50%
| <tt>NPC.cs.4277</tt>
|-
| rowspan="2" | dislike, hate
| rude
| 100%
| <tt>NPC.cs.4278</tt>
|-
| polite, neutral
| 100%
| <tt>NPC.cs.4279</tt>
|-
| rowspan="2" | neutral
| rude
| 100%
| <tt>NPC.cs.4280</tt>
|-
| polite, neutral
| 100%
| <tt>NPC.cs.4281</tt>
|}

===Overworld sprites===
The overworld sprites are stored in <tt>Characters/NpcName</tt>, 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===
The dialogue portraits are stored in <tt>Portraits/NpcName</tt>. 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.

Here's an [https://cdn.discordapp.com/attachments/156109690059751424/729820558966915122/unknown.png example portrait guide], courtesy of TheLimeyDragon#1993 on Discord.

===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===
Festivals are tricky things. Everyone in the vanilla game is added to the festival map by placing tiles on the Set-Up and MainEvent map layers from a character tilesheet that draws from NPCDispositions to get exactly who to place. This is not ideal for custom NPCs, since you have no way of knowing where on the NPCDispositions data list your NPC goes when a player is using multiple custom NPCs. For this reason, it is recommended to use {{nexus mod|1820|TMXLoader}}, as it has a festival addition function to add your character to the Festival Maps, since it will draw upon your character's internal name instead of their position on the list. It's fairly easy to do, and there's an explanation on the {{nexus mod|1820|TMXLoader}} Nexus Description.

For adding them to festivals in 1.5 using Content Patcher, see [[Modding:Migrate to Stardew Valley 1.5#Festival changes]].

==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 <tt>[CP] Dobson</tt>.</li>
<li>Create the following files:
* <tt>assets/dialogue.json</tt> containing the dialogue.
* <tt>assets/marriageDialogue.json</tt> containing the marriage dialogue (if applicable).
* <tt>assets/sprites.png</tt> containing their overworld sprites.
* <tt>assets/portraits.png</tt> containing their portraits.
* <tt>assets/schedule.json</tt> containing their schedule data.
</li>
<li>Edit the <tt>content.json</tt> 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]]

[[pt:Modificações:Dados do NPC]]
602

правки

Навигация