Changes

Jump to navigation Jump to search
add info from Modding:Migrate to Stardew Valley 1.6 (main author Pathoschild, Tlitookilakin, with formatting fixes by Margotbean)
← [[Modding:Index|Index]]

This page documents how the game stores and parses data for [[Animals#Cat or Dog|pets]]. This is an advanced guide for mod developers.

==Data Format==
You can now create and customize [[Animals#Cat or Dog|pets]] & pet breeds by editing the new <samp>Data/Pets</samp> asset.

This consists of a string → model lookup, where...
* The key is a [[Modding:Common data field types#Unique string ID|unique string ID]] for the pet (not the pet breed). The vanilla IDs are <samp>Cat</samp> and <samp>Dog</samp>.
* The value is a model with the fields listed below.

===Basic info===
{| class="wikitable"
|-
! field
! effect
|-
| <samp>DisplayName</samp>
| A [[Modding:Tokenizable strings|tokenizable string]] for the pet type's display name (e.g. "cat" or "dog"). For example, the vanilla adoption events show this when Marnie asks if you want to adopt the cat/dog.
|}

===Audio & sprites===
{| class="wikitable"
|-
! field
! effect
|-
| <samp>BarkSound</samp>
| The [[#Custom audio|cue ID]] for the pet's occasional 'bark' sound.
|-
| <samp>ContentSound</samp>
| The [[#Custom audio|cue ID]] for the sound which the pet makes when you pet it.
|-
| <samp>RepeatContentSoundAfter</samp>
| ''(Optional)'' The number of milliseconds until the <samp>ContentSound</samp> is repeated once. This is used by the dog, who pants twice when pet. Defaults to -1 (disabled).
|-
| <samp>EmoteOffset</samp>
| ''(Optional)'' A pixel offset for the emote drawn above the pet sprite, specified as an object with <samp>X</samp> and <samp>Y</samp> fields. For example, this affects the heart emote shown after petting it. Default none.
|}

===Events===
{| class="wikitable"
|-
! field
! effect
|-
| <samp>EventOffset</samp>
| ''(Optional)'' The pixel offset for the pet when shown in events like Marnie's adoption event, specified as an object with <samp>X</samp> and <samp>Y</samp> fields. Default none.
|-
| <samp>AdoptionEventLocation</samp><br /><samp>AdoptionEventId</samp>
| ''(Optional)'' If both fields are set, the location and [[Modding:Event data|event ID]] which lets the player adopt this pet. This forces the event to play after 20 days if its preconditions haven't been met yet. Default <samp>Farm</samp> and none respectively.
|-
| <samp>SummitPerfectionEvent</samp>
| ''(Optional)'' How to render the pet during the summit [[perfection]] slideshow. If this isn't set, the pet won't be shown in the slideshow.

This consists of a model with these fields:

{| class="wikitable"
|-
! field
! effect
|-
| <samp>SourceRect</samp>
| The source rectangle within the pet's texture to draw.
|-
| <samp>AnimationLength</samp>
| The number of frames to show starting from the <samp>SourceRect</samp>.
|-
| <samp>Motion</samp>
| The motion to apply to the pet sprite.
|-
| <samp>Flipped</samp>
| ''(Optional)'' Whether to flip the pet sprite left-to-right. Default false.
|-
| <samp>PingPong</samp>
| ''(Optional)'' Whether to apply the 'ping pong' effect to the pet sprite animation. Default false.
|}
|}

===Gifts===
{| class="wikitable"
|-
! field
! effect
|-
| <samp>GiftChance</samp>
| ''(Optional)'' The random probability each day that the pet will give the player a gift from the <samp>Gifts</samp> list when they interact with the pet. Specified as a value between 0 (never) and 1 (always). Default .2 (20% chance).
|-
| <samp>Gifts</samp>
| ''(Optional)'' The list of gifts that this pet can give if the <samp>GiftChance</samp> is successful. Default none.

This consists of a list of models with these fields:

{| class="wikitable"
|-
! field
! effect
|-
| <samp>Id</samp>
| The [[Modding:Common data field types#Unique string ID|unique string ID]] for this entry within the list.
|-
| <samp>QualifiedItemID</samp>
| The [[Modding:Common data field types#Item ID|qualified item ID]] for the gift item to create.
|-
| <samp>Stack</samp>
| ''(Optional)'' The stack size of the gift item to produce. Default 1.
|-
| <samp>MinimumFriendshipThreshold</samp>
| ''(Optional)'' The friendship level that this pet must be at before it can give this gift. Defaults to 1000 (max friendship).
|-
| <samp>Weight</samp>
| ''(Optional)'' The option's weight when randomly choosing a gift, relative to other gifts in the list (e.g. <samp>2</samp> is twice as likely as <samp>1</samp>). Default 1.
|}
|}

===Behavior===
{| class="wikitable"
|-
! field
! effect
|-
| <samp>Id</samp>
| The [[Modding:Common data field types#Unique string ID|unique string ID]] for this entry within the list.
|-
| <samp>MoveSpeed</samp>
| ''(Optional)'' How quickly the pet can move. Default 2.
|-
| <samp>SleepOnBedChance</samp><br /><samp>SleepNearBedChance</samp><br /><samp>SleepOnRugChance</samp>
| ''(Optional)'' The percentage chances for the locations where the pet will sleep each night, as a decimal value between 0 (never) and 1 (always). Each value is checked in the order listed at left until a match is found. If none of them match, the pet will choose a random empty spot in the farmhouse; if none was found, it'll sleep next to its pet bowl outside.
|-
| <samp>Behaviors</samp>
| The pet's possible actions and behaviors, defined as the states in a state machine. Essentially the pet will be in one state at any given time, which also determines which state they can transition to next. For example, a cat can transition from <samp>Walk</samp> to <samp>BeginSitDown</samp>, but it can't skip instantly from <samp>Walk</samp> to <samp>SitDownLick</samp>.

This consists of a list of models with these fields:

<dl>
<dt>Required fields:</dt>
<dd>
{| class="wikitable"
|-
! field
! effect
|-
| <samp>Id</samp>
| A unique ID for the state. This only needs to be unique within the pet type (e.g. <samp>Cat</samp> and <samp>Dog</samp> can have different behaviors with the same ID).
|}
</dd>

<dt>Direction:</dt>
<dd>
{| class="wikitable"
|-
! field
! effect
|-
| <samp>Direction</samp>
| ''(Optional)'' The specific direction to face at the start of this state (one of <samp>left</samp>, <samp>right</samp>, <samp>up</samp>, or <samp>down</samp>), unless overridden by <samp>RandomizeDirection</samp>.
|-
| <samp>RandomizeDirection</samp>
| ''(Optional)'' Whether to point the pet in a random direction at the start of this state (overriding the <samp>Direction</samp> if specified). Default false.
|-
| <samp>IsSideBehavior</samp>
| ''(Optional)'' Whether to constrain the pet's facing direction to left and right while the state is active. Default false.
|}
</dd>

<dt>Movement:</dt>
<dd>
{| class="wikitable"
|-
! field
! effect
|-
| <samp>WalkInDirection</samp>
| ''(Optional)'' Whether to walk in the pet's facing direction. Default false.
|-
| <samp>MoveSpeed</samp>
| ''(Optional)'' Overrides the pet's <samp>MoveSpeed</samp> field while this state is active. Default -1 (which uses the pet's <samp>MoveSpeed</samp> value).
|}
</dd>

<dt>Audio:</dt>
<dd>
{| class="wikitable"
|-
! field
! effect
|-
| <samp>SoundOnStart</samp>
| ''(Optional)'' The [[#Custom audio|audio cue ID]] for the sound to play when the state starts. If set to <samp>BARK</samp>, the pet's <samp>BarkSound</samp> (or breed's <samp>BarkOverride</samp>) field is used. Defaults to none.
|-
| <samp>SoundRange</samp><br /><samp>SoundRangeFromBorder</samp>
| ''(Optional)'' When set, the <samp>SoundOnStart</samp> is only audible if the pet is within this many tiles away from the player (<samp>SoundRange</samp>) or past the border of the screen (<samp>SoundRangeFromBorder</samp>). Default -1 (no distance check).
|-
| <samp>SoundIsVoice</samp>
| ''(Optional)'' Whether to mute the <samp>SoundOnStart</samp> when the 'mute animal sounds' option is set. Default false.
|}
</dd>

<dt>Behavior transitions:</dt>
<dd>
{| class="wikitable"
|-
! field
! effect
|-
| <samp>AnimationEndBehaviorChanges</samp><br /><samp>TimeoutBehaviorChanges</samp><br /><samp>PlayerNearbyBehaviorChanges</samp><br /><samp>RandomBehaviorChanges</samp><br /><samp>JumpLandBehaviorChanges</samp>
| ''(Optional)'' A list of possible behavior transitions to start when the criteria are achieved. If multiple transitions are listed, a random one will be selected. If omitted, it won't affect behavior transitions.

These are triggered when this behavior's animation finishes (<samp>AnimationEndBehaviorChanges</samp>), when the set duration ends (<samp>TimeoutBehaviorChanges</samp>), when the player is within 2 tiles of the pet (<samp>PlayerNearbyBehaviorChanges</samp>), randomly at the start of each frame based on the <samp>RandomBehaviorChangeChance</samp> field (<samp>RandomBehaviorChanges</samp>), and when the pet finishes a jump (<samp>JumpLandBehaviorChanges</samp>).

These consist of a list of models with these fields:
{| class="wikitable"
|-
! field
! effect
|-
| <samp>Behavior</samp><br /><samp>LeftBehavior</samp><br /><samp>RightBehavior</samp><br /><samp>UpBehavior</samp><br /><samp>DownBehavior</samp>
| The ID of the behavior to start. The pet will check for a behavior field matching its current facing direction first, then try the <samp>Behavior</samp>. If none are specified, the current behavior will continue unchanged.
|-
| <samp>OutsideOnly</samp>
| ''(Optional)'' Whether the transition can only happen if the pet is outside. Default false.
|-
| <samp>Weight</samp>
| ''(Optional)'' The option's weight when randomly choosing a behavior, relative to other behaviors in the list (e.g. <samp>2</samp> is twice as likely as <samp>1</samp>). Default 1.
|}
|-
| <samp>Duration</samp><br /><samp>MinimumDuration</samp><br /><samp>MaximumDuration</samp>
| ''(Optional)'' The millisecond duration until the pet transitions to a behavior in the <samp>TimeoutBehaviorChanges</samp> field, if set. You must specify either a specific duration, or an inclusive minimum-to-maximum range in which the game will choose a random duration. If omitted, the behavior won't have a duration limit.
|-
| <samp>RandomBehaviorChangeChance</samp>
| ''(Optional)'' The random probability at the start of each frame that the pet will transition to a behavior in the <samp>RandomBehaviorChanges</samp> field, if set. Specified as a value between 0 (never) and 1 (always). Default 0.
|}
</dd>

<dt>Animation and per-frame sounds:</dt>
<dd>
{| class="wikitable"
|-
! field
! effect
|-
| <samp>Animation</samp>
| ''(Optional)'' The animation frames to play while this state is active. This consists of a list of models with these fields:
{| class="wikitable"
|-
! field
! effect
|-
| <samp>Frame</samp>
| The frame index in the animation. This should be an incremental number starting at 0.
|-
| <samp>Duration</samp>
| The millisecond duration for which the frame should be kept on-screen before continuing to the next frame.
|-
| <samp>HitGround</samp>
| ''(Optional)'' Whether to play the footstep sound for the tile under the pet when the frame starts. Default false.
|-
| <samp>Jump</samp>
| ''(Optional)'' Whether the pet should perform a small hop when the frame starts, including a 'dwop' sound. Default false.
|-
| <samp>Sound</samp>
| ''(Optional)'' The [[#Custom audio|audio cue ID]] for the sound to play when the animation starts or loops. If set to <samp>BARK</samp>, the pet's <samp>BarkSound</samp> (or breed's <samp>BarkOverride</samp>) field is used. Defaults to none.
|-
| <samp>SoundRange</samp><br /><samp>SoundRangeFromBorder</samp><br /><samp>SoundIsVoice</samp>
| See description for the equivalent behavior fields, but applies to the frame's <samp>Sound</samp> field instead.
|}
|-
| <samp>Shake</samp>
| ''(Optional)'' The millisecond duration for which to shake the pet when the state starts. Default 0.
|-
| <samp>LoopMode</samp>
| ''(Optional)'' What to do when the last animation frame is reached while the behavior is still active. The possible values are <samp>Hold</samp> (keep the last frame visible until the animation ends), <samp>Loop</samp> (restart from the first frame), or <samp>None</samp> (equivalent to <samp>Loop</samp>). Default <samp>None</samp>.
|-
| <samp>AnimationMinimumLoops</samp><br /><samp>AnimationMaximumLoops</samp>
| ''(Optional)'' The minimum and maximum number of times to play the animation. Both must be specified to have any effect. The game will choose an inclusive random value between them. Both default to -1 (don't repeat animation).
|}
</dd>
</dl>
|}

===Breeds===
{| class="wikitable"
|-
! field
! effect
|-
| <samp>Breeds</samp>
| The cosmetic breeds which can be selected in the character customization menu when creating a save. This consists of a list of models with these fields:
{| class="wikitable"
|-
! field
! effect
|-
| <samp>ID</samp>
| The unique ID for the breed within the pet type.
|-
| <samp>Texture</samp>
| The asset name for the breed spritesheet for the pet's in-game sprite. This should be 128 pixels wide, and 256 (cat) or 288 (dog) pixels high.
|-
| <samp>IconTexture</samp>
| The asset name for the breed icon texture, shown on the character customization screen and in-game menu. This should be a 16x16 pixel icon.
|-
| <samp>IconSourceRect</samp>
| The icon's pixel area within the <samp>IconTexture</samp>, specified as an object with <samp>X</samp>, <samp>Y</samp>, <samp>Width</samp>, and <samp>Height</samp> fields.
|-
| <samp>BarkOverride</samp>
| ''(Optional)'' Override the pet's <samp>BarkSound</samp> field for this breed, if set.
|-
| <samp>VoicePitch</samp>
| ''(Optional)'' The [[wikipedia:Pitch (music)|pitch]] applied to the pet's bark sound, measured as a decimal value relative to 1. Defaults to 1.
|}
|}

===Advanced===
{| class="wikitable"
|-
! field
! effect
|-
| <samp>CustomFields</samp>
| The [[#Custom data fields|custom fields]] for this entry.
|}


[[Category:Modding]]
138

edits

Navigation menu