Changes

Line 58: Line 58:     
==Format==
 
==Format==
 +
[[Modding:Crop data|Crops]] are still stored in <samp>Data/Crops</samp>, but that asset has been overhauled in Stardew Valley 1.6. The slash-delimited entries are now models to simplify edits and enable new features.
 +
 +
This consists of a string → model lookup, where...
 +
* The key is the unqualified [[#Custom items|item ID]] for the seed item.
 +
* The value is model with the fields listed below.
 +
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Index
+
! field
! Field
+
! effect
! colspan="2"|Example Value
   
|-
 
|-
| Key
+
!colspan="2"| Growth
| Seed Index <small>(from [[Modding:Items|ObjectInformation.xnb]])</small>
  −
| 473 <small>''(Bean Starter)''</small>
  −
| 455 <small>''(Spangle Seeds)''</small>
   
|-
 
|-
| 0
+
| <samp>Seasons</samp>
| Days in each stage of growth
+
| The seasons in which this crop can grow (any combination of <samp>spring</samp>, <samp>summer</samp>, <samp>fall</samp>, and <samp>winter</samp>).
| 1 1 1 3 4
  −
| 1 2 3 2
   
|-
 
|-
| 1
+
| <samp>DaysInPhase</samp>
| Growth Season(s)
+
| The number of days in each visual step of growth before the crop is harvestable. Each step corresponds to a sprite in the crop's row (see <samp>SpriteIndex</samp>).
| spring
+
 
| summer
+
For example, a crop with <code>"DaysInPhase": [ 1, 1, 1, 1 ]</code> will grow from seed to harvestable in 4 days, moving to the next sprite in the row each day.
 
|-
 
|-
| 2
+
| <samp>RegrowDays</samp>
| Index in Sprite Sheet <small>(<samp>Content\TileSheets\Crops.xnb</samp>)</small>
+
| ''(Optional)'' The number of days before the crop regrows after harvesting, or -1 if it can't regrow. The crop will keep the full-grown sprite (i.e. the last phase in <samp>DaysInPhase</samp>) during this time. Default -1.
| 1
  −
| 29
   
|-
 
|-
| 3
+
| <samp>IsRaised</samp>
| Index of Harvest <small>(from [[Modding:Items|ObjectInformation.xnb]])</small>
+
| ''(Optional)'' Whether this is a raised crop on a trellis that can't be walked through. Default false.
| 188 <small>''(Green Bean)''</small>
  −
| 593 <small>''(Summer Spangle)''</small>
   
|-
 
|-
| 4
+
| <samp>IsPaddyCrop</samp>
| Regrow after Harvest
+
| ''(Optional)'' Whether this crop can be planted near water for a unique paddy dirt texture, faster growth time, and auto-watering. For example, [[Rice Shoot|rice]] and [[Taro Root|taro]] are paddy crops. Default false.
| 3
  −
| -1
   
|-
 
|-
| 5
+
| <samp>NeedsWatering</samp>
| Harvest Method
+
| ''(Optional)'' Whether this crop needs to be watered to grow (e.g. [[Fiber Seeds|fiber seeds]] don't). Default true.
| 0
  −
| 0
   
|-
 
|-
| 6
+
!colspan="2"| Harvest
| Chance for Extra Harvest
  −
| true 1 2 6 0
  −
| false
   
|-
 
|-
| 7
+
| <samp>HarvestItemId</samp>
| Raised Seeds
+
| The item ID produced when this crop is harvested.
| true
  −
| false
   
|-
 
|-
| 8
+
| <samp>HarvestMethod</samp>
| Tint Color
+
| ''(Optional)'' How the crop can be harvested. This can be <samp>Grab</samp> (crop is harvested by hand) or <samp>Scythe</samp> (harvested with a [[scythe]]). Default <samp>Grab</samp>.
| false
+
|-
| true 0 208 255 99 255 210 255 212 0 255 144 122 255 0 238 206 91 255
+
| <samp>HarvestMinStack</samp><br /><samp>HarvestMaxStack</samp>
|}
+
| ''(Optional)'' The minimum and maximum number of <samp>HarvestItemId</samp> to produce (before <samp>HarvestMaxIncreasePerFarmingLevel</samp> and <samp>ExtraHarvestChance</samp> are applied). A value within this range (inclusive) will be randomly chosen each time the crop is harvested. The minimum defaults to 1, and the maximum defaults to the minimum.
 +
|-
 +
| <samp>HarvestMinQuality</samp><br /><samp>HarvestMaxQuality</samp>
 +
| ''(Optional)'' If set, the minimum and maximum quality of the harvest crop. These fields set a constraint that's applied after the quality is calculated normally, they don't affect the initial quality logic.
 +
|-
 +
| <samp>HarvestMaxIncreasePerFarmingLevel</samp>
 +
| ''(Optional)'' The number of extra harvests to produce per farming level. This is rounded down to the nearest integer and added to <samp>HarvestMaxStack</samp>. Defaults to 0.
   −
===Days in each stage of growth===
+
For example, a value of 0.2 is equivalent to +1 max at level 5 and +2 at level 10.
The number of days in each visual step of growth. The final stage will be harvestable after the specified number of days.
+
|-
 +
| <samp>ExtraHarvestChance</samp>
 +
| ''(Optional)'' The probability that harvesting the crop will produce extra harvest items, as a value between 0 (never) and 0.9 (nearly always). This is repeatedly rolled until it fails, then the number of successful rolls is added to the produced count. For example, [[tomato]]es use 0.05. Default 0. This is [https://www.desmos.com/calculator/ok9c2tw6o5 a geometric series with expected value] of <samp>1/(1-ExtraHarvestChance) - 1</samp>, so it will grow faster than you expect it should. For example, with a value of <samp>0.9</samp>, this field has an expected value of nine additional crops.
 +
|-
 +
!colspan="2"| Appearance
 +
|-
 +
| <samp>Texture</samp>
 +
| The asset name for the texture (under the game's <samp>Content</samp> folder) containing the crop sprite. For example, the vanilla crops use <samp>TileSheets\crops</samp>.
 +
|-
 +
| <samp>SpriteIndex</samp>
 +
| ''(Optional)'' The index of this crop in the <samp>Texture</samp>, one crop per row, where 0 is the top row. Default 0.
 +
|-
 +
| <samp>TintColors</samp>
 +
| ''(Optional)'' The colors with which to tint the sprite when drawn (e.g. for colored flowers). A random color from the list will be chosen for each crop. See [[#Color fields|color format]]. Default none.
 +
|-
 +
!colspan="2"| Achievements
 +
|-
 +
| <samp>CountForMonoculture</samp>
 +
| ''(Optional)'' Whether the player can ship 300 of this crop's harvest item to unlock the monoculture [[achievements|achievement]]. Default false.
 +
|-
 +
| <samp>CountForPolyculture</samp>
 +
| ''(Optional)'' Whether the player must ship 15 of this crop's harvest item (along with any other required crops) to unlock the polyculture [[achievements|achievement]]. Default false.
 +
|-
 +
!colspan="2"| Advanced
 +
|-
 +
| <samp>PlantableLocationRules</samp>
 +
| ''(Optional)'' The rules to decide which locations you can plant the seed in, if applicable. The first matching rule is used. This can override location checks (e.g. crops being limited to the farm), but not built-in requirements like crops needing dirt.
   −
Note that speedgrow/agricultralist can only remove up to 3 days per stage of growth, so if your growth stages are very long the fertilizers may appear to work weirdly.
+
This consists of a list of models with these fields:
   −
===Regrow after harvest===
+
{| class="wikitable"
Either -1 for no regrowth, or the number of days until the crop can be harvested again.
+
|-
 
+
! field
===Harvest method===
+
! effect
1 for Scythe, 0 for all others
+
|-
 
+
| <samp>Id</samp>
===Chance for extra harvest===
+
| The [[Modding:Common data field types#Unique string ID|unique string ID]] for this entry within the list.
If this value is true, then the numbers that follow are parsed as:
+
|-
#minHarvest
+
| <samp>Result</samp>
#maxHarvest
+
| Indicates whether the seed can be planted in a location if this entry is selected. The possible values are:
#maxHarvestIncreasePerFarmingLevel
+
* <samp>Default</samp>: the seed can be planted if the location normally allows it. This can be used to stop processing further rules, and/or set a custom <samp>DeniedMessage</samp>.
#chanceForExtraCrops
+
* <samp>Allow</samp>: the seed can be planted here, regardless of whether the location normally allows it.
 
+
* <samp>Deny</samp>: the seed can't be planted here, regardless of whether the location normally allows it.
The game determines the number of crops gained at a single harvest using the following code from <samp>Crops.cs::harvest()</samp>, where <samp>num</samp> is the number of crops gained:
+
|-
 
+
| <samp>Condition</samp>
<syntaxhighlight lang="C#">
+
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether this entry applies. Default true.
if (this.minHarvest > 1 || this.maxHarvest > 1)
+
|-
    num = random.Next(this.minHarvest, Math.Max(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel));
+
| <samp>PlantedIn</samp>
 
+
| ''(Optional)'' The planting context to apply this rule for. The possible values are <samp>Ground</samp> (planted directly in dirt), <samp>GardenPot</samp> (planted in a [[Garden Pot|garden pot]]), or <samp>Any</samp>. Default <samp>Any</samp>.
if (this.chanceForExtraCrops > 0.0)
+
|-
    while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops))
+
| <samp>DeniedMessage</samp>
        num++;
+
| ''(Optional)'' If this rule prevents planting the seed, the tokenizable string to show to the player (or <samp>null</samp> to default to the normal behavior for the context). This also applies when the <samp>Result</samp> is <samp>Default</samp>, if that causes the planting to be denied.
 
+
|}
if (random.NextDouble() < (double)Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05)
+
|-
    num *= 2;
+
| <samp>CustomFields</samp>
</syntaxhighlight>
+
| The [[#Custom data fields|custom fields]] for this entry.
 
+
|}
The value in <samp>chanceForExtraCrops</samp> may add additional crops to a harvest, calculated independently of the other 3 variables.  For example, each harvest of a Potato Seed (475) has &#8776;20% chance of yielding an extra potato, in addition to the one Potato given as standard harvest.  Each harvest of a Blueberry Seed (481) has &#8776;2% chance of yielding an extra Blueberry, in addition to the 3 Blueberries given as standard harvest.
  −
 
  −
The chance for doubling the determined yield depends on Daily Luck: With a minimal value of -0.1 and a maximal value of +0.125 (accounting for the [[Special Charm]]), the chance ranges from 0.001<span style="text-decoration: overline">6</span>% (1 out of 60,000) to 0.02041<span style="text-decoration: overline">6</span>% (49 out of 240,000; or roughly 1 out of 4,898).
  −
 
  −
===Raised seeds===
  −
True for trellis crops (Grapes, Hops, Green Beans), false for all others.
     −
===Tint color===
+
For example, this adds a custom cucumber crop (assuming you've already added [[#Custom items|custom items]] for cucumber seeds and cucumber):
If Tint Color is true, a string of rgb() values follows.  In the example above, Summer Spangle can be one of 6 different colors:
+
{{#tag:syntaxhighlight|<nowiki>
*rgb(0, 208, 255)
+
{
*rgb(99, 255, 210)
+
    "Format": "</nowiki>{{Content Patcher version}}<nowiki>",
*rgb(255, 212, 0)
+
    "Changes": [
*rgb(255, 144, 122)
+
        {
*rgb(255, 0, 238)
+
            "Action": "EditData",
*rgb(206, 91, 255)
+
            "Target": "Data/Crops",
 +
            "Entries": {
 +
                "Example.Id_CucumberSeeds": {
 +
                    "Seasons": [ "summer" ],
 +
                    "DaysInPhase": [ 1, 2, 2, 2 ], // grows in 7 days with four growing sprites
 +
                    "HarvestItemId": "Example.Id_Cucumber",
 +
                    "Texture": "{{InternalAssetKey: assets/crops.png}}",
 +
                    "SpriteIndex": 0
 +
                }
 +
            }
 +
        }
 +
    ]
 +
}</nowiki>|lang=javascript}}
    
[[Category:Modding]]
 
[[Category:Modding]]
138

edits