Modding:Fish data

From Stardew Valley Wiki
Jump to: navigation, search

Modding:Index

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

Parsing fish spawn conditions

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. (Reverse engineered from BobberBar and GameLocation::getFish.)

Spawn locations

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 GameLocation::getFishingLocation, which can be overridden for each game location. The following areas are defined:

  • Cindersap Forest:
    • pond (area #1 for tiles (0, 0) through (52, 42) inclusively);
    • river (area #0 matching any other part of the forest).
  • 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 Data\Locations.xnb, specifically field indexes 4 (spring), 5 (summer), 6 (fall), and 7 (winter). Each field contains any number of <int fishID> (matching Data\Fish.xnb) + <int areaID> (or -1 for any area) pairs. For example, Cindersap Forest has this fish data for summer: 153 -1 145 0 144 -1 138 0 132 0 706 0 704 0 702 0. That can be parsed as:

value fish area
153 -1 Green Algae any (pond or river)
145 0 Sunfish river
144 -1 Pike any (pond or river)
138 0 Rainbow Trout river
132 0 Bream river
706 0 Shad river
704 0 Dorado river
702 0 Chub river

Fish data and spawn criteria

The fish data and spawn criteria is stored as thirteen slash-delimited fields in Data\Fish.xnb:

index syntax example content
0 name Pufferfish The fish name.
1 number 80 How often the fish darts in the fishing minigame; between 15 (carp) and 100 (glacierfish).
2 "mixed|dart|smooth|floater|sinker" floater How the bobber behaves during the fishing minigame.
3 int 1 The minimum fish size (in inches).
4 int 36 The maximum fish size (in inches).
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 ["spring|summer|fall|winter"]+ season ID The seasons when they spawn. May specify multiple. (This is ignored. Seasons are taken from Locations.xnb instead)
7 "sunny|rainy|both" sunny The weather when they spawn.
8 690 .4 685 .1 Unused.
9 number 4 Minimum depth; used in spawn rate calculation (see below). The minimum water depth to cast to for maximizing the chance of catching a type of fish.
10 number .3 Spawn multiplier; used in spawn rate calculation (see below).
11 number .5 Depth multiplier; used in spawn rate calculation (see below).
12 level 0 The minimum fishing level.

Note that as of v1.2, the game multiplies fish size by 2.54 for all languages other than English (for conversion from inches to cm). See FishingRod::draw.

Spawn rate

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}.