Dynamic Weather System

## Overview

The dynamic weather system is a system added to V:SotN around the end of October 2015 as part of the Patreon weather update. This system is highly dynamic and optimized to work within a set of parameters. This system builds off of the Ultra Dynamic Sky blueprint and was completely adapted to fit Project Freelance Games' needs. This includes adding a better system for changing clouds, and a system that implements weather events based on local temperature, and fluctuating temperature based on weather events and cloud coverage. Since the player is planned to only visit the Sailzane Desert on special occasions, weather there will be predetermined and the Dynamic Weather System will not be active in that region.

## Clouds

Clouds are those fluffy white things that float over your head in the sky and cast shadows on the ground!

In a technical sense of the Dynamic Weather System, they work in three different stages; clear, normal, and overcast. It was observed that early on, if the Dynamic Weather System reached an extreme in cloud coverage, clear or overcast, it had a tendency to get stuck like that and the clouds would have a hard time changing. Safeguards were put into place to prevent this, so clouds shouldn't get stuck the way they were.

In the **normal stage** of the clouds, which is when the *cloudTargetDensity* variable is between it's minimum and maximum (0.0 to 4.5). In this stage, two different variables that produce the clouds by interacting within a material will run through a linear interpolation process that decide how the clouds will look. (*(cloudDensity)lerp(cloudDensityTarget)*). The *cloudDensityTarget* variable will fluctuate +/- 0.65 every minute and smoothly fade from the current *cloudDensity* to the target density. Because an in-game day lasts an hour and twenty-four minutes, this means that the clouds will update a total of 84 times throughout the day. This will happen regardless of the stage they're in.

In the **clear stage**, there are is a *cloudDensityTarget* of less than or equal to 0.0. The Dynamic Weather System will detect this on it's next update and will force an addition of a random float between 0.4 and 0.65 to the *cloudDensityTarget*, thus increasing cloud coverage.

In the **overcast stage**, there is a *cloudDensityTarget* of greater than or equal to 4.5. The Dynamic Weather System will detect this on it's next update and force the removal of a random float from between 0.64 and 0.925 to the *cloudDensityTarget*, thus decreasing cloud coverage.

## Rain / Snow Events

Rain and snow events, like cloud coverage, are random based on certain parameters and are polled in ~1 minute intervals. In the code, temperature is measured in integers and match up to the Fahrenheit measuring system. Any event that occurs when the integer is equal to or below 32 will be snow and anything that occurs above 32 will be rain. If a snow weather event is occurring, a safe guard is in place so that if another weather update is polled, it can not change to rain, even if the temperature is above 32. This also works in the opposite way for rain to snow.

Weather events can only occur if the *cloudDensityTarget* is 3.0 or greater. There is a node set that allows a 1 in 5 chance for a weather event to start if the conditions are right.

If the weather event occurs for more than half a day, (42 minutes), the storm will be forced to break up. Due to the random nature of the system, it is possible for a storm to start up a minute after one had been forced to stop.

Rain and snow can also stop naturally. If the *cloudDensityTarget* variable is between 2.5 and 2.0, a node set will handle deciding if the weather event will stop. If these conditions are right, the weather event has a 1 in 5 chance to stop.

Due to unrealistic conditions, weather events can be forced to stop naturally as well. If the *cloudDensityTarget* drops to 2.0 and below, then any weather event occurring will be forced to stop.

## Temperature

Perhaps one of the most complex variables in the Dynamic Weather System, this variable polls an update four times every day and controls what weather event will occur if the chance to start one is given. The variable will also change based on parameters of cloud coverage and presence weather events. The default temperature in the Northern regions of Vilous is 40\*F, with a min/max temperature of 20\*F to 70\*F.

To the right is a logic flowchart that handles how temperature is determined.