Beispiel #1
0
        internal static void CheckForStaticRainChanges(WeatherConditions curr, MersenneTwister Dice, double ChanceForNonNormalRain)
        {
            if (Game1.isLightning && Game1.isRaining)
            {
                curr.SetRainAmt(130);
            }
            double rainOdds, newRainOdds;

            rainOdds    = Dice.NextDouble();
            newRainOdds = Dice.NextDouble();

            //random chance to just set rain at a differnt number
            if (rainOdds < ChanceForNonNormalRain)
            {
                //yay use of probablity distribution
                ProbabilityDistribution <RainLevels> RainSpread = new ProbabilityDistribution <RainLevels>(RainLevels.Normal);
                RainSpread.AddNewCappedEndPoint(.12, RainLevels.Sunshower);
                RainSpread.AddNewCappedEndPoint(.28, RainLevels.Light);
                RainSpread.AddNewCappedEndPoint(.351, RainLevels.Normal);
                RainSpread.AddNewCappedEndPoint(.1362, RainLevels.Moderate);
                RainSpread.AddNewCappedEndPoint(.09563, RainLevels.Heavy);
                RainSpread.AddNewCappedEndPoint(.0382, RainLevels.Severe);
                RainSpread.AddNewCappedEndPoint(.0094, RainLevels.Torrential);
                RainSpread.AddNewCappedEndPoint(.0049, RainLevels.Typhoon);
                RainSpread.AddNewCappedEndPoint(.00287, RainLevels.NoahsFlood);

                if (!(RainSpread.GetEntryFromProb(newRainOdds, out RainLevels Result)))
                {
                    Result = RainLevels.Normal;
                    ClimatesOfFerngill.Logger.Log("The rain probablity spread has failed to find an rain level. Falling back to normal rain", LogLevel.Error);
                }

                curr.SetRainAmt(WeatherUtilities.ReturnRndRainAmtInLevel(Dice, Result));

                if (ClimatesOfFerngill.WeatherOpt.Verbose)
                {
                    ClimatesOfFerngill.Logger.Log($"We've set the rain to a non normal value - with roll {rainOdds} for setting non normal, and {newRainOdds} for category {Result}, resulting in new rain target {curr.AmtOfRainDrops} in category {WeatherUtilities.GetRainCategory(curr.AmtOfRainDrops)}");
                }
            }

            curr.TodayRain += curr.AmtOfRainDrops;
            curr.RefreshRainAmt();
        }
Beispiel #2
0
        internal static void DynamicRainOnNewDay(WeatherConditions curr, MersenneTwister Dice)
        {
            if (!curr.HasWeather(CurrentWeather.Rain))
            {
                return;
            }

            curr.SetRainAmt(70);
            //Rain chances. This will also affect storms (in that storms still can have variable rain) .
            //only roll this if it's actually raining. :|
            double roll = Dice.NextDouble();

            if (roll <= ClimatesOfFerngill.WeatherOpt.VariableRainChance && Game1.isRaining)
            {
                ClimatesOfFerngill.Logger.Log($"With {roll}, we are setting for variable rain against {ClimatesOfFerngill.WeatherOpt.VariableRainChance}");
                curr.SetVariableRain(true);

                //check for overcast chance first.
                if (Dice.NextDouble() < ClimatesOfFerngill.WeatherOpt.OvercastChance && !Game1.isLightning)
                {
                    WeatherUtilities.SetWeatherOvercast(true);
                    SDVUtilities.AlterWaterStatusOfCrops(water: false);
                    SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_overcast"), 0);
                }

                //now that we've done that base check, we need to change the rainfall...
                //... after we calc rainfall to see if it's watered. Essentially, every time this is called,
                //... it'll check to see if it should flip the tiles.

                //Variable Rain may set the starting rain at 0300 to be something else than normal, and as such, StartingRain should
                // only be checked if IsVariableRain is true.

                // Odds are fixed: Normal (default) is 72%, Light is 16%, Heavy is 6%, Sunshower is 5%, Severe is 1%
                double startingRainRoll = Dice.NextDouble();
                if (startingRainRoll <= .72)
                {
                    curr.StartingRain = RainLevels.Normal;
                }
                else if (startingRainRoll > .72 && startingRainRoll <= .88)
                {
                    curr.StartingRain = RainLevels.Light;
                }
                else if (startingRainRoll > .88 && startingRainRoll <= .94)
                {
                    curr.StartingRain = RainLevels.Heavy;
                }
                else if (startingRainRoll > .94 && startingRainRoll <= .99)
                {
                    curr.StartingRain = RainLevels.Sunshower;
                }
                else if (startingRainRoll > .99)
                {
                    curr.StartingRain = RainLevels.Severe;
                }

                if (Game1.isLightning && !(curr.StartingRain == RainLevels.Light || curr.StartingRain == RainLevels.Sunshower || curr.StartingRain == RainLevels.Normal))
                {
                    curr.StartingRain = RainLevels.Heavy;
                }

                curr.SetRainAmt(WeatherUtilities.GetRainCategoryMidPoint(curr.StartingRain));
                curr.TodayRain = curr.AmtOfRainDrops;

                //now run this for 0300 to 0600.
                for (int i = 0; i < 17; i++)
                {
                    curr.SetRainAmt(GetNewRainAmount(curr.AmtOfRainDrops, ClimatesOfFerngill.Translator));
                    curr.TodayRain += curr.AmtOfRainDrops;
                }

                //set starting amount at 6am
                curr.RefreshRainAmt();
            }
        }