Difference between revisions of "Modding:Weather data"

From Stardew Valley Wiki
Jump to navigation Jump to search
(copy from canimod.com with permission, dual-licensed CC BY-NC-SA for compatibility with wiki. Main author is Kylindra, with contributions from Pathoschild.")
 
(Rewriting the weather guide.)
Line 1: Line 1:
<pre>
+
__TOC__
---
 
layout: default
 
title: Weather
 
intro: >
 
    This page explains how the game handles weather. This is meant as an in-depth overview for
 
    modders.
 
permalink: /for-devs/weather
 
redirect_from:
 
    - /guides/weather
 
---
 
  
Weather in Stardew Valley runs from multiple sources.
+
== Overview ==
  
## Coding Explanation
+
Weather in Stardew Valley is set within the '''newDayAfterFade()''' function. For those using '''SMAPI''', this function runs before the '''AfterNewDayStarted''' event.
First off, weather (for tomorrow) is controlled by the variable weatherForTomorrow. It's an _int_, and takes one of the following arguments
 
  
weather | value
+
The weather is controlled by the variable '''weatherForTomorrow''', an integer. It takes one of the following arguments (For a description of each weather as the player sees it, look at [[Weather]])
------------ | -------------
 
weather_sunny | 0
 
weather_rain | 1
 
weather_debris | 2
 
weather_lightning | 3
 
weather_festival | 4
 
weather_snow | 5
 
weather_wedding | 6
 
  
The weather debris for the season differs (weather_debris), and is offset _16_ in spring, _24_ in summer, _18_ in fall, and nothing in winter. It failsafes to _20_.
+
{|style="border: 1px solid black;"
 +
|-
 +
!style="width: 225px;"|Variable (Weather)
 +
!Value
 +
|-
 +
|weather_sunny (Sunny)
 +
|0
 +
|-
 +
| weather_rain  (Rain)
 +
| 1
 +
|-
 +
| weather_debris (Windy)
 +
| 2
 +
|-
 +
|weather_lightning (Lightning)
 +
| 3
 +
|-
 +
|weather_festival (Festival)
 +
| 4
 +
|-
 +
|weather_snow (Snow)
 +
| 5
 +
|-
 +
|weather_wedding (Wedding)
 +
| 6
 +
|}
  
prepareSpouseForWedding() sets the weather to wedding.
+
===How Weather Is Set ===
  
The meat of this is in newDayAfterFade()
+
To determine how it's set, and what debris is set, the following steps are followed:
  
First, for weather, it checks if the wedding is today. It sets it to 6 if it is.
+
# After it handles day chance code, it checks for force weather (which is in the table at the bottom)
 +
# It checks if today is a festival, and if it is, it sets the weather to 4. ('''weather_festival''')
 +
# If today is a wedding, it sets the weather to 6. ('''weather_wedding''').
 +
# It then updates if it was raining yesterday by checking the isRaining or isLightning flags.
 +
# It then clears all the flags, and sets them in the following pattern
 +
## If it is going to rain or storm, set the rain flag to true
 +
## If it is going to storm, set the storm flag to true
 +
## If the weather is (sunny, debris) or (festival || snowy || wedding), clear all the flags
 +
## and then if it's snowy, set snowy to true
 +
## It then sets the song based on this
 +
## Clear the debris weather array and clear the flag
 +
## if bloom isn't null, clear it's visibility
 +
## If the wedding is debris, populate the debris array.
 +
# If it's not raining, and the chance to rain tomorrow is less than .1, it will try to create a bloom day.
 +
# It then calculates the rain chance for tomorrow. It follows the following algorithm
 +
## Check to see if it's summer.
 +
### If not, check to see if it's winter.
 +
#### If it's not, the rain chance is .183
 +
#### Else, it's .63
 +
### If it is, it uses the following: Check if it's day 1.
 +
#### If it's not, the chance is .12 + '''dayOfMonth''' * 3/1000
 +
#### If it is, the chance is 0. Which.. is kinda redundant, as the force days take care of this.
 +
# Check to see if a random number is less than the odds. If it is, it follows the following algorithm
 +
## Set '''weatherForTomorrow''' to 1. ('''weather_rain''')
 +
## If:
 +
### It's summer, and if a random number is less than .85
 +
### Or If it's not winter, and if a random number is less than .25 AND the day of the month is more than 2 and more than 27 days have been played
 +
### Set '''weatherForTomorrow''' to 3. ('''weather_lightning''')
 +
## If it is winter
 +
### Set '''weatherForTomorrow''' to 5. ('''weather_snow''')
 +
# Else, if it's over the rain odds.
 +
## If you've played less than or 2 days.  
 +
## Or: if
 +
### It's not spring
 +
### Or a random number is greater than or equal to .2 (so 80%) and spring.
 +
### And it's not fall
 +
### Or a random number is greater than or equal to .6 (so 40%) and fall.
 +
### Or: If there is a wedding today
 +
#### Set '''weatherForTomorrow''' to 0. ('''weather_sunny''') if true
 +
#### Set '''weatherForTomorrow''' to 2. ('''weather_debris''') if false
 +
## Check if tomorrow is a festival, and set weather to 4 ('''weather_festival''') if true.
 +
## Again force the 3rd day to be 1. ('''weather_rain''').
  
On the following days, you get the following weather by force:
+
At this point, the main function is done setting weather.
  
day | season | year |weather
+
=== TV Channel ===
----|--------|-------|-------
 
1|spring|any|weather_sunny
 
2|spring|1|weather_sunny
 
3|spring|1|weather_rain[1]
 
4|spring|1|weather_sunny
 
13|spring|any|weather_festival
 
24|spring|any|weather_festival
 
1|summer|any|weather_sunny
 
11|summer|any|weather_festival
 
13|summer|any|weather_lightning
 
26|summer|any|weather_lightning
 
28|summer|any|weather_festival
 
1|fall|any|weather_sunny
 
16|fall|any|weather_festival
 
27|fall|any|weather_festival
 
1|winter|any|weather_sunny
 
8|winter|any|weather_festival
 
25|winter|any|weather_festival
 
  
[1] The game first sets it to weather_sunny and then in a later check to weather_rain
+
The TV checks the weather, but will occasionally set it on certain days. It follows the following chart:
 
 
At this point, it checks if it's rainy or storming, and sets the flags.
 
 
 
If it's 0-2-4-5-6, it clears all rainy, storm or lightning tracks. (it then manually sets snowing after this..)
 
 
 
It then sets the debris array to active, and then it starts setting weather for the next day (!).
 
 
 
In summer, the chance of rain the next day is : 0% if it's the first day, and  .13 + .003 * the day of the month
 
In winter, the chance of 'rain' is 63%.
 
In fall and spring, it's 18.3%
 
 
 
It then picks a number, and if it's less than the chance of rain, it sets it equal to rain. It then checks if it's summer, and rain in summer has an 85% chance of becoming storms. OR: In any month that isn't winter, as long as you've played more than 27 days and it's at least the third day of the month, you have a 25% chance of the rain becoming a storm.
 
 
 
In winter, rain always becomes snow.
 
 
 
If the number is over the chance of rain, it checks you've played for at least 2 days, and that it's not a wedding day. In spring, there is a 20% chance of wind, and in fall, a 60% chance of the weather becoming windy.
 
 
 
Then, it finally sets the weather to sunny
 
 
 
It then checks to make sure that the next day is a festival day. If so, it sets it to weather_festival. If the current day is the 2nd day of spring, it makes sure the third day is rainy. (again.) (It's sets this by making sure you've played 2 days.) and updates your current weather icon near the end of the function (After a bunch of other things.)
 
 
 
## TV channel
 
 
 
Now, if you check the TV, it both can check the current weather or alter it. (getWeatherForceast())
 
  
 
The TV force sets by:
 
The TV force sets by:
  
day | season | year |weather
+
{| style="border: 1px solid black;"
----|--------|-------|-------
+
|-
1|spring|any|weather_sunny[1]
+
!day
1|summer|any|weather_sunny[1]
+
!season
13|summer|any|weather_lightning[2]
+
!year
25|summer|any|weather_lightning[2]
+
!weather
1|fall|any|weather_sunny[1]
+
|-
1|winter|any|weather_sunny[1]
+
|1
 +
|spring
 +
|any
 +
|weather_sunny[1]
 +
|-
 +
|1
 +
|summer
 +
|any
 +
|weather_sunny[1]
 +
|-
 +
|13
 +
|summer
 +
|any
 +
|weather_lightning[2]
 +
|-
 +
|25
 +
|summer
 +
|any
 +
|weather_lightning[2]
 +
|-
 +
|1
 +
|fall
 +
|any
 +
|weather_sunny[1]
 +
|-
 +
|1
 +
|winter
 +
|any
 +
|weather_sunny[1]
 +
|}
  
[1] also set (and therefore overriden) by the newDay() function
+
[1] also set (and therefore overriden) by the '''newDayAfterFade()''' function<br>
 
[2] These are set by current_day mod 12, which results in the 13th and 25th.
 
[2] These are set by current_day mod 12, which results in the 13th and 25th.
  
Line 109: Line 143:
 
It returns an empty string for all other weathers. (which should be none, but.)
 
It returns an empty string for all other weathers. (which should be none, but.)
  
### Notes:
+
==== Notes: ====
  
The TV will not neccesarilly be accurate for Summer 13,26 or Spring 2,4. Those are force set within the newDayAfterFade() function.
+
The TV will not necessarily be accurate for Summer 13,26 or Spring 2,4. Those are force set within the newDayAfterFade() function.
  
## Rain Totem:  
+
== Weather Icon ==
 +
Thanks to Entoarox, the logic for this is pretty simple:
  
It makes sure you aren't in multiplayer and that tomorrow isn't a festival day. If so, it sets the weather for tomorrow to weather_rain. Of an interesting note, see the TV notes above.  
+
This is set by Game1::updateWeatherIcon().  
  
===========================================
+
The following will always apply: snowing sets '''7''', sunny '''2''', wedding '''0''', festival '''1''',
 +
raining '''4''', stormy '''5'''
 +
<br>
 +
In spring, debris weather is '''3''', summer will be '''unset''' (this defaults to sunny), fall '''6''', and winter '''7''' (the same as snowing)
 +
<br>
 +
These icons are located in '''LooseSprite/Cursors.xnb'''
  
Now that we've broken down the flow, here's a (long winded) breakdown of each weather's chances.
+
== Rain Totem ==
  
## Sunny Weather (0,4,6)
+
The rain totem item is (681), and is controlled by Object::rainTotem (invoked by Object::performUseAction)  
  
In _Spring_, there is first an 18.3% base chance that it rains assuming that it's not overriden. (81.7% chance remaining for other weathers). If it doesn't rain, it has an 80% chance to remain sunny. (except on Spring 3, which will always be rainy.). This means in _Spring_, there is a 66.4% chance of it being sunny.
+
It makes sure you aren't in multiplayer and that tomorrow isn't a festival day. If so, it sets the weather for tomorrow to weather_rain and displays the message. Of a note, the item is still used up and every other animation is played even if it's not set if you're in MP or if tomorrow is a festival day.
  
In _Summer_, there is a diminishing chance daily of sunny weather, but generally, you have a 86% chance on the second day, to 79.9% chance on the last day. The precise chance is: 1 - [13% + (.3 * day of the month)] per day, and it's a 0% chance on day 1. Bear in mind that Summer 12,13,24 and 26 will be stormy.
+
== Breakdown of Weather Chances by Type ==
  
In _Fall_, the odds are precisely the same as Spring. There's no forced weather though.
+
Now that we've broken down the flow, here's a (long winded) breakdown of each weather's chances.
  
In _Winter_, there is a 63% chance of preciptation, so only a 37% chance of sunny weather.
+
=== Sunny Weather (Weather Variables: 0,4,6) ===
  
## Rainy Weather (1)
+
In ''Spring'', there is first an 18.3% base chance that it rains assuming that it's not overridden. (81.7% chance remaining for other weathers). If it doesn't rain, it has an 80% chance to remain sunny. (except on Spring 3, which will always be rainy.). This means in _Spring_, there is a 66.4% chance of it being sunny.
  
In _Spring_, you have a 18.3% chance of rain. If it rains, there's only a 25% chance of storms, _as long as it is not Year 1_. So the rain odds in Spring is a flat 18.3% in Year 1, and 13.725% in Year 2 and beyond. It will be rainy on Spring 3 Year 1.
+
In ''Summer'', there is a diminishing chance daily of sunny weather, but generally, you have a 86% chance on the second day, to 79.9% chance on the last day. The precise chance is: 1 - [13% + (.3 * day of the month)] per day, and it's a 0% chance on day 1. Bear in mind that Summer 12,13,24 and 26 will be stormy.
  
In _Summer_, you have a steadily increasing chance of rain starting at 14% on Summer 2 to a 21.1% chance on Summer 27. However, during _Summer_, you have a 85% chance to make the rain into storms. So you have a scale of [13% + (.3 * day of the month)] * .85 to determine your chances of rainfall. (See the note about forced weather above.)
+
In ''Fall'', the odds are precisely the same as Spring. There's no forced weather though.
  
In _Fall_, it's the same as _Spring_, although Fall Year 1 can be stormy, so it's 13.725%.  
+
In ''Winter'', there is a 63% chance of precipitation, so only a 37% chance of sunny weather.
  
In _Winter_, it does not rain.
+
=== Rainy Weather (1) ===
  
## Debris Weather (2)
+
In ''Spring'', you have a 18.3% chance of rain. If it rains, there's only a 25% chance of storms, _as long as it is not Year 1_. So the rain odds in Spring is a flat 18.3% in Year 1, and 13.725% in Year 2 and beyond. It will be rainy on Spring 3 Year 1.
  
In _Spring_, you have a 20% chance for this after rain, so approximately 16.6% chance of debris weather.
+
In ''Summer'', you have a steadily increasing chance of rain starting at 14% on Summer 2 to a 21.1% chance on Summer 27. However, during ''Summer'', you have a 85% chance to make the rain into storms. So you have a scale of [13% + (.3 * day of the month)] * .85 to determine your chances of rainfall. (See the note about forced weather above.)
  
In _Summer_ you cannot have debris weather.
+
In ''Fall'', it's the same as ''Spring'', although Fall Year 1 can be stormy, so it's 13.725%.  
  
In _Fall_, you have a 60% chance for this after rain, so approximately 49.8% chance of debris weather.
+
In ''Winter'', it does not rain.
  
In _Winter_ you cannot have debris weather.
+
=== Debris Weather (2) ===
  
## Stormy Weather (3)
+
In ''Spring'', you have a 20% chance for this after rain, so approximately 16.6% chance of debris weather.
  
In _Spring_, you have a 4.57% of storms.
+
In ''Summer'' and ''Winter'' you cannot have debris weather.
  
In _Summer_, you have a variable chance of storms. It starts at 11.9% and increases to 17.9% chance.
+
In ''Fall'', you have a 60% chance for this after rain, so approximately 49.8% chance of debris weather.
  
In _Fall_, you have a 4.57% of storms.
+
=== Stormy Weather (3) ===
  
In _Winter_ you cannot have stormy weather.
+
In ''Spring'', you have a 4.57% of storms.
  
## Snowy Weather
+
In ''Summer'', you have a variable chance of storms. It starts at 11.9% and increases to 17.9% chance.
  
In _Winter_, you have a 63% chance of snow.
+
In ''Fall'', you have a 4.57% of storms.
  
No other season has snow.
+
In ''Winter'', you cannot have stormy weather.
  
# Override Table
+
=== Snowy Weather ===
  
day | season | year |weather|overriden by
+
In ''Winter'', you have a 63% chance of snow.
----|--------|-------|-------|--------
 
1|spring|any|weather_sunny|newday and tv
 
2|spring|1|weather_sunny|newday
 
3|spring|1|weather_rain|newday
 
4|spring|1|weather_sunny|newday
 
13|spring|any|weather_festival|newday
 
24|spring|any|weather_festival|newday
 
1|summer|any|weather_sunny|newday and tv
 
11|summer|any|weather_festival|newday
 
13|summer|any|weather_lightning|newday and tv
 
25|summer|any|weather_lightning|tv
 
26|summer|any|weather_lightning|newday
 
28|summer|any|weather_festival|newday
 
1|fall|any|weather_sunny|newday and tv
 
16|fall|any|weather_festival|newday
 
27|fall|any|weather_festival|newday
 
1|winter|any|weather_festival|newday and tv
 
8|winter|any|weather_festival|newday
 
25|winter|any|weather_festival|newday
 
  
# Weather Icon
+
No other season has snow.
Thanks to Entoarox, the logic for this is pretty simple:
 
The following will always apply: snowing sets _7_, sunny _2_, wedding _0_, festival _1_, raining _4_, stormy _5_
 
 
 
In spring, debris weather is _3_, summer will be __unset__, fall _6_, and winter _7_ (the same as snowing)
 
  
These icons are located in _LooseSprite/Cursors.xnb_
+
== Weather and Save Files ==
  
# Weather and Save Files
+
Your save file is a snapshot of the day at 0600 the next morning. As such, changing WeatherForTommorow in there will not affect the day loaded. If you really need to alter weather in the save file, you'll want to look at the following attributes: '''isRaining, isDebrisWeather, isLightning, isSnowing'''. For details of what to set which, look at the next section. This applies to trying to change weather in game, as well.
  
Your save file is a snapshot of the day at 0600 the next morning. As such, changing WeatherForTommorow in there will not affect the day loaded. If you really need to alter weather, you'll want to look at the following attributes: ```isRaining, isDebrisWeather, isLightning, isSnowing```
+
'''NB:''' Changing isDebrisWeather during an active game will not by itself create the array. You will need to call '''Game1::populateDebrisWeatherArray''' to get the debris populated. Corrospondingly, if you are removing the debris weather flag, remember to call '''Game1::debrisWeather::Clear'''
  
# Detecting Current Weather
+
== Detecting Current Weather (in game) ==
  
 
This is a brief overview. While it's generally obvious, I'll lay it out
 
This is a brief overview. While it's generally obvious, I'll lay it out
  
weather | isRaining | isDebrisWeather| isLightning| isSnowing
+
{| style="border: 1px solid black;"
-------|-----------|------------|-----------|--------------
+
|-
Sunny|F|F|F|F
+
! weather  
Rainy|T|F|F|F
+
! isRaining  
Storm|T|F|T|F
+
! isDebrisWeather
Debris|F|T|F|F
+
! isLightning
Snowing|F|F|F|T
+
! isSnowing
Festival|F|F|F|F
+
|-
Wedding|F|F|F|F
+
| Sunny
 
+
| F
# Comments (Modding)
+
| F
 
+
| F
Q. How do I fix the TV not being accurate, or add new strings?
+
| F
 
+
|-
A. Override the function that does forecasts. Very difficult, although theoretically possible in SMAPI (and probably more fully in FarmHand)
+
| Rainy
 
+
|T
Q. I want to set snowy weather outside Winter!
+
|F
 
+
|F
A. You can, as long as you keep in mind what days try to override that.
+
|F
 
+
|-
Q. What about adding new weathers?
+
|Storm
 
+
|T
A. Err.. Outside the scope of this, I'm afraid
+
|F
 +
|T
 +
|F
 +
|-
 +
|Debris
 +
|F
 +
|T
 +
|F
 +
|F
 +
|-
 +
|Snowing
 +
|F
 +
|F
 +
|F
 +
|T
 +
|-
 +
|Festival
 +
| F
 +
| F
 +
| F
 +
| F
 +
|-
 +
|Wedding
 +
| F
 +
| F
 +
| F
 +
| F
 +
|}
  
Q. I see that debris has code for winter but cannot be triggered
+
== Notes/FAQ ==
  
A. Correct. It's also got an offset of 0, so you might have to do something about drawing the debris.
+
* The TV can be fixed by overriding it - or just by using Entoroax'S fRAMEWORK
 +
* You can set snow and debris at any time, the game just won't.
  
Q. Any modding limitations?
+
== Appendix: Override Table ==
  
A. _Yes_. Bear in mind that SMAPI's PlayerEvents.LoadedGame and TimeEvents.DayOfMonthChanged run before SDV runs it's new day. The overrides and festival days will override your weather. That said, you can get snow and windy weather out of season. Also, debris weather will generally render as whatever the day was before due to how updateWeatherIcon() handles that in summer, but as snow in winter.
+
{| style="border: 1px solid black;"
</pre>
+
|-
 +
!Day
 +
!Season
 +
!Year
 +
!Forced Weather
 +
!Overriden by
 +
|-
 +
|1
 +
|spring
 +
|any
 +
|weather_sunny
 +
|newday and tv
 +
|-
 +
|2
 +
|spring
 +
|1
 +
|weather_sunny
 +
|newday
 +
|-
 +
|3
 +
|spring
 +
|1
 +
|weather_rain
 +
|newday
 +
|-
 +
|4
 +
|spring
 +
|1
 +
|weather_sunny
 +
|newday
 +
|-
 +
|13
 +
|spring
 +
|any
 +
|weather_festival
 +
|newday
 +
|-
 +
|24
 +
|spring
 +
|any
 +
|weather_festival
 +
|newday
 +
|-
 +
|1
 +
|summer
 +
|any
 +
|weather_sunny
 +
|newday and tv
 +
|-
 +
|11
 +
|summer
 +
|any
 +
|weather_festival
 +
|newday
 +
|-
 +
|13
 +
|summer
 +
|any
 +
|weather_lightning
 +
|newday and tv
 +
|-
 +
|25
 +
|summer
 +
|any
 +
|weather_lightning
 +
|tv
 +
|-
 +
|26
 +
|summer
 +
|any
 +
|weather_lightning
 +
|newday
 +
|-
 +
|28
 +
|summer
 +
|any
 +
|weather_festival
 +
|newday
 +
|-
 +
|1
 +
|fall
 +
|any
 +
|weather_sunny
 +
|newday and tv
 +
|-
 +
|16
 +
|fall
 +
|any
 +
|weather_festival
 +
|newday
 +
|-
 +
|27
 +
|fall
 +
|any
 +
|weather_festival
 +
|newday
 +
|-
 +
|1
 +
|winter
 +
|any
 +
|weather_festival
 +
|newday and tv
 +
|-
 +
|8
 +
|winter
 +
|any
 +
|weather_festival
 +
|newday
 +
|-
 +
|25
 +
|winter
 +
|any
 +
|weather_festival
 +
|newday
 +
|}

Revision as of 01:32, 3 May 2017

Overview

Weather in Stardew Valley is set within the newDayAfterFade() function. For those using SMAPI, this function runs before the AfterNewDayStarted event.

The weather is controlled by the variable weatherForTomorrow, an integer. It takes one of the following arguments (For a description of each weather as the player sees it, look at Weather)

Variable (Weather) Value
weather_sunny (Sunny) 0
weather_rain (Rain) 1
weather_debris (Windy) 2
weather_lightning (Lightning) 3
weather_festival (Festival) 4
weather_snow (Snow) 5
weather_wedding (Wedding) 6

How Weather Is Set

To determine how it's set, and what debris is set, the following steps are followed:

  1. After it handles day chance code, it checks for force weather (which is in the table at the bottom)
  2. It checks if today is a festival, and if it is, it sets the weather to 4. (weather_festival)
  3. If today is a wedding, it sets the weather to 6. (weather_wedding).
  4. It then updates if it was raining yesterday by checking the isRaining or isLightning flags.
  5. It then clears all the flags, and sets them in the following pattern
    1. If it is going to rain or storm, set the rain flag to true
    2. If it is going to storm, set the storm flag to true
    3. If the weather is (sunny, debris) or (festival || snowy || wedding), clear all the flags
    4. and then if it's snowy, set snowy to true
    5. It then sets the song based on this
    6. Clear the debris weather array and clear the flag
    7. if bloom isn't null, clear it's visibility
    8. If the wedding is debris, populate the debris array.
  6. If it's not raining, and the chance to rain tomorrow is less than .1, it will try to create a bloom day.
  7. It then calculates the rain chance for tomorrow. It follows the following algorithm
    1. Check to see if it's summer.
      1. If not, check to see if it's winter.
        1. If it's not, the rain chance is .183
        2. Else, it's .63
      2. If it is, it uses the following: Check if it's day 1.
        1. If it's not, the chance is .12 + dayOfMonth * 3/1000
        2. If it is, the chance is 0. Which.. is kinda redundant, as the force days take care of this.
  8. Check to see if a random number is less than the odds. If it is, it follows the following algorithm
    1. Set weatherForTomorrow to 1. (weather_rain)
    2. If:
      1. It's summer, and if a random number is less than .85
      2. Or If it's not winter, and if a random number is less than .25 AND the day of the month is more than 2 and more than 27 days have been played
      3. Set weatherForTomorrow to 3. (weather_lightning)
    3. If it is winter
      1. Set weatherForTomorrow to 5. (weather_snow)
  9. Else, if it's over the rain odds.
    1. If you've played less than or 2 days.
    2. Or: if
      1. It's not spring
      2. Or a random number is greater than or equal to .2 (so 80%) and spring.
      3. And it's not fall
      4. Or a random number is greater than or equal to .6 (so 40%) and fall.
      5. Or: If there is a wedding today
        1. Set weatherForTomorrow to 0. (weather_sunny) if true
        2. Set weatherForTomorrow to 2. (weather_debris) if false
    3. Check if tomorrow is a festival, and set weather to 4 (weather_festival) if true.
    4. Again force the 3rd day to be 1. (weather_rain).

At this point, the main function is done setting weather.

TV Channel

The TV checks the weather, but will occasionally set it on certain days. It follows the following chart:

The TV force sets by:

day season year weather
1 spring any weather_sunny[1]
1 summer any weather_sunny[1]
13 summer any weather_lightning[2]
25 summer any weather_lightning[2]
1 fall any weather_sunny[1]
1 winter any weather_sunny[1]

[1] also set (and therefore overriden) by the newDayAfterFade() function
[2] These are set by current_day mod 12, which results in the 13th and 25th.

Description:

It will check the weather, and do the following:

  • Sunny or Wedding: A 50% chance of one of two strings: "It's going to be clear and sunny all day." or "It's going to be a beautiful, sunny day tommorow!"
  • Rain: "It's going to rain all day tomorrow"
  • Debris: Spring: "Partially cloudy with a light breeze. Expect lots of pollen!" Not Fall: "It's going to snow all day. Make sure you bundle up, folks!" and defaults with: "It's going to be cloudy, with gusts of wind throught the day."
  • Storm: "Looks like a storm is approaching. Thunder and lightning is expected."
  • Festival: It attempts to read the festival data, will spit out an amusing "Um... that's odd. My information sheet just says 'null'. This is embarrassing..." if it fails to read the data, other wise will read out where it is and when it is.
  • Snow: A 50% chance of one of two strings: "Expect a few inches of snow tomorrow" or "Bundle up, folks. It's going to snow tomorrow!"

It returns an empty string for all other weathers. (which should be none, but.)

Notes:

The TV will not necessarily be accurate for Summer 13,26 or Spring 2,4. Those are force set within the newDayAfterFade() function.

Weather Icon

Thanks to Entoarox, the logic for this is pretty simple:

This is set by Game1::updateWeatherIcon().

The following will always apply: snowing sets 7, sunny 2, wedding 0, festival 1, raining 4, stormy 5
In spring, debris weather is 3, summer will be unset (this defaults to sunny), fall 6, and winter 7 (the same as snowing)
These icons are located in LooseSprite/Cursors.xnb

Rain Totem

The rain totem item is (681), and is controlled by Object::rainTotem (invoked by Object::performUseAction)

It makes sure you aren't in multiplayer and that tomorrow isn't a festival day. If so, it sets the weather for tomorrow to weather_rain and displays the message. Of a note, the item is still used up and every other animation is played even if it's not set if you're in MP or if tomorrow is a festival day.

Breakdown of Weather Chances by Type

Now that we've broken down the flow, here's a (long winded) breakdown of each weather's chances.

Sunny Weather (Weather Variables: 0,4,6)

In Spring, there is first an 18.3% base chance that it rains assuming that it's not overridden. (81.7% chance remaining for other weathers). If it doesn't rain, it has an 80% chance to remain sunny. (except on Spring 3, which will always be rainy.). This means in _Spring_, there is a 66.4% chance of it being sunny.

In Summer, there is a diminishing chance daily of sunny weather, but generally, you have a 86% chance on the second day, to 79.9% chance on the last day. The precise chance is: 1 - [13% + (.3 * day of the month)] per day, and it's a 0% chance on day 1. Bear in mind that Summer 12,13,24 and 26 will be stormy.

In Fall, the odds are precisely the same as Spring. There's no forced weather though.

In Winter, there is a 63% chance of precipitation, so only a 37% chance of sunny weather.

Rainy Weather (1)

In Spring, you have a 18.3% chance of rain. If it rains, there's only a 25% chance of storms, _as long as it is not Year 1_. So the rain odds in Spring is a flat 18.3% in Year 1, and 13.725% in Year 2 and beyond. It will be rainy on Spring 3 Year 1.

In Summer, you have a steadily increasing chance of rain starting at 14% on Summer 2 to a 21.1% chance on Summer 27. However, during Summer, you have a 85% chance to make the rain into storms. So you have a scale of [13% + (.3 * day of the month)] * .85 to determine your chances of rainfall. (See the note about forced weather above.)

In Fall, it's the same as Spring, although Fall Year 1 can be stormy, so it's 13.725%.

In Winter, it does not rain.

Debris Weather (2)

In Spring, you have a 20% chance for this after rain, so approximately 16.6% chance of debris weather.

In Summer and Winter you cannot have debris weather.

In Fall, you have a 60% chance for this after rain, so approximately 49.8% chance of debris weather.

Stormy Weather (3)

In Spring, you have a 4.57% of storms.

In Summer, you have a variable chance of storms. It starts at 11.9% and increases to 17.9% chance.

In Fall, you have a 4.57% of storms.

In Winter, you cannot have stormy weather.

Snowy Weather

In Winter, you have a 63% chance of snow.

No other season has snow.

Weather and Save Files

Your save file is a snapshot of the day at 0600 the next morning. As such, changing WeatherForTommorow in there will not affect the day loaded. If you really need to alter weather in the save file, you'll want to look at the following attributes: isRaining, isDebrisWeather, isLightning, isSnowing. For details of what to set which, look at the next section. This applies to trying to change weather in game, as well.

NB: Changing isDebrisWeather during an active game will not by itself create the array. You will need to call Game1::populateDebrisWeatherArray to get the debris populated. Corrospondingly, if you are removing the debris weather flag, remember to call Game1::debrisWeather::Clear

Detecting Current Weather (in game)

This is a brief overview. While it's generally obvious, I'll lay it out

weather isRaining isDebrisWeather isLightning isSnowing
Sunny F F F F
Rainy T F F F
Storm T F T F
Debris F T F F
Snowing F F F T
Festival F F F F
Wedding F F F F

Notes/FAQ

  • The TV can be fixed by overriding it - or just by using Entoroax'S fRAMEWORK
  • You can set snow and debris at any time, the game just won't.

Appendix: Override Table

Day Season Year Forced Weather Overriden by
1 spring any weather_sunny newday and tv
2 spring 1 weather_sunny newday
3 spring 1 weather_rain newday
4 spring 1 weather_sunny newday
13 spring any weather_festival newday
24 spring any weather_festival newday
1 summer any weather_sunny newday and tv
11 summer any weather_festival newday
13 summer any weather_lightning newday and tv
25 summer any weather_lightning tv
26 summer any weather_lightning newday
28 summer any weather_festival newday
1 fall any weather_sunny newday and tv
16 fall any weather_festival newday
27 fall any weather_festival newday
1 winter any weather_festival newday and tv
8 winter any weather_festival newday
25 winter any weather_festival newday