Jump to content

Modding:Fish data: Difference between revisions

From Stardew Valley Wiki
imported>Falseroku
m →Aquarium fish: Add texture index
imported>BarleyZP
 
(13 intermediate revisions by 4 users not shown)
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 <code>GameLocation::getFishingLocation</code>, which can be overridden for each game location. The following areas are defined:
You can edit fish data by editing the <samp>Data/Fish</samp> data asset.  
* [[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:
This consists of a string → string lookup, where...
{| class="wikitable"
* The key is a [[Modding:Common data field types#Unique string ID|unique string ID]] for the fish.
|-
* The value is a slash-deliminated string with the fields listed below:
! 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 value 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]].
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 value of the field at index 1 is <code>trap</code>, the fish can only be caught using a [[Crab Pot|crab pot]], and it uses this format:
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 138: Line 93:
| [{{t|min time}} {{t|max time}}]+
| [{{t|min time}} {{t|max time}}]+
| <code>1200 1600</code>
| <code>1200 1600</code>
| The time of day when they spawn. The min time is inclusive, max time is exclusive. May specify multiple ranges.
| The time of day when the fish can spawn. The min time is inclusive, max time is exclusive. May specify multiple ranges.
|-
|-
| 6
| 6
Line 148: Line 103:
| {{t|weather}}
| {{t|weather}}
| <code>sunny</code>
| <code>sunny</code>
| The weather when they spawn; one of <code>sunny</code>, <code>rainy</code>, or  <code>both</code>.
| The weather when the fish can spawn; one of <code>sunny</code>, <code>rainy</code>, or  <code>both</code>.
|-
|-
| 8
| 8
Line 158: Line 113:
| {{t|max depth}}
| {{t|max depth}}
| <code>4</code>
| <code>4</code>
| 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).
| The minimum number of tiles from land that the player must cast their rod such that the chance for catching this fish is not decreased. If the player casts closer to land than this minimum, they will accrue a penalty of <samp>(depth multiplier * chance)</samp> percentage points for each tile below this minimum.<ref name="checkreqs">See <samp>GameLocation::CheckGenericFishRequirements</samp> in the game code</ref>
|-
|-
| 10
| 10
| {{t|spawn multiplier}}
| {{t|chance}}
| <code>.3</code>
| <code>.3</code>
| The spawn multiplier used in the spawn rate calculation (see below).
| The base chance for catching this fish once it has already been determined as one of the possible fish to catch at a tile. After applying buffs from [[Skills|fishing level]] and the [[Training Rod]], this value is clamped to <samp>0.9</samp> before applying other buffs such as from the [[Curiosity Lure]] and [[Targeted Bait]].<ref name="checkreqs" />
|-
|-
| 11
| 11
| {{t|depth multiplier}}
| {{t|depth multiplier}}
| <code>.5</code>
| <code>.5</code>
| The depth multiplier used in the spawn rate calculation (see below).
| A multiplier used when penalizing the player for not casting their rod at least <samp>max depth</samp> tiles from land.<ref name="checkreqs" />
|-
|-
| 12
| 12
Line 181: Line 136:
|}
|}


