Difference between revisions of "Modding:Schedule data"

From Stardew Valley Wiki
Jump to navigation Jump to search
m (→‎Initial commands: correction)
(→‎Schedule points: expand, rewrite incorrect information)
Line 131: Line 131:
  
 
===Schedule points===
 
===Schedule points===
<source lang="yaml">
+
The rest of the schedule script consists of slash-delimited entries, each containing space-separated fields which specify a start time, destination, and what to do when the NPC reaches it:
<time> <map> <coord x y> <position> <animation> <Strings>
+
: <tt>{{t|time}} {{o|location}} {{t|tileX}} {{t|tileY}} {{o|facingDirection}} {{o|animation}} {{o|dialogue}}</tt>
</source>
 
  
* {{t|time}} is the time at which the schedule event begins, in military time (24 hour format, no colon)
+
If the <tt>location</tt> field is omitted, the rest of the fields are parsed as normal. The other optional fields must be in sequential order (e.g. you can skip <tt>dialogue</tt>, but you can't skip <tt>animation</tt> and then specify <tt>dialogue</tt>).
* {{o|map}} is the map on which the target location is
 
* {{o|coord x y}} is the x and y coordinates of the target location, without a comma
 
* {{o|position}} The direction the NPC actor shall face once reaching the target location.
 
* {{o|animation}} (optional): is the animation the NPC actor will execute at reaching the target location.
 
* {{o|Strings}} (optional): This is managed from strings/schedule/<NPC Name>. A specific format must be followed!
 
  
At {{t|time}} the NPC begins to travel to the target location. Once there, {{o|animation}} is executed until the next schedule event begins. There is possibly no limit to how many schedule events one schedule entry may contain.
+
{| class="wikitable"
 +
|-
 +
! field
 +
! description
 +
|-
 +
| <tt>time</tt>
 +
| The time at which the schedule event begins, in military time (24 hour format, no colon).
 +
|-
 +
| <tt>location</tt>
 +
| <p>''(optional)'' The location name the NPC should walk towards. If omitted, defaults to the [[Bus Stop|bus stop]] (if married to a player) or their default location.</p><p>'''Note:''' the game has special logic for unlockable locations. If this is JojaMart/Railroad and it's not available yet, the game gets the replacement destination from the first entry in the <tt>{{t|location}}_Replacement</tt> schedule if available; otherwise it switches to the <tt>default</tt> schedule if available, else <tt>spring</tt>. If this is CommunityCenter and it's not available yet, the game switches to the <tt>default</tt> schedule if available, else <tt>spring</tt>.</p>
 +
|-
 +
| <tt>tileX</tt><br /><tt>tileY</tt>
 +
| The X and Y [[Modding:Modder Guide/Game Fundamentals#Tiles|tile coordinates]] the NPC should walk towards.
 +
|-
 +
| <tt>facingDirection</tt>
 +
| ''(optional)'' The direction to face after reaching the destination. Defaults to down.
 +
|-
 +
| <tt>animation</tt>
 +
| ''(optional)'' The animation to play when the NPC reaches the destination.
 +
|-
 +
| <tt>dialogue</tt>
 +
| <p>''(optional)'' The dialogue the NPC should use when they reach their destination. This must be an [[Modding:Modder Guide/APIs/Content|asset name]] and entry key in this exact format (including quotes): <tt>"assetName:key"</tt>. Any slashes in the asset name should be double backslashes (<tt>\\</tt>).</p><p>For example, <tt>\"Strings\\schedules\\Abigail:Sun.000\"</tt> means "open the file at <tt>Strings\schedules\Abigail.xnb</tt> and get the text of the <tt>Sun.000</tt> key".
 +
|}
  
Strings format: {{o|\"Strings\\schedule\\NPC:schedule.000\"}} Where NPC is the chosen NPC file you are accessing in Strings/schedule.  'schedule' depends on the schedule itself.
+
For example, consider this schedule entry in Abigail's schedule:
 +
<pre>1300 Town 47 87 0 "Strings\\schedules\\Abigail:marriage_Mon.001"</pre>
  
If you are using "spring" then you must put spring.000, ect. Depending on how many times you have the schedule manage dialogue.
+
At 13:00 (1pm), Abigail will begin walking to tile (47, 87) in the Town location. When she reaches it, she'll face direction 0 (up) and say "''Hey, @. I like to relax here... it's so peaceful.''"
 
 
(If you have three "spring" scheduled dialogues.. each must be spring.000, spring.001, and spring.002).
 
 
 
Full Example Coding: {{o|1030 SeedShop 20 5 1 \"Strings\\schedules\\Abigail:Sun.000\"}}
 
 
 
This means in Abigail's {{t|Sun}} schedule, she will go to her mother's room at 1030 and access {{o|Sun.000}} which reads {{t|"Sun.000": "We're hiding in here so we don't have to talk to anyone.",}}
 
  
 
==Potential issues==
 
==Potential issues==

Revision as of 02:48, 11 March 2020

Index

Axe.png
Article Stub

This article is a stub and is missing information. You can help Stardew Valley Wiki by expanding it!

This page is a collection of notes and hypotheses about how the game stores schedule data for NPCs. Schedule data determines the times and locations where the relevant NPC actor is, moves to, and the animations it displays meanwhile.

Raw data

Schedule data is stored in Content/Characters/schedules/*.xnb files (one per character), which can be unpacked for editing. Here's the raw data for Abigail as of 1.3.36 for reference:

Data 
{
  "rain": "900 SeedShop 9 5 0/1100 SeedShop 13 20 0/1300 SeedShop 39 5 0/1500 SeedShop 7 9 2/1900 SeedShop 6 4 0/2200 SeedShop 1 9 3 abigail_sleep",
  "rain2": "900 SeedShop 34 5 0/1100 SeedShop 9 17 3/1400 Saloon 42 17 2 abigail_sit_down/2000 SeedShop 1 9 3 abigail_sleep",
  "winter_15": "900 SeedShop 39 5 0/1030 ScienceHouse 5 19 1/1430 Beach 30 34 2 \"Strings\\schedules\\Abigail:winter_15.000\"/2400 SeedShop 1 9 3 abigail_sleep",
  "marriage_Mon": "830 SeedShop 6 19 0 \"Strings\\schedules\\Abigail:marriage_Mon.000\"/1300 Town 47 87 0 \"Strings\\schedules\\Abigail:marriage_Mon.001\"/1700 Saloon 33 18 0 \"Strings\\schedules\\Abigail:marriage_Mon.002\"/2030 BusStop -1 23 3",
  "marriage_Fri": "800 SeedShop 36 9 0 \"Strings\\schedules\\Abigail:marriage_Fri.000\"/1100 Mountain 49 31 2 abigail_flute/1500 Saloon 42 17 2 abigail_sit_down \"Strings\\schedules\\Abigail:marriage_Fri.001\"/2030 BusStop -1 23 3",
  "fall_Mon": "900 SeedShop 10 5 0/1100 Beach 13 39 2/1800 SeedShop 1 9 3 abigail_sleep",
  "6": "900 SeedShop 39 5 0/1030 SeedShop 2 20 3/1500 Mountain 46 23 2 abigail_flute/2000 SeedShop 1 9 3 abigail_sleep",
  "16": "GOTO 6",
  "spring_4": "900 SeedShop 11 5 0 \"Strings\\schedules\\Abigail:spring_4.000\"/1230 Hospital 13 14 0 \"Strings\\schedules\\Abigail:spring_4.001\"/1330 Hospital 4 6 1 \"Strings\\schedules\\Abigail:spring_4.002\"/1600 SeedShop 10 5 0/2000 SeedShop 1 9 3 abigail_sleep",
  "Sun": "900 SeedShop 4 5 0/1030 SeedShop 20 5 1 \"Strings\\schedules\\Abigail:Sun.000\"/1300 Forest 14 40 2/2000 SeedShop 1 9 3 abigail_sleep",
  "11_6": "GOTO spring",
  "25_6": "GOTO spring",
  "11": "NOT friendship Sebastian 6/1000 SebastianRoom 5 4 2 abigail_sit_down/1700 SeedShop 1 9 3 abigail_sleep",
  "25": "NOT friendship Sebastian 6/GOTO 11",
  "Wed": "1000 ArchaeologyHouse 11 9 0/1800 Town 47 87 0/2200 SeedShop 1 9 3 abigail_sleep",
  "Fri": "900 SeedShop 34 5 0/1100 SeedShop 9 17 3/1500 Saloon 42 17 2 abigail_sit_down/2100 SeedShop 1 9 3 abigail_sleep",
  "fall": "900 SeedShop 39 5 0/1030 SeedShop 2 20 3/1300 BusStop 22 5 2/1700 SeedShop 3 6 0 abigail_videogames/1930 SeedShop 1 9 3 abigail_sleep",
  "winter": "900 SeedShop 39 5 0/1030 ScienceHouse 5 19 1/1430 SeedShop 3 6 0 abigail_videogames/1930 SeedShop 1 9 3 abigail_sleep",
  "summer": "900 SeedShop 39 5 0/1030 Railroad 30 45 0/1400 Mountain 49 31 1/1740 SeedShop 3 6 0 abigail_videogames/1930 SeedShop 1 9 3 abigail_sleep",
  "spring": "900 SeedShop 39 5 0/1030 SeedShop 2 20 3/1300 Town 73 54 2/1630 SeedShop 3 6 0 abigail_videogames/1930 SeedShop 1 9 3 abigail_sleep"
}

Schedule key

Each schedule has a key which is used to decide when it applies. The key must be one of the exact formats below (it's not dynamic). If multiple schedules apply, the first match in the order listed here is used.

Notes:

  • Most text is case-sensitive (e.g. Mon is not the same as mon).
  • The game's logic for schedule keys is in NPC::getSchedule.

Marriage schedules

These apply if the NPC is married to a player (not necessarily the main player). Married NPCs don't use any other schedule keys. If the marriage keys don't match, they won't have a schedule for that day.

syntax summary
marriageJob Used by Harvey on Tuesday/Thursday, Maru on Tuesday/Thursday, Penny on Tuesday/Wednesday/Friday.
marriage_<day of week> Applies on the given day of week when not raining.
Example: marriage_Mon

Normal schedules

These schedules apply to any non-marriage NPC. If none of these keys match, they won't have a schedule for that day.

syntax summary
<season>_<day of month> Applies on the given date.
Example: spring_15
<day of month>_<hearts> Applies on the given day of month if any player has at least that many hearts with the NPC. If multiple schedules apply, the one with the highest heart number is used.
Example: 11_6
<day of month> Applies on the given day of month.
Example: 16
bus For Pam only, applies if the bus is repaired.
rain2 50% chance of applying on rainy days.
rain Applies on rainy days.
<season>_<day of week>_<hearts> Applies in the given season and day of week, if any player has at least that many hearts with the NPC. If multiple schedules apply, the one with the highest heart number is used.
Example: spring_Mon_6
<season>_<day of week> Applies in the given season and day of week.
Example: spring_Mon
<day of week> Applies in the given day of week.
Example: Mon
<season> Applies in the given season.
Example: spring
spring_<day of week> Applies (in any season) on the given day of week.
Example: spring_Mon
<season>_spring_<hearts> Applies in the given season, if any player has at least that many hearts with the NPC. If multiple schedules apply, the one with the highest heart number is used.
Example: spring_Mon_6
spring Always applies.

Schedule script

Each schedule entry value has an arbitrary number of slash-delimited schedule commands matching one of the formats below.

Initial commands

A script may have one initial command as the first field in the script, before the first / character. The GOTO command can also appear in the next two fields after MAIL, or the next field after NOT.

command description
GOTO <key> (Note: this line only applies if GOTO is the first command. If it's not, see GOTO below.)
End the current script and load the schedule with the given key instead. If the key is "season", the current season name is used instead. If the schedule doesn't exist or can't be parsed, the spring schedule will be used instead.
Example: GOTO spring
NOT friendship <npc name> <hearts> End the current script if any player does have at least that many hearts with any of the named NPCs (can list multiple). If the script is ended, the spring schedule is used instead.
Example: NOT friendship Sebastian 6 Abigail 3 (script ends if any player has 6+ hearts with Sebastian and/or 3+ hearts with Abigail).
NOT Does nothing if the next word is not friendship.
MAIL <letter ID> Runs the next command if the player did not receive the given letter ID or world state ID (see HasFlag in the Content Patcher documentation). May
Example: MAIL ccVault/GOTO spring/GOTO summer (runs GOTO spring if the bus is repaired, or GOTO summer if it isn't; not limited to GOTO commands).
GOTO <key> (Note: this line only applies if GOTO is after NOT or MAIL. If it's not, see GOTO above.)
End the current script and load the schedule with the given key instead. If the key is "season", the current season name is used instead. If the key is "NO_SCHEDULE", the NPC has no schedule for the day. If the schedule doesn't exist or can't be parsed, the game crashes (or shows an error if playing with SMAPI).
Example: GOTO NO_SCHEDULE

Schedule points

The rest of the schedule script consists of slash-delimited entries, each containing space-separated fields which specify a start time, destination, and what to do when the NPC reaches it:

<time> [location] <tileX> <tileY> [facingDirection] [animation] [dialogue]

If the location field is omitted, the rest of the fields are parsed as normal. The other optional fields must be in sequential order (e.g. you can skip dialogue, but you can't skip animation and then specify dialogue).

field description
time The time at which the schedule event begins, in military time (24 hour format, no colon).
location

(optional) The location name the NPC should walk towards. If omitted, defaults to the bus stop (if married to a player) or their default location.

Note: the game has special logic for unlockable locations. If this is JojaMart/Railroad and it's not available yet, the game gets the replacement destination from the first entry in the <location>_Replacement schedule if available; otherwise it switches to the default schedule if available, else spring. If this is CommunityCenter and it's not available yet, the game switches to the default schedule if available, else spring.

tileX
tileY
The X and Y tile coordinates the NPC should walk towards.
facingDirection (optional) The direction to face after reaching the destination. Defaults to down.
animation (optional) The animation to play when the NPC reaches the destination.
dialogue

(optional) The dialogue the NPC should use when they reach their destination. This must be an asset name and entry key in this exact format (including quotes): "assetName:key". Any slashes in the asset name should be double backslashes (\\).

For example, \"Strings\\schedules\\Abigail:Sun.000\" means "open the file at Strings\schedules\Abigail.xnb and get the text of the Sun.000 key".

For example, consider this schedule entry in Abigail's schedule:

1300 Town 47 87 0 "Strings\\schedules\\Abigail:marriage_Mon.001"

At 13:00 (1pm), Abigail will begin walking to tile (47, 87) in the Town location. When she reaches it, she'll face direction 0 (up) and say "Hey, @. I like to relax here... it's so peaceful."

Potential issues

  • Using a time of 600 (when the day starts) for an event may not work. Try using 610 if you want an event early in the morning and the NPC doesn't move if you use 600.