internal static void SetWeatherNonSystemForTomorrow(MersenneTwister Dice, FerngillClimate GameClimate, double rainDays, double stormDays, double windyDays, RangePair TmrwTemps) { ProbabilityDistribution <string> WeatherDist = new ProbabilityDistribution <string>("sunny"); WeatherDist.AddNewEndPoint(rainDays, "rain"); if (ClimatesOfFerngill.WeatherOpt.DisableHighRainWind) { WeatherDist.AddNewCappedEndPoint(windyDays, "debris"); } double distOdd = Dice.NextDoublePositive(); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log(WeatherDist.ToString()); ClimatesOfFerngill.Logger.Log($"Distribution odds is {distOdd}"); } if (!(WeatherDist.GetEntryFromProb(distOdd, out string Result))) { Result = "sunny"; ClimatesOfFerngill.Logger.Log("The weather has failed to process in some manner. Falling back to [sunny]", LogLevel.Info); } if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"Weather result is {Result}"); } SetWeatherTomorrow(Result, Dice, GameClimate, stormDays, TmrwTemps); }
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(); }
private void SetTomorrowWeather() { //if tomorrow is a festival or wedding, we need to set the weather and leave. if (Utility.isFestivalDay(Game1.dayOfMonth + 1, Game1.currentSeason)) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_festival; Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"Festival tomorrow. Aborting processing.", LogLevel.Trace); } //if (WeatherOpt.Verbose) Monitor.Log(DebugOutput.ToString()); return; } if (Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_wedding; Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"Wedding tomorrow. Aborting processing.", LogLevel.Trace); } return; } if (WeatherUtilities.CheckForForceDay(DescriptionEngine, SDate.Now().AddDays(1), Monitor, WeatherOpt.Verbose)) { Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"The game will force tomorrow. Aborting processing.", LogLevel.Trace); } return; } if (WeatherOpt.Verbose) { Monitor.Log("Setting weather for tomorrow"); } //now set tomorrow's weather var OddsForTheDay = GameClimate.GetClimateForDate(SDate.Now().AddDays(1)); //get system odds double rainSystem = OddsForTheDay.RetrieveSystemOdds("rain"); double windSystem = OddsForTheDay.RetrieveSystemOdds("debris"); double sunSystem = OddsForTheDay.RetrieveSystemOdds("sunny"); if (!Game1.player.mailReceived.Contains("ccDoorUnlock")) { rainSystem = Math.Max(rainSystem - .1, 0); windSystem = Math.Max(windSystem - .1, 0); sunSystem = Math.Min(sunSystem + .2, 1); } //get loose odds double rainDays = OddsForTheDay.RetrieveOdds(Dice, "rain", SDate.Now().AddDays(1).Day); double windyDays = OddsForTheDay.RetrieveOdds(Dice, "debris", SDate.Now().AddDays(1).Day); double stormDays = OddsForTheDay.RetrieveOdds(Dice, "storm", SDate.Now().AddDays(1).Day); if (!Game1.player.mailReceived.Contains("ccDoorUnlock")) { rainDays = Math.Max(rainDays - .1, 0); windyDays = Math.Max(windyDays - .1, 0); } if (WeatherOpt.Verbose) { Monitor.Log($"Weather Odds are Rain: {rainDays:N3}, Windy: {windyDays:N3}, and Storm {stormDays:N3}"); Monitor.Log($"Weather System Odds are Rain: {rainSystem:N3}, Windy: {windSystem:N3}, and Storm {sunSystem:N3}"); } //set tomorrow's weather if (Conditions.trackerModel.IsWeatherSystem) { double SystemContinuesOdds = WeatherProcessing.GetWeatherSystemOddsForNewDay(Conditions); if (WeatherOpt.Verbose) { Monitor.Log($"Rolling system odds against {SystemContinuesOdds:N3}"); } if (Dice.NextDouble() < SystemContinuesOdds) { if (WeatherOpt.Verbose) { Monitor.Log($"Continuing system odds - now for {Conditions.trackerModel.WeatherSystemDays + 1} for weather {Conditions.trackerModel.WeatherSystemType}"); } Conditions.trackerModel.WeatherSystemDays++; WeatherProcessing.SetWeatherTomorrow(Conditions.trackerModel.WeatherSystemType, Dice, GameClimate, stormDays, Conditions.GetTomorrowTemps()); } else { if (WeatherOpt.Verbose) { Monitor.Log($"Ending system, new weather type."); } Conditions.trackerModel.IsWeatherSystem = false; WeatherProcessing.SetWeatherNonSystemForTomorrow(Dice, GameClimate, rainDays, stormDays, windyDays, Conditions.GetTomorrowTemps()); } } else { if (Dice.NextDouble() < WeatherOpt.WeatherSystemChance) { if (WeatherOpt.Verbose) { Monitor.Log($"Rolling system odds against {WeatherOpt.WeatherSystemChance:N3}, created system."); } ProbabilityDistribution <string> SystemDist = new ProbabilityDistribution <string>(); SystemDist.AddNewCappedEndPoint(rainSystem, "rain"); SystemDist.AddNewCappedEndPoint(windSystem, "debris"); SystemDist.AddNewCappedEndPoint(sunSystem, "sunny"); double distOdd = Dice.NextDouble(); if (!(SystemDist.GetEntryFromProb(distOdd, out string Result))) { Result = "sunny"; Monitor.Log("The weather has failed to process in some manner. Falling back to [sunny]", LogLevel.Info); } Conditions.SetNewWeatherSystem(Result, 1); WeatherProcessing.SetWeatherTomorrow(Result, Dice, GameClimate, stormDays, Conditions.GetTomorrowTemps()); } else { WeatherProcessing.SetWeatherNonSystemForTomorrow(Dice, GameClimate, rainDays, stormDays, windyDays, Conditions.GetTomorrowTemps()); } } }
private void SetTommorowWeather() { //if tomorrow is a festival or wedding, we need to set the weather and leave. if (Utility.isFestivalDay(Game1.dayOfMonth + 1, Game1.currentSeason)) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_festival; if (WeatherOpt.Verbose) { Monitor.Log($"Festival tomorrow. Aborting processing.", LogLevel.Trace); } //if (WeatherOpt.Verbose) Monitor.Log(DebugOutput.ToString()); return; } if (Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_wedding; if (WeatherOpt.Verbose) { Monitor.Log($"Wedding tomorrow. Aborting processing.", LogLevel.Trace); } return; } if (ForceDays.CheckForForceDay(DescriptionEngine, SDate.Now().AddDays(1), Monitor, WeatherOpt.Verbose)) { if (WeatherOpt.Verbose) { Monitor.Log($"The game will force tomorrow. Aborting processing.", LogLevel.Trace); } return; } if (WeatherOpt.Verbose) { Monitor.Log("Setting weather for tomorrow"); } //now set tomorrow's weather var OddsForTheDay = GameClimate.GetClimateForDate(SDate.Now().AddDays(1)); double rainDays = OddsForTheDay.RetrieveOdds(Dice, "rain", SDate.Now().AddDays(1).Day); double windyDays = OddsForTheDay.RetrieveOdds(Dice, "debris", SDate.Now().AddDays(1).Day); double stormDays = OddsForTheDay.RetrieveOdds(Dice, "storm", SDate.Now().AddDays(1).Day); if (WeatherOpt.Verbose) { Monitor.Log($"Odds are Rain: {rainDays.ToString("N3")}, Windy: {windyDays.ToString("N3")}, and Storm {stormDays.ToString("N3")}"); } ProbabilityDistribution <string> WeatherDist = new ProbabilityDistribution <string>("sunny"); WeatherDist.AddNewEndPoint(rainDays, "rain"); if (WeatherOpt.DisableHighRainWind) { WeatherDist.AddNewCappedEndPoint(windyDays, "debris"); } double distOdd = Dice.NextDoublePositive(); if (WeatherOpt.Verbose) { Monitor.Log(WeatherDist.ToString()); Monitor.Log($"Distribution odds is {distOdd}"); } if (!(WeatherDist.GetEntryFromProb(distOdd, out string Result))) { Result = "sunny"; Monitor.Log("The weather has failed to process in some manner. Falling back to [sunny]", LogLevel.Info); } if (WeatherOpt.Verbose) { Monitor.Log($"Weather result is {Result}"); } if (!Conditions.IsTodayTempSet) { throw new NullReferenceException("Today's temperatures have not been set!"); } //now parse the result. if (Result == "rain") { //snow applies first double MidPointTemp = Conditions.TodayHigh - ((Conditions.TodayHigh - Conditions.TodayLow) / 2); if ((Conditions.TodayHigh <= 2 || MidPointTemp <= 0) && Game1.currentSeason != "spring") { if (WeatherOpt.Verbose) { Monitor.Log($"Snow is enabled, with the High for the day being: {Conditions.TodayHigh}" + $" and the calculated midpoint temperature being {MidPointTemp}"); } Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_snow; } else { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_rain; } if (!GameClimate.AllowRainInWinter && Game1.currentSeason == "winter" && Game1.weatherForTomorrow == Game1.weather_rain) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_snow; } //apply lightning logic. if (Dice.NextDoublePositive() >= stormDays && Game1.weatherForTomorrow == Game1.weather_rain) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_lightning; if (SDate.Now().Year == 1 && SDate.Now().Season == "spring" && !WeatherOpt.AllowStormsSpringYear1) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_rain; } } //tracking time! - Snow fall on Fall 28, if the flag is set. if (Game1.dayOfMonth == 28 && Game1.currentSeason == "fall" && WeatherOpt.SnowOnFall28) { Conditions.ForceTodayTemps(2, -1); Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_snow; } } if (Result == "debris") { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_debris; } if (Result == "sunny") { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_sunny; } if (WeatherOpt.Verbose) { Monitor.Log($"We've set the weather for Tomorrow. It is: {DescriptionEngine.DescribeInGameWeather(Game1.weatherForTomorrow)}"); } }