===Spawn rate===
===Aquarium fish===
{{Stub|section=true|This information is based on version 1.3 of the game.  It has not been updated.}}
Fish in [[Fish Tank|fish tank]]s can be edited via the <samp>Data/AquariumFish</samp> asset.
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==
This consists of a string → string lookup, where...
Fish in [[Fish Tank|fish tank]]s can be edited via the <samp>Data/AquariumFish</samp> asset:
* The key is a [[Modding:Common data field types#Unique string ID|unique string ID]] for the aquarium fish, which must match the non-qualified item ID of the item being deposited into the tank.
* The value is a slash-deliminated string with the fields listed below:  


{| class="wikitable"
{| class="wikitable"
Line 202: Line 151:
| 0
| 0
| sprite index
| sprite index
| The index of the sprite in the <samp>LooseSprites/AquariumFish</samp> spritesheet, starting at 0 for the top-left sprite.
| The index of the sprite in the <samp>LooseSprites/AquariumFish</samp> spritesheet, starting at 0 for the top-left sprite. The fish sprites are 24x24px.
|-
|-
| 1
| 1
Line 213: Line 162:
|-
|-
| <samp>eel</samp>
| <samp>eel</samp>
|
| These fish have a clamped minimum velocity greater than 0, regardless of their behavior in <samp>Data/Fish</samp>.
|-
|-
| <samp>cephalopod</samp></samp>
| <samp>cephalopod</samp></samp>
|
| These fish have no minimum velocity. They favor moving downward in the tank rather than upward.
|-
|-
| <samp>crawl</samp>
| <samp>crawl</samp>
|
| These fish always stay at the bottom of the tank. They move horizontally along the tank bottom. These fish have no minimum velocity.
|-
|-
| <samp>ground</samp>
| <samp>ground</samp>
|
| These fish always stay near the bottom of the tank. They are closer to the glass than all other fish types. They move horizontally and vertically, but favor moving downward towards the tank bottom. These fish have no minimum velocity.
|-
|-
| <samp>fish</samp>
| <samp>fish</samp>
Line 228: Line 177:
|-
|-
| <samp>front_crawl</samp>
| <samp>front_crawl</samp>
| 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.
| Used for crawling fish whose sprites extend past the floor. They are closer to the glass than all other fish (besides <samp>ground</samp> fish). Otherwise, it has identical behavior to <samp>crawl</samp>.
|-
| <samp>static</samp>
| These fish always stay at the bottom of the tank. They do not move within the tank.
|-
| <samp>float</samp>
|
|}
|}
|-
|-
Line 243: Line 198:
| 7
| 7
| hat position
| hat position
| 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 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.
==References==
<references />


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


[[de:Modding:Fisch Daten]]
[[es:Modding:Datos de pescado]]
[[pt:Modificações:Dados de Peixes]]
[[pt:Modificações:Dados de Peixes]]
[[ru:Модификации:Рыболовство]]
[[ru:Модификации:Рыболовство]]
[[zh:模组:鱼类数据]]
[[zh:模组:鱼类数据]]

Latest revision as of 03:09, 16 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

You can edit fish data by editing the Data/Fish data asset.

This consists of a string → string lookup, where...

  • The key is a unique string ID for the fish.
  • The value is a slash-deliminated string with the fields listed below:

The value consists of two different formats: one for crab pot fish and one for fish that can be caught with the fishing rod.

If the value of the field at index 1 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 the fish can 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 the fish can 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 number of tiles from land that the player must cast their rod such that the chance for catching this fish is not decreased. If the player casts closer to land than this minimum, they will accrue a penalty of (depth multiplier * chance) percentage points for each tile below this minimum.[1]
10 <chance> .3 The base chance for catching this fish once it has already been determined as one of the possible fish to catch at a tile. After applying buffs from fishing level and the Training Rod, this value is clamped to 0.9 before applying other buffs such as from the Curiosity Lure and Targeted Bait.[1]
11 <depth multiplier> .5 A multiplier used when penalizing the player for not casting their rod at least max depth tiles from land.[1]
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.

This consists of a string → string lookup, where...

  • The key is a unique string ID for the aquarium fish, which must match the non-qualified item ID of the item being deposited into the tank.
  • The value is a slash-deliminated string with the fields listed below:
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 These fish have a clamped minimum velocity greater than 0, regardless of their behavior in Data/Fish.
cephalopod These fish have no minimum velocity. They favor moving downward in the tank rather than upward.
crawl These fish always stay at the bottom of the tank. They move horizontally along the tank bottom. These fish have no minimum velocity.
ground These fish always stay near the bottom of the tank. They are closer to the glass than all other fish types. They move horizontally and vertically, but favor moving downward towards the tank bottom. These fish have no minimum velocity.
fish
front_crawl Used for crawling fish whose sprites extend past the floor. They are closer to the glass than all other fish (besides ground fish). Otherwise, it has identical behavior to crawl.
static These fish always stay at the bottom of the tank. They do not move within the tank.
float
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.

References

  1. ↑ 1.0 1.1 1.2 See GameLocation::CheckGenericFishRequirements in the game code