Jump to content

Modding:Fish data: Difference between revisions

From Stardew Valley Wiki
imported>Margotbean
rm underscores
imported>BarleyZP
Restructure page and remove outdated information. Add up-to-date information about spawning fish (most of which is specified in Modding:Location data).
Line 1: Line 1:
← [[Modding:Index]]
← [[Modding:Index]]


This page explains how the game stores and parses fish data, including spawning mechanics. This is an advanced guide for mod developers.
This page explains how the game stores and parses [[fish]] data. This is an advanced guide for mod developers.


==Parsing fish spawn conditions==
==Data format==
The game checks two places to determine which fish to spawn when the player is fishing. This only applies to normal fish; the chance of spawning a legendary fish is calculated separately by the location code, ''before'' following the rules below. <small>(Reverse engineered from <samp>BobberBar</samp> and <samp>GameLocation::getFish</samp>.)</small>


===Spawn locations===
===Fish===
Each fish is assigned to an area within the location, and will only spawn if the player is within that area. The tile coordinates for each area is defined by the <samp>FishAreas</samp> field in the [[Modding:Location data#Contents|Location data]], which can be accessed in C# mods via <code>GameLocation::GetData</code>. The following areas are defined:
The fish data and spawn criteria is stored as fields in <code>Data\Fish.xnb</code>. This consists of two different formats: one for [[Crab pot|crab pot]] fish and one for fish that can be caught with the [[Tools#Fishing Poles|fishing rod]].
* [[Cindersap Forest]]:
** [[Cindersap Forest#The Pond|pond]] (area #1 for tiles <code>(0, 0)</code> through <code>(52, 42)</code> inclusively);
** [[Cindersap Forest#The River|river]] (area #0 matching any other part of the forest).
* [[Ginger Island#Island West|Ginger Island West]]
** Freshwater (area #2 for tiles <code>(36, 0)</code> through <code>(36, 80)</code> inclusively);
** Ocean (area #1 matching any other location)
* All other locations only have area -1, so where you fish from has no impact.
 
The fish that can be spawned in a given location are defined in the slash-delimited data from <code>Data\Locations.xnb</code> (see also: [[Modding:Location data]]) specifically field indexes 4 (spring), 5 (summer), 6 (fall), and 7 (winter). Each field contains any number of {{t|int fishID}} (matching <code>Data\Fish.xnb</code>) + {{t|int areaID}} (or -1 for any area) pairs. For example, [[Cindersap Forest]] has this fish data for summer: <code>153 -1 145 0 144 -1 138 0 132 0 706 0 704 0 702 0</code>. That can be parsed as:
{| class="wikitable"
|-
! value
! fish
! area
|-
| <code>153 -1</code>
| [[Green Algae]]
| any (pond or river)
|-
| <code>145 0</code>
| [[Sunfish]]
| river
|-
| <code>144 -1</code>
| [[Pike]]
| any (pond or river)
|-
| <code>138 0</code>
| [[Rainbow Trout]]
| river
|-
| <code>132 0</code>
| [[Bream]]
| river
|-
| <code>706 0</code>
| [[Shad]]
| river
|-
| <code>704 0</code>
| [[Dorado]]
| river
|-
| <code>702 0</code>
| [[Chub]]
| river
|}
 
===Fish data and spawn criteria===
The fish data and spawn criteria is stored as fields in <code>Data\Fish.xnb</code>. This consists of two different formats.


If the second field is <code>trap</code>, the fish can only be caught using a [[Crab Pot|crab pot]] and it uses this format:
If the second field is <code>trap</code>, the fish can only be caught using a [[Crab Pot|crab pot]] and it uses this format:
Line 181: Line 130:
|}
|}


===Spawn rate===
===Aquarium fish===
{{Stub|section=true|This information is based on version 1.3 of the game.  It has not been updated.}}
Every time the player casts with their fishing rod, a new spawning queue is created containing every available type of [[fish]] (including algae and seaweed) which meets the criteria based on location, season, time, and weather. The spawning queue is then shuffled so that the available types of fish are listed in a random order. A skill check with a random component is performed on each type of fish, in the order in which it is currently in the spawning queue. Success results in a bite ("''HIT!''") and failure results in the skill check being repeated with the next fish in the queue. If all fish in the queue fail the skill check, a random [[trash]] item is caught instead.
 
If a fish matches the spawning criteria, the probability that it will succeed in spawning is: ''{base spawn probability} = {spawn multiplier} - max(0, {minimum depth} - {actual depth}) × {depth multiplier} × {spawn multiplier} + {fishing level} / 50'', up to a maximum of 90%. The ''actual depth'' is the bobber's tile distance from land.
 
A fish can therefore spawn at a depth less than its ''minimum depth'', but the odds of doing so decreases for most fish.  A higher ''spawn multiplier'' and ''depth multiplier'' will result in a greater decrease in the odds of a fish spawning at a distance that is closer to shore than its ''minimum depth.''  The odds of fish spawning never increases when casting to a depth greater than 4, except for with the [[Octopus]] which reaches its maximum spawning rate at a depth of 5 or higher.
 
The relative probability that a specific type of fish (including algae and seaweed) in a location will spawn during a specific time and weather is: ''{relative spawn probability} = {base spawn probability} * POWER( ({all fish failure rate} - {this fish failure rate}) / ({number of fish} - 1}), ({fish queue position} - 1))'', where ''all fish'' and ''number of fish'' are all other fish present at the same location during the same time and weather conditions. This calculation is repeated for each possible position in the spawning order (''fish queue position'') for a type of fish, and then averaged. The total added relative spawn probability for all fish at a location at a certain time and weather will always be under 100%, with any remaining difference under 100% being the relative probability of catching [[trash]]: ''{trash probability} = 100% - {total relative spawn probability}''.
 
==Aquarium fish==
Fish in [[Fish Tank|fish tank]]s can be edited via the <samp>Data/AquariumFish</samp> asset:
Fish in [[Fish Tank|fish tank]]s can be edited via the <samp>Data/AquariumFish</samp> asset:


Line 245: Line 184:
| The pixel position of the hat on the sprite, specified as an object with <samp>X</samp> and <samp>Y</samp> values. Custom [[Modding:Fish data|fish in aquariums]] can wear [[hats]], just like vanilla [[Sea Urchin|sea urchins]].
| The pixel position of the hat on the sprite, specified as an object with <samp>X</samp> and <samp>Y</samp> values. Custom [[Modding:Fish data|fish in aquariums]] can wear [[hats]], just like vanilla [[Sea Urchin|sea urchins]].
|}
|}
==Spawning Fish==
Fish spawn data is stored in <samp>Data/Locations</samp>. Fish can be added to a location by editing the <samp>Fish</samp> field in the location's data entry. Distinct fishing areas can be defined within the same location (for example, a pond and a river within the same location that have different fish spawn chances) by editing the <samp>FishAreas</samp> field. These fishing areas can then be referenced by ID in the <samp>Fish</samp> field. See [[Modding:Location data]] for more information.


[[Category:Modding]]
[[Category:Modding]]

Revision as of 04:07, 13 June 2025

← Modding:Index

This page explains how the game stores and parses fish data. This is an advanced guide for mod developers.

Data format

Fish

The fish data and spawn criteria is stored as fields in Data\Fish.xnb. This consists of two different formats: one for crab pot fish and one for fish that can be caught with the fishing rod.

If the second field is trap, the fish can only be caught using a crab pot and it uses this format:

index syntax example content
0 <name> Lobster The fish name.
1 <type> trap Must be trap to indicate a crab pot catch.
2 <chance> .05 The percentage chance that this fish will be caught as a value between 0 and 1. Only applies if a fish listed earlier in the file isn't selected first.
3 688 .45 689 .35 690 .35 Unused.
4 <location> ocean The type of water body where the fish can be caught. The vanilla values are freshwater or ocean; mods may add their own region.
5 <min size> 2 The minimum and maximum size of the caught fish in inches for fishing stats. In non-English languages, this is converted to centimetres by multiplying by 2.54.
6 <max size> 20

Otherwise it's a fish that can be caught while fishing and uses this format:

index syntax example content
0 <name> Pufferfish The fish name.
1 <chance to dart> 80 How often the fish darts in the fishing minigame; between 15 (carp) and 100 (glacierfish).
2 <darting randomness> floater How the bobber behaves during the fishing minigame; one of mixed, smooth, floater, sinker, or dart.
3 <min size> 1 The minimum and maximum size of the caught fish in inches for fishing stats. In non-English languages, this is converted to centimetres by multiplying by 2.54.
4 <max size> 36
5 [<min time> <max time>]+ 1200 1600 The time of day when they spawn. The min time is inclusive, max time is exclusive. May specify multiple ranges.
6 [<season>]+ summer Unused; seasons are taken from Data/Locations instead.
7 <weather> sunny The weather when they spawn; one of sunny, rainy, or both.
8 <locations> 690 .4 685 .1 Unused; locations are taken from Data/Locations instead.
9 <max depth> 4 The minimum water depth to cast to for maximizing the chance of catching a type of fish; used in the spawn rate calculation (see below).
10 <spawn multiplier> .3 The spawn multiplier used in the spawn rate calculation (see below).
11 <depth multiplier> .5 The depth multiplier used in the spawn rate calculation (see below).
12 <fishing level> 0 The minimum fishing level needed for this fish to appear.
13 <first-catch tutorial eligible> true Indicates whether the fish can be selected for the first-catch tutorial.

Aquarium fish

Fish in fish tanks can be edited via the Data/AquariumFish asset:

index field purpose
0 sprite index The index of the sprite in the LooseSprites/AquariumFish spritesheet, starting at 0 for the top-left sprite. The fish sprites are 24x24px.
1 type The fish type, which influences their behavior. Possible values:
value notes
eel
cephalopod
crawl
ground
fish
front_crawl Used for crawling fish whose sprites extend past the floor. They are always closest to the glass and sort above other fish to avoid sorting issues.
2
3–5
idle animation
dart animation
The animation used by the fish when it's idling (2) or darting (3–5). This is specified as a list of space-delimited frames, where each frame is the sprite index in the LooseSprites/AquariumFish spritesheet to display. Each frame is displayed for 125ms. For example, Stingrays have their idle animation set to 70 70 70 71 71 72.

The dart animation is split into three fields: start (3), hold (4), and end (5).

6 texture The asset name for the texture containing the fish's sprite. Defaults to LooseSprites/AquariumFish.
7 hat position The pixel position of the hat on the sprite, specified as an object with X and Y values. Custom fish in aquariums can wear hats, just like vanilla sea urchins.

Spawning Fish

Fish spawn data is stored in Data/Locations. Fish can be added to a location by editing the Fish field in the location's data entry. Distinct fishing areas can be defined within the same location (for example, a pond and a river within the same location that have different fish spawn chances) by editing the FishAreas field. These fishing areas can then be referenced by ID in the Fish field. See Modding:Location data for more information.