Difference between revisions of "Modding:Fish data"

From Stardew Valley Wiki
Jump to navigation Jump to search
(Added a variable name for the results of the basic spawn rate formula, to make it clear that it is the same one being used in the formula for relative probability & changed my formula formatting to match the pre-existing formula)
Line 130: Line 130:
  
 
===Spawn rate===
 
===Spawn rate===
If a fish matches the spawn criteria, the probability that it will spawn is ''{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.
+
If a fish matches the spawn criteria, the probability that it will spawn 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 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'' 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.
 
A fish can 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'' 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 is ''base_spawn_probability * POWER( (all_fish_failure_rate - this_fish_failure_rate)/(number_of_fish - 1), (fish_queue_position - 1))''. 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 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 = 100% - total_relative_probability''.
+
The relative probability that a specific type of fish (including algae and seaweed) in a location will spawn is: ''relative_probability = {base spawn probability} * POWER( ({all fish failure rate} - {this fish failure rate}) / ({number of fish} - 1}), ({fish queue position} - 1))''. 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 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} = 100% - {total relative probability}''.
 
[[Category:Modding]]
 
[[Category:Modding]]
  
 
[[pt:Modificações:Dados de Peixes]]
 
[[pt:Modificações:Dados de Peixes]]

Revision as of 14:58, 30 October 2019

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

If a fish matches the spawn criteria, the probability that it will spawn 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 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 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 is: relative_probability = {base spawn probability} * POWER( ({all fish failure rate} - {this fish failure rate}) / ({number of fish} - 1}), ({fish queue position} - 1)). 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 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} = 100% - {total relative probability}.